function start($xtime = 0) { $dayFilter = 0; if ($xtime > 0) { $dayFilter = date("Ymd", $xtime); } $unix = new unix(); $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".{$xtime}.pid"; $pidTime = "/etc/artica-postfix/pids/YoutubeByHour.time"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid)) { $timepid = $unix->PROCCESS_TIME_MIN($pid); die; } @unlink($pidfile); @file_put_contents($pidfile, getmypid()); @unlink($pidTime); @file_put_contents($pidTime, time()); if (isset($GLOBALS["youtube_days_executed"])) { return; } $GLOBALS["youtube_days_executed"] = true; $q = new mysql_squid_builder(); $timekey = date('YmdH'); $Today = date("Y-m-d H"); $currenttable = "youtubehours_{$timekey}"; $LIST_TABLES_YOUTUBE_HOURS = $q->LIST_TABLES_YOUTUBE_HOURS(); youtube_events("LIST_TABLES_YOUTUBE_HOURS = " . count($LIST_TABLES_YOUTUBE_HOURS)); while (list($tablesource, $value) = each($LIST_TABLES_YOUTUBE_HOURS)) { if ($tablesource == $currenttable) { continue; } $tablesourcetime = $q->TIME_FROM_YOUTUBE_HOUR_TABLE($tablesource); if (date("Y-m-d H", $tablesourcetime) == $Today) { continue; } if ($dayFilter > 0) { if (date("Ymd", $tablesourcetime) != $dayFilter) { continue; } } youtube_events("Processing Youtube table {$tablesource}", __LINE__); if ($q->COUNT_ROWS($tablesource) == 0) { $q->QUERY_SQL("DROP TABLE `{$tablesource}`"); continue; } if (!_youtube_days($tablesource)) { continue; } $q->QUERY_SQL("DROP TABLE {$tablesource}"); } if (count($GLOBALS["YOUTUBE_IDS"]) > 0) { _youtube_ids(); } if (!$GLOBALS["ONLYHOURS"]) { youtube_events("youtube_count()"); youtube_count(); youtube_events("youtube_dayz()"); youtube_dayz(); } }
exit; } if ($argv[1] == '--dump-days') { dump_days(); exit; } if ($argv[1] == '--members-central-grouped') { members_central_grouped(); exit; } if ($argv[1] == '--summarize-daysingle') { _summarize_days($argv[2], $argv[3]); exit; } if ($argv[1] == '--youtube-dayz') { youtube_dayz(); exit; } if ($argv[1] == '--weekdaynum') { WeekDaysNums(); exit; } if ($argv[1] == '--youtubeweek') { youtube_week(); exit; } if ($argv[1] == '--macuid') { macuid(); exit; } if ($argv[1] == '--export-last-websites') {