day, %b -> short month, %G -> 4digit year; for all possibilities have a look at http://www.php.net/manual/de/function.strftime.php $datelang = "nl_NL"; // taal voor output , nl_NL -> phpnet.com.setlocale.php // WYSIWYG editor settings $pathtoscript = ""; // path from the file where mynews.inc.php is included to the folder where mynews.inc.php is actually stored in // with trailing slash if set! $wysiwyg = false; // zet wysiwyg editor aan/uit $filesPathFromDocRoot = ""; // Path to the folder where all uploaded files from FCKeditor are saved. Relative to the document root. with trailing slash! $txtclickback = "Click BACK in your browser!"; // RSS 0.9 settings $rssEnable = false; // set to true if you want to offer rss feed of your news $rssTitle = "pagina nieuws"; // Title of teh RSS feed $rssDescription = "Overzicht van de gemaakte pagina's!"; // Description of RSS feed $rssChannelUrl = "http://"; // Base URL of your Site (doesn't really matter) $rssNewspageUrl = ""; // URL of the site where you did the 'mynews.inc.php'-include $rssNumNews = 5; // Number of News to display in the rss feed $rssOrder = "ASC"; // order of news in the feed: ASC/DESC // ************************************************************ // ****************** functions - don't touch ***************** // ************************************************************ $now = time(); class mdasort { var $data; var $sortkeys; function _sortcmp($a, $b, $i = 0) { $r = strnatcmp($a[$this->sortkeys[$i][0]], $b[$this->sortkeys[$i][0]]); if ($this->sortkeys[$i][1] == "DESC") $r = $r * -1; if ($r == 0) { $i++; if ($this->sortkeys[$i]) $r = $this->_sortcmp($a, $b, $i); } return $r; } function msort() { if (count($this->sortkeys)) { usort($this->data, array($this, "_sortcmp")); } } } ###################################### config $dat = $News; $templatefile = $template; $pathtowysiwyg = ""; setlocale(LC_TIME, $datelang); $dateformat = "%e. %b. %G - %H:%M"; // http://www.php.net/manual/de/function.strftime.php $datelang = "nl_NL"; $empty = false; $version = "1.6.4"; if (isset($_REQUEST['id'])) $id = $_REQUEST['id']; if (isset($_REQUEST['action'])) $action = $_REQUEST['action']; if (isset($_REQUEST['story'])) $story = $_REQUEST['story']; if (isset($_REQUEST['teaser'])) $teaser = $_REQUEST['teaser']; if (isset($_REQUEST['time'])) $time = $_REQUEST['time']; if (isset($_REQUEST['date'])) $date = $_REQUEST['date']; // ************************** functions *********************** // ************************************************************ function getkey($index, $stuff) { foreach ($stuff->data as $key => $item) { if ($item['id'] == $index) { $ret = $key; break; } } return $ret; } function jsRedirect($url) { echo ""; } if (!function_exists('str_ireplace')) { function str_ireplace($search, $replace, $subject, $count = null) { if (is_string($search) && is_array($replace)) { trigger_error('Array to string conversion', E_USER_NOTICE); $replace = (string )$replace; } if (!is_array($search)) { $search = array($search); } if (!is_array($replace)) { $replace_string = $replace; $replace = array(); for ($i = 0, $c = count($search); $i < $c; $i++) { $replace[$i] = $replace_string; } } $length_replace = count($replace); $length_search = count($search); if ($length_replace < $length_search) { for ($i = $length_replace; $i < $length_search; $i++) { $replace[$i] = ''; } } $was_array = false; if (!is_array($subject)) { $was_array = true; $subject = array($subject); } $count = 0; foreach ($subject as $subject_key => $subject_value) { foreach ($search as $search_key => $search_value) { $segments = explode(strtolower($search_value), strtolower($subject_value)); $count += count($segments) - 1; $pos = 0; foreach ($segments as $segment_key => $segment_value) { $segments[$segment_key] = substr($subject_value, $pos, strlen($segment_value)); $pos += strlen($segment_value) + strlen($search_value); } $subject_value = implode($replace[$search_key], $segments); } $result[$subject_key] = $subject_value; } if ($was_array === true) { return $result[0]; } return $result; } } function paging($pages, $pagevar = "page", $ppv = 10, $first = "««« ", $firsts = "««« ", $prev = "««  ", $prevs = "««  ", $num = "{page}", $nums = "{page}", $sep = " | ", $more = "[...]", $next = "  »»", $nexts = "  »»", $last = " »»»", $lasts = " »»»") { // get URI parameters $getvars = $_SERVER['PHP_SELF'] . "?"; foreach ($_GET as $key => $val) { if ($key != $pagevar) { if (isset($val) && $val != "") { $getvars .= "$key=$val&"; } else { $getvars .= "$key&"; } } } $page = (is_numeric($_GET[$pagevar])) ? $_GET[$pagevar] : 1; $page = ($page > $pages) ? $pages : $page; $prevpage = ($page > 1) ? $page - 1 : 1; $nextpage = ($page < $pages) ? $page + 1 : $pages; $paging = ""; if ($pages > 1) { // first $paging .= ($page > 1) ? str_replace("{url}", "$getvars$pagevar=1", $first) : $firsts; // prev $paging .= ($page > 1) ? str_replace("{url}", "$getvars$pagevar=$prevpage", $prev) : $prevs; // pages $ppvrange = ceil($page / $ppv); $start = ($ppvrange - 1) * $ppv; $end = ($ppvrange - 1) * $ppv + $ppv; $end = ($end > $pages) ? $pages : $end; $paging .= ($start > 1) ? str_replace("{url}", "$getvars$pagevar=" . ($start - 1), $more) . $sep : ""; for ($i = 1; $i <= $pages; $i++) { if ($i > $start && $i <= $end) { $paging .= ($page == $i) ? str_replace("{page}", $i, $nums) . (($i < $end) ? $sep : "") : str_replace(array("{url}", "{page}"), array("$getvars$pagevar=$i", $i), $num) . (($i < $end) ? $sep : ""); } } $paging .= ($end < $pages) ? $sep . str_replace("{url}", "$getvars$pagevar=" . ($end + 1), $more) : ""; // next $paging .= ($page < $pages) ? str_replace("{url}", "$getvars$pagevar=$nextpage", $next) : $nexts; // last $paging .= ($page < $pages) ? str_replace("{url}", "$getvars$pagevar=$pages", $last) : $lasts; } return $paging; } // ************************** MAIN **************************** // ************************************************************ // init $foo = file($dat); $stuff = new mdasort; $stuff->sortkeys = array(array('time', 'DESC')); if (count($foo) == 0) { echo "foo nul
\n"; $empty = true; $nextindex = 1; } else { $i = 0; foreach ($foo as $line) { $line = explode("|", rtrim($line)); if ($line[2] == "static" || ($line[2] == "dynamic" && $line[1] < $now)) { $stuff->data[$i] = array("id" => $line[0], "time" => $line[1], "mode" => $line[2], "title" => $line[3], "story" => $line[4], "teaser" => $line[5]); $i++; } } if ($i > 0) { $stuff->sortkeys = array(array('id', 'DESC')); $stuff->msort(); $foo = current($stuff->data); $nextindex = $foo['id'] + 1; $stuff->sortkeys = array(array('time', 'DESC')); $stuff->msort(); $numposts = count($stuff->data); } else { $numposts = 0; $empty = true; } } // RSS stuff if ($rssEnable) { $info = pathinfo($_SERVER['PHP_SELF']); $info['dirname'] = ($info['dirname'] == "/") ? $info['dirname'] : $info['dirname'] . "/"; $url = $info['dirname'] . $pathtoscript . "rss.php?mndo=rss"; echo ""; } echo "

"; echo "
"; // display posts if ($do == "view") { if (!$empty) { $templates = implode("", file($templatefile)); $tpl_teaser = getTemplate("TEASER", $templates); $tpl_story = getTemplate("STORY", $templates); // show full story of specific news if (is_numeric($_GET['mnid'])) { $item = $stuff->data[getkey($_GET['mnid'], $stuff)]; $item['title'] = stripslashes($item['title']); $item['teaser'] = stripslashes($item['teaser']); $item['story'] = stripslashes($item['story']); if ($wrap !== false) $item['story'] = wordwrap($item['story'], $wrap, " ", 1); $match = array("{title}", "{time}", "{teaser}", "{story}", "{edit}", "{delete}", "{urltoallnews}"); $replace = array($item['title'], strftime($dateformat, $item['time']), $item['teaser'], $item['story'], "", "", "$me?do=view&page=" . $_GET['page']); $tmp = str_replace($match, $replace, $tpl_story); ob_start(); eval("?>" . $tmp . "data as $item) { if ($item['id'] != 0 && $i >= $from && $i < ($from + $ppp)) { $item['title'] = stripslashes($item['title']); $item['teaser'] = stripslashes($item['teaser']); $item['story'] = stripslashes($item['story']); $hasstory = (trim($item['story']) != "") ? true : false; if ($wrap !== false) $item['story'] = wordwrap($item['story'], $wrap, " ", 1); $match = array("{title}", "{time}", "{teaser}", "{story}", "{edit}", "{delete}","{urltofullstory}"); $replace = array($item['title'], strftime($dateformat, $item['time']), $item['teaser'], $item['story'], "", "", ($hasstory === true) ? "$me?mnid=" . $item['id'] . "&do=view" . "&page=" . $_GET['page'] : ""); $tmp = str_replace($match, $replace, $tpl_teaser); ob_start(); eval("?>" . $tmp . " 0) ? floor($numposts / $ppp) + 1 : ($numposts / $ppp); echo "

"; echo paging($numpages); echo "

"; } } } // closing table tags echo "
"; // einde nieuws } ?>