diff --git a/class2.php b/class2.php index a0bec62a3..3bc8d65ac 100644 --- a/class2.php +++ b/class2.php @@ -1127,27 +1127,77 @@ if (($_SERVER['QUERY_STRING'] == 'logout')/* || (($pref['user_tracking'] == 'ses exit(); } -/* -* Calculate time zone offset, based on session cookie set in e107.js. -* (Buyer beware: this may be wrong for the first pageview in a session, -* which is while the user is logged out, so not a problem...) -* -* Time offset is SECONDS. Seconds is much better than hours as a base, -* as some places have 30 and 45 minute time zones. -* It matches user clock time, instead of only time zones. -* Add the offset to MySQL/server time to get user time. -* Subtract the offset from user time to get server time. -* -*/ - -$tz = vartrue($pref['timezone'],'GMT'); //TODO Adjust on the front-end based on user timezone value. - -date_default_timezone_set($tz); // Must be set or PHP Warning thrown. - -unset($tz); -$e_deltaTime=0; +/** + * @addtogroup timezone + * @{ + */ + +/** + * Generate an array of time zones. + * + * @return array + * Array of time zones. + */ +function systemTimeZones() +{ + // Never do something time consuming twice if you can hold onto the results + // and re-use them. So we re-use the statically cached value to save time + // and memory. + static $zones = array(); + + // If Timezone list is not populated yet. + if(empty($zones)) + { + $zonelist = timezone_identifiers_list(); + $timeNow = date('m/d/Y H:i', $_SERVER['REQUEST_TIME']); + + foreach($zonelist as $zone) + { + // Because many time zones exist in PHP only for backward compatibility + // reasons and should not be used, the list is filtered by a regular + // expression. + if(preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) + { + $dateTimeZone = new DateTimeZone($zone); + $dateTime = new DateTime($timeNow, $dateTimeZone); + $offset = $dateTime->format('O'); + $offset = chunk_split($offset, 3, ':'); + + $zones[$zone] = str_replace('_', ' ', $zone) . ' (' . rtrim($offset, ':') . ')'; + } + } + + // Sort time zones alphabetically. + asort($zones); + } + + return $zones; +} + +/** + * Validate a timezone. + * + * @param string $zone + * Timezone. + * + * @return bool + */ +function systemTimeZoneIsValid($zone = '') +{ + $zones = systemTimeZones(); + $zoneKeys = array_keys($zones); + + if(in_array($zone, $zoneKeys)) + { + return true; + } + + return false; +} + +$e_deltaTime = 0; if (isset($_COOKIE['e107_tdOffset'])) { @@ -1163,6 +1213,10 @@ if (isset($_COOKIE['e107_tzOffset'])) define('TIMEOFFSET', $e_deltaTime); +/** + * @} End of "addtogroup timezone". + */ + // ---------------------------------------------------------------------------- @@ -1723,6 +1777,33 @@ function init_session() // New user model $user = e107::getUser(); + // Get user timezone. + $tzUser = $user->getTimezone(); + + // If user timezone is valid. + if (varset($tzUser, false) && systemTimeZoneIsValid($tzUser)) + { + // Sets the default timezone used by all date/time functions. + date_default_timezone_set($tzUser); + // Save timezone for later use. + define('USERTIMEZONE', $tzUser); + + unset($tzUser); + } + else + { + // Use system default timezone. + $pref = e107::getPref(); + $tz = vartrue($pref['timezone'], 'UTC'); + + // Sets the default timezone used by all date/time functions. + date_default_timezone_set($tz); + // Save timezone for later use. + define('USERTIMEZONE', $tz); + + unset($tz); + } + define('USERIP', e107::getIPHandler()->getIP(FALSE)); define('POST_REFERER', md5($user->getToken())); diff --git a/e107.htaccess b/e107.htaccess index 06b25d474..a2d147762 100644 --- a/e107.htaccess +++ b/e107.htaccess @@ -1,9 +1,9 @@ # Custom error pages for php scripts only - + ErrorDocument 400 /error.php?400 ErrorDocument 401 /error.php?401 ErrorDocument 403 /error.php?403 - ErrorDocument 404 /error.php?404 + ErrorDocument 404 /error.php?404 ErrorDocument 500 /error.php?500 diff --git a/e107_admin/boot.php b/e107_admin/boot.php index 550dbfb1d..d9ca9b4ce 100644 --- a/e107_admin/boot.php +++ b/e107_admin/boot.php @@ -20,7 +20,7 @@ if (!defined('e107_INIT')) header('Content-type: text/html; charset=utf-8', TRUE); -define('ADMINFEED', 'http://e107.org/adminfeed'); +define('ADMINFEED', 'https://e107.org/adminfeed'); @@ -67,6 +67,13 @@ if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'core' && ($_GET['type'] echo $text; } + else + { + if(e_DEBUG) + { + // echo "Feed failed: ".ADMINFEED; + } + } exit; } @@ -92,7 +99,7 @@ if(ADMIN && e_AJAX_REQUEST && varset($_GET['mode']) == 'addons' ) } - if($data = e107::getXml()->getRemoteFile('http://e107.org/feed/?limit=3&type='.$type,3)) + if($data = e107::getXml()->getRemoteFile('https://e107.org/feed/?limit=3&type='.$type,3)) { $rows = e107::getXml()->parseXml($data, 'advanced'); // print_a($rows); diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 51d15fcc1..180588451 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -727,43 +727,15 @@ $text .= " $text .= " - - - - - ".$frm->select_open('time_offset', 'class=tbox select time-offset');//use form handler because of the tabindex -$toffset = array("-12", "-11", "-10", "-9", "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", "+1", "+2", "+3", "+4", "+5", "+6", "+7", "+8", "+9", "+10", "+11", "+12", "+13", "+14", "+15", "+16"); -if(! isset($pref['time_offset'])) -{ - $pref['time_offset'] = "0"; -} - - -//XXX TODO FIXME - Do we still need this? - -foreach($toffset as $o) -{ - $text .= " - ".$frm->option($o, $o, ($o == $pref['time_offset']))." - "; -} - - - - $timeZones = timezone_identifiers_list(); - - + "; +$timeZones = systemTimeZones(); $text .= " - -
".PRFLAN_27."
- - - ".$frm->select('timezone', $timeZones, vartrue($pref['timezone'],'GMT'), 'useValues=1')." + ".$frm->select('timezone', $timeZones, vartrue($pref['timezone'], 'UTC'))." @@ -772,6 +744,7 @@ $text .= " "; + // =========== Registration Preferences. ================== diff --git a/e107_core/controllers/system/error.php b/e107_core/controllers/system/error.php index 9dd0afb70..02e0ebc2b 100644 --- a/e107_core/controllers/system/error.php +++ b/e107_core/controllers/system/error.php @@ -1,102 +1,104 @@ _forward('notfound'); - } - - public function actionNotfound() - { - $this->getResponse() - ->setRenderMod('error404') - ->addHeader('HTTP/1.0 404 Not Found'); - - $this->addTitle(LAN_ERROR_7); - $template = e107::getCoreTemplate('error', 404); - - $vars = new e_vars(array( - 'SITEURL' => SITEURL, - 'SEARCHURL' => e107::getUrl()->create('search'), - )); - - - $body = e107::getParser()->parseTemplate( - $this->updateTemplate($template['start']). - $this->updateTemplate($template['body']). - $this->updateTemplate($template['end']) - , true, null, $vars); - - $this->addBody($body); - } - /** - * Update template to v2.x spec. ALL CAPS shortcodes only. - * @param $template - * @return mixed - */ - private function updateTemplate($template) - { - $srch = array('{siteUrl}','{searchUrl}'); - $repl = array('{SITEURL}','{SEARCHURL}'); - - return str_replace($srch,$repl,$template); - } - - /** - * Alias + * Alias for "Error 403". */ public function action403() { $this->_forward('forbidden'); } + /** + * Alias for "Error 404". + */ + public function action404() + { + $this->_forward('notfound'); + } + + /** + * Error 403. + */ public function actionForbidden() { - $this->getResponse() - ->setRenderMod('error403') - ->addHeader('HTTP/1.0 403 Forbidden'); - - $this->addTitle(LAN_ERROR_7); - $template = e107::getCoreTemplate('error', 403); - - $vars = new e_vars(array( - 'SITEURL' => SITEURL, + $response = $this->getResponse(); + $response->setRenderMod('error403'); + $response->addHeader('HTTP/1.0 403 Forbidden'); + + $tp = e107::getParser(); + $tpl = e107::getCoreTemplate('error', '403'); + $sc = e107::getScBatch('error'); + + $title = LAN_ERROR_TITLE; + $subtitle = LAN_ERROR_4; + $caption = LAN_ERROR_45; + $content = LAN_ERROR_5 . '
' . LAN_ERROR_6 . '

' . LAN_ERROR_2; + + $sc->setVars(array( + 'title' => $title, + 'subtitle' => $subtitle, + 'caption' => $caption, + 'content' => $content, )); - - $body = e107::getParser()->parseTemplate( - $this->updateTemplate($template['start']). - $this->updateTemplate($template['body']). - $this->updateTemplate($template['end']) - , true, null, $vars); - + + $body = $tp->parseTemplate($tpl, true, $sc); $this->addBody($body); } - - function actionHelloWorld() + + /** + * Error 404. + */ + public function actionNotfound() { - //$this->addTitle('Hello!'); - //echo 'Hello World'; + $response = $this->getResponse(); + $response->setRenderMod('error404'); + $response->addHeader('HTTP/1.0 404 Not Found'); + + $tp = e107::getParser(); + $tpl = e107::getCoreTemplate('error', '404'); + $sc = e107::getScBatch('error'); + + $title = LAN_ERROR_TITLE; + $subtitle = LAN_ERROR_7; + $caption = LAN_ERROR_45; + $content = LAN_ERROR_21 . '
' . LAN_ERROR_9; + + $sc->setVars(array( + 'title' => $title, + 'subtitle' => $subtitle, + 'caption' => $caption, + 'content' => $content, + )); + + $body = $tp->parseTemplate($tpl, true, $sc); + $this->addBody($body); } + } diff --git a/e107_core/shortcodes/batch/error_shortcodes.php b/e107_core/shortcodes/batch/error_shortcodes.php new file mode 100644 index 000000000..7b3a3dcda --- /dev/null +++ b/e107_core/shortcodes/batch/error_shortcodes.php @@ -0,0 +1,81 @@ +var['title'], ''); + } + + /** + * @return mixed + */ + public function sc_error_subtitle() + { + return varset($this->var['subtitle'], ''); + } + + /** + * @return mixed + */ + public function sc_error_caption() + { + return varset($this->var['caption'], ''); + } + + /** + * @return mixed + */ + public function sc_error_content() + { + return varset($this->var['content'], ''); + } + + /** + * @return string + */ + public function sc_error_link_home() + { + $icon = e107::getParser()->toGlyph('fa-home'); + $url = SITEURL; + + return '' . $icon . ' ' . LAN_ERROR_20 . ''; + } + + /** + * @return string + */ + public function sc_error_link_search() + { + $icon = e107::getParser()->toGlyph('fa-search'); + $url = e107::getUrl()->create('search'); + + return '' . $icon . ' ' . LAN_ERROR_22 . ''; + } + +} + diff --git a/e107_core/shortcodes/single/news_categories.sc b/e107_core/shortcodes/single/news_categories.sc index 99bfd8921..8c63b8e16 100644 --- a/e107_core/shortcodes/single/news_categories.sc +++ b/e107_core/shortcodes/single/news_categories.sc @@ -61,7 +61,7 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; { $NEWSCAT_ITEM = "
- +
@@ -85,7 +85,7 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; } if(!defined("NEWSCAT_STYLE")) { - define("NEWSCAT_STYLE","width:96%"); + define("NEWSCAT_STYLE",''); } if(!defined("NEWSCAT_CATICON")) { @@ -131,7 +131,7 @@ $nbr_cols = (defined("NEWSCAT_COLS")) ? NEWSCAT_COLS : $nbr_cols; $text3 = "\n\n\n
-
+
\n"; $t = 0; $wid = floor(100/$nbr_cols); diff --git a/e107_core/sql/extended_timezones.php b/e107_core/sql/extended_timezones.php index 24955ade9..871aabc4c 100644 --- a/e107_core/sql/extended_timezones.php +++ b/e107_core/sql/extended_timezones.php @@ -14,121 +14,136 @@ * $Author$ */ -if (!defined('e107_INIT')) { exit; } +if(!defined('e107_INIT')) +{ + exit; +} -/* -This file is used with the extended user field 'predefined list' type. It is invoked when the value field is 'timezones'. +/** + * @file + * This file is used with the extended user field 'predefined list' type. It is + * invoked when the value field is 'timezones'. + * + * It is an example of an extended user field which access a predetermined list + * of key-pair values. In this example all the data is loaded into memory; for + * other applications the data may be read from a database, possibly with + * caching. + * + * The objective is to provide a uniform interface to such data. + * + * The class name must be the same as the file name - i.e. the list name + * prefixed with 'extended_'. + * + * The variable name must be 'timezones_list', and is an array of possible + * values, each of which is a value => text pair. + * + * The text is displayed in a drop-down; the value is returned. + * + * If function timezones_value() exists, it is called to create the displayed + * text. + */ -It is an example of an extended user field which access a predetermined list of key-pair values. In this example all the data is loaded -into memory; for other applications the data may be read from a database, possibly with caching. - -The objective is to provide a uniform interface to such data. - -The class name must be the same as the file name - i.e. the list name prefixed with 'extended_'. - -The variable name must be 'timezones_list', and is an array of possible values, each of which is a value => text pair -The text is displayed in a drop-down; the value is returned. -If function timezones_value() exists, it is called to create the displayed text -*/ +/** + * Class extended_timezones. + */ class extended_timezones { - private $timezonesList = array( - '-12' => "International DateLine West", - '-11' => "Samoa", - '-10' => "Hawaii", - '-9' => "Alaska", - '-8' => "Pacific Time (US and Canada)", - '-7' => "Mountain Time (US and Canada)", - '-6' => "Central Time (US and Canada), Central America", - '-5' => "Eastern Time (US and Canada)", - '-4' => "Atlantic Time (Canada)", - '-3.30' => 'Newfoundland', - '-3' => "Greenland, Brasilia, Buenos Aires, Georgetown", - '-2' => "Mid-Atlantic", - '-1' => "Azores, Cape Verde Islands", - '+0' => "UK, Ireland, Lisbon", - '+1' => "West Central Africa, Western Europe", - '+2' => "Greece, Egypt, parts of Africa", - '+3' => "Russia, Baghdad, Kuwait, Nairobi", - '+3.30' => 'Tehran, Iran', - '+4' => "Abu Dhabi, Kabul", - '+4.30' => 'Afghanistan', - '+5' => "Islamabad, Karachi", - '+5.30' => "Mumbai, Delhi, Calcutta", - '+5.45' => 'Kathmandu', - '+6' => "Astana, Dhaka", - '+7' => "Bangkok, Rangoon", - '+8' => "Hong Kong, Singapore, Perth, Beijing", - '+9' => "Tokyo, Seoul", - '+9.30' => 'Darwin, Adelaide', - '+10' => "Brisbane, Canberra, Sydney, Melbourne", - '+10.30' => 'Lord Howe Island', - '+11' => "Soloman Islands", - '+11.30' => 'Norfolk Island', - '+12' => "New Zealand, Fiji, Marshall Islands", - '+13' => "Tonga, Nuku'alofa, Rawaki Islands", - '+13.45' => 'Chatham Island', - '+14' => 'Kiribati: Line Islands' - ); - - - private $isEOF = FALSE; // True if at last element of list - private $bufferValid = FALSE; - + /** + * @var array + */ + private $timezonesList = array(); /** - * Call before using the 'next' format option, to ensure the array is indexed from the beginning + * @var bool + */ + private $isEOF = false; // True if at last element of list. + + /** + * @var bool + */ + private $bufferValid = false; + + /** + * Constructor. + */ + public function __construct() + { + $this->timezonesList = systemTimeZones(); + } + + /** + * Call before using the 'next' format option, to ensure the array is + * indexed from the beginning. */ public function pointerReset() { - $this->isEOF = (FALSE === reset($this->timezonesList)); - $this->bufferValid = TRUE; + $this->isEOF = (false === reset($this->timezonesList)); + $this->bufferValid = true; } /** - * Return a formatted timezone value + * Return a formatted timezone value * - * @param mixed $key - the key value to select - * @param string $formatSpec - defines format of return value + * @param mixed $key + * The key value to select. + * @param string $formatSpec + * Defines format of return value. * - * @return mixed (according to $formatSpec). FALSE if no value available - * 'array' - a single-element array; key as passed, and value to match key - * 'next' - as 'array', but ignores the passed $key and moves to next value. - * default - a string usable for display + * @return mixed + * (according to $formatSpec). + * false - if no value available. + * 'array' - a single-element array; key as passed, and value to match key + * 'next' - as 'array', but ignores the passed $key and moves to next value. + * 'default' - a string usable for display. */ public function getValue($key, $formatSpec = '') { - if ($formatSpec == 'next') + if($formatSpec == 'next') { - if (!$this->bufferValid) $this->pointerReset; // Make sure buffer is defined - if ($this->isEOF) return FALSE; + // Make sure buffer is defined. + if(!$this->bufferValid) + { + $this->pointerReset(); + } + + if($this->isEOF) + { + return false; + } + $key = key($this->timezonesList); $val = current($this->timezonesList); - if (FALSE === $val) + + if(false === $val) { - $this->isEOF = TRUE; - return FALSE; + $this->isEOF = true; + return false; } - $this->isEOF = (FALSE === next($this->timezonesList)); + + $this->isEOF = (false === next($this->timezonesList)); + return array($key => $val); } $exists = isset($this->timezonesList[$key]); - if (!$exists) return FALSE; + + if(!$exists) + { + return false; + } $val = $this->timezonesList[$key]; - if ($formatSpec == 'array') + + if($formatSpec == 'array') { return array($key => $val); } - - // Default (as per earlier implementations) - can be specified with 'display' format - return 'GMT'.$key.' - '.$val; + + // Default (as per earlier implementations) - can be specified with + // 'display' format. + return $val; } } - - -?> \ No newline at end of file diff --git a/e107_core/templates/error_template.php b/e107_core/templates/error_template.php index 2c035aa66..7263c8515 100644 --- a/e107_core/templates/error_template.php +++ b/e107_core/templates/error_template.php @@ -1,47 +1,187 @@ '; -$ERROR_TEMPLATE['404']['body'] = ' -

'.LAN_ERROR_45.'

-

- '.LAN_ERROR_21.'
'.LAN_ERROR_9.' -

- '.LAN_ERROR_20.'
- '.LAN_ERROR_22.' +/** + * 400 Bad Request. + */ +$ERROR_TEMPLATE['400'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} +
+
'; -$ERROR_TEMPLATE['404']['end'] = ''; - -$ERROR_TEMPLATE['403']['start'] = '
'; -$ERROR_TEMPLATE['403']['body'] = ' -

'.LAN_ERROR_4.'

-

- '.LAN_ERROR_5.'
'.LAN_ERROR_6.'

'.LAN_ERROR_2.' -

- '.LAN_ERROR_20.'
+/** + * 401 Unauthorized. + */ +$ERROR_TEMPLATE['401'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} +
+
'; -$ERROR_TEMPLATE['403']['end'] = '
'; +/** + * 403 Forbidden. + */ +$ERROR_TEMPLATE['403'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} +
+
+'; + +/** + * 404 Not Found. + */ +$ERROR_TEMPLATE['404'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} {ERROR_LINK_SEARCH} +
+
+'; + +/** + * 500 Internal server error. + */ +$ERROR_TEMPLATE['500'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} +
+
+'; + +/** + * Default error page. + */ +$ERROR_TEMPLATE['DEFAULT'] = ' +

+ {ERROR_TITLE} +

+

+ {ERROR_SUBTITLE} +

+
+
+
+
+ {ERROR_CAPTION} +
+
+ {ERROR_CONTENT} +
+
+
+
+
+ {ERROR_LINK_HOME} +
+
+'; diff --git a/e107_core/url/system/rewrite_url.php b/e107_core/url/system/rewrite_url.php index bf4745035..3a2aa7f30 100644 --- a/e107_core/url/system/rewrite_url.php +++ b/e107_core/url/system/rewrite_url.php @@ -42,7 +42,7 @@ class core_system_rewrite_url extends eUrlConfig 'name' => LAN_EURL_CORE_SYSTEM, // Module name 'label' => LAN_EURL_SYSTEM_REWRITE_LABEL, // Current profile name 'description' => LAN_EURL_SYSTEM_REWRITE_DESCR, // - 'examples' => array("{SITEURL}system/error404") + 'examples' => array("{SITEURL}system/error/404") ), 'form' => array(), // Under construction - additional configuration options 'callbacks' => array(), // Under construction - could be used for e.g. URL generator functionallity diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml index cd1f717f1..18fd42cdf 100644 --- a/e107_core/xml/default_install.xml +++ b/e107_core/xml/default_install.xml @@ -310,7 +310,6 @@ City, State, Country style.css75 - 0UTC11 diff --git a/e107_handlers/cache_handler.php b/e107_handlers/cache_handler.php index 652cc5090..05c2933c6 100644 --- a/e107_handlers/cache_handler.php +++ b/e107_handlers/cache_handler.php @@ -45,6 +45,12 @@ class ecache { */ public function setMD5($text, $hash=true) { + if($text === null) + { + $this->CachePageMD5 = md5(e_BASE.e_LANGUAGE.THEME.USERCLASS_LIST.defset('e_QUERY').filemtime(THEME.'theme.php')); + return $this; + } + $this->CachePageMD5 = ($hash === true) ? md5($text) : $text; return $this; } diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 99f8f0155..eda234c07 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -1177,7 +1177,7 @@ class comment $ret['comment'] = $text; - + $ret['moderate'] = $modcomment; $ret['comment_form'] = $comment; $ret['caption'] = "".$this->totalComments." ".LAN_COMMENTS; diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 87a09302b..7685f16ab 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -3036,11 +3036,26 @@ class e107 /** * Simple redirect method for developers. - * @param $url string : 'admin' to redirect to admin entry page or leave blank to go to home page (SITEURL) + * + * @param string $url + * 'admin' to redirect to admin entry page or leave blank to go to home page + * (SITEURL). + * @param int $http_response_code + * The HTTP status code to use for the redirection, defaults to 302. + * The valid values for 3xx redirection status codes are defined in RFC 2616 + * and the draft for the new HTTP status codes: + * - 301: Moved Permanently (the recommended value for most redirects). + * - 302: Found (default in PHP, sometimes used for spamming search engines). + * - 303: See Other. + * - 304: Not Modified. + * - 305: Use Proxy. + * - 307: Temporary Redirect. + * @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3 + * @see https://tools.ietf.org/html/draft-reschke-http-status-308-07 */ - public static function redirect($url='') + public static function redirect($url = '', $http_response_code = 302) { - self::getRedirect()->go($url); + self::getRedirect()->go($url, true, $http_response_code); } diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 91fe86888..efefb2ac1 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -4060,7 +4060,7 @@ class e_parser if($type == 'youtube') { // $thumbSrc = "https://i1.ytimg.com/vi/".$id."/0.jpg"; - $thumbSrc = "http://i1.ytimg.com/vi/".$id."/mqdefault.jpg"; + $thumbSrc = "https://i1.ytimg.com/vi/".$id."/mqdefault.jpg"; $video = ''; diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index c6fbf767d..fbb162de7 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -1255,6 +1255,7 @@ class e_file // $text = 'umask 0022'; //Could correct permissions issue with 0664 files. // Change Dir. + $folder = e107::getParser()->filter($folder,'file'); // extra filter to keep RIPS happy. switch($type) { diff --git a/e107_handlers/user_model.php b/e107_handlers/user_model.php index cad0e4f34..b0e9b2b78 100644 --- a/e107_handlers/user_model.php +++ b/e107_handlers/user_model.php @@ -219,6 +219,13 @@ class e_user_model extends e_admin_model return ($this->isAdmin() ? $this->get('user_perms') : false); } + final public function getTimezone() + { + // If timezone is not set, we return an empty string in order to use the + // default timezone is set for e107. + return ($this->get('user_timezone') ? $this->get('user_timezone') : ''); + } + /** * DEPRECATED - will be removed or changed soon (see e_session) * @return string diff --git a/e107_languages/English/lan_error.php b/e107_languages/English/lan_error.php index be471298c..b7e1e5d53 100644 --- a/e107_languages/English/lan_error.php +++ b/e107_languages/English/lan_error.php @@ -10,6 +10,7 @@ +----------------------------------------------------------------------------+ */ define("PAGE_NAME", "Error"); +define("LAN_ERROR_TITLE", "Oops!"); define("LAN_ERROR_1", "Error 401 - Authentication Failed"); define("LAN_ERROR_2", "The URL you've requested requires a correct username and password. Either you entered an incorrect username/password, or your browser doesn't support this feature."); @@ -21,7 +22,7 @@ define("LAN_ERROR_6", "Please inform the administrator of the referring page if define("LAN_ERROR_7", "Error 404 - Document Not Found"); define("LAN_ERROR_9", "Please inform the administrator of the referring page if you think this error message has been shown by mistake."); -define("LAN_ERROR_10", "Error 500 - Malformed Header"); +define("LAN_ERROR_10", "Error 500 - Internal server error"); define("LAN_ERROR_11", "The server encountered an internal error or misconfiguration and was unable to complete your request"); define("LAN_ERROR_12", "Please inform the administrator of the referring page if you think this error page has been shown by mistake."); define("LAN_ERROR_13", "Error - Unknown"); diff --git a/e107_plugins/forum/forum_post.php b/e107_plugins/forum/forum_post.php index 673e2beac..3711c2482 100644 --- a/e107_plugins/forum/forum_post.php +++ b/e107_plugins/forum/forum_post.php @@ -373,20 +373,25 @@ class forum_post_handler global $FORUMPOST, $subjectbox, $userbox, $poll_form, $fileattach, $fileattach_alert; // needed for BC. - $FORUM_POST_TEMPLATE = array(); - $FORUM_POSTED_TEMPLATE = array(); +//-- $FORUM_POST_TEMPLATE = array(); +//-- $FORUM_POSTED_TEMPLATE = array(); $FORUMREPLYPOSTED = ''; $FORUMTHREADPOSTED = ''; $FORUMPOLLPOSTED = ''; - $file = "forum_".$type."_template.php"; +// $file = "forum_".$type."_template.php"; - if($template = e107::getTemplate('forum', 'forum_post')) - { - $FORUM_POST_TEMPLATE = $template; - } - elseif (empty($FORUMPOST) && empty($FORUMREPLYPOSTED) && empty($FORUMTHREADPOSTED)) +// var_dump ($type); +// var_dump (e107::getTemplate('forum', 'forum_'.$type)); + $template = e107::getTemplate('forum', 'forum_'.$type); +//-- if($template = e107::getTemplate('forum', 'forum_'.$type)) +//-- { +//-- $FORUM_POST_TEMPLATE = $template; +//-- } +//-- elseif (empty($FORUMPOST) && empty($FORUMREPLYPOSTED) && empty($FORUMTHREADPOSTED)) + if (empty($template) && empty($FORUMPOST) && empty($FORUMREPLYPOSTED) && empty($FORUMTHREADPOSTED)) { + $file = "forum_".$type."_template.php"; if (is_readable(THEME.$file)) { include_once(THEME.$file); @@ -609,33 +614,29 @@ class forum_post_handler - if($type == 'post') +//-- if($type == 'post' || $type == 'posted') + if($template) { - $template= (deftrue('BOOTSTRAP')) ? $FORUM_POST_TEMPLATE : array('form'=>$FORUMPOST); +//-- $template= (deftrue('BOOTSTRAP')) ? $FORUM_POST_TEMPLATE : array('form'=>$FORUMPOST); + $template= (deftrue('BOOTSTRAP')) ? $template : array('form'=>$FORUMPOST); // print_a($template); return $this->upgradeTemplate($template); } - else - { - if (deftrue('BOOTSTRAP')) //v2.x - { - return $FORUM_POSTED_TEMPLATE; - } - else //v1.x - { +//-- else +//-- { +//-- if (deftrue('BOOTSTRAP')) //v2.x +//-- { +//-- return $FORUM_POSTED_TEMPLATE; +//-- } +//-- else //v1.x +//-- { return array( "reply" => $FORUMREPLYPOSTED, "thread" => $FORUMTHREADPOSTED, "poll" => $FORUMPOLLPOSTED ); - - } - - - } - - - +//-- } +//-- } } diff --git a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php index ceaabd52d..a7974332f 100644 --- a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php @@ -348,7 +348,8 @@ class forum_shortcodes extends e_shortcode if(USER && is_array($this->newFlagList) && in_array($this->var['forum_id'], $this->newFlagList)) { - $url = $this->sc_lastpost('url'); + + $url = $this->sc_lastpost(array('type'=>'url')); return "".IMAGE_new.''; } elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies')) @@ -418,13 +419,13 @@ class forum_shortcodes extends e_shortcode function sc_lastpostuser() { - return $this->sc_lastpost('username'); + return $this->sc_lastpost(array('type'=>'username')); } function sc_lastpostdate() { - return $this->sc_lastpost('datelink'); + return $this->sc_lastpost(array('type'=>'datelink')); } diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 9cfe9f6ab..79ed864e3 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -797,13 +797,15 @@ function sc_buttonsx() { global $forum, $thread; - if ($forum->checkPerm($this->var['thread_forum_id'], 'post') && $this->var['thread_active']) { $url = e107::url('forum','post')."?f=rp&id=".$this->var['thread_id']."&post=".$thread->threadId; // $url = e107::getUrl()->create('forum/thread/reply', array('id' => $thread->threadId)); - $replyUrl = "".LAN_FORUM_2006.""; } + $replyUrl = "".LAN_FORUM_2006.""; + if ($forum->checkPerm($this->var['thread_forum_id'], 'post')) { $ntUrl = e107::url('forum','post')."?f=nt&id=". $this->var['thread_forum_id']; @@ -828,10 +830,21 @@ function sc_buttonsx() } +/* +$text = '
+ '.($replyUrl?:"").' + +
+ + + +
+
{ARCHIVE_BULLET} {ARCHIVE_LINK} {ARCHIVE_AUTHOR} @ ({ARCHIVE_DATESTAMP}) ({ARCHIVE_CATEGORY})
+
+
"; + } + + $textnewsarchive .= $tp->parseTemplate($NEWSARCHIVE, FALSE, $news_archive_shortcodes); + $i++; + } + + $newsarchive = $ns->tablerender($this->pref['newsposts_archive_title'], $textnewsarchive, 'news_archive', true); + + $this->setNewsCache('newsarchive', $newsarchive); + + return $newsarchive; + } + + + private function setNewsFrontMeta($news, $type='news') + { + + $tp = e107::getParser(); + + if($type == 'news') + { + if($news['news_title'] && !defined('e_PAGETITLE')) + { + define('e_PAGETITLE', $news['news_title']); + e107::meta('og:title',$news['news_title']); + e107::meta('og:type','article'); + } + + if($news['news_meta_description'] && !defined('META_DESCRIPTION')) + { + e107::meta('description',$news['news_meta_description']); + e107::meta('og:description',$news['news_meta_description']); + //define('META_DESCRIPTION', $news['news_meta_description']); // deprecated + } + elseif($news['news_summary']) // BC compatibility + { + e107::meta('og:description',$news['news_summary']); + } + + // include news-thumbnail/image in meta. - always put this one first. + if($news['news_thumbnail']) + { + $iurl = (substr($news['news_thumbnail'],0,3)=="{e_") ? $news['news_thumbnail'] : SITEURL.e_IMAGE."newspost_images/".$news['news_thumbnail']; + $tmp = explode(",", $iurl); + foreach($tmp as $mimg) + { + if(substr($mimg,-8) == '.youtube') + { + continue; + } + e107::meta('og:image',$tp->thumbUrl($tmp[0],'w=500',false,true) ); + // e107::meta('og:image',$mimg); + } + + } + + // grab all images in news-body and add to meta. + $images = e107::getBB()->getContent('img',$news['news_body'],SITEURL.e_IMAGE."newspost_images/"); + $c =1; + foreach($images as $im) + { + if($c == 4){ break; } + e107::meta('og:image',$im); + $c++; + } + + // grab all youtube videos in news-body and add thumbnails to meta. + $youtube = e107::getBB()->getContent('youtube',$news['news_body']); + $c = 1; + foreach($youtube as $yt) + { + if($c == 3){ break; } + list($img,$tmp) = explode("?",$yt); + e107::meta('og:image',"http://img.youtube.com/vi/".$img."/0.jpg"); + $c++; + } + + + + $url = e107::getUrl()->create('news/view/item', $news,'full=1'); + e107::meta('og:url',$url); + + e107::meta('article:section',$news['category_name']); + + if($news['news_meta_keywords'] && !defined('META_KEYWORDS')) + { + e107::meta('keywords',$news['news_meta_keywords']); + $tmp = explode(",",$news['news_meta_keywords']); + foreach($tmp as $t) + { + e107::meta('article:tag', trim($t)); + } + + // define('META_KEYWORDS', $news['news_meta_keywords']); // deprecated + } + + + /* Facebook reference. + * http://developers.facebook.com/docs/opengraph/objects/builtin/ + */ + + return; + } + + + + if($news['category_name'] && !defined('e_PAGETITLE') && $type == 'category') + { + define('e_PAGETITLE', $tp->toHtml($news['category_name'],false,'TITLE_PLAIN')); + } + + if($news['category_meta_keywords'] && !defined('META_KEYWORDS')) + { + define('META_KEYWORDS', $news['category_meta_keywords']); + } + + if($news['category_meta_description'] && !defined('META_DESCRIPTION')) + { + define('META_DESCRIPTION', $news['category_meta_description']); + } + + + + } + + + + private function setNewsCache($cache_tag, $cache_data, $rowData=array()) + { + $e107cache = e107::getCache(); + $e107cache->setMD5(null,true); + + $e107cache->set($cache_tag, $cache_data); + $e107cache->set($cache_tag."_title", defined("e_PAGETITLE") ? e_PAGETITLE : ''); + $e107cache->set($cache_tag."_diz", defined("META_DESCRIPTION") ? META_DESCRIPTION : ''); + + $e107cache->set($cache_tag."_rows", e107::serialize($rowData,'json')); + + } + + + /** + * @param $cache_tag + * @param string $type 'title' or 'diz' or 'rows' or empty for html. + */ + private function getNewsCache($cachetag, $type=null) + { + if(!empty($type)) + { + $cachetag .= "_".$type; + } + $this->addDebug('CaheString lookup', $cachetag); + e107::getDebug()->log('Retrieving cache string:' . $cachetag); + + $ret = e107::getCache()->setMD5(null)->retrieve($cachetag); + + if($type == 'rows') + { + return e107::unserialize($ret); + } + + return $ret; + } + + /** + * @param $cacheString + * @return bool|string + */ + private function checkCache($cacheString) + { + $e107cache = e107::getCache(); + $this->addDebug("checkCache", 'true'); + $e107cache->setMD5(null); + + $cache_data = $e107cache->retrieve($cacheString); + $cache_title = $e107cache->retrieve($cacheString."_title"); + $cache_diz = $e107cache->retrieve($cacheString."_diz"); + $etitle = ($cache_title != "e_PAGETITLE") ? $cache_title : ""; + $ediz = ($cache_diz != "META_DESCRIPTION") ? $cache_diz : ""; + + if($etitle) + { + define('e_PAGETITLE', $etitle); + } + + if($ediz) + { + define("META_DESCRIPTION",$ediz); + } + + if ($cache_data) + { + return $cache_data; + } + else + { + return false; + } + } + + + private function renderCache($cache, $nfp = FALSE) + { + global $pref,$tp,$sql,$CUSTOMFOOTER, $FOOTER,$cust_footer,$ph; + global $db_debug,$ns,$eTimingStart, $error_handler, $db_time, $sql2, $mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb,$e107; + + return $cache; + + /*if (isset($nfp) && isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 2) + { + require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php"); + } + // render_newscats(); //fixme this shouldn't be here. + return $cache;*/ + } + + + private function render_newscats() // -- CNN Style Categories. ---- + { + $tp = e107::getParser(); + $ns = e107::getRender(); + + if (isset($this->pref['news_cats']) && $this->pref['news_cats'] == '1') + { + $text3 = $tp->toHTML("{NEWS_CATEGORIES}", TRUE, 'TITLE'); + return $ns->tablerender(LAN_NEWS_23, $text3, 'news_cat', true); + } + } + + + + private function renderListTemplate() + { + $this->addDebug("Method",'renderListTemplate()'); + $sql = e107::getDb(); + $tp = e107::getParser(); + + global $NEWSLISTSTYLE, $NEWSLISTTITLE; + + + if($newsCachedPage = checkCache($this->cacheString)) + { + return $this->renderCache($newsCachedPage, TRUE); + } + + $category = intval($this->subAction); + if ($this->action == 'cat' && $category != 0) + { + + $gen = new convert; + $sql->select("news_category", "*", "category_id='{$category}'"); + $row = $sql->fetch(); + extract($row); // still required for the table-render. :( + } + + if ($this->action == 'all') // show archive of all news items using list-style template. + { + $renTypeQry = ''; + + if(!empty($this->pref['news_list_templates']) && is_array($this->pref['news_list_templates'])) + { + $renTypeQry = " AND (n.news_render_type REGEXP '(^|,)(".implode("|", $this->pref['news_list_templates']).")(,|$)')"; + } + + // $news_total = $sql->count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")". str_replace("n.news", "news", $renTypeQry)); + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, + nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") AND n.news_start < ".time()." + AND (n.news_end=0 || n.news_end>".time().") "; + + $query .= $renTypeQry; + + $query .= " + ORDER BY n.news_sticky DESC, n.news_datestamp DESC + LIMIT ".intval($this->from).",".deftrue('NEWSALL_LIMIT', NEWSLIST_LIMIT); // NEWSALL_LIMIT just for BC. NEWSLIST_LIMIT is sufficient. + $category_name = ($this->defaultTemplate == 'list') ? PAGE_NAME : "All"; + unset($renTypeQry); + } + elseif ($this->action == 'cat') // show archive of all news items in a particular category using list-style template. + { + + // $news_total = $sql->count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_category=".intval($sub_action)); + + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, + nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_category=".intval($this->subAction)." + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + ORDER BY n.news_datestamp DESC + LIMIT ".intval($this->from).",".NEWSLIST_LIMIT; + } + elseif(vartrue($_GET['tag'])) + { + $tagsearch = e107::getParser()->filter($_GET['tag']); + + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, + nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_meta_keywords LIKE '%".$tagsearch."%' + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + ORDER BY n.news_datestamp DESC + LIMIT ".intval($this->from).",".NEWSLIST_LIMIT; + $category_name = 'Tag: "'.$tagsearch.'"'; + + } + elseif(!empty($_GET['author'])) + { + $authorSearch = e107::getParser()->filter($_GET['author']); + + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, + nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE u.user_name = '".$authorSearch."' + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + ORDER BY n.news_datestamp DESC + LIMIT ".intval($this->from).",".NEWSLIST_LIMIT; + $category_name = 'Author: "'.$authorSearch.'"'; + + + + } + + $newsList = array(); + + if(!empty($query) && $sql->gen($query)) + { + $news_total = $sql->foundRows(); + $newsList = $sql->db_getList(); + $ogImageCount = 0; + foreach($newsList as $row) + { + if(!empty($row['news_thumbnail'])) + { + $iurl = (substr($row['news_thumbnail'],0,3)=="{e_") ? $row['news_thumbnail'] : SITEURL.e_IMAGE."newspost_images/".$row['news_thumbnail']; + $tmp = explode(",", $iurl); + + if($tp->isImage($tmp[0])) + { + if($ogImageCount > 6) + { + break; + } + + e107::meta('og:image',$tp->thumbUrl($tmp[0],'w=500',false,true) ); + $ogImageCount++; + + } + } + + } + } + + + if($this->action == 'cat') + { + $this->setNewsFrontMeta($newsList[1], 'category'); + } + // elseif($category_name) + // { + // define('e_PAGETITLE', $tp->toHTML($category_name,FALSE,'TITLE')); + // } + e107::getDebug()->log("PageTitle: ".e_PAGETITLE); + $currentNewsAction = $this->action; + + $action = $currentNewsAction; + + if(deftrue('BOOTSTRAP')) // v2.x + { + $template = e107::getTemplate('news', 'news', 'list'); + } + else // v1.x + { + if(empty($NEWSLISTSTYLE)) + { + $NEWSLISTSTYLE = " +
+ + +
+ {NEWS_CATEGORY_ICON} + + {NEWSTITLELINK=extend} +
+ {NEWS_SUMMARY} + + {NEWS_DATE} + {NEWSCOMMENTS} + +
+ {SETIMAGE: w=55&h=55&crop=1} + {NEWSTHUMBNAIL} +
+
\n"; + } + + $template = array('start'=>'', 'item'=>$NEWSLISTSTYLE, 'end'=>''); + + } + + // Legacy Styling.. + $param = array(); + $param['itemlink'] = (defined("NEWSLIST_ITEMLINK")) ? NEWSLIST_ITEMLINK : ""; + $param['thumbnail'] =(defined("NEWSLIST_THUMB")) ? NEWSLIST_THUMB : "border:0px"; + $param['catlink'] = (defined("NEWSLIST_CATLINK")) ? NEWSLIST_CATLINK : ""; + $param['caticon'] = (defined("NEWSLIST_CATICON")) ? NEWSLIST_CATICON : defset('ICONSTYLE',''); + $param['current_action'] = $action; + $param['template_key'] = 'list'; + + // NEW - allow news batch shortcode override (e.g. e107::getScBatch('news', 'myplugin', true); ) + e107::getEvent()->trigger('news_list_parse', $newsList); + + $text = ''; + + if(vartrue($template['start'])) + { + $text .= $tp->parseTemplate($template['start'], true); + } + + if(!empty($newsList)) + { + foreach($newsList as $row) + { + $text .= $this->ix->render_newsitem($row, 'return', '', $template['item'], $param); + } + } + else // No News - empty. + { + $text .= "
".(strstr(e_QUERY, "month") ? LAN_NEWS_462 : LAN_NEWS_83)."
"; + } + + if(vartrue($template['end'])) + { + $text .= $tp->parseTemplate($template['end'], true); + } + + $icon = ($row['category_icon']) ? "" : ""; + + // Deprecated. + // $parms = $news_total.",".$amount.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action={$action}&subaction={$category}"); + // $parms = $news_total.",".$amount.",".$newsfrom.",".e_SELF.'?'.$action.".".$category.".[FROM]"; + // + // $text .= "
".$tp->parseTemplate("{NEXTPREV={$parms}}")."
"; + + $amount = NEWSLIST_LIMIT; + $nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ; + $url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms)); + $parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url; + + + // e107::getDebug()->log($newsUrlparms); + + $text .= $tp->parseTemplate("{NEXTPREV={$parms}}"); + + if(varset($template['caption'])) // v2.x + { + $NEWSLISTTITLE = str_replace("{NEWSCATEGORY}",$tp->toHTML($category_name,FALSE,'TITLE'), $template['caption']); + } + elseif(empty($NEWSLISTTITLE)) // default + { + $NEWSLISTTITLE = LAN_NEWS_82." '".$tp->toHTML($category_name,FALSE,'TITLE')."'"; + } + else // v1.x + { + $NEWSLISTTITLE = str_replace("{NEWSCATEGORY}",$tp->toHTML($category_name,FALSE,'TITLE'),$NEWSLISTTITLE); + } + + if($this->defaultTemplate != 'list') + { + $text .= "
"; + } + + + $cache_data = e107::getRender()->tablerender($NEWSLISTTITLE, $text, 'news', true); + + $this->setNewsCache($this->cacheString, $cache_data); + + + return $cache_data; + + + + + } + + + private function renderViewTemplate() + { + $this->addDebug("Method",'renderViewTemplate()'); + + if($newsCachedPage = $this->checkCache($this->cacheString)) + { + $this->addDebug("Cache",'active'); + $rows = $this->getNewsCache($this->cacheString,'rows'); + e107::getEvent()->trigger('user_news_item_viewed', $rows); + $this->addDebug("Event-triggered:user_news_item_viewed", $rows); + $text = $this->renderCache($newsCachedPage, TRUE); // This exits if cache used + $text .= $this->renderComments($rows); + return $text; + } + else + { + $this->addDebug("Cache",'inactive'); + } + + $sql = e107::getDb(); + // <-- Cache + + if(isset($this->pref['trackbackEnabled']) && $this->pref['trackbackEnabled']) + { + $query = " + SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, + nc.category_icon, nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id + WHERE n.news_id=".intval($this->subAction)." AND n.news_class REGEXP '".e_CLASS_REGEXP."' + AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + GROUP by n.news_id"; + } + else + { + $query = " + SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, + nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' + AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." + AND (n.news_end=0 || n.news_end>".time().") + AND n.news_id=".intval($this->subAction); + } + + + if ($sql->gen($query)) + { + $news = $sql->fetch(); + $id = $news['news_category']; // Use category of this news item to generate next/prev links + + e107::getEvent()->trigger('user_news_item_viewed', $news); + $this->addDebug("Event-triggered:user_news_item_viewed", $news); + + //***NEW [SecretR] - comments handled inside now + e107::setRegistry('news/page_allow_comments', !$news['news_allow_comments']); + if(!$news['news_allow_comments'] && isset($_POST['commentsubmit'])) + { + $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies) + + $clean_authorname = $_POST['author_name']; + $clean_comment = $_POST['comment']; + $clean_subject = $_POST['subject']; + + e107::getSingleton('comment')->enter_comment($clean_authorname, $clean_comment, 'news', $this->subAction, $pid, $clean_subject); + } + + //More SEO + $this->setNewsFrontMeta($news); + /* + if($news['news_title']) + { + if($this->pref['meta_news_summary'] && $news['news_title']) + { + define("META_DESCRIPTION",SITENAME.": ".$news['news_title']." - ".$news['news_summary']); + } + define("e_PAGETITLE",$news['news_title']); + }*/ + /* FIXME - better implementation: cache, shortcodes, do it inside the model/shortcode class itself. + if (TRUE) + { + // Added by nlStart - show links to previous and next news + if (!isset($news['news_extended'])) $news['news_extended'] = ''; + $news['news_extended'].="
".LAN_NEWS_85."   ".LAN_NEWS_84."
"; + $prev_query = "SELECT news_id, news_title FROM `#news` + WHERE `news_id` < ".intval($sub_action)." AND `news_category`=".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."' + AND NOT (`news_class` REGEXP ".$nobody_regexp.") + AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` DESC LIMIT 1'; + $sql->db_Select_gen($prev_query); + $prev_news = $sql->db_Fetch(); + if ($prev_news) + { + $news['news_extended'].="
".LAN_NEWS_86."
"; + } + $next_query = "SELECT news_id, news_title FROM `#news` AS n + WHERE `news_id` > ".intval($sub_action)." AND `news_category` = ".$id." AND `news_class` REGEXP '".e_CLASS_REGEXP."' + AND NOT (`news_class` REGEXP ".$nobody_regexp.") + AND `news_start` < ".time()." AND (`news_end`=0 || `news_end` > ".time().') ORDER BY `news_id` ASC LIMIT 1'; + $sql->db_Select_gen($next_query); + $next_news = $sql->db_Fetch(); + if ($next_news) + { + $news['news_extended'].="
".LAN_NEWS_87."
"; + } + $news['news_extended'].="

"; + }*/ + + $currentNewsAction = $this->action; + + $action = $currentNewsAction; + + $param = array(); + $param['current_action'] = $action; + $param['template_key'] = 'view'; + + if(vartrue($NEWSSTYLE)) + { + $template = $NEWSSTYLE; + } + elseif(function_exists("news_style")) // BC + { + $template = news_style($news, 'extend', $param); + } + else + { + $tmp = e107::getTemplate('news', 'news', 'view'); + $template = $tmp['item']; + unset($tmp); + } + + ob_start(); + $this->ix->render_newsitem($news, 'extend', '', $template, $param); + $cache_data = ob_get_contents(); + ob_end_clean(); + + $this->setNewsCache($this->cacheString, $cache_data, $news); + + $text = $cache_data; + $text .= $this->renderComments($news); + + return $text; + } + else + { + // $action = 'default'; + + //XXX item not found, redirect to avoid messing up search-engine data. + // e107::getRedirect()->go(null, true, 404); + header("HTTP/1.0 404 Not Found",true,404); + require_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_error.php"); + $text = e107::getMessage()->setTitle(LAN_ERROR_7, E_MESSAGE_INFO)->addInfo("Perhaps you're looking for one of the news items below?")->render(); + + $this->action = 'all'; + // $defaultUrl = e107::getUrl()->create('news/list/items'); + $text .= $this->renderListTemplate(); + + + return $text; + + } + + + } + + + private function renderComments($news) + { + $this->addDebug("Calling", "renderComments()"); + + // if(e107::getRegistry('news/page_allow_comments')) + if(isset($news['news_allow_comments']) && empty($news['news_allow_comments'])) // ie. comments active + { + global $comment_edit_query; //FIXME - kill me + $comment_edit_query = 'comment.news.'.$news['news_id']; + $comments = e107::getComment()->compose_comment('news', 'comment', $news['news_id'], null, $news['news_title'], false, true); + + + if(!empty($comments)) + { + $text = $comments['comment_form'] . $comments['comment'] .$comments['moderate']; + return e107::getRender()->tablerender($comments['caption'], $text,'comment', true); + } + + } + + $this->addDebug("Failed", "renderComments()"); + + return ''; + } + + + private function renderDefaultTemplate() + { + $this->addDebug("Method",'renderDefaultTemplate()'); + $tp = e107::getParser(); + $sql = e107::getDb(); + + if (empty($this->order)) + { + $order = 'news_datestamp'; + } + $order = $tp -> toDB($this->order, true); /// @todo - try not to use toDB() - triggers prefilter + + $interval = $this->pref['newsposts']; + + global $NEWSSTYLE; + + switch ($this->action) + { + case "list" : + $sub_action = intval($this->subAction); + // $news_total = $sql->db_Count("news", "(*)", "WHERE news_category={$sub_action} AND news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().")"); + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, + nc.category_icon, nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND n.news_category={$sub_action} + ORDER BY n.news_sticky DESC,".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW; + + $noNewsMessage = LAN_NEWS_463; + break; + + + case "item" : + $sub_action = intval($this->subAction); + $news_total = 1; + if(isset($this->pref['trackbackEnabled']) && $this->pref['trackbackEnabled']) + { + $query = " + SELECT COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, + nc.category_icon, nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id + WHERE n.news_id=".$this->subAction." AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + GROUP by n.news_id"; + } + else + { + $query = " + SELECT n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, + nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_id=".$this->subAction." AND n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().")"; + } + + $noNewsMessage = LAN_NEWS_83; + break; + + + case "month" : + case "day" : + $item = $tp -> toDB($this->subAction).'20000101'; + $year = substr($item, 0, 4); + $month = substr($item, 4,2); + + + + if ($this->action == 'day') + { + $day = substr($item, 6, 2); + $lastday = $day; + $startdate = mktime(0, 0, 0, $month, $day, $year); + } + else + { // A month's worth + $day = 1; + $startdate = mktime(0, 0, 0, $month, $day, $year); + $lastday = date("t", $startdate); + } + + + $enddate = mktime(23, 59, 59, $month, $lastday, $year); + + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, + nc.category_icon, nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) AND n.news_datestamp BETWEEN {$startdate} AND {$enddate} + ORDER BY ".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW; + + $noNewsMessage = LAN_NEWS_462; + + break; + + case 'default' : + default : + //$action = ''; + $this->cacheString = 'news.php_default_'; // Make sure its sensible + // $news_total = $sql->db_Count("news", "(*)", "WHERE news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (news_class REGEXP ".$nobody_regexp.") AND news_start < ".time()." AND (news_end=0 || news_end>".time().") AND news_render_type<2" ); + + if(!isset($this->pref['newsposts_archive'])) + { + $this->pref['newsposts_archive'] = 0; + } + $interval = $this->pref['newsposts']-$this->pref['newsposts_archive']; // Number of 'full' posts to show + + // Get number of news item to show + if(isset($this->pref['trackbackEnabled']) && $this->pref['trackbackEnabled']) { + $query = " + SELECT SQL_CALC_FOUND_ROWS COUNT(tb.trackback_pid) AS tb_count, n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, + nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, nc.category_meta_description, + COUNT(*) AS tbcount + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + LEFT JOIN #trackback AS tb ON tb.trackback_pid = n.news_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) + GROUP by n.news_id + ORDER BY news_sticky DESC, ".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW; + } + else + { + $query = " + SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, + nc.category_meta_keywords, nc.category_meta_description + FROM #news AS n + LEFT JOIN #user AS u ON n.news_author = u.user_id + LEFT JOIN #news_category AS nc ON n.news_category = nc.category_id + WHERE n.news_class REGEXP '".e_CLASS_REGEXP."' AND NOT (n.news_class REGEXP ".$this->nobody_regexp.") + AND n.news_start < ".time()." AND (n.news_end=0 || n.news_end>".time().") + AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) + ORDER BY n.news_sticky DESC, ".$order." DESC LIMIT ".intval($this->from).",".ITEMVIEW; + } + + $noNewsMessage = LAN_NEWS_83; + } // END - switch($action) + + + if($newsCachedPage = $this->checkCache($this->cacheString)) // normal news front-page - with cache. + { + + + if(!$this->action) + { + // Removed, themes should use {FEATUREBOX} shortcode instead + // if (isset($this->pref['fb_active'])) + // { + // require_once(e_PLUGIN."featurebox/featurebox.php"); + // } + // Removed, legacy + // if (isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 1) + // { + // require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php"); + // } + + } + + //news archive + if ($this->action != "item" && $this->action != 'list' && $this->pref['newsposts_archive']) + { + $sql = e107::getDb(); + + if ($sql->gen($query)) + { + $newsAr = $sql -> db_getList(); + + if($newsarchive = $this->checkCache('newsarchive')) + { + $newsCachedPage = $newsCachedPage.$newsarchive; + } + else + { + $this->show_newsarchive($newsAr,$interval); + } + } + } + $this->renderCache($newsCachedPage, TRUE); + } + + + if (!($news_total = $sql->gen($query))) + { // No news items + + return "
".$noNewsMessage."
"; + + } + + $newsAr = $sql -> db_getList(); + $news_total=$sql->total_results; + // Get number of entries + //$sql -> db_Select_gen("SELECT FOUND_ROWS()"); + // $frows = $sql -> db_Fetch(); + //$news_total = $frows[0]; + + //echo "
Total ".$news_total." items found, ".count($newsAr)." displayed, Interval = {$interval}

"; + + $p_title = ($this->action == "item") ? $newsAr[1]['news_title'] : $tp->toHTML($newsAr[1]['category_name'],FALSE,'TITLE'); + + switch($this->action) + { + case 'item': + $this->setNewsFrontMeta($newsAr[1]); + break; + + case 'list': + default: + $this->setNewsFrontMeta($newsAr[1], 'list'); + break; + } + + /*if($action != "" && !is_numeric($action)) + { + if($action == "item" && $this->pref['meta_news_summary'] && $newsAr[1]['news_title']) + { + define("META_DESCRIPTION",SITENAME.": ".$newsAr[1]['news_title']." - ".$newsAr[1]['news_summary']); + } + define("e_PAGETITLE", $p_title); + }*/ + + $currentNewsAction = $this->action; + + $action = $currentNewsAction; + + if(!$action) + { + // Removed, themes should use {FEATUREBOX} shortcode instead + // if (isset($this->pref['fb_active'])){ // --->feature box + // require_once(e_PLUGIN."featurebox/featurebox.php"); + // } + + // Removed, legacy + // if (isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 1){ + // require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php"); + // } + } + + if(isset($this->pref['news_unstemplate']) && $this->pref['news_unstemplate'] && file_exists(THEME."news_template.php")) + { + // theme specific template required ... + + $ALTERNATECLASSES = null; + $NEWSCLAYOUT = null; + + require_once(THEME."news_template.php"); + + if(empty($ALTERNATECLASS1)) + { + return TRUE; + } + + $newscolumns = (isset($NEWSCOLUMNS) ? $NEWSCOLUMNS : 1); + $newspercolumn = (isset($NEWSITEMSPERCOLUMN) ? $NEWSITEMSPERCOLUMN : 10); + $newsdata = array(); + $loop = 1; + $param = array(); + $param['current_action'] = $action; + foreach($newsAr as $news) { + + if(is_array($ALTERNATECLASSES)) + { + $newsdata[$loop] .= "
".$this->ix->render_newsitem($news, "return", '', '', $param)."
"; + $ALTERNATECLASSES = array_reverse($ALTERNATECLASSES); + } + else + { + $newsdata[$loop] .= $this->ix->render_newsitem($news, 'return', '', '', $param); + } + $loop ++; + if($loop > $newscolumns) { + $loop = 1; + } + } + $loop = 1; + foreach($newsdata as $data) { + $var = "ITEMS{$loop}"; + $$var = $data; + $loop ++; + } + $text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSCLAYOUT); + + + // Deprecated + // $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".$e107->url->getUrl('core:news', 'main', "action=nextprev&to_action=".($action ? $action : 'default' )."&subaction=".($sub_action ? $sub_action : "0")); + + // $sub_action = intval($sub_action); + // $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]"; + + $amount = ITEMVIEW; + $nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ; + $url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms)); + $parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url; + + $text .= $tp->parseTemplate("{NEXTPREV={$parms}}"); + + // $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); + // $text .= ($nextprev ? "
".$nextprev."
" : ""); + // $text=''.$text.'
'.$nextprev.'
'; + + echo $text; + $this->setNewsCache($this->cacheString, $text); + } + else + { + ob_start(); + + $newpostday = 0; + $thispostday = 0; + $this->pref['newsHeaderDate'] = 1; + $gen = new convert(); + /* + if(vartrue($NEWSLISTSTYLE)) $template = $NEWSLISTSTYLE; v1.x doesn't do this.. so no point doing it here. + else + { + $tmp = e107::getTemplate('news', 'news', 'list'); + $template = $tmp['item']; + unset($tmp); + } + */ + if (!defined("DATEHEADERCLASS")) { + define("DATEHEADERCLASS", "nextprev"); + // if not defined in the theme, default class nextprev will be used for new date header + } + + // #### normal newsitems, rendered via render_newsitem(), the $query is changed above (no other changes made) --------- + $param = array(); + $param['current_action'] = $action; + $param['template_key'] = 'default'; + + // Get Correct Template + // XXX we use $NEWSLISTSTYLE above - correct as we are currently in list mode - XXX No this is not NEWSLISTSTYLE - which provides only summaries. + // TODO requires BC testing if we comment this one + if(vartrue($NEWSSTYLE)) + { + $template = $NEWSSTYLE; + } + else + { + $tmp = e107::getTemplate('news', 'news', 'default'); // default - we show the full items, except for the 'extended' part.. + $template = $tmp['item']; + unset($tmp); + } + + + + // NEW - news category title when in list + if($sub_action && 'list' == $action && vartrue($newsAr[1]['category_name'])) + { + // we know category name - pass it to the nexprev url + $category_name = $newsAr[1]['category_name']; + if(vartrue($newsAr[1]['category_sef'])) $newsUrlparms['name'] = $newsAr[1]['category_sef']; + if(!isset($NEWSLISTCATTITLE)) + { + $NEWSLISTCATTITLE = "

".$tp->toHTML($category_name,FALSE,'TITLE')."

"; + } + else + { + $NEWSLISTCATTITLE = str_replace("{NEWSCATEGORY}",$tp->toHTML($category_name,FALSE,'TITLE'),$NEWSLISTCATTITLE); + } + echo $NEWSLISTCATTITLE; + } + + $i= 1; + + $socialInstalled = e107::isInstalled('social'); + + while(isset($newsAr[$i]) && $i <= $interval) + { + $news = $newsAr[$i]; + + // Set the Values for the social shortcode usage. + if($socialInstalled == true) + { + $socialArray = array('url'=>e107::getUrl()->create('news/view/item', $news, 'full=1'), 'title'=>$tp->toText($news['news_title']), 'tags'=>$news['news_meta_keywords']); + $socialObj = e107::getScBatch('social'); + + if(is_object($socialObj)) + { + $socialObj->setVars($socialArray); + } + } + + if(function_exists("news_style")) // BC + { + $template = news_style($news, $action, $param); + } + + + // render new date header if pref selected ... + $thispostday = strftime("%j", $news['news_datestamp']); + if ($newpostday != $thispostday && (isset($this->pref['news_newdateheader']) && $this->pref['news_newdateheader'])) + { + echo "
".strftime("%A %d %B %Y", $news['news_datestamp'])."
"; + } + $newpostday = $thispostday; + $news['category_id'] = $news['news_category']; + if ($action == "item") + { + unset($news['news_render_type']); + e107::getEvent()->trigger('user_news_item_viewed', $news); + //e107::getDebug()->log($news); + } + // $template = false; + $this->ix->render_newsitem($news, 'default', '', $template, $param); + + + $i++; + } + + $amount = ITEMVIEW; + $nitems = defined('NEWS_NEXTPREV_NAVCOUNT') ? '&navcount='.NEWS_NEXTPREV_NAVCOUNT : '' ; + $url = rawurlencode(e107::getUrl()->create($this->route, $this->newsUrlparms)); + // Example of passing route data instead building the URL outside the shortcode - for a reference only + // $url = rawurlencode('url::'.$newsRoute.'::'.http_build_query($newsUrlparms, null, '&')); + $parms = 'tmpl_prefix='.deftrue('NEWS_NEXTPREV_TMPL', 'default').'&total='.$news_total.'&amount='.$amount.'¤t='.$this->from.$nitems.'&url='.$url; + + echo $tp->parseTemplate("{NEXTPREV={$parms}}"); + + // $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'.($action ? $action : 'default' ).($sub_action ? ".".$sub_action : ".0").".[FROM]"; + // $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); + // echo ($nextprev ? "
".$nextprev."
" : ""); + + $cache_data = ob_get_clean(); + + $this->setNewsCache($this->cacheString, $cache_data); + + return $cache_data; + } + + } +} + +$newsObj = new news_front; +require_once(HEADERF); +$newsObj->render(); +if(E107_DBG_BASIC) +{ + $newsObj->debug(); +} +require_once(FOOTERF); +exit; + + + + +//require_once(e_HANDLER."comment_class.php"); +//$cobj = new comment; + + + +//------------------------------------------------------ +// DISPLAY NEWS IN 'CATEGORY' LIST FORMAT HERE +//------------------------------------------------------ +// Just title and a few other details + + + + + +//------------------------------------------------------ +// DISPLAY SINGLE ITEM IN EXTENDED FORMAT HERE +//------------------------------------------------------ + + + +//------------------------------------------------------ +// DISPLAY NEWS IN LIST FORMAT HERE +//------------------------------------------------------ +// Show title, author, first part of news item... + + +// ##### -------------------------------------------------------------------------------------------------------------- + + +// #### new: news archive --------------------------------------------------------------------------------------------- + +// #### END ----------------------------------------------------------------------------------------------------------- + +if ($action != "item") { + if (is_numeric($action)){ + $action = ""; + } + // $parms = $news_total.",".ITEMVIEW.",".$newsfrom.",".e_SELF.'?'."[FROM].".$action.(isset($sub_action) ? ".".$sub_action : ""); + // $nextprev = $tp->parseTemplate("{NEXTPREV={$parms}}"); + // echo ($nextprev ? "
".$nextprev."
" : ""); +} + +if(is_dir("remotefile")) { + require_once(e_HANDLER."file_class.php"); + $file = new e_file; + // $reject = array('$.','$..','/','CVS','thumbs.db','*._$', 'index', 'null*', 'Readme.txt'); + // $crem = $file -> get_files(e_BASE."remotefile", "", $reject); + $crem = $file -> get_files(e_BASE."remotefile", '~Readme\.txt'); + if(count($crem)) { + foreach($crem as $loadrem) { + if(strstr($loadrem['fname'], "load_")) { + require_once(e_BASE."remotefile/".$loadrem['fname']); + } + } + } +} + +if (isset($this->pref['nfp_display']) && $this->pref['nfp_display'] == 2 && is_readable(e_PLUGIN."newforumposts_main/newforumposts_main.php")) +{ + require_once(e_PLUGIN."newforumposts_main/newforumposts_main.php"); +} + +render_newscats(); + +require_once(FOOTERF); + + +// ========================================================================= + + +?> diff --git a/e107_plugins/rss_menu/rss.php b/e107_plugins/rss_menu/rss.php index 3175f1881..1c1f13e69 100644 --- a/e107_plugins/rss_menu/rss.php +++ b/e107_plugins/rss_menu/rss.php @@ -110,6 +110,8 @@ if (empty($rss_type)) } +while (@ob_end_clean()); + // Returning feeds here // Conversion table for old urls ------- $conversion[1] = 'news'; @@ -199,7 +201,6 @@ class rssCreate $sql_rs = new db; global $rssgen; $sql = e107::getDb(); - $pref = e107::getPref(); $tp = e107::getParser(); $this->e107 = e107::getInstance(); @@ -207,7 +208,6 @@ class rssCreate $this -> path = e_PLUGIN."rss_menu/"; $this -> rssType = $rss_type; $this -> topicid = $topic_id; - $this -> offset = $pref['time_offset'] * 3600; $this -> limit = $row['rss_limit']; $this -> contentType = $row['rss_name']; @@ -422,7 +422,7 @@ class rssCreate ".$tp->toRss($rss_title)." ".$pref['siteurl']." ".$tp->toRss($pref['sitedescription'])." - ".$itemdate = date("r", ($time + $this -> offset))." + ".$itemdate = date("r", ($time))." http://backend.userland.com/rss092\n"; foreach($this -> rssItems as $value) @@ -473,8 +473,8 @@ class rssCreate ".$tp->toRss(SITEDISCLAIMER)." ".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].") ".$this->nospam($pref['siteadminemail'])." (".$pref['siteadmin'].") - ".date("r",($time + $this -> offset))." - ".date("r",($time + $this -> offset))." + ".date("r",($time))." + ".date("r",($time))." http://backend.userland.com/rss e107 (http://e107.org) hourly @@ -549,7 +549,7 @@ class rssCreate echo "\n"; } - echo "".date("r", ($value['pubdate'] + $this -> offset))."\n"; + echo "".date("r", ($value['pubdate']))."\n"; if($link) { @@ -596,7 +596,7 @@ class rssCreate ".$pref['siteurl']." ".$tp->toRss($pref['sitedescription'])." ".CORE_LC.(defined("CORE_LC2") ? "-".CORE_LC2 : "")." - ".$this->get_iso_8601_date($time + $this -> offset). " + ".$this->get_iso_8601_date($time). " ".$this->nospam($pref['siteadminemail'])." nospam($pref['siteadminemail'])."\" /> @@ -629,7 +629,7 @@ class rssCreate ".$tp->toRss($value['title'])." ".$link." - ".$this->get_iso_8601_date($time + $this -> offset)." + ".$this->get_iso_8601_date($time)." ".$value['author']." ".$tp->toRss($value['category_name'])." ".$tp->toRss($value['description']). " @@ -653,7 +653,7 @@ class rssCreate echo " ".$pref['siteurl']."\n ".$tp->toRss($rss_title)."\n - ".$this->get_iso_8601_date($time + $this -> offset)."\n"; + ".$this->get_iso_8601_date($time)."\n"; // Recommended echo " @@ -689,7 +689,7 @@ class rssCreate echo " ".$value['link']."\n ".$tp->toRss($value['title'])."\n - ".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."\n"; + ".$this->get_iso_8601_date($value['pubdate'])."\n"; // Recommended $author = ($value['author']) ? $value['author'] : "unknown"; @@ -713,7 +713,7 @@ class rssCreate // // Jane Doe // - echo "".$this->get_iso_8601_date($value['pubdate'] + $this -> offset)."\n"; + echo "".$this->get_iso_8601_date($value['pubdate'])."\n"; // // http://example.org/ // Fourty-Two diff --git a/e107_web/css/backcompat.css b/e107_web/css/backcompat.css index f6033242f..fe5624497 100644 --- a/e107_web/css/backcompat.css +++ b/e107_web/css/backcompat.css @@ -29,5 +29,14 @@ div.checkboxes label.checkbox { display: block } textarea.bbarea { margin:0; } #chatbox-input-block { text-align:center } +ul.breadcrumb { margin:15px 0; } ul.breadcrumb li { display:inline-block; padding-right:5px;} -ul.breadcrumb li span.divider { padding-left:5px; } \ No newline at end of file +ul.breadcrumb li span.divider { padding-left:5px; } + +.row { margin-left:15px; margin-right:15px; } +.col-md-3 { float:left; width:25%; margin-right:15px} + +.thumbnail img { border-radius:8px; } + +.img-responsive { max-width:100%; } + diff --git a/error.php b/error.php index c9f71eeb6..816b4d9e3 100644 --- a/error.php +++ b/error.php @@ -1,115 +1,159 @@ ".LAN_ERROR_37." ".LAN_ERROR_35."
".LAN_ERROR_36."

".LAN_ERROR_3."
-
".LAN_ERROR_2."
".LAN_ERROR_20."
"; - break; - case 401: - $errorHeader = "HTTP/1.1 401 Unauthorized"; - $errorText = "

".LAN_ERROR_37." ".LAN_ERROR_1."

".LAN_ERROR_2."

".LAN_ERROR_3."
-
".LAN_ERROR_2."
".LAN_ERROR_20."
"; - break; - case 403: - $errorHeader = "HTTP/1.1 403 Forbidden"; - $errorText = "

".LAN_ERROR_37." ".LAN_ERROR_4."

".LAN_ERROR_5."

".LAN_ERROR_6."
-
".LAN_ERROR_2."
".LAN_ERROR_20."
"; - break; - case 404: - $errorHeader = "HTTP/1.1 404 Not Found"; - $errorText = "

".LAN_ERROR_37." ".LAN_ERROR_7."

".LAN_ERROR_21.'
'.LAN_ERROR_9."

"; - if (strlen($errFrom)) $errorText .= LAN_ERROR_23." {$errFrom} ".LAN_ERROR_24." -- ".LAN_ERROR_19."

"; - //.LAN_ERROR_23."{$errTo}".LAN_ERROR_24."

" ??? - - $errorText .= "

".LAN_ERROR_45."

"; - if($errReturnTo) - { - foreach ($errReturnTo as $url => $label) - { - $errorText .= "".$label."
"; - } - $errorText .= '
'; - } - $errorText .= "".LAN_ERROR_20."
"; - $errorText .= "".LAN_ERROR_22.""; - break; - case 500: - $errorHeader = "HTTP/1.1 500 Internal Server Error"; - $errorText = "

".LAN_ERROR_37." ".LAN_ERROR_10."

".LAN_ERROR_11."

".LAN_ERROR_12."
-
".LAN_ERROR_2."
".LAN_ERROR_20."
"; - break; - case 999: - if (E107_DEBUG_LEVEL) - { - echo LAN_ERROR_33."
\n";
-	  print_r($_SERVER);
-	  print_r($_REQUEST);
-	  echo "\n
\n"; - } - else - { - header("location: ".e_HTTP."index.php"); - exit; - } - break; - - default : - $errorText = "

".LAN_ERROR_13." (".$errorQuery.")

".LAN_ERROR_14."

".LAN_ERROR_15."
-
"; - -// default: -// $errorText = LAN_ERROR_34." e_QUERY = '".e_QUERY."'
".LAN_ERROR_20.""; -// break; + session_start(); +} + +// Include language file. +e107::coreLan('error'); + + +/** + * Class error_front. + */ +class error_front +{ + + /** + * @var + */ + private $errorNumber; + + /** + * Constructor. + */ + public function __construct() + { + if(is_numeric(e_QUERY)) + { + $this->errorNumber = intval(e_QUERY); + } + + $this->renderErrorPage(); + } + + /** + * Renders the error page. + */ + public function renderErrorPage() + { + switch($this->errorNumber) + { + case 400: + header('HTTP/1.1 400 Bad Request'); + + $subtitle = LAN_ERROR_35; // Error 400 - Bad Request + $caption = LAN_ERROR_45; + $content = LAN_ERROR_36 . '
' . LAN_ERROR_3; + break; + + case 401: + header('HTTP/1.1 401 Unauthorized'); + + $subtitle = LAN_ERROR_1; // Error 401 - Authentication Failed + $caption = LAN_ERROR_45; + $content = LAN_ERROR_2 . '
' . LAN_ERROR_3; + break; + + case 403: + header('HTTP/1.1 403 Forbidden'); + + $subtitle = LAN_ERROR_4; // Error 403 - Access forbidden + $caption = LAN_ERROR_45; + $content = LAN_ERROR_5 . '
' . LAN_ERROR_6 . '

' . LAN_ERROR_2; + break; + + case 404: + header('HTTP/1.1 404 Not Found'); + + $subtitle = LAN_ERROR_7; // Error 404 - Document Not Found + $caption = LAN_ERROR_45; + $content = LAN_ERROR_21 . '
' . LAN_ERROR_9; + + $errFrom = isset($_SESSION['e107_http_referer']) ? $_SESSION['e107_http_referer'] : $_SERVER['HTTP_REFERER']; + + if(strlen($errFrom)) + { + $content .= '
'; + $content .= '
'; + $content .= LAN_ERROR_23 . ' ' . $errFrom . ' '; + $content .= LAN_ERROR_24; + } + + break; + + case 500: + header('HTTP/1.1 500 Internal Server Error'); + + $subtitle = LAN_ERROR_10; // Error 500 - Internal server error + $caption = LAN_ERROR_14; + $content = LAN_ERROR_11 . '
' . LAN_ERROR_12; + break; + + case 999: + if(!defset('E107_DEBUG_LEVEL', false)) + { + e107::redirect(); + } + + $this->errorNumber = 'DEFAULT'; // Use default template. + + $subtitle = LAN_ERROR_33; + $caption = LAN_ERROR_14; + $content = '
' . print_r($_SERVER) . print_r($_REQUEST) . '
'; + break; + + default: + $this->errorNumber = 'DEFAULT'; // Use default template. + $errorQuery = htmlentities($_SERVER['QUERY_STRING']); + + $subtitle = LAN_ERROR_13 . ' (' . $errorQuery . ')'; // Error - Unknown + $caption = LAN_ERROR_14; + $content = LAN_ERROR_15; + break; + } + + $tp = e107::getParser(); + $tpl = e107::getCoreTemplate('error', $this->errorNumber); + $sc = e107::getScBatch('error'); + + $sc->setVars(array( + 'title' => LAN_ERROR_TITLE, + 'subtitle' => $subtitle, + 'caption' => $caption, + 'content' => $content, + )); + + $body = $tp->parseTemplate($tpl, true, $sc); + e107::getRender()->tablerender('', $body); + } + } -if ($errorHeader) header($errorHeader); require_once(HEADERF); - -e107::getRender()->tablerender(PAGE_NAME, $errorText); +new error_front(); require_once(FOOTERF); -?> \ No newline at end of file diff --git a/install.php b/install.php index 3954565dd..c4b3f8357 100644 --- a/install.php +++ b/install.php @@ -220,7 +220,7 @@ class e_install var $previous_steps; var $stage; var $post_data; - var $required = ""; //TODO - use for highlighting required fields with css/js. + var $required = array(); //TODO - use for highlighting required fields with css/js. var $logFile; // Name of log file, empty string if logging disabled var $dbLink = NULL; // DB link - needed for PHP5.3 bug var $session = null; @@ -398,12 +398,12 @@ class e_install function display_required() { - if(!$this->required) + if(empty($this->required)) { return; } $this->required = array_filter($this->required); - if(vartrue($this->required)) + if(!empty($this->required)) { $this->template->SetTag("required","
". implode("
",$this->required)."
"); $this->required = array(); @@ -1064,7 +1064,7 @@ class e_install $this->required['u_name'] = LANINS_086; // } - if(vartrue($this->required['u_name']) || vartrue($this->required['pass1'])) + if(!empty($this->required['u_name']) || !empty($this->required['pass1'])) { return $this->stage_5(); } @@ -1220,7 +1220,7 @@ class e_install $this->required['sitetheme'] = LANINS_114; // 'Please select a theme.'; } - if(vartrue($this->required['sitetheme']) || vartrue($this->required['sitename'])) + if(!empty($this->required['sitetheme']) || !empty($this->required['sitename'])) { return $this->stage_6(); } @@ -2019,7 +2019,7 @@ class SimpleTemplate var $open_tag = "{"; var $close_tag = "}"; - function SimpleTemplate() + function __construct() { define("TEMPLATE_TYPE_FILE", 0); define("TEMPLATE_TYPE_DATA", 1); diff --git a/news.php b/news.php index 9f507ae82..e0d0ce63c 100644 --- a/news.php +++ b/news.php @@ -20,6 +20,13 @@ */ require_once("class2.php"); + +if(e_DEBUG === 'news') +{ + require_once(e_PLUGIN."news/news.php"); +// exit; +} + include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE); require_once(e_HANDLER."news_class.php"); @@ -185,7 +192,7 @@ if(!empty($_GET['author']) || substr($action,0,4) == 'author=') } -if(E107_DBG_PATH) +if(e_DEBUG === 'news') { echo "
"; echo "

SEF Debug Info

";