$v) { $display_data[$k]['comments'] = n("SELECT * FROM `comments` WHERE `article_id`='" . $v['id'] . "'"); $name = 1; $uri = ""; while(isset($_GET[$name])) { $name = $_GET[$name]; $uri .= "/" . $name; } $list_cat = u($v['cats']); $numero = 0; $foun = true; if(isset($list_cat[$numero])) { while(!n("SELECT * FROM `categories` WHERE `id`='" . $list_cat[$numero] . "' AND `deleted`!='1'")) { $numero ++; if($numero >= sizeof($list_cat)) { break; $foun = false; } } } else { $foun = false; } if($foun) { $it = o("SELECT * FROM `categories` WHERE `id`='" . $list_cat[$numero] . "' AND `deleted`!='1'"); $this_cat_url = $it->url; } else { $this_cat_url = "uncategorised"; } $array[$k]["url"] = "/" . $this_cat_url . "/" . $v['id'] . "/" . date("Y-m-d-", $v['timestamp']) . h($v['title']); } } return $array; } // Set up this category $display_data = Array(); $category_data = new StdClass(); $category_data -> id = $category_data -> html = $category_data -> url = $category_data -> description = $category_data -> tags = ""; $_cat = (isset($_GET[0])) ? e($_GET[0]) : ""; if($_cat=="uncategorised") { $final_query .= "`cats` REGEXP 'a:0:{}'"; } else if(n("SELECT * FROM `categories` WHERE `url`='$_cat' AND `deleted`!='1' LIMIT 1")) { $category_data = o("SELECT * FROM `categories` WHERE `url`='$_cat' AND `deleted`!='1' LIMIT 1"); $final_query .= "`cats` REGEXP 's:([0-9]+):\"" . $category_data -> id . "\"'"; } elseif(preg_replace("/(^\/|\/$)/", "", $_SERVER['REQUEST_URI'])!="") { #$final_query .= "`cats`=''"; } $temp_base = preg_quote($_SERVER['HTTP_HOST'], "/"); if(!preg_match("/^$temp_base/", preg_replace("/https?:\/\//i", "", SITE_BASE))) { $name = 1; $uri = ""; while(isset($_GET[$name])) { $name = $_GET[$name]; $uri .= "/" . $name; } header("Location: " . SITE_BASE . $uri, true, 301); } // List categories $available_categories = Array(); $q = q("SELECT * FROM `categories` WHERE `deleted`!='1'"); while($a = mysql_fetch_assoc($q)) { $available_categories[$a['id']] = $a; } // List Dates $list_dates = Array(); $today_month = date("m", time()); $today_year = date("Y", time()); if($today_month==12) { $today_year++; $today_month = 1; } else { $today_month++; } $stamp = mktime(0, 0, 0, $today_month, 0, $today_year); if($today_month==1) { $today_year--; $today_month = 12; } else { $today_month--; } $new_stamp = mktime(0, 0, 0, $today_month, 0, $today_year); $count = 0; while($count < 12) { if(n("SELECT * FROM `articles` WHERE `timestamp`>='$new_stamp' AND `timestamp`<='$stamp' AND `deleted`!='1' LIMIT 1")) { $list_dates[date("F Y", $stamp)] = "$today_year/" . ((strlen($today_month==1)) ? "0" . $today_month : $today_month); $count = 0; } else { $count ++; } if($today_month==1) { $today_year--; $today_month = 12; } else { $today_month--; } $stamp = $new_stamp; $new_stamp = mktime(0, 0, 0, $today_month, 0, $today_year); } // Set up this article $article_data = new StdClass(); $article_data -> id = $article_data -> cats = $article_data -> title = $article_data -> short = $article_data -> long = $article_data -> image = $article_data -> tags = $article_data -> timestamp = ""; $comments_data = Array(); $_article = (isset($_GET[$_cat])) ? e($_GET[$_cat]) : ""; if(n("SELECT * FROM `articles` WHERE `id`='$_article' AND `deleted`!='1'")) { // Run post data of comments if(isset($_POST['comment'])) { $comment = e($_POST['comment']); $name = e($_POST['name']); $article_id = $_article; $timestamp = time(); q("INSERT INTO `comments` SET `name`='$name', `comment`='$comment', `article_id`='$article_id', `timestamp`='$timestamp', `status`='$set_comments'"); // Set comments is found in config. Determines whether auto verify or needs verifying. } $article_data = o("SELECT * FROM `articles` WHERE `id`='$_article' AND `deleted`!='1' LIMIT 1"); $q = q("SELECT * FROM `comments` WHERE `article_id`='$_article' AND `status`='1' ORDER BY `timestamp` DESC"); While($a = mysql_fetch_assoc($q)) { $comments_data[$a['id']] = $a; } } // Check to see if tags names have been searched for. $tags = ""; if(isset($_GET['tag']) && $_GET['tag']!="") { $tags = $_GET['tag']; $_tags = preg_replace("/-/i", "([^a-z0-9_\.\/-]+)", preg_quote($_GET['tag'], "/")); if($final_query!="") { $final_query .= " AND "; } $final_query .= "`tags` REGEXP '(^|,)([^a-z0-9_\.\/-]+)?$_tags([^a-z0-9_\.\/-]+)?(,|$)'"; } // Check to see if date has been searched for. $date = 0; if($temp = preg_match("/\/([0-9]{4})\/(([0-9]{1,2}))?(\/([0-9]{1,2}))?/i", $_SERVER['REQUEST_URI'], $_date)) { $year = $_date[1]; $month = (isset($_GET[$year])) ? $_GET[$year] : 0; $day = (isset($_GET[$month])) ? $_GET[$month] : 0; $upper_day = ($day!=0) ? $day + 1 : 0; $upper_month = ($day==0) ? $month + 1 : $month; $upper_year = ($month==0) ? $year + 1 : $year; $lower_boundary = mktime(0, 0, 0, $month, $day, $year); $upper_boundary = mktime(0, 0, 0, $upper_month, $upper_day, $upper_year); #echo "From $day/$month/$year -> $upper_day/$upper_month/$upper_year"; $page_title = date("F Y", $upper_boundary); if($final_query!="") { $final_query .= " AND "; } $final_query .= "`timestamp` >= '$lower_boundary' AND `timestamp`<='$upper_boundary'"; } // Add number of available comments to article info // add Url to article info if($final_query!="") { $final_query .= " AND "; } $final_query .= "`deleted`!='1' ORDER BY `timestamp` DESC "; $full_number = n("SELECT * FROM `articles` WHERE $final_query"); #echo $final_query; if($full_number) { $display_data = Array(); $q = q("SELECT * FROM `articles` WHERE $final_query $limiting"); while($a = mysql_fetch_assoc($q)) { $display_data[$a['id']] = $a; } } $display_data = get_info($display_data); krsort($display_data); $meta_description = $category_data -> description; $meta_keywords = $category_data -> tags; $page_title = $category_data -> html; $browser_title = $category_data -> html; $uril = preg_replace("/(" . ((SITE_REL!="/") ? preg_quote(SITE_REL, "/") . "|" : "") . "^\/|\/$)/", "", $_SERVER['REQUEST_URI']); if($uril=="") $uril = "/"; if($article_data -> id != "") { // Display a Single Article $meta_description = substr($article_data -> short, 0, 250) . "..."; $meta_keywords = $article_data -> tags; $name = 0; $uri = ""; while(isset($_GET[$name])) { $name = $_GET[$name]; $uri .= "/" . $name; } $list_cat = u($article_data -> cats); $numero = 0; $foun = true; if(isset($list_cat[$numero])) { while(!n("SELECT * FROM `categories` WHERE `id`='" . $list_cat[$numero] . "' AND `deleted`!='1'")) { $numero ++; if($numero >= sizeof($list_cat)) { break; $foun = false; } } } else { $foun = false; } if($foun) { $it = o("SELECT * FROM `categories` WHERE `id`='" . $list_cat[$numero] . "' AND `deleted`!='1'"); $this_cat_url = $it->url; } else { $this_cat_url = "uncategorised"; } if($uri != "/" . $this_cat_url . "/" . $article_data -> id . "/" . date("Y-m-d-", $article_data->timestamp) . h($article_data->title)) { header("Location: " . SITE_BASE . "/" . $this_cat_url . "/" . $article_data -> id . "/" . date("Y-m-d-", $article_data->timestamp) . h($article_data->title), true, 301); } // The page is an article page. Yay! if(file_exists("templates/article.php")) { include("templates/article.php"); } } else if(sizeof($_GET)==0 || (sizeof($_GET) == 1 && $_GET[0] == 'feed')) { $q = q("SELECT* FROM `articles` WHERE `deleted`!='1' ORDER BY `id` DESC LIMIT 10"); $display_data = Array(); while($o = mysql_fetch_assoc($q)) { $display_data[$o['id']] = $o; } $display_data = get_info($display_data); // Load a homepage if(sizeof($_GET)!=0) { if(file_exists("templates/rss.php")) { include("templates/rss.php"); } } else { $rss_feed_mgr = "feed.rss"; // Display results of the current search if(file_exists("templates/home.php")) { include("templates/home.php"); } else if(file_exists("templates/view.php")) { include("templates/view.php"); } } } else if(!empty($category_data -> id) || preg_replace("/(^\/|\/$)/", "", $_SERVER['REQUEST_URI'])=="" || !empty($display_data)) { $page_title = $p_t; $browser_title = $b_t; $meta_description = $m_d; $meta_keywords = $m_k; if(preg_match("/\.rss$/", $_SERVER['REQUEST_URI'])) { if(file_exists("templates/rss.php")) { include("templates/rss.php"); } } else { // Display results of the current search $rss_feed_mgr = ".rss"; if(file_exists("templates/view.php")) { include("templates/view.php"); } } } else { header("HTTP/1.0 404 Not Found"); // Error 404s include("templates/header.php"); echo "

Error 404

Sorry, we could not find the page."; include("templates/footer.php"); } ?>