az ocne dreamhosttan email aldım ve sunucuyu cok zorladıgı icin BUTTON.php dosyasının calıstırmasını durdurduklarını bildirdiler. Acaba bu dosyada ne gibi değişiklikler yapsam rahatlatabilirim ?
Saymasada olur sadece giris saysın ona gore sıralayabileyim. ACABA boyle bir değişiklik mumkunmu ?
Dosyalar asagıda...
*************
BUTTON.PHP - sunucuyu zorlayan
**************
SETTINGS_BUTTON.PHP
*************
Ve diger icerilen dosyada da :
Saymasada olur sadece giris saysın ona gore sıralayabileyim. ACABA boyle bir değişiklik mumkunmu ?
Dosyalar asagıda...
*************
BUTTON.PHP - sunucuyu zorlayan
PHP:
// Help prevent register_globals injection
define('ATSPHP', 1);
$CONF = array();
$FORM = array();
$TMPL = array();
// Change the path to your full path if necessary
$CONF['path'] = '.';
// Connect to the database
require_once("{$CONF['path']}/settings_sql.php");
require_once("{$CONF['path']}/sources/sql/{$CONF['sql']}.php");
$DB = new sql;
$DB->connect($CONF['sql_host'], $CONF['sql_username'], $CONF['sql_password'], $CONF['sql_database']);
// Settings
$settings = $DB->fetch("SELECT * FROM {$CONF['sql_prefix']}_settings", __FILE__, __LINE__);
$CONF = array_merge($CONF, $settings);
// Check id for backwards compatability with 4.x
if (isset($_GET['id']) && $_GET['id'] && !$_GET['u']) {
$username = $DB->escape($_GET['id']);
}
else {
$username = $DB->escape($_GET['u']);
}
// Is this a unique hit?
$ip = getenv("REMOTE_ADDR");
list($ip_sql, $unq_pv) = $DB->fetch("SELECT ip_address, unq_pv FROM {$CONF['sql_prefix']}_ip_log WHERE ip_address = '$ip' AND username = '{$username}'", __FILE__, __LINE__);
$unique_sql = ', unq_pv_overall = unq_pv_overall + 1, unq_pv_0_daily = unq_pv_0_daily + 1, unq_pv_0_weekly = unq_pv_0_weekly + 1, unq_pv_0_monthly = unq_pv_0_monthly + 1';
if ($ip == $ip_sql && $unq_pv == 0) {
$DB->query("UPDATE {$CONF['sql_prefix']}_ip_log SET unq_pv = 1 WHERE ip_address = '{$ip}' AND username = '{$username}'", __FILE__, __LINE__);
}
elseif ($ip != $ip_sql) {
$DB->query("INSERT INTO {$CONF['sql_prefix']}_ip_log (ip_address, username, unq_pv) VALUES ('{$ip}', '{$username}' ,1)", __FILE__, __LINE__);
}
else {
$unique_sql = '';
}
// Update stats
$DB->query("UPDATE {$CONF['sql_prefix']}_stats SET tot_pv_overall = tot_pv_overall + 1, tot_pv_0_daily = tot_pv_0_daily + 1, tot_pv_0_weekly = tot_pv_0_weekly + 1, tot_pv_0_monthly = tot_pv_0_monthly + 1{$unique_sql} WHERE username = '{$username}'", __FILE__, __LINE__);
// What button to display?
$rank_on_button = 0;
if ($CONF['ranks_on_buttons']) {
// See if rank is freshly cached. If so, use cached value. If not, calculate rank.
list($rank_cache, $rank_cache_time) = $DB->fetch("SELECT rank_cache, rank_cache_time FROM {$CONF['sql_prefix']}_stats WHERE username = '{$username}'", __FILE__, __LINE__);
$current_time = time();
if ($current_time - (12*3600) < $rank_cache_time) {
if ($rank_cache > 0 && $rank_cache <= $CONF['button_num']) {
$rank = $rank_cache;
$location = "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
$rank_on_button = 1;
}
}
else {
require_once "{$CONF['path']}/sources/misc/classes.php";
$rank_by = base::rank_by();
list($hits) = $DB->fetch("SELECT {$rank_by} FROM {$CONF['sql_prefix']}_stats WHERE username = '{$username}'", __FILE__, __LINE__);
if ($hits) {
$result = $DB->select_limit("SELECT count(*) FROM {$CONF['sql_prefix']}_stats WHERE ({$rank_by}) >= $hits", $CONF['button_num'], 0, __FILE__, __LINE__);
list($rank) = $DB->fetch_array($result);
$new_rank_cache = 0;
if ($rank <= $CONF['button_num']) {
$location = "{$CONF['button_dir']}/{$rank}.{$CONF['button_ext']}";
$rank_on_button = 1;
$new_rank_cache = $rank;
}
}
if ($new_rank_cache) {
$DB->query("UPDATE {$CONF['sql_prefix']}_stats SET rank_cache = {$new_rank_cache}, rank_cache_time = {$current_time} WHERE username = '{$username}'", __FILE__, __LINE__);
}
}
// Stat Buttons
if ($CONF['ranks_on_buttons'] == 2) {
require_once "{$CONF['path']}/settings_buttons.php";
exit;
}
}
$DB->close();
if (!$rank_on_button) {
$location = $CONF['button_url'];
}
header("Location: {$location}");
?>
**************
SETTINGS_BUTTON.PHP
PHP:
<?php
if (!defined('ATSPHP')) {
die("This file cannot be accessed directly.");
}
$TMPL = $DB->fetch("SELECT *
FROM {$CONF['sql_prefix']}_sites sites, {$CONF['sql_prefix']}_stats stats
WHERE sites.username = stats.username AND sites.username = '{$username}'", __FILE__, __LINE__);
if ($rank) {
$TMPL['rank'] = $rank;
}
else {
$TMPL['rank'] = $TMPL['old_rank'];
}
$TMPL['average_rating'] = $TMPL['num_ratings'] > 0 ? round($TMPL['total_rating'] / $TMPL['num_ratings'], 0) : 0;
$ranking_periods = array('daily', 'weekly', 'monthly');
$ranking_methods = array('unq_pv', 'tot_pv', 'unq_in', 'tot_in', 'unq_out', 'tot_out');
foreach ($ranking_periods as $ranking_period) {
foreach ($ranking_methods as $ranking_method) {
$TMPL["{$ranking_method}_avg_{$ranking_period}"] = 0;
for ($i = 0; $i < 10; $i++) {
$TMPL["{$ranking_method}_avg_{$ranking_period}"] = $TMPL["{$ranking_method}_avg_{$ranking_period}"] + $TMPL["{$ranking_method}_{$i}_{$ranking_period}"];
}
$TMPL["{$ranking_method}_avg_{$ranking_period}"] = $TMPL["{$ranking_method}_avg_{$ranking_period}"] / 10;
}
}
$TMPL['average_rating'] = $TMPL['num_ratings'] > 0 ? round($TMPL['total_rating'] / $TMPL['num_ratings'], 0) : 0;
$img = imagecreatefrompng("{$CONF['path']}/images/ranking.png");
$color1 = imagecolorallocate($img, 0, 0, 255);
$color2 = imagecolorallocate($img, 255, 255, 255);
header ("Content-type: image/png");
imagestring($img, 2, 52, 0, $TMPL['unq_pv_0_daily'], $color1);
imagestring($img, 2, 60, 11, $TMPL['unq_pv_avg_daily'], $color1);
imagestring($img, 2, 33, 24, "{$TMPL['average_rating']}/5", $color1);
imagestring($img, 5, 126, 20, $TMPL['rank'], $color2);
imagepng($img);
?>
*************
Ve diger icerilen dosyada da :
PHP:
<?php
$CONF['sql'] = 'mysql';
$CONF['sql_host'] = 'mysql.xxxx.com';
$CONF['sql_database'] = '';
$CONF['sql_username'] = '';
$CONF['sql_password'] = '';
$CONF['sql_prefix'] = 'ats';
?>