C:\xampp\htdocs\kptv2\cron\monthly_cron.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php     

error_reporting
(0);
// error_reporting(E_ALL);
//ini_set("display_errors", 0);

$db_name "kptv";
$db_host "localhost";
$db_password "bBRWRXMBU3HmqCzP";
$db_usrName "kptv";

// echo $db_name."/".$db_host."/".$db_password."/".$db_usrName;

//$ip=$_SERVER['REMOTE_ADDR']; 
$datenow date("Y-m-d");
include(
'/var/www/sites/kptv.ro/public_html/radio/admin/dbconn2.php');
require_once 
"/var/www/sites/kptv.ro/public_html/radio/common/database.php";
require_once 
"/var/www/sites/kptv.ro/public_html/radio/ro/func/vote.php";

//require_once "../common/database.php";
//include('./radio/admin/dbconn2.php');
//require_once "../ro/func/vote.php";

//****************** Exportalja a top20 listat
$database = new Database($db_host$db_name$db_usrName$db_password);
$sql_cat $database->query("SELECT * FROM toplistcategories");

while (
$row mysql_fetch_assoc($sql_cat)) 
{
    
$sql7 $database->query("SELECT ID, artist, song, up, active, prev_month, months_in_top, added_date, mp3 FROM top20 WHERE active=1 && type_of_list=".$row['ID']." ORDER BY up DESC LIMIT 20");

     
$ourFileName "/var/www/sites/kptv.ro/public_html/radio/toplist-export/export_".$datenow."-".$row['title'].".csv";

     
$ourFileHandle fopen($ourFileName'w') or die("can't open file");
     
$i 1;
     
//print_r ($row);
     
$putinto $row['title'].'TM;;;;;';
     
$putinto .= "\n\nTM;ST;Artist/Piesa;Nr.voturi;LM;M\n"//artist;song;up;active;prev_month;months_in_top;added_date;mp3\n
     
while ($row7=mysql_fetch_assoc($sql7)) {    
         
//print_r($row7);
         //echo '<br>'.$row7['artist'].'<br>';
         //$putinto .= implode(";",$row7);
         
         
$putinto .= $i.';';
         
$putinto .= ';';
         
$putinto .= $row7['artist'].'/'.$row7['song'].';';
         
$putinto .= $row7['up'].';';
         
$putinto .= $row7['prev_month'].';';
         
$putinto .= $row7['months_in_top'];
         
$putinto .= "\n";
         
$i++;
     }
    
    
$putinto .= "\nPropuneri;;;;;\n\n";
     
    
$sql8 $database->query("SELECT ID, artist, song, up, active, prev_month, months_in_top, added_date, mp3 FROM top20plus WHERE active=1 && type_of_list=".$row['ID']." ORDER BY up DESC LIMIT 20");
    
    
$i 1;
     
$putinto .= "TM;ST;Artist/Piesa;Nr.voturi;LM;M\n"//artist;song;up;active;prev_month;months_in_top;added_date;mp3\n
     
while ($row7=mysql_fetch_assoc($sql8)) {    
         
//print_r($row7);
         //echo '<br>'.$row7['artist'].'<br>';
         //$putinto .= implode(";",$row7);
         
         
$putinto .= $i.';';
         
$putinto .= ';';
         
$putinto .= $row7['artist'].'/'.$row7['song'].';';
         
$putinto .= $row7['up'].';';
         
$putinto .= $row7['prev_month'].';';
         
$putinto .= $row7['months_in_top'];
         
$putinto .= "\n";
         
$i++;
     }
     
     
fwrite($ourFileHandle$putinto); 
     
fclose($ourFileHandle);    
     
     
chmod($ourFileName0644);

}
/********/

$sql_cat $database->query("SELECT * FROM toplistcategories");

while (
$row mysql_fetch_assoc($sql_cat)) 
{
    echo 
'<br>'.$row['title'].' '.$row['ID'].'<br>';
    
$type_of_list $row['ID'];
    
$vote = new Vote();

    
//save the prev_month to the prev_month
    
$prevMonth $vote->orderPrevMonth($type_of_list);
    
/*
    echo '<pre>';
    print_r ($prevMonth);
    echo '</pre>';
    exit();
    */
    
    //update prev_month_2 field
    //$prevMonth_2 = $vote->orderPrevMonth('prev_month','DESC',$type_of_list);
    
$vote->handlePrevMonth($prevMonth);

//    echo 'getTop20';
    
$top20List $vote->getTop20("up""DESC"$type_of_list );
    
// usort($top20List, "sortByOrder");
    /*echo "<pre>";
    print_r($top20List);
    echo "</pre>";
    exit();*/

//    echo 'getTop20Plus';
    
$top20ListPlus $vote->getTop20Plus("up""DESC"$type_of_list);
    
// usort($top20ListPlus, "sortByOrder");

    // echo "<pre>";
    // print_r($top20List);
    // die();

//    echo 'handleTop20Top20PlusLoc';
    
$vote->handleTop20Top20PlusLoc($top20List$top20ListPlus);
    
//echo 'sumTop20';
    
    //folosleges mert valami total fieldet akar updatelni
    //$vote->sumTop20($type_of_list);

    //ez is folosleges
    //$vote->handleUp($vote->getTop20("up","ASC", $type_of_list), "top20");
    //ez is folosleges
    //$vote->handleUp($vote->getTop20Plus("up","ASC", $type_of_list), "top20plus");

    //echo 'increaseMonthsInTop';
    
$vote->increaseMonthsInTop($type_of_list);    
    
$vote->copyCurrentMonthToPrevMonth($type_of_list);
    
    
//delete unused (position > 20) song from toplist
    
$vote->deleteSongs($type_of_list);
    
$vote->reset();
}

function 
sortByOrder($a$b) {
    return 
$b['up'] - $a['up'];
}

?>
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586