set_time_limit(0); $conn = getConnection("news_db"); //$conn = getConnection("news_db"); $keywords = ''; $list_query = "select keyword from every_day_keywords "; $list1 = mysql_query($list_query, $conn) or die('MySQL query error ' . mysql_error() . ' ' . $list_query); $test_i = 0; while ($row = mysql_fetch_array($list1)) { if ($test_i == 0) { $test_i = 3; $keywords = '' . $row[0]; } else { $keywords = $keywords . ',' . $row[0]; } } $row = mysql_fetch_array($result); mysql_free_result($result); $today_str = date("Y/m/d", time()); //今天日期 $yest_str = date("Y/m/d", strtotime("-1 day")); //昨天日期 $yest_minus1_str = date("Y/m/d", strtotime("-2 day")); //昨天日期 if (strlen($keywords) > 0) { $keyword_array = explode(",", $keywords); for ($i = 0; $i < sizeof($keyword_array); $i++) { job('"' . $keyword_array[$i] . '"', (string) $yest_minus1_str, (string) $today_str); } } passthru('kill -9 ' . getmypid()); exec('kill -9 ' . getmypid());
if (strlen($MyKeyword) > 0) { $conn = getConnection("news_db"); $sql = 'TRUNCATE TABLE old_news_keywords'; mysql_query($sql, $conn); $keyword_array = explode(",", $MyKeyword); for ($i = 0; $i < sizeof($keyword_array); $i++) { if (strlen($keyword_array[$i]) > 0) { $sql = "INSERT INTO old_news_keywords (keyword) VALUES ('" . $keyword_array[$i] . "' )"; //date("Y-m-d",strtotime($news_date)) //strip_tags($g_element->parent()->parent()->childNodes(1)) mysql_query($sql, $conn); } } //$keyword_array=explode (",",$MyKeyword); for ($i = 0; $i < sizeof($keyword_array); $i++) { if (strlen($keyword_array[$i]) > 0) { job('"' . $keyword_array[$i] . '"', $MyStart, $MyEnd); //V3 } } } passthru('kill -9 ' . getmypid()); exec('kill -9 ' . getmypid()); exit(0); //V1 job('"'.$keyword_array[$i].'"',(string)$yest_minus1_str ,(string)$today_str); //V2 job('"'.$MyKeyword.'"',$MyStart ,$MyEnd); } } } else { echo 'server不支援pcntl_fork ,請調整server設定'; } }
$do = trim(strtolower($_GET['do'])); } switch ($do) { case 'view': $error = false; view($pdo); break; case 'article': $error = false; article($pdo); break; case 'job': if (isset($_SESSION['login']) && $_SESSION['permission'] == 'teacher' && (isset($_GET['token'], $_SESSION['token']) && $_GET['token'] == $_SESSION['token'])) { if (validRequest()) { $error = false; job($pdo); } } break; case 'add': if (isset($_SESSION['login']) && $_SESSION['permission'] == 'teacher' && (isset($_GET['token'], $_SESSION['token']) && $_GET['token'] == $_SESSION['token'])) { if (validRequest()) { $error = false; add($pdo); } } break; case 'delete': if (isset($_SESSION['login']) && ($_SESSION['permission'] == 'teacher' || $_SESSION['permission'] == 'admin') && (isset($_GET['token'], $_SESSION['token']) && $_GET['token'] == $_SESSION['token'])) { if (validRequest()) { $error = false;