| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | class DATE |
|---|
| 4 | { |
|---|
| 5 | var $sday,$smon,$syea,$shou,$eday,$emon,$eyea,$ehou; |
|---|
| 6 | function DATE($mas) |
|---|
| 7 | { |
|---|
| 8 | list($this->sday,$this->smon,$this->syea,$this->shou,$this->eday,$this->emon,$this->eyea,$this->ehou)=$mas; |
|---|
| 9 | } |
|---|
| 10 | function BeginDate() |
|---|
| 11 | { |
|---|
| 12 | return("$this->sday.$this->smon.$this->syea"); |
|---|
| 13 | } |
|---|
| 14 | function EndDate() |
|---|
| 15 | { |
|---|
| 16 | return("$this->eday.$this->emon.$this->eyea"); |
|---|
| 17 | } |
|---|
| 18 | function sdate() |
|---|
| 19 | { |
|---|
| 20 | return("$this->syea-$this->smon-$this->sday"); |
|---|
| 21 | } |
|---|
| 22 | function edate() |
|---|
| 23 | { |
|---|
| 24 | return("$this->eyea-$this->emon-$this->eday"); |
|---|
| 25 | } |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | function UsersTrafficPeriodPDFHeader($page) { |
|---|
| 30 | |
|---|
| 31 | global $pdfFile; |
|---|
| 32 | global $DATE; |
|---|
| 33 | global $SAMSConf; |
|---|
| 34 | |
|---|
| 35 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 36 | $lang="./lang/lang.WIN1251"; |
|---|
| 37 | else |
|---|
| 38 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 39 | require($lang); |
|---|
| 40 | |
|---|
| 41 | $sdate=$DATE->sdate(); |
|---|
| 42 | $edate=$DATE->edate(); |
|---|
| 43 | |
|---|
| 44 | $pdfFile->AddPage(); |
|---|
| 45 | $imagefile = "$SAMSConf->ICONSET/usergroup_48.jpg"; |
|---|
| 46 | $pdfFile->Image($imagefile,20,10,20,20); |
|---|
| 47 | |
|---|
| 48 | $pdfFile->SetFont('Nimbus','',15); |
|---|
| 49 | //$pdfFile->SetFont('SUSESerif-Roman','',16); |
|---|
| 50 | $pdfFile->SetXY(50, 15); |
|---|
| 51 | $pdfFile->Write(0, " $usersbuttom_2_traffic_UsersTrafficPeriod_1 $sdate - $edate ($lang_pdfReport_page $page)"); |
|---|
| 52 | $pdfFile->SetXY(50, 25); |
|---|
| 53 | $pdfFile->Write(0, " $usersbuttom_2_traffic_UsersTrafficPeriod_2 "); |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | $pdfFile->SetFont('Nimbus','',11); |
|---|
| 57 | //$pdfFile->SetFont('SUSESerif-Roman','',11); |
|---|
| 58 | $ycount=40; |
|---|
| 59 | $pdfFile->SetXY(30, $ycount); |
|---|
| 60 | $pdfFile->Write(0, "N"); |
|---|
| 61 | $pdfFile->SetXY(40, $ycount); |
|---|
| 62 | $pdfFile->Write(0, "$usersbuttom_2_traffic_UsersTrafficPeriod_4"); |
|---|
| 63 | $pdfFile->SetXY(130, $ycount); |
|---|
| 64 | $pdfFile->Write(0, "$usersbuttom_2_traffic_UsersTrafficPeriod_7"); |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | $pdfFile->SetFont('Nimbus','',11); |
|---|
| 68 | //$pdfFile->SetFont('SUSESerif-Roman','',11); |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | function UsersTrafficPeriodPDF() |
|---|
| 73 | { |
|---|
| 74 | global $SAMSConf; |
|---|
| 75 | global $DATE; |
|---|
| 76 | global $pdfFile; |
|---|
| 77 | |
|---|
| 78 | $sdate=$DATE->sdate(); |
|---|
| 79 | $edate=$DATE->edate(); |
|---|
| 80 | $currentPage = 1; |
|---|
| 81 | |
|---|
| 82 | db_connect($SAMSConf->LOGDB) or exit(); |
|---|
| 83 | mysql_select_db($SAMSConf->LOGDB); |
|---|
| 84 | |
|---|
| 85 | UsersTrafficPeriodPDFHeader($currentPage); |
|---|
| 86 | |
|---|
| 87 | $ycount=50; |
|---|
| 88 | $count=0; |
|---|
| 89 | $result=mysql_query("SELECT sum(size) as all_sum,sum(hit),user,domain FROM cachesum WHERE date>=\"$sdate\"&&date<=\"$edate\" group by user,domain order by all_sum desc"); |
|---|
| 90 | while($row=mysql_fetch_array($result)) |
|---|
| 91 | { |
|---|
| 92 | $result_2=mysql_query("SELECT * FROM ".$SAMSConf->SAMSDB.".squidusers WHERE ".$SAMSConf->SAMSDB.".squidusers.nick=\"$row[user]\"&&".$SAMSConf->SAMSDB.".squidusers.domain=\"$row[domain]\""); |
|---|
| 93 | $row_2=mysql_fetch_array($result_2); |
|---|
| 94 | |
|---|
| 95 | $pdfFile->SetXY(30, $ycount); |
|---|
| 96 | $pdfFile->Write(0, $count+1); |
|---|
| 97 | $pdfFile->SetXY(40, $ycount); |
|---|
| 98 | $aaa=convert_cyr_string($row['user'],"k","w"); |
|---|
| 99 | $pdfFile->Write(0, $aaa); |
|---|
| 100 | $pdfFile->SetXY(80, $ycount); |
|---|
| 101 | $aaa=convert_cyr_string("$row_2[family] $row_2[name]","k","w"); |
|---|
| 102 | $pdfFile->Write(0, $aaa); |
|---|
| 103 | $pdfFile->SetXY(130, $ycount); |
|---|
| 104 | $aaa=ReturnTrafficFormattedSize($row[0]-$row[1]); |
|---|
| 105 | $pdfFile->Write(0, $aaa); |
|---|
| 106 | |
|---|
| 107 | $count=$count+1; |
|---|
| 108 | $size2=$size2+$row[0]; |
|---|
| 109 | $hitsize=$hitsize+$row[1]; |
|---|
| 110 | $traf=$traf+$row[0]-$row[1]; |
|---|
| 111 | $ycount+=7; |
|---|
| 112 | |
|---|
| 113 | if ($count % 30 == 0) { |
|---|
| 114 | $currentPage = $currentPage + 1; |
|---|
| 115 | UsersTrafficPeriodPDFHeader($currentPage); |
|---|
| 116 | $ycount = 50; |
|---|
| 117 | } |
|---|
| 118 | } |
|---|
| 119 | mysql_free_result($result); |
|---|
| 120 | |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | function AllUsersTrafficPDF() |
|---|
| 125 | { |
|---|
| 126 | //define('FPDF_FONTPATH','lib/font/'); |
|---|
| 127 | //require('lib/fpdf.php'); |
|---|
| 128 | |
|---|
| 129 | global $SAMSConf; |
|---|
| 130 | global $DATE; |
|---|
| 131 | global $pdfFile; |
|---|
| 132 | |
|---|
| 133 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 134 | $lang="./lang/lang.WIN1251"; |
|---|
| 135 | else |
|---|
| 136 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 137 | require($lang); |
|---|
| 138 | |
|---|
| 139 | $sdate=$DATE->sdate(); |
|---|
| 140 | $edate=$DATE->edate(); |
|---|
| 141 | $bdate=$DATE->BeginDate(); |
|---|
| 142 | $eddate=$DATE->EndDate(); |
|---|
| 143 | |
|---|
| 144 | db_connect($SAMSConf->LOGDB) or exit(); |
|---|
| 145 | mysql_select_db($SAMSConf->LOGDB); |
|---|
| 146 | |
|---|
| 147 | $result=mysql_query("SELECT * FROM ".$SAMSConf->SAMSDB.".squidusers "); |
|---|
| 148 | while($row=mysql_fetch_array($result)) |
|---|
| 149 | { |
|---|
| 150 | if($row['size']>0) |
|---|
| 151 | { |
|---|
| 152 | $pdfFile->AddPage(); |
|---|
| 153 | $imagefile = "$SAMSConf->ICONSET/usergroup_48.jpg"; |
|---|
| 154 | $pdfFile->Image($imagefile,20,10,20,20); |
|---|
| 155 | |
|---|
| 156 | $pdfFile->SetFont('Nimbus','',14); |
|---|
| 157 | //$pdfFile->SetFont('SUSESerif-Roman','',16); |
|---|
| 158 | $pdfFile->SetXY(50, 15); |
|---|
| 159 | $pdfFile->Write(0, " $lang_pdfReport_user $row[nick] ($sdate - $edate)"); |
|---|
| 160 | |
|---|
| 161 | $pdfFile->SetXY(30, 40); |
|---|
| 162 | $pdfFile->Write(0, $lang_pdfReport_date); |
|---|
| 163 | |
|---|
| 164 | $pdfFile->SetXY(60, 40); |
|---|
| 165 | $pdfFile->Write(0, $lang_pdfReport_size); |
|---|
| 166 | $pdfFile->SetXY(90, 40); |
|---|
| 167 | $pdfFile->Write(0, $lang_pdfReport_cache); |
|---|
| 168 | $pdfFile->SetXY(130, 40); |
|---|
| 169 | $pdfFile->Write(0, $lang_pdfReport_traffic); |
|---|
| 170 | |
|---|
| 171 | $ycount=50; |
|---|
| 172 | $pdfFile->SetFont('Nimbus','',11); |
|---|
| 173 | //$pdfFile->SetFont('SUSESerif-Roman','',11); |
|---|
| 174 | $result2=mysql_query("SELECT sum(cachesum.size),cachesum.date,cachesum.user,cachesum.domain,sum(cachesum.hit) FROM cachesum WHERE cachesum.user=\"$row[nick]\" &&cachesum.date>=\"$sdate\" &&cachesum.date<=\"$edate\" &&cachesum.domain=\"$row[domain]\" GROUP BY date"); |
|---|
| 175 | while($row2=mysql_fetch_array($result2)) |
|---|
| 176 | { |
|---|
| 177 | |
|---|
| 178 | $pdfFile->SetXY(30, $ycount); |
|---|
| 179 | $aaa=ReturnDate($row2['date']); |
|---|
| 180 | $pdfFile->Write(0, $aaa); |
|---|
| 181 | |
|---|
| 182 | $pdfFile->SetXY(60, $ycount); |
|---|
| 183 | $pdfFile->Write(0, $row2[0]); |
|---|
| 184 | $pdfFile->SetXY(90, $ycount); |
|---|
| 185 | $pdfFile->Write(0, $row2[4]); |
|---|
| 186 | $pdfFile->SetXY(130, $ycount); |
|---|
| 187 | $aaa=ReturnTrafficFormattedSize($row2[0]-$row2[4]); |
|---|
| 188 | $pdfFile->Write(0, " $aaa"); |
|---|
| 189 | |
|---|
| 190 | $count=$count+1; |
|---|
| 191 | $size=$size+$row[0]; |
|---|
| 192 | $cache=$cache+$row[4]; |
|---|
| 193 | $ycount+=7; |
|---|
| 194 | } |
|---|
| 195 | mysql_free_result($result2); |
|---|
| 196 | |
|---|
| 197 | $ycount+=20; |
|---|
| 198 | |
|---|
| 199 | $pdfFile->SetXY(30, $ycount-10); |
|---|
| 200 | $pdfFile->Write(0, $lang_pdfReport_site); |
|---|
| 201 | $pdfFile->SetXY(130, $ycount-10); |
|---|
| 202 | $pdfFile->Write(0, $lang_pdfReport_size); |
|---|
| 203 | $pdfFile->SetXY(160, $ycount-10); |
|---|
| 204 | $pdfFile->Write(0, $lang_pdfReport_cache); |
|---|
| 205 | |
|---|
| 206 | $query="select trim(leading \"http://\" from substring_index(url,'/',3)) as norm_url,sum(size) as url_size,sum(hit) as hit_size from cache where user=\"$row[nick]\"&&domain=\"$row[domain]\"&&date>=\"$sdate\"&&date<=\"$edate\" group by norm_url order by url_size desc limit 50"; |
|---|
| 207 | $result3=mysql_query($query); |
|---|
| 208 | while($row3=mysql_fetch_array($result3)) |
|---|
| 209 | { |
|---|
| 210 | $pdfFile->SetXY(30, $ycount); |
|---|
| 211 | $pdfFile->Write(0, $row3['norm_url']); |
|---|
| 212 | $pdfFile->SetXY(130, $ycount); |
|---|
| 213 | $pdfFile->Write(0, $row3['url_size']); |
|---|
| 214 | $pdfFile->SetXY(160, $ycount); |
|---|
| 215 | $pdfFile->Write(0, $row3['hit_size']); |
|---|
| 216 | |
|---|
| 217 | $ycount+=7; |
|---|
| 218 | if($ycount>=273) |
|---|
| 219 | { |
|---|
| 220 | $pdfFile->AddPage(); |
|---|
| 221 | $ycount=50; |
|---|
| 222 | } |
|---|
| 223 | } |
|---|
| 224 | mysql_free_result($result3); |
|---|
| 225 | } |
|---|
| 226 | } |
|---|
| 227 | mysql_free_result($result); |
|---|
| 228 | |
|---|
| 229 | } |
|---|
| 230 | |
|---|
| 231 | |
|---|
| 232 | function UsersTrafficPeriodPDFlib($pdfFile) |
|---|
| 233 | { |
|---|
| 234 | global $SAMSConf; |
|---|
| 235 | global $DATE; |
|---|
| 236 | global $PAGE; |
|---|
| 237 | |
|---|
| 238 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 239 | $lang="./lang/lang.WIN1251"; |
|---|
| 240 | else |
|---|
| 241 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 242 | require($lang); |
|---|
| 243 | |
|---|
| 244 | $sdate=$DATE->sdate(); |
|---|
| 245 | $edate=$DATE->edate(); |
|---|
| 246 | $bdate=$DATE->BeginDate(); |
|---|
| 247 | $eddate=$DATE->EndDate(); |
|---|
| 248 | |
|---|
| 249 | db_connect($SAMSConf->LOGDB) or exit(); |
|---|
| 250 | mysql_select_db($SAMSConf->LOGDB); |
|---|
| 251 | |
|---|
| 252 | $imagefile = "$SAMSConf->ICONSET/usergroup_48.jpg"; |
|---|
| 253 | $image = PDF_load_image($pdfFile, "auto", $imagefile, ""); |
|---|
| 254 | if (!$image) |
|---|
| 255 | { |
|---|
| 256 | die( "Error: " . PDF_get_errmsg($pdfFile) ); |
|---|
| 257 | } |
|---|
| 258 | $fontdir = "lib/font/"; |
|---|
| 259 | pdf_set_parameter($pdfFile, "FontOutline", "Nimbus=$fontdir/Nimbus.ttf"); |
|---|
| 260 | |
|---|
| 261 | $ycount=700; |
|---|
| 262 | $result=mysql_query("SELECT sum(size) as all_sum,sum(hit),user,domain FROM cachesum WHERE date>=\"$sdate\"&&date<=\"$edate\" group by user,domain order by all_sum desc"); |
|---|
| 263 | while($row=mysql_fetch_array($result)) |
|---|
| 264 | { |
|---|
| 265 | if($ycount==700) |
|---|
| 266 | { |
|---|
| 267 | pdf_begin_page($pdfFile, 595, 842); |
|---|
| 268 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 269 | { |
|---|
| 270 | $font = PDF_findfont($pdfFile, "Nimbus", "cp1251",1); |
|---|
| 271 | PDF_setfont($pdfFile, $font, 16); |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | PDF_fit_image($pdfFile, $image, 50, 760, "" ); |
|---|
| 275 | pdf_show_xy($pdfFile, "$usersbuttom_2_traffic_UsersTrafficPeriod_1", 170, 780); |
|---|
| 276 | pdf_show_xy($pdfFile, "$usersbuttom_2_traffic_UsersTrafficPeriod_2", 120, 760); |
|---|
| 277 | PDF_setfont($pdfFile, $font, 10); |
|---|
| 278 | pdf_show_xy($pdfFile, "$traffic_2 $bdate $traffic_3 $eddate", 220, 740); |
|---|
| 279 | |
|---|
| 280 | pdf_moveto($pdfFile, 20, 720); |
|---|
| 281 | pdf_lineto($pdfFile, 575, 720); |
|---|
| 282 | pdf_stroke($pdfFile); |
|---|
| 283 | |
|---|
| 284 | PDF_setfont($pdfFile, $font, 12); |
|---|
| 285 | pdf_show_xy($pdfFile, "$usersbuttom_2_traffic_UsersTrafficPeriod_4", 160, $ycount); |
|---|
| 286 | pdf_show_xy($pdfFile, "$usersbuttom_2_traffic_UsersTrafficPeriod_7", 410, $ycount); |
|---|
| 287 | |
|---|
| 288 | PDF_setfont($pdfFile, $font, 11); |
|---|
| 289 | $ycount-=40; |
|---|
| 290 | |
|---|
| 291 | } |
|---|
| 292 | $result_2=mysql_query("SELECT * FROM ".$SAMSConf->SAMSDB.".squidusers WHERE ".$SAMSConf->SAMSDB.".squidusers.nick=\"$row[user]\"&&".$SAMSConf->SAMSDB.".squidusers.domain=\"$row[domain]\""); |
|---|
| 293 | $row_2=mysql_fetch_array($result_2); |
|---|
| 294 | pdf_show_xy($pdfFile, $count+1, 50, $ycount); |
|---|
| 295 | pdf_show_xy($pdfFile, "$row[user]", 80, $ycount); |
|---|
| 296 | $aaa=convert_cyr_string("$row_2[family] $row_2[name]","k","w"); |
|---|
| 297 | pdf_show_xy($pdfFile, $aaa, 160, $ycount); |
|---|
| 298 | if($SAMSConf->realtraffic=="real") |
|---|
| 299 | { |
|---|
| 300 | $aaa=ReturnTrafficFormattedSize($row[0]-$row[1]); |
|---|
| 301 | pdf_show_xy($pdfFile, $aaa, 400, $ycount); |
|---|
| 302 | } |
|---|
| 303 | else |
|---|
| 304 | { |
|---|
| 305 | $aaa=ReturnTrafficFormattedSize($row[0]); |
|---|
| 306 | pdf_show_xy($pdfFile, $aaa, 400, $ycount); |
|---|
| 307 | } |
|---|
| 308 | //$aaa=ReturnTrafficFormattedSize($row[1]); |
|---|
| 309 | //pdf_show_xy($pdfFile, $aaa, 375, $ycount); |
|---|
| 310 | |
|---|
| 311 | $count=$count+1; |
|---|
| 312 | $size2=$size2+$row[0]; |
|---|
| 313 | $hitsize=$hitsize+$row[1]; |
|---|
| 314 | $traf=$traf+$row[0]-$row[1]; |
|---|
| 315 | $ycount-=20; |
|---|
| 316 | if($ycount==40) |
|---|
| 317 | { |
|---|
| 318 | PDF_setfont($pdfFile, $font, 9); |
|---|
| 319 | pdf_show_xy($pdfFile, "Created by SAMS (C) 2003-2008", 250, 20); |
|---|
| 320 | pdf_show_xy($pdfFile, "page $PAGE", 500, 10); |
|---|
| 321 | pdf_end_page($pdfFile); |
|---|
| 322 | $ycount=700; |
|---|
| 323 | $PAGE+=1; |
|---|
| 324 | |
|---|
| 325 | } |
|---|
| 326 | } |
|---|
| 327 | PDF_close_image($pdfFile, $image); |
|---|
| 328 | PDF_setfont($pdfFile, $font, 9); |
|---|
| 329 | pdf_show_xy($pdfFile, "Created by SAMS (C) 2003-2008", 250, 20); |
|---|
| 330 | pdf_show_xy($pdfFile, "page $PAGE", 500, 10); |
|---|
| 331 | pdf_end_page($pdfFile); |
|---|
| 332 | $PAGE+=1; |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | |
|---|
| 336 | } |
|---|
| 337 | |
|---|
| 338 | function AllUsersTrafficPDFlib() |
|---|
| 339 | { |
|---|
| 340 | global $SAMSConf; |
|---|
| 341 | global $DATE; |
|---|
| 342 | global $pdfFile; |
|---|
| 343 | global $PAGE; |
|---|
| 344 | |
|---|
| 345 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 346 | $lang="./lang/lang.WIN1251"; |
|---|
| 347 | else |
|---|
| 348 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 349 | require($lang); |
|---|
| 350 | |
|---|
| 351 | $sdate=$DATE->sdate(); |
|---|
| 352 | $edate=$DATE->edate(); |
|---|
| 353 | $bdate=$DATE->BeginDate(); |
|---|
| 354 | $eddate=$DATE->EndDate(); |
|---|
| 355 | |
|---|
| 356 | db_connect($SAMSConf->LOGDB) or exit(); |
|---|
| 357 | mysql_select_db($SAMSConf->LOGDB); |
|---|
| 358 | |
|---|
| 359 | $imagefile = "$SAMSConf->ICONSET/user.jpg"; |
|---|
| 360 | $image = PDF_load_image($pdfFile, "auto", $imagefile, ""); |
|---|
| 361 | if(!$image) |
|---|
| 362 | { |
|---|
| 363 | die( "Error: " . PDF_get_errmsg($pdfFile) ); |
|---|
| 364 | } |
|---|
| 365 | $fontdir = "lib/font/"; |
|---|
| 366 | pdf_set_parameter($pdfFile, "FontOutline", "Nimbus=$fontdir/Nimbus.ttf"); |
|---|
| 367 | |
|---|
| 368 | $result=mysql_query("SELECT * FROM ".$SAMSConf->SAMSDB.".squidusers WHERE squidusers.size>\"0\" "); |
|---|
| 369 | while($row=mysql_fetch_array($result)) |
|---|
| 370 | { |
|---|
| 371 | $ycount=700; |
|---|
| 372 | if($row['size']>0) |
|---|
| 373 | { |
|---|
| 374 | pdf_begin_page($pdfFile, 595, 842); |
|---|
| 375 | |
|---|
| 376 | $result2=mysql_query("SELECT sum(cachesum.size),cachesum.date,cachesum.user,cachesum.domain,sum(cachesum.hit) FROM cachesum WHERE cachesum.user=\"$row[nick]\" &&cachesum.date>=\"$sdate\" &&cachesum.date<=\"$edate\" &&cachesum.domain=\"$row[domain]\" GROUP BY date"); |
|---|
| 377 | while($row2=mysql_fetch_array($result2)) |
|---|
| 378 | { |
|---|
| 379 | if($ycount>=700) |
|---|
| 380 | { |
|---|
| 381 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 382 | { |
|---|
| 383 | $font = PDF_findfont($pdfFile, "Nimbus", "cp1251",1); |
|---|
| 384 | PDF_setfont($pdfFile, $font, 16); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | PDF_fit_image($pdfFile, $image, 50, 760, "" ); |
|---|
| 388 | pdf_show_xy($pdfFile, "$traffic_1 $row[nick]", 170, 780); |
|---|
| 389 | pdf_show_xy($pdfFile, "$userbuttom_2_traffic_UserTrafficPeriod_2", 120, 760); |
|---|
| 390 | PDF_setfont($pdfFile, $font, 10); |
|---|
| 391 | pdf_show_xy($pdfFile, "$traffic_2 $bdate $traffic_3 $eddate", 220, 740); |
|---|
| 392 | |
|---|
| 393 | pdf_moveto($pdfFile, 20, 720); |
|---|
| 394 | pdf_lineto($pdfFile, 575, 720); |
|---|
| 395 | pdf_stroke($pdfFile); |
|---|
| 396 | |
|---|
| 397 | PDF_setfont($pdfFile, $font, 12); |
|---|
| 398 | pdf_show_xy($pdfFile, "$traffic_data", 110, $ycount); |
|---|
| 399 | pdf_show_xy($pdfFile, "$userbuttom_2_traffic_UserTrafficPeriod_5", 290, $ycount); |
|---|
| 400 | $ycount-=30; |
|---|
| 401 | PDF_setfont($pdfFile, $font, 11); |
|---|
| 402 | } |
|---|
| 403 | |
|---|
| 404 | $aaa=ReturnDate($row2['date']); |
|---|
| 405 | pdf_show_xy($pdfFile, $aaa, 100, $ycount); |
|---|
| 406 | //pdf_show_xy($pdfFile, $row2[4], 230, $ycount); |
|---|
| 407 | if($SAMSConf->realtraffic=="real") |
|---|
| 408 | { |
|---|
| 409 | $aaa=ReturnTrafficFormattedSize($row2[0]-$row2[4]); |
|---|
| 410 | pdf_show_xy($pdfFile, $aaa, 290, $ycount); |
|---|
| 411 | } |
|---|
| 412 | else |
|---|
| 413 | { |
|---|
| 414 | $aaa=ReturnTrafficFormattedSize($row2[0]); |
|---|
| 415 | pdf_show_xy($pdfFile, $aaa, 290, $ycount); |
|---|
| 416 | |
|---|
| 417 | } |
|---|
| 418 | |
|---|
| 419 | $size=$size+$row[0]; |
|---|
| 420 | $cache=$cache+$row[4]; |
|---|
| 421 | $ycount-=20; |
|---|
| 422 | |
|---|
| 423 | if($ycount==40) |
|---|
| 424 | { |
|---|
| 425 | PDF_setfont($pdfFile, $font, 9); |
|---|
| 426 | pdf_show_xy($pdfFile, "Created by SAMS (C) 2003-2008", 250, 20); |
|---|
| 427 | pdf_show_xy($pdfFile, "page $PAGE", 500, 10); |
|---|
| 428 | pdf_end_page($pdfFile); |
|---|
| 429 | pdf_begin_page($pdfFile, 595, 842); |
|---|
| 430 | $ycount=700; |
|---|
| 431 | $PAGE+=1; |
|---|
| 432 | } |
|---|
| 433 | } |
|---|
| 434 | mysql_free_result($result2); |
|---|
| 435 | |
|---|
| 436 | //if($ycount!=500) |
|---|
| 437 | PDF_setfont($pdfFile, $font, 9); |
|---|
| 438 | pdf_show_xy($pdfFile, "Created by SAMS (C) 2003-2008", 250, 20); |
|---|
| 439 | pdf_show_xy($pdfFile, "page $PAGE", 500, 10); |
|---|
| 440 | pdf_end_page($pdfFile); |
|---|
| 441 | $PAGE+=1; |
|---|
| 442 | } |
|---|
| 443 | |
|---|
| 444 | } |
|---|
| 445 | mysql_free_result($result); |
|---|
| 446 | PDF_close_image($pdfFile, $image); |
|---|
| 447 | |
|---|
| 448 | } |
|---|
| 449 | |
|---|
| 450 | |
|---|
| 451 | global $pdfFile; |
|---|
| 452 | global $SAMSConf; |
|---|
| 453 | global $DATE; |
|---|
| 454 | global $PAGE; |
|---|
| 455 | |
|---|
| 456 | //echo "$argv[0] $argv[1] $argv[2]\n"; |
|---|
| 457 | if($argv[1]==1) |
|---|
| 458 | { |
|---|
| 459 | $path="$argv[2]/mysqltools.php"; |
|---|
| 460 | require($path); |
|---|
| 461 | } |
|---|
| 462 | else |
|---|
| 463 | require('./mysqltools.php'); |
|---|
| 464 | |
|---|
| 465 | $year=strftime("%Y"); |
|---|
| 466 | $mon=strftime("%m"); |
|---|
| 467 | $day=strftime("%d"); |
|---|
| 468 | |
|---|
| 469 | $DATE=new DATE(Array( 1, $mon, $year, 0, 31, $mon, $year, 23), $sdate, $edate); |
|---|
| 470 | $SAMSConf=new SAMSCONFIG(); |
|---|
| 471 | if($SAMSConf->LANGCODE=="RU") |
|---|
| 472 | $lang="./lang/lang.WIN1251"; |
|---|
| 473 | else |
|---|
| 474 | $lang="./lang/lang.$SAMSConf->LANG"; |
|---|
| 475 | require($lang); |
|---|
| 476 | |
|---|
| 477 | $PAGE=1; |
|---|
| 478 | if($SAMSConf->PDFLIB=="pdflib") |
|---|
| 479 | { |
|---|
| 480 | $pdfFile=pdf_new(); |
|---|
| 481 | PDF_open_file($pdfFile, ""); |
|---|
| 482 | pdf_set_info($pdfFile, "Creator", "Created by SAMS"); |
|---|
| 483 | pdf_set_info($pdfFile, "Title", "$usersbuttom_2_traffic_UsersTrafficPeriod_1 $usersbuttom_2_traffic_UsersTrafficPeriod_2"); |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | UsersTrafficPeriodPDFlib($pdfFile); |
|---|
| 487 | AllUsersTrafficPDFlib(); |
|---|
| 488 | |
|---|
| 489 | pdf_close($pdfFile); |
|---|
| 490 | $pdf = pdf_get_buffer($pdfFile); |
|---|
| 491 | $pdflen = strlen($pdf); |
|---|
| 492 | print("$pdf"); |
|---|
| 493 | pdf_delete($pdfFile); |
|---|
| 494 | |
|---|
| 495 | } |
|---|
| 496 | if($SAMSConf->PDFLIB=="fpdf") |
|---|
| 497 | { |
|---|
| 498 | define('FPDF_FONTPATH','lib/font/'); |
|---|
| 499 | require('lib/fpdf.php'); |
|---|
| 500 | $pdfFile = new FPDF(); |
|---|
| 501 | $pdfFile->Open(); |
|---|
| 502 | |
|---|
| 503 | $pdfFile-> AddFont('Nimbus','','Nimbus.php'); |
|---|
| 504 | $pdfFile->SetAuthor("SQUID Account Management System"); |
|---|
| 505 | $pdfFile->SetCreator("Created by SAMS."); |
|---|
| 506 | $pdfFile->SetTitle("SAMS users statistic"); |
|---|
| 507 | UsersTrafficPeriodPDF(); |
|---|
| 508 | AllUsersTrafficPDF(); |
|---|
| 509 | $pdfFile->Output(); |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | |
|---|
| 513 | ?> |
|---|