{ echo "Failed to connect to MySQL: " . mysqli_connect_error(); }*/ //получаем кол-во новостей на один регион //получаем необходимые параметры из базы list($region_count, $city_count, $extra_key_count) = getTablesRecordCount($con); echo "region_count: " . $region_count . "<br/>"; echo "city_count: " . $city_count . "<br/>"; echo "extra_key_count: " . $extra_key_count . "<br/>"; $news_count_for_posting = $region_count * $news_per_region; echo "news_count_for_posting: " . $news_count_for_posting . "<br/>"; //получаем список всех новостей, у которых время постинга больше текущего времени на 5 мин $news_for_posting_array = getNewsIdForPostingArray($con, $news_count_for_posting); echo var_dump($news_for_posting_array); $server_name = $argv[1]; for ($i = 0; $i < count($news_for_posting_array); $i++) { postNews($con, $news_for_posting_array[$i]); $result_array = getPageInfo($con, $news_for_posting_array[$i]); $href = "/" . str_replace(" ", "-", $result_array["region_name_latin"]) . "/" . str_replace(" ", "-", $result_array["city_page_key"]) . ".html"; $url = "http://" . $server_name . $href; $ch = curl_init(); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_exec($ch); echo "curl_exec executed..." . "<br/>"; curl_close($ch); echo $url . "<br/>"; } //случайно выбараем mysqli_close($con); unset($con);
</form> <?php if (isset($_POST['editProfile'])) { //check for CSRF if ($_SESSION['token'] !== $_POST['token']) { echo "error"; die("Request forgery detected"); } header("Location: editProfile.php"); } ?> <?php showProfile(); postNews(); ?> <?php function showNewsWComments() { require 'database.php'; $name = $_SESSION['userAccount']; //show posted stories $stmt = $mysqli->prepare("SELECT * FROM news WHERE poster=?"); if (!$stmt) { printf("Query Prep Failed: %s\n", $mysqli->error); exit; } $stmt->bind_param('s', $name); $stmt->execute(); $result = $stmt->get_result();