Help needed with toplist

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help needed with toplist

    I have a toplist script which resets daily at 00:00. Can someone help me to restet this toplist after two days?

    Here are config.php and update.php


    config.php

    PHP Code:
    <?php
    $mysqlhost 
    "";
    $database "";
    $mysqluser "";
    $password "";
    $sections "";
    $sites "";
    $ban "";
    $tmp "";
    $news "";
    $rekl "";
    $in_dir "in";
    $out_dir "out";
    $admin_dir "admin";
    $update_file "updates.dat";
    $connection mysql_connect($mysqlhost$mysqluser$password);
    if(!
    $connection)
    {
    header("Content-type: text/vnd.wap.wml; charset=utf-8");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Cache-Control: no-cache, must-relative");
    $error mysql_error();
    echo <<< END
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'><wml>
    <card id='error' title='Error'>
    <p align='left'>
    No connection to MySQL<br/>
    <a href='/'>Home</a><br/>
    </p>
    </card>
    </wml>
    END;
    exit();
    }
    if(!
    mysql_select_db($database$connection))
    {
    header("Content-type: text/vnd.wap.wml; charset=utf-8");
    header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
    header("Cache-Control: no-cache, must-relative");
    $error mysql_error();
    echo <<< END
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE wml PUBLIC '-//WAPFORUM//DTD WML 1.3//EN' 'http://www.wapforum.org/DTD/wml13.dtd'><wml>
    <card id='error' title='Error'>
    <p align='left'>
    The database could not be accessed<br/>
    <a href='/'>Home</a><br/>
    </p>
    </card>
    </wml>
    END;
    exit();
    }
    $sp dirname($_SERVER['PHP_SELF']);
    if(
    strpos($sp$admin_dir) == false && strpos($sp$in_dir) == false && strpos($sp$out_dir) == false)
    {
    $fd fopen($update_file"r");
    flock($fdLOCK_EX LOCK_SH);
    $buff fgets($fd);
    if(
    $buff != date("d"))
    {
    define("OK""OK");
    $fdesc fopen($update_file"w");
    fputs($fdescdate("d"));
    include(
    "update.php");
    fclose($fdesc);
    }
    flock($fdLOCK_UN);
    fclose($fd);
    }
    if(isset(
    $_GET['version']))
    {
    $version $_GET['version'];
    }
    else
    {
    $version "html";  //Default HTML
    }
    switch(
    $version)
    {
    case 
    'wml':
    $version 0;
    break;
    case 
    'html':
    $version 1;
    break;
    default:
    $version 0;
    break;
    }
    if(
    $version == 1)
    {
    $font "Comic Sans MS";
    $color "#3366FF";
    $background "#DFE6EF";
    $links "#3A4F6C";
    $form_color "#3A4F6C";
    $favicon "/favicon.ico";
    }
    ?>

    update.php

    PHP Code:
    <?php
    if(!defined("OK")) die();

    $sql mysql_query("SELECT * FROM `".$sites."` WHERE `all_in` != 0;");

    $date date("d-m-Y_H-i-s");

    $fd fopen("./logs/".$date.".txt""w");
    $data "LOGS DATE: ".date("d-m-Y H:i:s")."\n";

    while(
    $sa mysql_fetch_array($sql))
    {
    $data .= $sa['site']."|".$sa['in']."/".$sa['out']."|".$sa['all_in']."/".$sa['all_out']."\n";
    }

    fwrite($fd$data);
    fclose($fd);

    $fp fopen("month.dat""r");
    flock($fpLOCK_EX LOCK_SH);

    $buffer fgets($fp);

        if(
    $buffer != date("m"))
        {
        
    $fdp fopen("month.dat""w");
        
    fputs($fdpdate("m"));
        
    fclose($fdp);
        
    mysql_unbuffered_query("UPDATE `".$sites."` SET `all_in` = 0, `all_out` = 0;");
        }

    flock($fpLOCK_UN);
    fclose($fp);

    mysql_unbuffered_query("TRUNCATE TABLE `".$tmp."`;");
    mysql_unbuffered_query("UPDATE `".$sites."` SET `in` = 0, `out` = 0;");
    mysql_unbuffered_query("DELETE FROM `".$sites."` WHERE `all_in` = 0 AND `days` > 2;");
    ?>
    Last edited by arnage; 27.06.12, 12:25.

    #2
    update.php

    PHP Code:
    <?php
    if(!defined("OK")) die();

    $sql mysql_query("SELECT * FROM `".$sites."` WHERE `all_in` != 0;");

    $date date("d-m-Y_H-i-s");

    $fd fopen("./logs/".$date.".txt""w");
    $data "LOGS DATE: ".date("d-m-Y H:i:s")."\n";

    while(
    $sa mysql_fetch_array($sql))
    {
    $data .= $sa['site']."|".$sa['in']."/".$sa['out']."|".$sa['all_in']."/".$sa['all_out']."\n";
    }

    fwrite($fd$data);
    fclose($fd);

    $fp fopen("month.dat""r");
    flock($fpLOCK_EX LOCK_SH);

    $buffer fgets($fp);

        if(
    $buffer != date("m"))
        {
        
    $fdp fopen("month.dat""w");
        
    fputs($fdpdate("m"));
        
    fclose($fdp);
        
    mysql_unbuffered_query("UPDATE `".$sites."` SET `all_in` = 0, `all_out` = 0;");
        }

    flock($fpLOCK_UN);
    fclose($fp);

    mysql_unbuffered_query("TRUNCATE TABLE `".$tmp."`;");
    if(
    is_int(date("d") / 2))
        
    mysql_unbuffered_query("UPDATE `".$sites."` SET `in` = 0, `out` = 0;");
    mysql_unbuffered_query("DELETE FROM `".$sites."` WHERE `all_in` = 0 AND `days` > 2;");
    ?>
    libra.wen.ru

    Comment


      #3
      @s3nzo not working

      Comment

      Working...
      X