How to use info class

Best Phoronix-test-suite code snippet using info

ad_statistic.php

Source:ad_statistic.php Github

copy

Full Screen

...91 $timezone = $Info->option['timezone'] * 3600;92 $today = getdate(CURRENT_TIME + $timezone);93 //Filter -------------------------94 //Date from95 $dfrom_info = $this->get_date_info($this->filter['date_from'], 0);96 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){97 $dfrom_info['month'] = $today['mon'] - 6;98 }99 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){100 $dfrom_info['year'] = $today['year'];101 }102 if ( $dfrom_info['month'] < 1 ){103 $dfrom_info['month'] += 12;104 $dfrom_info['year']--;105 }106 //Date to107 $dto_info = $this->get_date_info($this->filter['date_to'], 0);108 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){109 $dto_info['month'] = $today['mon'];110 }111 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){112 $dto_info['year'] = $today['year'];113 }114 //Check dates115 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){116 $dfrom_info['month'] = $today['mon'] - 6;117 $dto_info['year'] = $today['year'];118 if ( $dfrom_info['month'] < 1 ){119 $dfrom_info['month'] += 12;120 $dfrom_info['year']--;121 }122 $dto_info['month'] = $today['mon'];123 $dto_info['year'] = $today['year'];124 }125 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-01';126 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-31';127 //--------------------------------128 //Get stat info129 $DB->query("SELECT MONTH(stat_date) AS stat_month, YEAR(stat_date) AS stat_year, sum(day_visitors) AS month_visitors FROM ". $DB->prefix ."stat_day WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY MONTH(stat_date) ORDER BY stat_date ASC");130 $stat_count = $DB->num_rows();131 $stat_data = $DB->fetch_all_array();132 $DB->free_result();133 //Count total visitors134 $total_visitors = 0;135 for ($i=0; $i<$stat_count; $i++){136 $total_visitors += $stat_data[$i]['month_visitors'];137 }138 //List stats139 $month_names = explode(',', $Lang->data['general_date_month']);140 for ($i=0; $i<$stat_count; $i++){141 $percent = !$total_visitors ? '0%' : round(($stat_data[$i]['month_visitors'] * 100) / $total_visitors, 1) .'%';142 $month_number = $stat_data[$i]["stat_month"] - 1; //Convert from 1-12 to 0-11 for month number143 $Template->set_block_vars("statrow", array(144 "MONTH" => isset($month_names[$month_number]) ? trim($month_names[$month_number]) : $stat_data[$i]["stat_month"],145 "YEAR" => $stat_data[$i]["stat_year"],146 "VISITORS" => $stat_data[$i]["month_visitors"],147 "PERCENT" => $percent,148 ));149 }150 $Template->set_vars(array(151 'TOTAL_VISITORS' => $total_visitors,152 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], 0, $dfrom_info['year']),153 'FDATE_TO' => $this->make_date_string($dto_info['month'], 0, $dto_info['year']),154 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_months"],155 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),156 "L_DATE_FROM" => $Lang->data["stat_date_from"],157 "L_DATE_TO" => $Lang->data["stat_date_to"],158 "L_MONTHS" => $Lang->data["stat_months"],159 "L_VISITORS" => $Lang->data["stat_visitors"],160 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],161 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],162 ));163 }164 function view_stat_days(){165 global $Session, $DB, $Template, $Lang, $Info, $Func;166 $Info->tpl_main = "statistic_days";167 $timezone = $Info->option['timezone'] * 3600;168 $today = getdate(CURRENT_TIME + $timezone);169 //Filter -------------------------170 //Date from171 $dfrom_info = $this->get_date_info($this->filter['date_from']);172 if ( ($dfrom_info['day'] < 1) || ($dfrom_info['day'] > 31) ){173 $dfrom_info['day'] = 1;174 }175 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){176 $dfrom_info['month'] = $today['mon'] - 3;177 }178 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){179 $dfrom_info['year'] = $today['year'];180 }181 if ( $dfrom_info['month'] < 1 ){182 $dfrom_info['month'] += 12;183 $dfrom_info['year']--;184 }185 //Date to186 $dto_info = $this->get_date_info($this->filter['date_to']);187 if ( ($dto_info['day'] < 1) || ($dto_info['day'] > 31) ){188 $dto_info['day'] = 31;189 }190 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){191 $dto_info['month'] = $today['mon'];192 }193 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){194 $dto_info['year'] = $today['year'];195 }196 //Check dates197 while ( ($dto_info['day'] > 0) && !$Func->check_anydate($dto_info['month'], $dto_info['day'], $dto_info['year']) ){198 $dto_info['day']--;199 }200 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){201 $dfrom_info['month'] = $today['mon'] - 3;202 $dto_info['year'] = $today['year'];203 if ( $dfrom_info['month'] < 1 ){204 $dfrom_info['month'] += 12;205 $dfrom_info['year']--;206 }207 $dto_info['month'] = $today['mon'];208 $dto_info['year'] = $today['year'];209 }210 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-'. $dfrom_info['day'];211 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-'. $dto_info['day'];212 //--------------------------------213 //Get stat info214 $DB->query("SELECT WEEKDAY(stat_date) AS wday, sum(day_visitors) AS wday_visitors FROM ". $DB->prefix ."stat_day WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY wday ORDER BY wday ASC");215 $stat_count = $DB->num_rows();216 $stat_data = $DB->fetch_all_array();217 $DB->free_result();218 //Count total visitors219 $total_visitors = 0;220 for ($i=0; $i<$stat_count; $i++){221 $total_visitors += $stat_data[$i]['wday_visitors'];222 }223 //List stats224 $week_names = explode(',', $Lang->data['general_date_day']);225 for ($i=0; $i<7; $i++){226 $flag = -1;227 for ($j=0; $j<$stat_count; $j++){228 if ( $stat_data[$j]["wday"] == $i ){229 $flag = $j;230 break;231 }232 }233 if ( $flag != -1 ){234 $percent = !$total_visitors ? '0%' : round(($stat_data[$flag]['wday_visitors'] * 100) / $total_visitors, 1) .'%';235 $Template->set_block_vars("statrow", array(236 "WDAY" => isset($week_names[$stat_data[$flag]["wday"]]) ? trim($week_names[$stat_data[$flag]["wday"]]) : $stat_data[$flag]["wday"],237 "VISITORS" => $stat_data[$flag]["wday_visitors"],238 "PERCENT" => $percent,239 ));240 }241 else{242 $Template->set_block_vars("statrow", array(243 "WDAY" => isset($week_names[$i]) ? trim($week_names[$i]) : $i,244 "VISITORS" => 0,245 "PERCENT" => '0%',246 ));247 }248 }249 $month_names = explode(',', $Lang->data['general_date_month']);250 $dfrom_day = sprintf('%02d', $dfrom_info['day']);251 $dto_day = sprintf('%02d', $dto_info['day']);252 $Template->set_vars(array(253 'TOTAL_VISITORS' => $total_visitors,254 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], $dfrom_info['day'], $dfrom_info['year']),255 'FDATE_TO' => $this->make_date_string($dto_info['month'], $dto_info['day'], $dto_info['year']),256 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_days"],257 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $dfrom_day .' '. $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $dto_day .' '. $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),258 "L_DATE_FROM" => $Lang->data["stat_date_from"],259 "L_DATE_TO" => $Lang->data["stat_date_to"],260 "L_DAYS" => $Lang->data["stat_days"],261 "L_VISITORS" => $Lang->data["stat_visitors"],262 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],263 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],264 ));265 }266 function view_stat_hours(){267 global $Session, $DB, $Template, $Lang, $Info, $Func;268 $Info->tpl_main = "statistic_hours";269 $timezone = $Info->option['timezone'] * 3600;270 $today = getdate(CURRENT_TIME + $timezone);271 //Filter -------------------------272 //Date from273 $dfrom_info = $this->get_date_info($this->filter['date_from']);274 if ( ($dfrom_info['day'] < 1) || ($dfrom_info['day'] > 31) ){275 $dfrom_info['day'] = 1;276 }277 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){278 $dfrom_info['month'] = $today['mon'] - 3;279 }280 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){281 $dfrom_info['year'] = $today['year'];282 }283 if ( $dfrom_info['month'] < 1 ){284 $dfrom_info['month'] += 12;285 $dfrom_info['year']--;286 }287 //Date to288 $dto_info = $this->get_date_info($this->filter['date_to']);289 if ( ($dto_info['day'] < 1) || ($dto_info['day'] > 31) ){290 $dto_info['day'] = 31;291 }292 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){293 $dto_info['month'] = $today['mon'];294 }295 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){296 $dto_info['year'] = $today['year'];297 }298 //Check dates299 while ( ($dto_info['day'] > 0) && !$Func->check_anydate($dto_info['month'], $dto_info['day'], $dto_info['year']) ){300 $dto_info['day']--;301 }302 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){303 $dfrom_info['month'] = $today['mon'] - 3;304 $dto_info['year'] = $today['year'];305 if ( $dfrom_info['month'] < 1 ){306 $dfrom_info['month'] += 12;307 $dfrom_info['year']--;308 }309 $dto_info['month'] = $today['mon'];310 $dto_info['year'] = $today['year'];311 }312 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-'. $dfrom_info['day'];313 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-'. $dto_info['day'];314 //--------------------------------315 //Get stat info316 $DB->query("SELECT stat_hour, SUM(hour_visitors) AS dhour_visitors FROM ". $DB->prefix ."stat_hour WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY stat_hour ORDER BY stat_hour ASC");317 $stat_count = $DB->num_rows();318 $stat_data = $DB->fetch_all_array();319 $DB->free_result();320 //Count total visitors321 $total_visitors = 0;322 for ($i=0; $i<$stat_count; $i++){323 $total_visitors += $stat_data[$i]['dhour_visitors'];324 }325 //List stats326 for ($i=0; $i<24; $i++){327 $flag = -1;328 for ($j=0; $j<$stat_count; $j++){329 if ( $stat_data[$j]["stat_hour"] == $i ){330 $flag = $j;331 break;332 }333 }334 if ( $flag != -1 ){335 $percent = !$total_visitors ? '0%' : round(($stat_data[$flag]['dhour_visitors'] * 100) / $total_visitors, 1) .'%';336 $Template->set_block_vars("statrow", array(337 "HOUR" => sprintf('%02d', $stat_data[$flag]["stat_hour"]),338 "VISITORS" => $stat_data[$flag]["dhour_visitors"],339 "PERCENT" => $percent,340 ));341 }342 else{343 $Template->set_block_vars("statrow", array(344 "HOUR" => sprintf('%02d', $i),345 "VISITORS" => 0,346 "PERCENT" => '0%',347 ));348 }349 }350 $month_names = explode(',', $Lang->data['general_date_month']);351 $dfrom_day = sprintf('%02d', $dfrom_info['day']);352 $dto_day = sprintf('%02d', $dto_info['day']);353 $Template->set_vars(array(354 'TOTAL_VISITORS' => $total_visitors,355 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], $dfrom_info['day'], $dfrom_info['year']),356 'FDATE_TO' => $this->make_date_string($dto_info['month'], $dto_info['day'], $dto_info['year']),357 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_hours"],358 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $dfrom_day .' '. $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $dto_day .' '. $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),359 "L_DATE_FROM" => $Lang->data["stat_date_from"],360 "L_DATE_TO" => $Lang->data["stat_date_to"],361 "L_HOURS" => $Lang->data["stat_hours"],362 "L_VISITORS" => $Lang->data["stat_visitors"],363 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],364 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],365 ));366 }367 function view_stat_countries(){368 global $Session, $DB, $Template, $Lang, $Info, $Func;369 $Info->tpl_main = "statistic_countries";370 $timezone = $Info->option['timezone'] * 3600;371 $today = getdate(CURRENT_TIME + $timezone);372 //Filter -------------------------373 //Date from374 $dfrom_info = $this->get_date_info($this->filter['date_from']);375 if ( ($dfrom_info['day'] < 1) || ($dfrom_info['day'] > 31) ){376 $dfrom_info['day'] = 1;377 }378 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){379 $dfrom_info['month'] = $today['mon'] - 3;380 }381 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){382 $dfrom_info['year'] = $today['year'];383 }384 if ( $dfrom_info['month'] < 1 ){385 $dfrom_info['month'] += 12;386 $dfrom_info['year']--;387 }388 //Date to389 $dto_info = $this->get_date_info($this->filter['date_to']);390 if ( ($dto_info['day'] < 1) || ($dto_info['day'] > 31) ){391 $dto_info['day'] = 31;392 }393 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){394 $dto_info['month'] = $today['mon'];395 }396 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){397 $dto_info['year'] = $today['year'];398 }399 //Check dates400 while ( ($dto_info['day'] > 0) && !$Func->check_anydate($dto_info['month'], $dto_info['day'], $dto_info['year']) ){401 $dto_info['day']--;402 }403 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){404 $dfrom_info['month'] = $today['mon'] - 3;405 $dto_info['year'] = $today['year'];406 if ( $dfrom_info['month'] < 1 ){407 $dfrom_info['month'] += 12;408 $dfrom_info['year']--;409 }410 $dto_info['month'] = $today['mon'];411 $dto_info['year'] = $today['year'];412 }413 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-'. $dfrom_info['day'];414 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-'. $dto_info['day'];415 //--------------------------------416 //Get stat info417 $DB->query("SELECT country_id, SUM(country_visitors) AS tcountry_visitors FROM ". $DB->prefix ."stat_country WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY country_id ORDER BY country_id ASC");418 $stat_count = $DB->num_rows();419 $stat_data = $DB->fetch_all_array();420 $DB->free_result();421 //Count total visitors422 $total_visitors = 0;423 $where_sql = "WHERE c2='..'";424 for ($i=0; $i<$stat_count; $i++){425 $total_visitors += $stat_data[$i]['tcountry_visitors'];426 $where_sql .= " OR c2='". $stat_data[$i]['country_id'] ."'";427 }428 //Get country names429 $DB->query("SELECT c2, country FROM ". $DB->prefix ."country_code ". $where_sql);430 $country_info = array();431 if ( $DB->num_rows() ){432 while ($tmp_info = $DB->fetch_array() ){433 $country_info[$tmp_info['c2']] = $tmp_info['country'];434 }435 }436 //List stats437 for ($i=0; $i<$stat_count; $i++){438 $country = $stat_data[$i]["country_id"];439 $percent = !$total_visitors ? '0%' : round(($stat_data[$i]['tcountry_visitors'] * 100) / $total_visitors, 1) .'%';440 $Template->set_block_vars("statrow", array(441 "COUNTRY" => ($country == '..') ? $Lang->data['stat_unknown'] : (isset($country_info[$country]) ? $country_info[$country] : $country),442 "FLAG" => ($country == '..') ? '' : ' <img src="images/flags/'. $country .'.gif" border="0">',443 "VISITORS" => $stat_data[$i]["tcountry_visitors"],444 "PERCENT" => $percent,445 ));446 }447 $month_names = explode(',', $Lang->data['general_date_month']);448 $dfrom_day = sprintf('%02d', $dfrom_info['day']);449 $dto_day = sprintf('%02d', $dto_info['day']);450 $Template->set_vars(array(451 'TOTAL_VISITORS' => $total_visitors,452 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], $dfrom_info['day'], $dfrom_info['year']),453 'FDATE_TO' => $this->make_date_string($dto_info['month'], $dto_info['day'], $dto_info['year']),454 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_countries"],455 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $dfrom_day .' '. $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $dto_day .' '. $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),456 "L_DATE_FROM" => $Lang->data["stat_date_from"],457 "L_DATE_TO" => $Lang->data["stat_date_to"],458 "L_COUNTRIES" => $Lang->data["stat_countries"],459 "L_VISITORS" => $Lang->data["stat_visitors"],460 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],461 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],462 ));463 }464 function view_stat_browsers(){465 global $Session, $DB, $Template, $Lang, $Info, $Func;466 $Info->tpl_main = "statistic_browsers";467 $timezone = $Info->option['timezone'] * 3600;468 $today = getdate(CURRENT_TIME + $timezone);469 //Filter -------------------------470 //Date from471 $dfrom_info = $this->get_date_info($this->filter['date_from']);472 if ( ($dfrom_info['day'] < 1) || ($dfrom_info['day'] > 31) ){473 $dfrom_info['day'] = 1;474 }475 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){476 $dfrom_info['month'] = $today['mon'] - 3;477 }478 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){479 $dfrom_info['year'] = $today['year'];480 }481 if ( $dfrom_info['month'] < 1 ){482 $dfrom_info['month'] += 12;483 $dfrom_info['year']--;484 }485 //Date to486 $dto_info = $this->get_date_info($this->filter['date_to']);487 if ( ($dto_info['day'] < 1) || ($dto_info['day'] > 31) ){488 $dto_info['day'] = 31;489 }490 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){491 $dto_info['month'] = $today['mon'];492 }493 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){494 $dto_info['year'] = $today['year'];495 }496 //Check dates497 while ( ($dto_info['day'] > 0) && !$Func->check_anydate($dto_info['month'], $dto_info['day'], $dto_info['year']) ){498 $dto_info['day']--;499 }500 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){501 $dfrom_info['month'] = $today['mon'] - 3;502 $dto_info['year'] = $today['year'];503 if ( $dfrom_info['month'] < 1 ){504 $dfrom_info['month'] += 12;505 $dfrom_info['year']--;506 }507 $dto_info['month'] = $today['mon'];508 $dto_info['year'] = $today['year'];509 }510 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-'. $dfrom_info['day'];511 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-'. $dto_info['day'];512 //--------------------------------513 //Get stat info514 $DB->query("SELECT browser_name, SUM(browser_visitors) AS tbrowser_visitors FROM ". $DB->prefix ."stat_browser WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY browser_name ORDER BY browser_name ASC");515 $stat_count = $DB->num_rows();516 $stat_data = $DB->fetch_all_array();517 $DB->free_result();518 //Count total visitors519 $total_visitors = 0;520 for ($i=0; $i<$stat_count; $i++){521 $total_visitors += $stat_data[$i]['tbrowser_visitors'];522 }523 //List stats524 for ($i=0; $i<$stat_count; $i++){525 $percent = !$total_visitors ? '0%' : round(($stat_data[$i]['tbrowser_visitors'] * 100) / $total_visitors, 1) .'%';526 $Template->set_block_vars("statrow", array(527 "BROWSER" => ($stat_data[$i]["browser_name"] == '..') ? $Lang->data['stat_unknown'] : $stat_data[$i]["browser_name"],528 "VISITORS" => $stat_data[$i]["tbrowser_visitors"],529 "PERCENT" => $percent,530 ));531 }532 $month_names = explode(',', $Lang->data['general_date_month']);533 $dfrom_day = sprintf('%02d', $dfrom_info['day']);534 $dto_day = sprintf('%02d', $dto_info['day']);535 $Template->set_vars(array(536 'TOTAL_VISITORS' => $total_visitors,537 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], $dfrom_info['day'], $dfrom_info['year']),538 'FDATE_TO' => $this->make_date_string($dto_info['month'], $dto_info['day'], $dto_info['year']),539 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_browsers"],540 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $dfrom_day .' '. $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $dto_day .' '. $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),541 "L_DATE_FROM" => $Lang->data["stat_date_from"],542 "L_DATE_TO" => $Lang->data["stat_date_to"],543 "L_BROWSERS" => $Lang->data["stat_browsers"],544 "L_VISITORS" => $Lang->data["stat_visitors"],545 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],546 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],547 ));548 }549 function view_stat_referers(){550 global $Session, $DB, $Template, $Lang, $Info, $Func;551 $Info->tpl_main = "statistic_referers";552 $timezone = $Info->option['timezone'] * 3600;553 $today = getdate(CURRENT_TIME + $timezone);554 //Filter -------------------------555 //Date from556 $dfrom_info = $this->get_date_info($this->filter['date_from']);557 if ( ($dfrom_info['day'] < 1) || ($dfrom_info['day'] > 31) ){558 $dfrom_info['day'] = 1;559 }560 if ( ($dfrom_info['month'] < 1) || ($dfrom_info['month'] > 12) ){561 $dfrom_info['month'] = $today['mon'] - 3;562 }563 if ( ($dfrom_info['year'] < 1) || ($dfrom_info['year'] > 9999) ){564 $dfrom_info['year'] = $today['year'];565 }566 if ( $dfrom_info['month'] < 1 ){567 $dfrom_info['month'] += 12;568 $dfrom_info['year']--;569 }570 //Date to571 $dto_info = $this->get_date_info($this->filter['date_to']);572 if ( ($dto_info['day'] < 1) || ($dto_info['day'] > 31) ){573 $dto_info['day'] = 31;574 }575 if ( ($dto_info['month'] < 1) || ($dto_info['month'] > 12) ){576 $dto_info['month'] = $today['mon'];577 }578 if ( ($dto_info['year'] < 1) || ($dto_info['year'] > 9999) ){579 $dto_info['year'] = $today['year'];580 }581 //Check dates582 while ( ($dto_info['day'] > 0) && !$Func->check_anydate($dto_info['month'], $dto_info['day'], $dto_info['year']) ){583 $dto_info['day']--;584 }585 if ( ($dto_info['year'] < $dfrom_info['year']) || (($dto_info['year'] == $dfrom_info['year']) && ($dto_info['month'] < $dfrom_info['month'])) ){586 $dfrom_info['month'] = $today['mon'] - 3;587 $dto_info['year'] = $today['year'];588 if ( $dfrom_info['month'] < 1 ){589 $dfrom_info['month'] += 12;590 $dfrom_info['year']--;591 }592 $dto_info['month'] = $today['mon'];593 $dto_info['year'] = $today['year'];594 }595 $date_from = $dfrom_info['year'] .'-'. $dfrom_info['month'] .'-'. $dfrom_info['day'];596 $date_to = $dto_info['year'] .'-'. $dto_info['month'] .'-'. $dto_info['day'];597 //--------------------------------598 //Get stat info599 $DB->query("SELECT referer_url, SUM(referer_visitors) AS treferer_visitors FROM ". $DB->prefix ."stat_referer WHERE stat_date>='". $date_from ."' AND stat_date<='". $date_to ."' GROUP BY referer_url ORDER BY referer_url ASC");600 $stat_count = $DB->num_rows();601 $stat_data = $DB->fetch_all_array();602 $DB->free_result();603 //Count total visitors604 $total_visitors = 0;605 for ($i=0; $i<$stat_count; $i++){606 $total_visitors += $stat_data[$i]['treferer_visitors'];607 }608 //List stats609 for ($i=0; $i<$stat_count; $i++){610 $percent = !$total_visitors ? '0%' : round(($stat_data[$i]['treferer_visitors'] * 100) / $total_visitors, 1) .'%';611 $Template->set_block_vars("statrow", array(612 "REFERER" => ($stat_data[$i]["referer_url"] == '..') ? $Lang->data['stat_unknown'] : $stat_data[$i]["referer_url"],613 "VISITORS" => $stat_data[$i]["treferer_visitors"],614 "PERCENT" => $percent,615 ));616 }617 $month_names = explode(',', $Lang->data['general_date_month']);618 $dfrom_day = sprintf('%02d', $dfrom_info['day']);619 $dto_day = sprintf('%02d', $dto_info['day']);620 $Template->set_vars(array(621 'TOTAL_VISITORS' => $total_visitors,622 'FDATE_FROM' => $this->make_date_string($dfrom_info['month'], $dfrom_info['day'], $dfrom_info['year']),623 'FDATE_TO' => $this->make_date_string($dto_info['month'], $dto_info['day'], $dto_info['year']),624 "L_PAGE_TITLE" => $Lang->data["menu_admin"] . $Lang->data['general_arrow'] . $Lang->data["menu_admin_stat"] . $Lang->data['general_arrow'] . $Lang->data["stat_report_referers"],625 'L_REPORT_TITLE' => sprintf($Lang->data['stat_from_to_date'], $dfrom_day .' '. $month_names[$dfrom_info['month'] - 1] .' '. $dfrom_info['year'], $dto_day .' '. $month_names[$dto_info['month'] - 1] .' '. $dto_info['year'] ),626 "L_DATE_FROM" => $Lang->data["stat_date_from"],627 "L_DATE_TO" => $Lang->data["stat_date_to"],628 "L_REFERERS" => $Lang->data["stat_referers"],629 "L_VISITORS" => $Lang->data["stat_visitors"],630 "L_TOTAL_VISITORS" => $Lang->data["stat_total_visitors"],631 "L_BUTTON_VIEW" => $Lang->data["stat_button_view"],632 ));633 }634 function get_date_info($date_string, $get_day = 1){635 $date_info = explode($this->date_separate, $date_string);636 $count = 0;637 $result = array();638 $result['month'] = isset($date_info[$count]) ? intval($date_info[$count]) : 0;639 $count++;640 if ( $get_day ){641 $result['day'] = isset($date_info[$count]) ? intval($date_info[$count]) : 0;642 $count++;643 }644 $result['year'] = isset($date_info[$count]) ? intval($date_info[$count]) : 0;645 if ( ($result['year'] > 1) && ($result['year'] < 100) ){646 $result['year'] += 2000;647 }648 return $result;649 }650 function make_date_string($month, $day, $year){651 if ( $day > 0 ){652 return sprintf('%02d', $month) . $this->date_separate . sprintf('%02d', $day) . $this->date_separate . sprintf('%04d', $year);653 }654 else{655 return sprintf('%02d', $month) . $this->date_separate . sprintf('%04d', $year);656 }657 }658}...

Full Screen

Full Screen

tables_update.inc.php

Source:tables_update.inc.php Github

copy

Full Screen

...24 while ($phpgw_setup->oProc->next_record())25 {26 $owner[count($owner)] = $phpgw_setup->oProc->f($field);27 }28 if($phpgw_setup->alessthanb($setup_info['phpgwapi']['currentver'],'0.9.10pre4'))29 {30 $acctstbl = 'accounts';31 }32 else33 {34 $acctstbl = 'phpgw_accounts';35 }36 for($i=0;$i<count($owner);$i++)37 {38 $phpgw_setup->oProc->query("SELECT account_id FROM $acctstbl WHERE account_lid='".$owner[$i]."'");39 $phpgw_setup->oProc->next_record();40 $phpgw_setup->oProc->query("UPDATE $table SET $field=".$phpgw_setup->oProc->f("account_id")." WHERE $field='".$owner[$i]."'");41 }42 }43 $phpgw_setup->oProc->AlterColumn($table, $field, array('type' => 'int', 'precision' => 4, 'nullable' => false, 'default' => 0));44 }45 $test[] = '0.9.1';46 function todo_upgrade0_9_1()47 {48 global $setup_info;49 $setup_info['todo']['currentver'] = '0.9.2';50 return $setup_info['todo']['currentver'];51 }52 $test[] = '0.9.2';53 function todo_upgrade0_9_2()54 {55 global $setup_info;56 $setup_info['todo']['currentver'] = '0.9.3pre1';57 return $setup_info['todo']['currentver'];58 }59 $test[] = '0.9.3pre1';60 function todo_upgrade0_9_3pre1()61 {62 global $setup_info;63 todo_v0_9_2to0_9_3update_owner('todo','todo_owner');64 $setup_info['todo']['currentver'] = '0.9.3pre2';65 return $setup_info['todo']['currentver'];66 }67 $test[] = '0.9.3pre2';68 function todo_upgrade0_9_3pre2()69 {70 global $setup_info;71 $setup_info['todo']['currentver'] = '0.9.3pre3';72 return $setup_info['todo']['currentver'];73 }74 $test[] = '0.9.3pre3';75 function todo_upgrade0_9_3pre3()76 {77 global $setup_info, $phpgw_setup;78 $phpgw_setup->oProc->AddColumn("todo", "todo_id_parent", array("type" => "int", "precision" => 4, "nullable" => false, "default" => "0"));79 $setup_info['todo']['currentver'] = '0.9.3pre4';80 return $setup_info['todo']['currentver'];81 }82 $test[] = '0.9.3pre4';83 function todo_upgrade0_9_3pre4()84 {85 global $setup_info;86 $setup_info['todo']['currentver'] = '0.9.3pre4';87 return $setup_info['todo']['currentver'];88 }89 $test[] = '0.9.3pre5';90 function todo_upgrade0_9_3pre5()91 {92 global $setup_info;93 $setup_info['todo']['currentver'] = '0.9.3pre6';94 return $setup_info['todo']['currentver'];95 }96 $test[] = '0.9.3pre6';97 function todo_upgrade0_9_3pre6()98 {99 global $setup_info;100 $setup_info['todo']['currentver'] = '0.9.3pre7';101 return $setup_info['todo']['currentver'];102 }103 $test[] = '0.9.3pre7';104 function todo_upgrade0_9_3pre7()105 {106 global $setup_info;107 $setup_info['todo']['currentver'] = '0.9.3pre8';108 return $setup_info['todo']['currentver'];109 }110 $test[] = '0.9.3pre8';111 function todo_upgrade0_9_3pre8()112 {113 global $setup_info;114 $setup_info['todo']['currentver'] = '0.9.3pre9';115 return $setup_info['todo']['currentver'];116 }117 $test[] = '0.9.3pre9';118 function todo_upgrade0_9_3pre9()119 {120 global $setup_info;121 $setup_info['todo']['currentver'] = '0.9.3pre10';122 return $setup_info['todo']['currentver'];123 }124 $test[] = '0.9.3pre10';125 function todo_upgrade0_9_3pre10()126 {127 global $setup_info;128 $setup_info['todo']['currentver'] = '0.9.3';129 return $setup_info['todo']['currentver'];130 }131 $test[] = '0.9.3';132 function todo_upgrade0_9_3()133 {134 global $setup_info;135 $setup_info['todo']['currentver'] = '0.9.4pre1';136 return $setup_info['todo']['currentver'];137 }138 $test[] = '0.9.4pre1';139 function todo_upgrade0_9_4pre1()140 {141 global $setup_info;142 $setup_info['todo']['currentver'] = '0.9.4pre2';143 return $setup_info['todo']['currentver'];144 }145 $test[] = '0.9.4pre2';146 function todo_upgrade0_9_4pre2()147 {148 global $setup_info;149 $setup_info['todo']['currentver'] = '0.9.4pre3';150 return $setup_info['todo']['currentver'];151 }152 $test[] = '0.9.4pre3';153 function todo_upgrade0_9_4pre3()154 {155 global $phpgw_info, $phpgw_setup;156 $phpgw_setup->oProc->AddColumn("todo", "todo_startdate", array("type" => "int", "precision" => 4));157 $phpgw_setup->oProc->RenameColumn("todo", "todo_datedue", "todo_enddate");158 $setup_info['todo']['currentver'] = '0.9.4pre4';159 return $setup_info['todo']['currentver'];160 }161 $test[] = '0.9.4pre4';162 function todo_upgrade0_9_4pre4()163 {164 global $setup_info;165 $setup_info['todo']['currentver'] = '0.9.4pre5';166 return $setup_info['todo']['currentver'];167 }168 $test[] = '0.9.4pre5';169 function todo_upgrade0_9_4pre5()170 {171 global $setup_info;172 $setup_info['todo']['currentver'] = '0.9.4';173 return $setup_info['todo']['currentver'];174 }175 $test[] = '0.9.4';176 function todo_upgrade0_9_4()177 {178 global $setup_info;179 $setup_info['todo']['currentver'] = '0.9.5pre1';180 return $setup_info['todo']['currentver'];181 }182 $test[] = '0.9.5pre1';183 function todo_upgrade0_9_5pre1()184 {185 global $setup_info;186 $setup_info['todo']['currentver'] = '0.9.5pre2';187 return $setup_info['todo']['currentver'];188 }189 $test[] = '0.9.5pre2';190 function todo_upgrade0_9_5pre2()191 {192 global $setup_info;193 $setup_info['todo']['currentver'] = '0.9.5';194 return $setup_info['todo']['currentver'];195 }196 $test[] = '0.9.5';197 function todo_upgrade0_9_5()198 {199 global $setup_info;200 $setup_info['todo']['currentver'] = '0.9.6';201 return $setup_info['todo']['currentver'];202 }203 $test[] = '0.9.6';204 function todo_upgrade0_9_6()205 {206 global $setup_info;207 $setup_info['todo']['currentver'] = '0.9.7pre1';208 return $setup_info['todo']['currentver'];209 }210 $test[] = '0.9.7pre1';211 function todo_upgrade0_9_7pre1()212 {213 global $setup_info;214 $setup_info['todo']['currentver'] = '0.9.7pre2';215 return $setup_info['todo']['currentver'];216 }217 $test[] = '0.9.7pre2';218 function todo_upgrade0_9_7pre2()219 {220 global $setup_info;221 $setup_info['todo']['currentver'] = '0.9.7pre3';222 return $setup_info['todo']['currentver'];223 }224 $test[] = '0.9.7pre3';225 function todo_upgrade0_9_7pre3()226 {227 global $setup_info;228 $setup_info['todo']['currentver'] = '0.9.7';229 return $setup_info['todo']['currentver'];230 }231 $test[] = '0.9.7';232 function todo_upgrade0_9_7()233 {234 global $setup_info;235 $setup_info['todo']['currentver'] = '0.9.8pre1';236 return $setup_info['todo']['currentver'];237 }238 $test[] = '0.9.8pre1';239 function todo_upgrade0_9_8pre1()240 {241 global $setup_info;242 $setup_info['todo']['currentver'] = '0.9.8pre2';243 return $setup_info['todo']['currentver'];244 }245 $test[] = '0.9.8pre2';246 function todo_upgrade0_9_8pre2()247 {248 global $setup_info;249 $setup_info['todo']['currentver'] = '0.9.8pre3';250 return $setup_info['todo']['currentver'];251 }252 $test[] = '0.9.8pre3';253 function todo_upgrade0_9_8pre3()254 {255 global $setup_info;256 $setup_info['todo']['currentver'] = '0.9.8pre4';257 return $setup_info['todo']['currentver'];258 }259 $test[] = '0.9.8pre4';260 function todo_upgrade0_9_8pre4()261 {262 global $setup_info;263 $setup_info['todo']['currentver'] = '0.9.8pre5';264 return $setup_info['todo']['currentver'];265 }266 $test[] = '0.9.8pre5';267 function todo_upgrade0_9_8pre5()268 {269 global $setup_info;270 $setup_info['todo']['currentver'] = '0.9.9pre1';271 return $setup_info['todo']['currentver'];272 }273 $test[] = '0.9.9pre1';274 function todo_upgrade0_9_9pre1()275 {276 global $setup_info;277 $setup_info['todo']['currentver'] = '0.9.9';278 return $setup_info['todo']['currentver'];279 }280 $test[] = '0.9.9';281 function todo_upgrade0_9_9()282 {283 global $setup_info;284 $setup_info['todo']['currentver'] = '0.9.10pre1';285 return $setup_info['todo']['currentver'];286 }287 $test[] = '0.9.10pre1';288 function todo_upgrade0_9_10pre1()289 {290 global $setup_info;291 $setup_info['todo']['currentver'] = '0.9.10pre2';292 return $setup_info['todo']['currentver'];293 }294 $test[] = '0.9.10pre2';295 function todo_upgrade0_9_10pre2()296 {297 global $setup_info;298 $setup_info['todo']['currentver'] = '0.9.10pre3';299 return $setup_info['todo']['currentver'];300 }301 $test[] = '0.9.10pre3';302 function todo_upgrade0_9_10pre3()303 {304 global $setup_info;305 $setup_info['todo']['currentver'] = '0.9.10pre4';306 return $setup_info['todo']['currentver'];307 }308 $test[] = '0.9.10pre4';309 function todo_upgrade0_9_10pre4()310 {311 global $setup_info;312 $setup_info['todo']['currentver'] = '0.9.10pre5';313 return $setup_info['todo']['currentver'];314 }315 $test[] = '0.9.10pre5';316 function todo_upgrade0_9_10pre5()317 {318 global $setup_info;319 $setup_info['todo']['currentver'] = '0.9.10pre6';320 return $setup_info['todo']['currentver'];321 }322 $test[] = '0.9.10pre6';323 function todo_upgrade0_9_10pre6()324 {325 global $setup_info;326 $setup_info['todo']['currentver'] = '0.9.10pre7';327 return $setup_info['todo']['currentver'];328 }329 $test[] = '0.9.10pre7';330 function todo_upgrade0_9_10pre7()331 {332 global $setup_info;333 $setup_info['todo']['currentver'] = '0.9.10pre8';334 return $setup_info['todo']['currentver'];335 }336 $test[] = '0.9.10pre8';337 function todo_upgrade0_9_10pre8()338 {339 global $setup_info;340 $setup_info['todo']['currentver'] = '0.9.10pre9';341 return $setup_info['todo']['currentver'];342 }343 $test[] = '0.9.10pre9';344 function todo_upgrade0_9_10pre9()345 {346 global $setup_info;347 $setup_info['todo']['currentver'] = '0.9.10pre10';348 return $setup_info['todo']['currentver'];349 }350 $test[] = '0.9.10pre10';351 function todo_upgrade0_9_10pre10()352 {353 global $setup_info;354 $setup_info['todo']['currentver'] = '0.9.10pre11';355 return $setup_info['todo']['currentver'];356 }357 $test[] = '0.9.10pre11';358 function todo_upgrade0_9_10pre11()359 {360 global $setup_info;361 $setup_info['todo']['currentver'] = '0.9.10pre12';362 return $setup_info['todo']['currentver'];363 }364 $test[] = '0.9.10pre12';365 function todo_upgrade0_9_10pre12()366 {367 global $setup_info;368 $setup_info['todo']['currentver'] = '0.9.10pre13';369 return $setup_info['todo']['currentver'];370 }371 $test[] = '0.9.10pre13';372 function todo_upgrade0_9_10pre13()373 {374 global $setup_info;375 $setup_info['todo']['currentver'] = '0.9.10pre14';376 return $setup_info['todo']['currentver'];377 }378 $test[] = '0.9.10pre14';379 function todo_upgrade0_9_10pre14()380 {381 global $setup_info;382 $setup_info['todo']['currentver'] = '0.9.10pre15';383 return $setup_info['todo']['currentver'];384 }385 $test[] = '0.9.10pre15';386 function todo_upgrade0_9_10pre15()387 {388 global $setup_info;389 $setup_info['todo']['currentver'] = '0.9.10pre16';390 return $setup_info['todo']['currentver'];391 }392 $test[] = '0.9.10pre16';393 function todo_upgrade0_9_10pre16()394 {395 global $setup_info;396 $setup_info['todo']['currentver'] = '0.9.10pre17';397 return $setup_info['todo']['currentver'];398 }399 $test[] = '0.9.10pre17';400 function todo_upgrade0_9_10pre17()401 {402 global $setup_info;403 $setup_info['todo']['currentver'] = '0.9.10pre18';404 return $setup_info['todo']['currentver'];405 }406 $test[] = '0.9.10pre18';407 function todo_upgrade0_9_10pre18()408 {409 global $setup_info;410 $setup_info['todo']['currentver'] = '0.9.10pre19';411 return $setup_info['todo']['currentver'];412 }413 $test[] = '0.9.10pre19';414 function todo_upgrade0_9_10pre19()415 {416 global $setup_info;417 $setup_info['todo']['currentver'] = '0.9.10pre20';418 return $setup_info['todo']['currentver'];419 }420 $test[] = '0.9.10pre20';421 function todo_upgrade0_9_10pre20()422 {423 global $setup_info;424 $setup_info['todo']['currentver'] = '0.9.10pre21';425 return $setup_info['todo']['currentver'];426 }427 $test[] = '0.9.10pre21';428 function todo_upgrade0_9_10pre21()429 {430 global $setup_info;431 $setup_info['todo']['currentver'] = '0.9.10pre22';432 return $setup_info['todo']['currentver'];433 }434 $test[] = '0.9.10pre22';435 function todo_upgrade0_9_10pre22()436 {437 global $setup_info, $phpgw_setup;438 $phpgw_setup->oProc->RenameTable('todo','phpgw_todo');439 $setup_info['todo']['currentver'] = '0.9.10pre23';440 return $setup_info['todo']['currentver'];441 }442 $test[] = '0.9.10pre23';443 function todo_upgrade0_9_10pre23()444 {445 global $setup_info;446 $setup_info['todo']['currentver'] = '0.9.10pre24';447 return $setup_info['todo']['currentver'];448 }449 $test[] = '0.9.10pre24';450 function todo_upgrade0_9_10pre24()451 {452 global $setup_info;453 $setup_info['todo']['currentver'] = '0.9.10pre25';454 return $setup_info['todo']['currentver'];455 }456 $test[] = '0.9.10pre25';457 function todo_upgrade0_9_10pre25()458 {459 global $setup_info;460 $setup_info['todo']['currentver'] = '0.9.10pre26';461 return $setup_info['todo']['currentver'];462 }463 $test[] = '0.9.10pre26';464 function todo_upgrade0_9_10pre26()465 {466 global $setup_info,$phpgw_setup;467 $phpgw_setup->oProc->AddColumn('phpgw_todo','todo_cat',array('type' => 'int','precision' => 4,'nullable' => True));468 $setup_info['todo']['currentver'] = '0.9.10pre27';469 return $setup_info['todo']['currentver'];470 }471 $test[] = '0.9.10pre27';472 function todo_upgrade0_9_10pre27()473 {474 global $setup_info;475 $setup_info['todo']['currentver'] = '0.9.10pre28';476 return $setup_info['todo']['currentver'];477 }478 $test[] = '0.9.10pre28';479 function todo_upgrade0_9_10pre28()480 {481 global $setup_info;482 $setup_info['todo']['currentver'] = '0.9.10';483 return $setup_info['todo']['currentver'];484 }485 $test[] = '0.9.10';486 function todo_upgrade0_9_10()487 {488 global $setup_info;489 $setup_info['todo']['currentver'] = '0.9.11.001';490 return $setup_info['todo']['currentver'];491 }492 $test[] = '0.9.11';493 function todo_upgrade0_9_11()494 {495 global $setup_info;496 $setup_info['todo']['currentver'] = '0.9.11.001';497 return $setup_info['todo']['currentver'];498 }499 $test[] = '0.9.11.001';500 function todo_upgrade0_9_11_001()501 {502 global $setup_info;503 $setup_info['todo']['currentver'] = '0.9.11.002';504 return $setup_info['todo']['currentver'];505 }506 $test[] = '0.9.11.003';507 function todo_upgrade0_9_11_003()508 {509 global $setup_info;510 $setup_info['todo']['currentver'] = '0.9.11.004';511 return $setup_info['todo']['currentver'];512 }513 $test[] = '0.9.11.004';514 function todo_upgrade0_9_11_004()515 {516 global $setup_info;517 $setup_info['todo']['currentver'] = '0.9.11.005';518 return $setup_info['todo']['currentver'];519 }520 $test[] = '0.9.11.005';521 function todo_upgrade0_9_11_005()522 {523 global $setup_info;524 $setup_info['todo']['currentver'] = '0.9.11.006';525 return $setup_info['todo']['currentver'];526 }527 $test[] = '0.9.11.006';528 function todo_upgrade0_9_11_006()529 {530 global $setup_info;531 $setup_info['todo']['currentver'] = '0.9.11.007';532 return $setup_info['todo']['currentver'];533 }534 $test[] = '0.9.11.007';535 function todo_upgrade0_9_11_007()536 {537 global $setup_info;538 $setup_info['todo']['currentver'] = '0.9.11.008';539 return $setup_info['todo']['currentver'];540 }541 $test[] = '0.9.11.008';542 function todo_upgrade0_9_11_008()543 {544 global $setup_info;545 $setup_info['todo']['currentver'] = '0.9.11.009';546 return $setup_info['todo']['currentver'];547 }548 $test[] = '0.9.11.009';549 function todo_upgrade0_9_11_009()550 {551 global $setup_info;552 $setup_info['todo']['currentver'] = '0.9.11.010';553 return $setup_info['todo']['currentver'];554 }555 $test[] = '0.9.11.010';556 function todo_upgrade0_9_11_010()557 {558 global $setup_info;559 $setup_info['todo']['currentver'] = '0.9.11.011';560 return $setup_info['todo']['currentver'];561 }562 $test[] = '0.9.11.011';563 function todo_upgrade0_9_11_011()564 {565 global $setup_info;566 $setup_info['todo']['currentver'] = '0.9.13.001';567 return $setup_info['todo']['currentver'];568 }569 $test[] = '0.9.13.001';570 function todo_upgrade0_9_13_001()571 {572 global $setup_info;573 $setup_info['todo']['currentver'] = '0.9.13.002';574 return $setup_info['todo']['currentver'];575 }576 $test[] = '0.9.13.002';577 function todo_upgrade0_9_13_002()578 {579 global $setup_info, $phpgw_setup;580 $phpgw_setup->oProc->AddColumn('phpgw_todo','todo_id_main',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));581 $phpgw_setup->oProc->AddColumn('phpgw_todo','todo_level',array('type' => 'int','precision' => 2,'default' => 0,'nullable' => False));582 $phpgw_setup->oProc->AlterColumn('phpgw_todo','todo_id_parent',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));583 $phpgw_setup->oProc->AlterColumn('phpgw_todo','todo_cat',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));584 $phpgw_setup->oProc->AlterColumn('phpgw_todo','todo_enddate',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));585 $db = $phpgw_setup->db;586 $phpgw_setup->oProc->query("select todo_id from phpgw_todo where todo_id_main='0'");587 while ($phpgw_setup->oProc->next_record())588 {589 $db->query("update phpgw_todo set todo_id_main='" . $phpgw_setup->oProc->f('todo_id') . "' "590 . "where todo_id='" . $phpgw_setup->oProc->f('todo_id') . "'");591 }592 $phpgw_setup->oProc->query("select todo_id_parent from phpgw_todo");593 while ($phpgw_setup->oProc->next_record())594 {595 if ($phpgw_setup->oProc->f('todo_id_parent') != 0)596 {597 $db->query("update phpgw_todo set todo_id_main='" . $phpgw_setup->oProc->f('todo_id_parent') . "',"598 . "todo_level='1' where todo_id_parent='" . $phpgw_setup->oProc->f('todo_id_parent') . "'");599 }600 }601 $setup_info['todo']['currentver'] = '0.9.13.003';602 return $setup_info['todo']['currentver'];603 }604 $test[] = '0.9.13.003';605 function todo_upgrade0_9_13_003()606 {607 global $setup_info, $phpgw_setup;608 $phpgw_setup->oProc->AddColumn('phpgw_todo','todo_title',array('type' => 'varchar','precision' => 255,'nullable' => False));609 $phpgw_setup->oProc->AlterColumn('phpgw_todo','todo_owner',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));610 $setup_info['todo']['currentver'] = '0.9.13.004';611 return $setup_info['todo']['currentver'];612 }613 $test[] = '0.9.13.004';614 function todo_upgrade0_9_13_004()615 {616 $GLOBALS['setup_info']['todo']['currentver'] = '0.9.15.001';617 return $GLOBALS['setup_info']['todo']['currentver'];618 }619 $test[] = '0.9.14';620 function todo_upgrade0_9_14()621 {622 $GLOBALS['setup_info']['todo']['currentver'] = '0.9.15.001';623 return $GLOBALS['setup_info']['todo']['currentver'];624 }625 $test[] = '0.9.14.500';626 function todo_upgrade0_9_14_500()627 {628 $GLOBALS['setup_info']['todo']['currentver'] = '0.9.15.001';629 return $GLOBALS['setup_info']['todo']['currentver'];630 }631 $test[] = '0.9.15.001';632 function todo_upgrade0_9_15_001()633 {634 $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();635 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_todo','todo_assigned',array('type' => 'varchar','precision' => 255,'nullable' => False));636 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_todo','assigned_group',array('type' => 'varchar','precision' => 255,'nullable' => False));637 if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())638 {639 $GLOBALS['setup_info']['todo']['currentver'] = '0.9.15.002';640 return $GLOBALS['setup_info']['todo']['currentver'];641 }642 }643 $test[] = '0.9.15.002';644 function todo_upgrade0_9_15_002()645 {646 $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();647 $GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_todo','entry_date',array('type' => 'int','precision' => 4,'default' => 0,'nullable' => False));648 if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())649 {650 $GLOBALS['setup_info']['todo']['currentver'] = '0.9.15.003';651 return $GLOBALS['setup_info']['todo']['currentver'];652 }653 }...

Full Screen

Full Screen

SessionInfoTest.php

Source:SessionInfoTest.php Github

copy

Full Screen

...79 $this->fail( 'Expected exception not thrown', 'bad metadata' );80 } catch ( \InvalidArgumentException $ex ) {81 $this->assertSame( 'Invalid metadata', $ex->getMessage(), 'bad metadata' );82 }83 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [84 'provider' => $provider,85 'userInfo' => $anonInfo86 ] );87 $this->assertSame( $provider, $info->getProvider() );88 $this->assertNotNull( $info->getId() );89 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );90 $this->assertSame( $anonInfo, $info->getUserInfo() );91 $this->assertTrue( $info->isIdSafe() );92 $this->assertFalse( $info->forceUse() );93 $this->assertFalse( $info->wasPersisted() );94 $this->assertFalse( $info->wasRemembered() );95 $this->assertFalse( $info->forceHTTPS() );96 $this->assertNull( $info->getProviderMetadata() );97 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [98 'provider' => $provider,99 'userInfo' => $unverifiedUserInfo,100 'metadata' => [ 'Foo' ],101 ] );102 $this->assertSame( $provider, $info->getProvider() );103 $this->assertNotNull( $info->getId() );104 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );105 $this->assertSame( $unverifiedUserInfo, $info->getUserInfo() );106 $this->assertTrue( $info->isIdSafe() );107 $this->assertFalse( $info->forceUse() );108 $this->assertFalse( $info->wasPersisted() );109 $this->assertFalse( $info->wasRemembered() );110 $this->assertFalse( $info->forceHTTPS() );111 $this->assertSame( [ 'Foo' ], $info->getProviderMetadata() );112 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [113 'provider' => $provider,114 'userInfo' => $userInfo115 ] );116 $this->assertSame( $provider, $info->getProvider() );117 $this->assertNotNull( $info->getId() );118 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );119 $this->assertSame( $userInfo, $info->getUserInfo() );120 $this->assertTrue( $info->isIdSafe() );121 $this->assertFalse( $info->forceUse() );122 $this->assertFalse( $info->wasPersisted() );123 $this->assertTrue( $info->wasRemembered() );124 $this->assertFalse( $info->forceHTTPS() );125 $this->assertNull( $info->getProviderMetadata() );126 $id = $manager->generateSessionId();127 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [128 'provider' => $provider,129 'id' => $id,130 'persisted' => true,131 'userInfo' => $anonInfo132 ] );133 $this->assertSame( $provider, $info->getProvider() );134 $this->assertSame( $id, $info->getId() );135 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );136 $this->assertSame( $anonInfo, $info->getUserInfo() );137 $this->assertFalse( $info->isIdSafe() );138 $this->assertFalse( $info->forceUse() );139 $this->assertTrue( $info->wasPersisted() );140 $this->assertFalse( $info->wasRemembered() );141 $this->assertFalse( $info->forceHTTPS() );142 $this->assertNull( $info->getProviderMetadata() );143 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [144 'provider' => $provider,145 'id' => $id,146 'userInfo' => $userInfo147 ] );148 $this->assertSame( $provider, $info->getProvider() );149 $this->assertSame( $id, $info->getId() );150 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );151 $this->assertSame( $userInfo, $info->getUserInfo() );152 $this->assertFalse( $info->isIdSafe() );153 $this->assertFalse( $info->forceUse() );154 $this->assertFalse( $info->wasPersisted() );155 $this->assertTrue( $info->wasRemembered() );156 $this->assertFalse( $info->forceHTTPS() );157 $this->assertNull( $info->getProviderMetadata() );158 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [159 'id' => $id,160 'persisted' => true,161 'userInfo' => $userInfo,162 'metadata' => [ 'Foo' ],163 ] );164 $this->assertSame( $id, $info->getId() );165 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );166 $this->assertSame( $userInfo, $info->getUserInfo() );167 $this->assertFalse( $info->isIdSafe() );168 $this->assertFalse( $info->forceUse() );169 $this->assertTrue( $info->wasPersisted() );170 $this->assertFalse( $info->wasRemembered() );171 $this->assertFalse( $info->forceHTTPS() );172 $this->assertNull( $info->getProviderMetadata() );173 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [174 'id' => $id,175 'remembered' => true,176 'userInfo' => $userInfo,177 ] );178 $this->assertFalse( $info->wasRemembered(), 'no provider' );179 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [180 'provider' => $provider,181 'id' => $id,182 'remembered' => true,183 ] );184 $this->assertFalse( $info->wasRemembered(), 'no user' );185 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [186 'provider' => $provider,187 'id' => $id,188 'remembered' => true,189 'userInfo' => $anonInfo,190 ] );191 $this->assertFalse( $info->wasRemembered(), 'anonymous user' );192 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [193 'provider' => $provider,194 'id' => $id,195 'remembered' => true,196 'userInfo' => $unverifiedUserInfo,197 ] );198 $this->assertFalse( $info->wasRemembered(), 'unverified user' );199 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [200 'provider' => $provider,201 'id' => $id,202 'remembered' => false,203 'userInfo' => $userInfo,204 ] );205 $this->assertFalse( $info->wasRemembered(), 'specific override' );206 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [207 'id' => $id,208 'idIsSafe' => true,209 ] );210 $this->assertSame( $id, $info->getId() );211 $this->assertSame( SessionInfo::MIN_PRIORITY + 5, $info->getPriority() );212 $this->assertTrue( $info->isIdSafe() );213 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [214 'id' => $id,215 'forceUse' => true,216 ] );217 $this->assertFalse( $info->forceUse(), 'no provider' );218 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [219 'provider' => $provider,220 'forceUse' => true,221 ] );222 $this->assertFalse( $info->forceUse(), 'no id' );223 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 5, [224 'provider' => $provider,225 'id' => $id,226 'forceUse' => true,227 ] );228 $this->assertTrue( $info->forceUse(), 'correct use' );229 $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [230 'id' => $id,231 'forceHTTPS' => 1,232 ] );233 $this->assertTrue( $info->forceHTTPS() );234 $fromInfo = new SessionInfo( SessionInfo::MIN_PRIORITY, [235 'id' => $id . 'A',236 'provider' => $provider,237 'userInfo' => $userInfo,238 'idIsSafe' => true,239 'forceUse' => true,240 'persisted' => true,241 'remembered' => true,242 'forceHTTPS' => true,243 'metadata' => [ 'foo!' ],244 ] );245 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 4, [246 'copyFrom' => $fromInfo,247 ] );248 $this->assertSame( $id . 'A', $info->getId() );249 $this->assertSame( SessionInfo::MIN_PRIORITY + 4, $info->getPriority() );250 $this->assertSame( $provider, $info->getProvider() );251 $this->assertSame( $userInfo, $info->getUserInfo() );252 $this->assertTrue( $info->isIdSafe() );253 $this->assertTrue( $info->forceUse() );254 $this->assertTrue( $info->wasPersisted() );255 $this->assertTrue( $info->wasRemembered() );256 $this->assertTrue( $info->forceHTTPS() );257 $this->assertSame( [ 'foo!' ], $info->getProviderMetadata() );258 $info = new SessionInfo( SessionInfo::MIN_PRIORITY + 4, [259 'id' => $id . 'X',260 'provider' => $provider2,261 'userInfo' => $unverifiedUserInfo,262 'idIsSafe' => false,263 'forceUse' => false,264 'persisted' => false,265 'remembered' => false,266 'forceHTTPS' => false,267 'metadata' => null,268 'copyFrom' => $fromInfo,269 ] );270 $this->assertSame( $id . 'X', $info->getId() );271 $this->assertSame( SessionInfo::MIN_PRIORITY + 4, $info->getPriority() );272 $this->assertSame( $provider2, $info->getProvider() );273 $this->assertSame( $unverifiedUserInfo, $info->getUserInfo() );274 $this->assertFalse( $info->isIdSafe() );275 $this->assertFalse( $info->forceUse() );276 $this->assertFalse( $info->wasPersisted() );277 $this->assertFalse( $info->wasRemembered() );278 $this->assertFalse( $info->forceHTTPS() );279 $this->assertNull( $info->getProviderMetadata() );280 $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [281 'id' => $id,282 ] );283 $this->assertSame(284 '[' . SessionInfo::MIN_PRIORITY . "]null<null>$id",285 (string)$info,286 'toString'287 );288 $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [289 'provider' => $provider,290 'id' => $id,291 'persisted' => true,292 'userInfo' => $userInfo293 ] );294 $this->assertSame(295 '[' . SessionInfo::MIN_PRIORITY . "]Mock<+:{$userInfo->getId()}:UTSysop>$id",296 (string)$info,297 'toString'298 );299 $info = new SessionInfo( SessionInfo::MIN_PRIORITY, [300 'provider' => $provider,301 'id' => $id,302 'persisted' => true,303 'userInfo' => $unverifiedUserInfo304 ] );305 $this->assertSame(306 '[' . SessionInfo::MIN_PRIORITY . "]Mock<-:{$userInfo->getId()}:UTSysop>$id",307 (string)$info,308 'toString'309 );310 }311 public function testCompare() {312 $id = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';313 $info1 = new SessionInfo( SessionInfo::MIN_PRIORITY + 1, [ 'id' => $id ] );314 $info2 = new SessionInfo( SessionInfo::MIN_PRIORITY + 2, [ 'id' => $id ] );315 $this->assertTrue( SessionInfo::compare( $info1, $info2 ) < 0, '<' );316 $this->assertTrue( SessionInfo::compare( $info2, $info1 ) > 0, '>' );317 $this->assertTrue( SessionInfo::compare( $info1, $info1 ) === 0, '==' );318 }319}...

Full Screen

Full Screen

module.audio.la.php

Source:module.audio.la.php Github

copy

Full Screen

1<?php2/////////////////////////////////////////////////////////////////3/// getID3() by James Heinrich <info@getid3.org> //4// available at http://getid3.sourceforge.net //5// or http://www.getid3.org //6/////////////////////////////////////////////////////////////////7// See readme.txt for more details //8/////////////////////////////////////////////////////////////////9// //10// module.audio.la.php //11// module for analyzing LA (LosslessAudio) audio files //12// dependencies: module.audio.riff.php //13// ///14/////////////////////////////////////////////////////////////////15getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);16class getid3_la extends getid3_handler17{18 function Analyze() {19 $info = &$this->getid3->info;20 $offset = 0;21 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);22 $rawdata = fread($this->getid3->fp, $this->getid3->fread_buffer_size());23 switch (substr($rawdata, $offset, 4)) {24 case 'LA02':25 case 'LA03':26 case 'LA04':27 $info['fileformat'] = 'la';28 $info['audio']['dataformat'] = 'la';29 $info['audio']['lossless'] = true;30 $info['la']['version_major'] = (int) substr($rawdata, $offset + 2, 1);31 $info['la']['version_minor'] = (int) substr($rawdata, $offset + 3, 1);32 $info['la']['version'] = (float) $info['la']['version_major'] + ($info['la']['version_minor'] / 10);33 $offset += 4;34 $info['la']['uncompressed_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));35 $offset += 4;36 if ($info['la']['uncompressed_size'] == 0) {37 $info['error'][] = 'Corrupt LA file: uncompressed_size == zero';38 return false;39 }40 $WAVEchunk = substr($rawdata, $offset, 4);41 if ($WAVEchunk !== 'WAVE') {42 $info['error'][] = 'Expected "WAVE" ('.getid3_lib::PrintHexBytes('WAVE').') at offset '.$offset.', found "'.$WAVEchunk.'" ('.getid3_lib::PrintHexBytes($WAVEchunk).') instead.';43 return false;44 }45 $offset += 4;46 $info['la']['fmt_size'] = 24;47 if ($info['la']['version'] >= 0.3) {48 $info['la']['fmt_size'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));49 $info['la']['header_size'] = 49 + $info['la']['fmt_size'] - 24;50 $offset += 4;51 } else {52 // version 0.2 didn't support additional data blocks53 $info['la']['header_size'] = 41;54 }55 $fmt_chunk = substr($rawdata, $offset, 4);56 if ($fmt_chunk !== 'fmt ') {57 $info['error'][] = 'Expected "fmt " ('.getid3_lib::PrintHexBytes('fmt ').') at offset '.$offset.', found "'.$fmt_chunk.'" ('.getid3_lib::PrintHexBytes($fmt_chunk).') instead.';58 return false;59 }60 $offset += 4;61 $fmt_size = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));62 $offset += 4;63 $info['la']['raw']['format'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));64 $offset += 2;65 $info['la']['channels'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));66 $offset += 2;67 if ($info['la']['channels'] == 0) {68 $info['error'][] = 'Corrupt LA file: channels == zero';69 return false;70 }71 $info['la']['sample_rate'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));72 $offset += 4;73 if ($info['la']['sample_rate'] == 0) {74 $info['error'][] = 'Corrupt LA file: sample_rate == zero';75 return false;76 }77 $info['la']['bytes_per_second'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));78 $offset += 4;79 $info['la']['bytes_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));80 $offset += 2;81 $info['la']['bits_per_sample'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 2));82 $offset += 2;83 $info['la']['samples'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));84 $offset += 4;85 $info['la']['raw']['flags'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 1));86 $offset += 1;87 $info['la']['flags']['seekable'] = (bool) ($info['la']['raw']['flags'] & 0x01);88 if ($info['la']['version'] >= 0.4) {89 $info['la']['flags']['high_compression'] = (bool) ($info['la']['raw']['flags'] & 0x02);90 }91 $info['la']['original_crc'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));92 $offset += 4;93 // mikeØbevin*de94 // Basically, the blocksize/seekevery are 61440/19 in La0.4 and 73728/1695 // in earlier versions. A seekpoint is added every blocksize * seekevery96 // samples, so 4 * int(totalSamples / (blockSize * seekEvery)) should97 // give the number of bytes used for the seekpoints. Of course, if seeking98 // is disabled, there are no seekpoints stored.99 if ($info['la']['version'] >= 0.4) {100 $info['la']['blocksize'] = 61440;101 $info['la']['seekevery'] = 19;102 } else {103 $info['la']['blocksize'] = 73728;104 $info['la']['seekevery'] = 16;105 }106 $info['la']['seekpoint_count'] = 0;107 if ($info['la']['flags']['seekable']) {108 $info['la']['seekpoint_count'] = floor($info['la']['samples'] / ($info['la']['blocksize'] * $info['la']['seekevery']));109 for ($i = 0; $i < $info['la']['seekpoint_count']; $i++) {110 $info['la']['seekpoints'][] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));111 $offset += 4;112 }113 }114 if ($info['la']['version'] >= 0.3) {115 // Following the main header information, the program outputs all of the116 // seekpoints. Following these is what I called the 'footer start',117 // i.e. the position immediately after the La audio data is finished.118 $info['la']['footerstart'] = getid3_lib::LittleEndian2Int(substr($rawdata, $offset, 4));119 $offset += 4;120 if ($info['la']['footerstart'] > $info['filesize']) {121 $info['warning'][] = 'FooterStart value points to offset '.$info['la']['footerstart'].' which is beyond end-of-file ('.$info['filesize'].')';122 $info['la']['footerstart'] = $info['filesize'];123 }124 } else {125 // La v0.2 didn't have FooterStart value126 $info['la']['footerstart'] = $info['avdataend'];127 }128 if ($info['la']['footerstart'] < $info['avdataend']) {129 if ($RIFFtempfilename = tempnam(GETID3_TEMP_DIR, 'id3')) {130 if ($RIFF_fp = fopen($RIFFtempfilename, 'w+b')) {131 $RIFFdata = 'WAVE';132 if ($info['la']['version'] == 0.2) {133 $RIFFdata .= substr($rawdata, 12, 24);134 } else {135 $RIFFdata .= substr($rawdata, 16, 24);136 }137 if ($info['la']['footerstart'] < $info['avdataend']) {138 fseek($this->getid3->fp, $info['la']['footerstart'], SEEK_SET);139 $RIFFdata .= fread($this->getid3->fp, $info['avdataend'] - $info['la']['footerstart']);140 }141 $RIFFdata = 'RIFF'.getid3_lib::LittleEndian2String(strlen($RIFFdata), 4, false).$RIFFdata;142 fwrite($RIFF_fp, $RIFFdata, strlen($RIFFdata));143 fclose($RIFF_fp);144 $getid3_temp = new getID3();145 $getid3_temp->openfile($RIFFtempfilename);146 $getid3_riff = new getid3_riff($getid3_temp);147 $getid3_riff->Analyze();148 if (empty($getid3_temp->info['error'])) {149 $info['riff'] = $getid3_temp->info['riff'];150 } else {151 $info['warning'][] = 'Error parsing RIFF portion of La file: '.implode($getid3_temp->info['error']);152 }153 unset($getid3_temp, $getid3_riff);154 }155 unlink($RIFFtempfilename);156 }157 }158 // $info['avdataoffset'] should be zero to begin with, but just in case it's not, include the addition anyway159 $info['avdataend'] = $info['avdataoffset'] + $info['la']['footerstart'];160 $info['avdataoffset'] = $info['avdataoffset'] + $offset;161 //$info['la']['codec'] = RIFFwFormatTagLookup($info['la']['raw']['format']);162 $info['la']['compression_ratio'] = (float) (($info['avdataend'] - $info['avdataoffset']) / $info['la']['uncompressed_size']);163 $info['playtime_seconds'] = (float) ($info['la']['samples'] / $info['la']['sample_rate']) / $info['la']['channels'];164 if ($info['playtime_seconds'] == 0) {165 $info['error'][] = 'Corrupt LA file: playtime_seconds == zero';166 return false;167 }168 $info['audio']['bitrate'] = ($info['avdataend'] - $info['avdataoffset']) * 8 / $info['playtime_seconds'];169 //$info['audio']['codec'] = $info['la']['codec'];170 $info['audio']['bits_per_sample'] = $info['la']['bits_per_sample'];171 break;172 default:173 if (substr($rawdata, $offset, 2) == 'LA') {174 $info['error'][] = 'This version of getID3() ['.$this->getid3->version().'] does not support LA version '.substr($rawdata, $offset + 2, 1).'.'.substr($rawdata, $offset + 3, 1).' which this appears to be - check http://getid3.sourceforge.net for updates.';175 } else {176 $info['error'][] = 'Not a LA (Lossless-Audio) file';177 }178 return false;179 break;180 }181 $info['audio']['channels'] = $info['la']['channels'];182 $info['audio']['sample_rate'] = (int) $info['la']['sample_rate'];183 $info['audio']['encoder'] = 'LA v'.$info['la']['version'];184 return true;185 }186}187?>...

Full Screen

Full Screen

module.audio.lpac.php

Source:module.audio.lpac.php Github

copy

Full Screen

1<?php2/////////////////////////////////////////////////////////////////3/// getID3() by James Heinrich <info@getid3.org> //4// available at http://getid3.sourceforge.net //5// or http://www.getid3.org //6/////////////////////////////////////////////////////////////////7// See readme.txt for more details //8/////////////////////////////////////////////////////////////////9// //10// module.audio.lpac.php //11// module for analyzing LPAC Audio files //12// dependencies: module.audio-video.riff.php //13// ///14/////////////////////////////////////////////////////////////////15getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true);16class getid3_lpac extends getid3_handler17{18 function Analyze() {19 $info = &$this->getid3->info;20 fseek($this->getid3->fp, $info['avdataoffset'], SEEK_SET);21 $LPACheader = fread($this->getid3->fp, 14);22 if (substr($LPACheader, 0, 4) != 'LPAC') {23 $info['error'][] = 'Expected "LPAC" at offset '.$info['avdataoffset'].', found "'.$StreamMarker.'"';24 return false;25 }26 $info['avdataoffset'] += 14;27 $info['fileformat'] = 'lpac';28 $info['audio']['dataformat'] = 'lpac';29 $info['audio']['lossless'] = true;30 $info['audio']['bitrate_mode'] = 'vbr';31 $info['lpac']['file_version'] = getid3_lib::BigEndian2Int(substr($LPACheader, 4, 1));32 $flags['audio_type'] = getid3_lib::BigEndian2Int(substr($LPACheader, 5, 1));33 $info['lpac']['total_samples']= getid3_lib::BigEndian2Int(substr($LPACheader, 6, 4));34 $flags['parameters'] = getid3_lib::BigEndian2Int(substr($LPACheader, 10, 4));35 $info['lpac']['flags']['is_wave'] = (bool) ($flags['audio_type'] & 0x40);36 $info['lpac']['flags']['stereo'] = (bool) ($flags['audio_type'] & 0x04);37 $info['lpac']['flags']['24_bit'] = (bool) ($flags['audio_type'] & 0x02);38 $info['lpac']['flags']['16_bit'] = (bool) ($flags['audio_type'] & 0x01);39 if ($info['lpac']['flags']['24_bit'] && $info['lpac']['flags']['16_bit']) {40 $info['warning'][] = '24-bit and 16-bit flags cannot both be set';41 }42 $info['lpac']['flags']['fast_compress'] = (bool) ($flags['parameters'] & 0x40000000);43 $info['lpac']['flags']['random_access'] = (bool) ($flags['parameters'] & 0x08000000);44 $info['lpac']['block_length'] = pow(2, (($flags['parameters'] & 0x07000000) >> 24)) * 256;45 $info['lpac']['flags']['adaptive_prediction_order'] = (bool) ($flags['parameters'] & 0x00800000);46 $info['lpac']['flags']['adaptive_quantization'] = (bool) ($flags['parameters'] & 0x00400000);47 $info['lpac']['flags']['joint_stereo'] = (bool) ($flags['parameters'] & 0x00040000);48 $info['lpac']['quantization'] = ($flags['parameters'] & 0x00001F00) >> 8;49 $info['lpac']['max_prediction_order'] = ($flags['parameters'] & 0x0000003F);50 if ($info['lpac']['flags']['fast_compress'] && ($info['lpac']['max_prediction_order'] != 3)) {51 $info['warning'][] = 'max_prediction_order expected to be "3" if fast_compress is true, actual value is "'.$info['lpac']['max_prediction_order'].'"';52 }53 switch ($info['lpac']['file_version']) {54 case 6:55 if ($info['lpac']['flags']['adaptive_quantization']) {56 $info['warning'][] = 'adaptive_quantization expected to be false in LPAC file stucture v6, actually true';57 }58 if ($info['lpac']['quantization'] != 20) {59 $info['warning'][] = 'Quantization expected to be 20 in LPAC file stucture v6, actually '.$info['lpac']['flags']['Q'];60 }61 break;62 default:63 //$info['warning'][] = 'This version of getID3() ['.$this->getid3->version().'] only supports LPAC file format version 6, this file is version '.$info['lpac']['file_version'].' - please report to info@getid3.org';64 break;65 }66 $getid3_temp = new getID3();67 $getid3_temp->openfile($this->getid3->filename);68 $getid3_temp->info = $info;69 $getid3_riff = new getid3_riff($getid3_temp);70 $getid3_riff->Analyze();71 $info['avdataoffset'] = $getid3_temp->info['avdataoffset'];72 $info['riff'] = $getid3_temp->info['riff'];73 $info['error'] = $getid3_temp->info['error'];74 $info['warning'] = $getid3_temp->info['warning'];75 $info['lpac']['comments']['comment'] = $getid3_temp->info['comments'];76 $info['audio']['sample_rate'] = $getid3_temp->info['audio']['sample_rate'];77 unset($getid3_temp, $getid3_riff);78 $info['audio']['channels'] = ($info['lpac']['flags']['stereo'] ? 2 : 1);79 if ($info['lpac']['flags']['24_bit']) {80 $info['audio']['bits_per_sample'] = $info['riff']['audio'][0]['bits_per_sample'];81 } elseif ($info['lpac']['flags']['16_bit']) {82 $info['audio']['bits_per_sample'] = 16;83 } else {84 $info['audio']['bits_per_sample'] = 8;85 }86 if ($info['lpac']['flags']['fast_compress']) {87 // fast88 $info['audio']['encoder_options'] = '-1';89 } else {90 switch ($info['lpac']['max_prediction_order']) {91 case 20: // simple92 $info['audio']['encoder_options'] = '-2';93 break;94 case 30: // medium95 $info['audio']['encoder_options'] = '-3';96 break;97 case 40: // high98 $info['audio']['encoder_options'] = '-4';99 break;100 case 60: // extrahigh101 $info['audio']['encoder_options'] = '-5';102 break;103 }104 }105 $info['playtime_seconds'] = $info['lpac']['total_samples'] / $info['audio']['sample_rate'];106 $info['audio']['bitrate'] = (($info['avdataend'] - $info['avdataoffset']) * 8) / $info['playtime_seconds'];107 return true;108 }109}110?>...

Full Screen

Full Screen

Volume.php

Source:Volume.php Github

copy

Full Screen

1<?php2/*3 * Copyright 2014 Google Inc.4 *5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not6 * use this file except in compliance with the License. You may obtain a copy of7 * the License at8 *9 * http://www.apache.org/licenses/LICENSE-2.010 *11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the14 * License for the specific language governing permissions and limitations under15 * the License.16 */17class Google_Service_Books_Volume extends Google_Model18{19 protected $accessInfoType = 'Google_Service_Books_VolumeAccessInfo';20 protected $accessInfoDataType = '';21 public $etag;22 public $id;23 public $kind;24 protected $layerInfoType = 'Google_Service_Books_VolumeLayerInfo';25 protected $layerInfoDataType = '';26 protected $recommendedInfoType = 'Google_Service_Books_VolumeRecommendedInfo';27 protected $recommendedInfoDataType = '';28 protected $saleInfoType = 'Google_Service_Books_VolumeSaleInfo';29 protected $saleInfoDataType = '';30 protected $searchInfoType = 'Google_Service_Books_VolumeSearchInfo';31 protected $searchInfoDataType = '';32 public $selfLink;33 protected $userInfoType = 'Google_Service_Books_VolumeUserInfo';34 protected $userInfoDataType = '';35 protected $volumeInfoType = 'Google_Service_Books_VolumeVolumeInfo';36 protected $volumeInfoDataType = '';37 /**38 * @param Google_Service_Books_VolumeAccessInfo39 */40 public function setAccessInfo(Google_Service_Books_VolumeAccessInfo $accessInfo)41 {42 $this->accessInfo = $accessInfo;43 }44 /**45 * @return Google_Service_Books_VolumeAccessInfo46 */47 public function getAccessInfo()48 {49 return $this->accessInfo;50 }51 public function setEtag($etag)52 {53 $this->etag = $etag;54 }55 public function getEtag()56 {57 return $this->etag;58 }59 public function setId($id)60 {61 $this->id = $id;62 }63 public function getId()64 {65 return $this->id;66 }67 public function setKind($kind)68 {69 $this->kind = $kind;70 }71 public function getKind()72 {73 return $this->kind;74 }75 /**76 * @param Google_Service_Books_VolumeLayerInfo77 */78 public function setLayerInfo(Google_Service_Books_VolumeLayerInfo $layerInfo)79 {80 $this->layerInfo = $layerInfo;81 }82 /**83 * @return Google_Service_Books_VolumeLayerInfo84 */85 public function getLayerInfo()86 {87 return $this->layerInfo;88 }89 /**90 * @param Google_Service_Books_VolumeRecommendedInfo91 */92 public function setRecommendedInfo(Google_Service_Books_VolumeRecommendedInfo $recommendedInfo)93 {94 $this->recommendedInfo = $recommendedInfo;95 }96 /**97 * @return Google_Service_Books_VolumeRecommendedInfo98 */99 public function getRecommendedInfo()100 {101 return $this->recommendedInfo;102 }103 /**104 * @param Google_Service_Books_VolumeSaleInfo105 */106 public function setSaleInfo(Google_Service_Books_VolumeSaleInfo $saleInfo)107 {108 $this->saleInfo = $saleInfo;109 }110 /**111 * @return Google_Service_Books_VolumeSaleInfo112 */113 public function getSaleInfo()114 {115 return $this->saleInfo;116 }117 /**118 * @param Google_Service_Books_VolumeSearchInfo119 */120 public function setSearchInfo(Google_Service_Books_VolumeSearchInfo $searchInfo)121 {122 $this->searchInfo = $searchInfo;123 }124 /**125 * @return Google_Service_Books_VolumeSearchInfo126 */127 public function getSearchInfo()128 {129 return $this->searchInfo;130 }131 public function setSelfLink($selfLink)132 {133 $this->selfLink = $selfLink;134 }135 public function getSelfLink()136 {137 return $this->selfLink;138 }139 /**140 * @param Google_Service_Books_VolumeUserInfo141 */142 public function setUserInfo(Google_Service_Books_VolumeUserInfo $userInfo)143 {144 $this->userInfo = $userInfo;145 }146 /**147 * @return Google_Service_Books_VolumeUserInfo148 */149 public function getUserInfo()150 {151 return $this->userInfo;152 }153 /**154 * @param Google_Service_Books_VolumeVolumeInfo155 */156 public function setVolumeInfo(Google_Service_Books_VolumeVolumeInfo $volumeInfo)157 {158 $this->volumeInfo = $volumeInfo;159 }160 /**161 * @return Google_Service_Books_VolumeVolumeInfo162 */163 public function getVolumeInfo()164 {165 return $this->volumeInfo;166 }167}...

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1require_once('/usr/share/phoronix-test-suite/pts-core/pts-core.php');2require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file.php');3require_once('/usr/share/phoronix-test-suite/pts-core/objects/pts_result_file_parser.php');4$rfp = new pts_result_file_parser();5$rfp->parse_file('resultfile.xml');6$res = $rfp->get_result_object();7$rf = $res->test_result_buffer;8$no_of_test_profiles = $rf->get_test_profile_count();9$no_of_test_results = $rf->get_test_count();10$no_of_system_components = $rf->get_system_count();11$test_profile = $rf->get_test_profile(0);12$test_profile_name = $test_profile->get_identifier();13$test_profile_version = $test_profile->get_version();14$test_profile_description = $test_profile->get_description();15$test_result = $rf->get_test_result(0);16$test_result_identifier = $test_result->get_identifier();17$test_result_value = $test_result->get_result_value();18$test_result_units = $test_result->get_result_scale();19$test_result_status = $test_result->get_result_status();20$test_result_details = $test_result->get_result_details();21$test_result_attributes = $test_result->get_result_attributes();22$test_result_parameters = $test_result->get_arguments();23$test_result_environment = $test_result->get_environment_variables();24$system_component = $rf->get_system_component(0);

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1use pts\test_profile;2use pts\test_profile;3use pts\test_result_buffer;4use pts\client\pts_client;5use pts\module_manager;6use pts\result_file_output;7use pts\result_file_analyzer;8use pts\result_file;9use pts\result_merge;10use pts\result_parser;11use pts\result_file_output_manager;12use pts\results;13use pts\test_result;14use pts\test_result_buffer;15use pts\test_result_buffer_manager;16use pts\test_result_buffer_output_manager;17use pts\test_result_buffer_parser;18use pts\test_result_buffer_parser_manager;19use pts\test_result_buffer_result_manager;20use pts\test_result_buffer_result_parser;21use pts\test_result_buffer_result_parser_manager;

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$test = new pts_test_profile('test');3$test->test_profile->set_title('test');4$test->test_profile->set_version('1.0');5$test->test_profile->set_license('GPL');6$test->test_profile->set_description('test');7$test->test_profile->set_test_executable('test');8$test->test_profile->set_test_hardware('test');9$test->test_profile->set_test_software('test');10$test->test_profile->set_test_type('test');11$test->test_profile->set_test_category('test');12$test->test_profile->set_test_provides('test');13$test->test_profile->set_test_result_scale('test');14$test->test_profile->set_test_result_proportion('test');15$test->test_profile->set_test_result_format('test');16$test->test_profile->set_test_result_comparison('test');17$test->test_profile->set_test_result_value('test');18$test->test_profile->set_test_result_units('test');19$test->test_profile->set_test_result_min('test');20$test->test_profile->set_test_result_max('test');21$test->test_profile->set_test_result_pass('test');22$test->test_profile->set_test_result_fail('test');23$test->test_profile->set_test_result_error('test');24$test->test_profile->set_test_result_precision('test');

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$test = new pts_test('testname');3$test->run_test();4require_once('pts-core/pts-core.php');5$test = new pts_test('testname');6$test->run_test();7require_once('pts-core/pts-core.php');8$test = new pts_test('testname');9$test->run_test();10require_once('pts-core/pts-core.php');11$test = new pts_test('testname');12$test->run_test();13require_once('pts-core/pts-core.php');14$test = new pts_test('testname');15$test->run_test();16require_once('pts-core/pts-core.php');17$test = new pts_test('testname');18$test->run_test();19require_once('pts-core/pts-core.php');20$test = new pts_test('testname');21$test->run_test();22require_once('pts-core/pts-core.php');23$test = new pts_test('testname');24$test->run_test();25require_once('pts-core/pts-core.php');26$test = new pts_test('testname');27$test->run_test();28require_once('pts-core/pts-core.php');29$test = new pts_test('testname');30$test->run_test();

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1require_once('pts-core/pts-core.php');2$pts = new pts_client();3$pts->init();4$test_profile = new pts_test_profile('test1');5$test_profile->save_to_file('test1.xml');6require_once('pts-core/pts-core.php');7$pts = new pts_client();8$pts->init();9$test_profile = new pts_test_profile('test2');10$test_profile->save_to_file('test2.xml');11require_once('pts-core/pts-core.php');12$pts = new pts_client();13$pts->init();14$test_profile = new pts_test_profile('test3');15$test_profile->save_to_file('test3.xml');16require_once('pts-core/pts-core.php');17$pts = new pts_client();18$pts->init();19$test_profile = new pts_test_profile('test4');20$test_profile->save_to_file('test4.xml');21require_once('pts-core/pts-core.php');22$pts = new pts_client();23$pts->init();24$test_profile = new pts_test_profile('test5');25$test_profile->save_to_file('test5.xml');26require_once('pts-core/pts-core.php');27$pts = new pts_client();28$pts->init();29$test_profile = new pts_test_profile('test6');30$test_profile->save_to_file('test6.xml');31require_once('pts-core/pts-core.php');32$pts = new pts_client();33$pts->init();34$test_profile = new pts_test_profile('test7');35$test_profile->save_to_file('test7.xml');36require_once('pts-core/pts-core.php');37$pts = new pts_client();38$pts->init();39$test_profile = new pts_test_profile('test8');

Full Screen

Full Screen

info

Using AI Code Generation

copy

Full Screen

1include 'pts-core/pts-core.php';2$test = new pts_test('test');3$test->set_test_profile('test');4$test->test_profile->set_supported_platform('Linux');5$test->test_profile->set_supported_platform('Windows');6$test->test_profile->set_supported_platform('MacOS');7$test->test_profile->set_supported_platform('BSD');8$test->test_profile->add_dependency('test2');9$test->test_profile->add_dependency('test3');10$test->test_profile->add_dependency('test4');11$test->test_profile->add_dependency('test5');12$test->test_profile->add_dependency('test6');13$test->test_profile->add_dependency('test7');14$test->test_profile->add_dependency('test8');15$test->test_profile->add_dependency('test9');16$test->test_profile->add_dependency('test10');17$test->test_profile->add_dependency('test11');18$test->test_profile->add_dependency('test12');19$test->test_profile->add_dependency('test13');20$test->test_profile->add_dependency('test14');21$test->test_profile->add_dependency('test15');22$test->test_profile->add_dependency('test16');23$test->test_profile->add_dependency('test17');24$test->test_profile->add_dependency('test18');25$test->test_profile->add_dependency('test19');26$test->test_profile->add_dependency('test20');27$test->test_profile->add_dependency('test21');28$test->test_profile->add_dependency('test22');29$test->test_profile->add_dependency('test23');

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Phoronix-test-suite automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in info

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful