diff --git a/e107_core/bbcodes/bb_alert.php b/e107_core/bbcodes/bb_alert.php new file mode 100644 index 000000000..56d9b54f6 --- /dev/null +++ b/e107_core/bbcodes/bb_alert.php @@ -0,0 +1,60 @@ +".$code_text.""; + } + + +} + + + + + + + +?> \ No newline at end of file diff --git a/e107_core/shortcodes/batch/page_shortcodes.php b/e107_core/shortcodes/batch/page_shortcodes.php index 0002fb9cb..d7628a5ab 100644 --- a/e107_core/shortcodes/batch/page_shortcodes.php +++ b/e107_core/shortcodes/batch/page_shortcodes.php @@ -267,12 +267,14 @@ class cpage_shortcodes extends e_shortcode $buttonText = (empty($this->var['menu_button_text'])) ? LAN_READ_MORE : $this->var['menu_button_text']; $buttonUrl = (empty($this->var['menu_button_url'])) ? $url : $tp->replaceConstants($this->var['menu_button_url']); - + $buttonTarget = (empty($this->var['menu_button_target'])) ? '' : ' target="'.$this->var['menu_button_target'].'" '; //TODO add pref to admin area. + $text = vartrue($options['text'], $buttonText); $size = vartrue($options['size'], ""); + $inc = ($size) ? " btn-".$size : ""; - return ''.$text.''; + return ''.$text.''; } @@ -281,7 +283,12 @@ class cpage_shortcodes extends e_shortcode $tp = e107::getParser(); // return $tp->toHTML($this->var['menu_title'], true, 'TITLE'); - } + } + + function sc_cmenuname($parm='') + { + return $this->var['menu_name']; + } function sc_cmenubody($parm='') diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 7af644aa3..1d5dc426b 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -37,6 +37,7 @@ class e_bbcode $pref = e107::getPref(); $this->core_bb = array( + 'alert', 'blockquote', 'img', 'i', 'u', 'center', '_br', 'color', 'size', 'code', 'flash', 'link', 'email', diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 0a09907d4..2d8f43a9e 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -3290,15 +3290,25 @@ class e_parser $key = substr($k,8); $ytpref[$key] = $v; } - } - + } + + unset($ytpref['bbcode_responsive']); // do not include in embed code. + + if(!empty($ytpref['cc_load_policy'])) + { + $ytpref['cc_lang_pref'] = e_LAN; // switch captions with chosen user language. + } + $ytqry = http_build_query($ytpref); - + + $defClass = (deftrue('BOOTSTRAP')) ? "embed-responsive embed-responsive-16by9" : "video-responsive"; // levacy backup. + + if($type == 'youtube') { // $thumbSrc = "https://i1.ytimg.com/vi/".$id."/0.jpg"; $thumbSrc = "http://i1.ytimg.com/vi/".$id."/mqdefault.jpg"; - $video = ''; + $video = ''; if($thumb == 'tag') @@ -3326,13 +3336,15 @@ class e_parser { return $thumbSrc; } + + if($thumb == 'video') { - return '
'.$video.'
'; + return '
'.$video.'
'; } - return '
'.$video.'
'; + return '
'.$video.'
'; } @@ -3352,7 +3364,7 @@ class e_parser } $video = ''; - return '
'.$video.'
'; + return '
'.$video.'
'; } if($type == 'mp4') //TODO FIXME diff --git a/e107_plugins/log/consolidate.php b/e107_plugins/log/consolidate.php index a3e5af734..858a549b5 100644 --- a/e107_plugins/log/consolidate.php +++ b/e107_plugins/log/consolidate.php @@ -2,21 +2,15 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2015 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - * - * - * - * $Source: /cvs_backup/e107_0.8/e107_plugins/log/consolidate.php,v $ - * $Revision$ - * $Date$ - * $Author$ + */ /* first thing to do is check if the log file is out of date ... */ -// $pathtologs = e_PLUGIN."log/logs/"; + if (!defined('e107_INIT')){ exit; } @@ -31,15 +25,507 @@ $pfile = "logp_".$date.".php"; // Today's log file $ifileprev = "logi_".$yesterday.".php"; $ifile = "logi_".$date.".php"; +// Begin v2.x cleanup. +class logConsolidate +{ + + function ___construct() + { + + } + + function createLog($pathtologs, $statTotal='', $statUnique='') + { + global $pfile, $ifile; + + if(!is_writable($pathtologs)) + { + echo "Log directory is not writable - please CHMOD ".e_LOG." to 777"; + echo '
Path to logs: '.$pathtologs; + return FALSE; + } + + $varStart = chr(36); + $quote = chr(34); + + $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n". + $varStart."refererData = ".$quote.$quote.";\n". + $varStart."ipAddresses = ".$quote.$quote.";\n". + $varStart."hosts = ".$quote.$quote.";\n". + $varStart."siteTotal = ".$quote."0".$quote.";\n". + $varStart."siteUnique = ".$quote."0".$quote.";\n". + $varStart."screenInfo = array();\n". + $varStart."browserInfo = array();\n". + $varStart."osInfo = array();\n". + $varStart."pageInfo = array(\n"; + + $data .= "\n);\n\n?". chr(62); + + if(!touch($pathtologs.$pfile)) { + return FALSE; + } + + if(!touch($pathtologs.$ifile)) { + return FALSE; + } + + if(!is_writable($pathtologs.$pfile)) { + $old = umask(0); + chmod($pathtologs.$pfile, 0777); + umask($old); + // return FALSE; + } + + if(!is_writable($pathtologs.$ifile)) { + $old = umask(0); + chmod($pathtologs.$ifile, 0777); + umask($old); + // return FALSE; + } + + if ($handle = fopen($pathtologs.$pfile, 'w')) + { + fwrite($handle, $data); + } + fclose($handle); + + + $data = ""; + + if ($handle = fopen($pathtologs.$ifile, 'w')) + { + fwrite($handle, $data); + } + fclose($handle); + return; + } + + + + + /** + * Called if both today's and yesterday's log files missing, to see + * if there are any older files we could process. Return FALSE if nothing + * Otherwise return a string of relevant information + * @param $pathtologs + * @return bool|string + */ + function check_for_old_files($pathtologs) + { + $no_files = TRUE; + if ($dir_handle = opendir($pathtologs)) + { + while (false !== ($file = readdir($dir_handle))) + { + // Do match on #^logp_(\d{1,3})\.php$#i + if (preg_match('#^logp_(\d{1,3}\.\d{4})\.php$#i',$file,$match) == 1) + { // got a matching file + $yesterday = $match[1]; // Day of year - zero is 1st Jan + $pfileprev = "logp_".$yesterday.".php"; // Yesterday's log file + $ifileprev = "logi_".$yesterday.".php"; + list($day,$year) = explode('.',$yesterday); + $tstamp = mktime(0,0,0,1,1,$year) + ($day*86400); + $date2 = date("Y-m-j", $tstamp); // Yesterday's date for the database summary + $temp = array($pfileprev,$ifileprev,$date2,$tstamp); + return implode('|',$temp); + } + } + } + return FALSE; + } + + + + + + // for future use. + private function collate($pfile) + { + if(is_readable(e_LOG.$pfile)) + { + require(e_LOG.$pfile); // contains $pageInfo; + } + else + { + return false; + } + + return null; + } + + + + + /** + * @param $url + * @param bool $logQry + * @param string $err_code + * @return bool|mixed|string + */ + function getPageKey($url,$logQry=false,$err_code='') + { + $pageDisallow = "cache|file|eself|admin"; + $tagRemove = "(\\\)|(\s)|(\')|(\")|(eself)|( )|(\.php)|(\.html)"; + $tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|( )"; + + preg_match("#/(.*?)(\?|$)(.*)#si", $url, $match); + $match[1] = isset($match[1]) ? $match[1] : ''; + $pageName = substr($match[1], (strrpos($match[1], "/")+1)); + + $pageName = preg_replace("/".$tagRemove."/si", "", $pageName); + + if($pageName == "") + { + return "index"; + } + + if(preg_match("/".$pageDisallow."/i", $pageName)) + { + return false; + } + + if ($logQry) + { + $pageName .= '+'.$match[3]; // All queries match + } + + $pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely + + + return $pageName; + } + + + /** + * Process Raw Backup Log File. e. e_LOG."log/2015-09-24_SiteStats.log + * This method can be used in the case of a database corruption to restore stats to the database. + * @param string $file + * @example processRawBackupLog('2015-09-24_SiteStats.log', false); + */ + function processRawBackupLog($file, $savetoDB=false) + { + $path = e_LOG."log/".$file; + + if(!is_readable($path)) + { + return false; + } + + $handle = fopen($path, "r"); + + $pageTotal = array(); + + if ($handle) + { + while (($buffer = fgets($handle, 4096)) !== false) + { + if($vars = $this->splitRawBackupLine($buffer)) + { + $key = $this->getPageKey($vars['eself']); + + $pageTotal[$key]['url'] = $vars['eself']; + $pageTotal[$key]['ttl'] += 1; + + if(!isset($pageTotal[$key]['unq'])) + { + $pageTotal[$key]['unq'] = 0; + } + + if(isset($vars['unique'])) + { + if($vars['unique'] == 1) + { + $pageTotal[$key]['unq'] += 1; + } + } + else + { + $pageTotal[$key]['unq'] += 1; + } + } + } + + if (!feof($handle)) + { + echo "Error: unexpected fgets() fail\n"; + } + + fclose($handle); + + echo "

".$file."

"; + print_a($pageTotal); + } + + if($savetoDB === false) + { + echo "Saving mode is off"; + return true; + } + + + if(!empty($pageTotal)) + { + list($date,$name) = explode("_", $file, 2); + + $unix = strtotime($date); + + $datestamp = date("Y-m-j", $unix); + + if(!empty($datestamp)) + { + $sql = e107::getDb(); + + if($sql->select('logstats','log_id',"log_id='".$datestamp."' ")) + { + $sql->update('logstats', "log_id='".$datestamp."-bak' WHERE log_id='".$datestamp."' "); + } + + if($this->collatePageInfo($pageTotal, $datestamp)) + { + echo "
Data saved to database with id: ".$datestamp; + } + else + { + echo "
Couldn't save data to database with id: ".$datestamp; + } + } + + } + } + + + + + private function splitRawBackupLine($line) + { + list($datestamp,$bla,$data) = explode("\t",$line, 3); + + if(!empty($data)) + { + parse_str($data,$vars); + return $vars; + } + + return false; + } + + /** + * Fix corrupted page data. + * Re-calculate all page totals from all existing database information and save to DB as 'pageTotal'. . + */ + function collatePageTotalDB() + { + $sql = e107::getDb(); + + $qry = "SELECT * FROM `#logstats` WHERE `log_id` REGEXP '^[0-9]' AND `log_data` LIKE '%http%'"; + $data = $sql->retrieve($qry,true); + + $pageTotal = array(); + + foreach($data as $values) + { + $tmp = explode(chr(1),$values['log_data']); + unset($tmp[0],$tmp[1]); + $thisTotal = array(); + + foreach($tmp as $val) + { + if(!empty($val)) + { + list($url,$ttl,$unq) = explode("|",$val); + $key = $this->getPageKey($url); + + $thisTotal[$key]['url'] = $url; + $thisTotal[$key]['ttlv'] += $ttl; + $thisTotal[$key]['unqv'] += $unq; + + $pageTotal[$key]['url'] = $url; + $pageTotal[$key]['ttlv'] += $ttl; + $pageTotal[$key]['unqv'] += $unq; + } + + } + + // echo "

".$values['log_id']."

"; + // print_a($thisTotal); + + } + + if(empty($pageTotal)) + { + return false; + } + + $id = $sql->retrieve('logstats','log_uniqueid', "log_id='pageTotal'"); + + $insertData = array( + 'log_uniqueid' => intval($id), + 'log_id'=> 'pageTotal', + 'log_data'=> serialize($pageTotal) + ); + + // echo "

Total

"; + // print_a($pageTotal); + + return $sql->replace('logstats', $insertData); + + } + + + /** + * collate page total information using today's data and totals stored in DB. + * @param $pageInfo - from today's file. + * @return bool + */ + function collatePageTotal($pageInfo=array()) + { + $sql = e107::getDb(); + + if($sql->select("logstats", "*", "log_id='pageTotal' ")) + { + $tmp = $sql->fetch(); + $pageTotal = unserialize($tmp['log_data']); + $uniqueID = $tmp['log_uniqueid']; + unset($tmp); + + } + else + { + $pageTotal = array(); + $uniqueID = 0; + } + + // echo "

DB Totals

"; + // print_a($pageTotal); + + // echo "

From File

"; + // print_a($pageInfo); + + foreach($pageInfo as $key => $info) + { + $pageTotal[$key]['url'] = $info['url']; + $pageTotal[$key]['ttlv'] += $info['ttl']; + $pageTotal[$key]['unqv'] += $info['unq']; + } + + // echo "

Consilidated

"; + // print_a($pageTotal); + + if(empty($pageTotal)) + { + return false; + } + + $insertData = array( + 'log_uniqueid' => intval($uniqueID), + 'log_id' => 'pageTotal', + 'log_data' => serialize($pageTotal) + ); + + return $sql->replace('logstats', $insertData); + + } + + + /** + * Collate individual page information into an array and save to database. + * @param array $pageInfo + * @param string $date - the value saved to log_id ie. Y-m-j , 2015-02-1, 2015-02-30 + * @return bool + */ + function collatePageInfo($pageInfo, $date) + { + + $sql = e107::getDb(); + $tp = e107::getParser(); + + $data = ""; + $dailytotal = 0; + $uniquetotal = 0; + + foreach($pageInfo as $key => $value) + { + $data .= $value['url']."|".$value['ttl']."|".$value['unq'].chr(1); + $dailytotal += $value['ttl']; + $uniquetotal += $value['unq']; + } + + $data = $dailytotal.chr(1).$uniquetotal.chr(1) . $data; + return $sql->insert("logstats", "0, '$date', '".$tp -> toDB($data, true)."'"); + } + + + /** + * Reset (empty) yesterday's log files. + * @return bool + */ + function resetLogFiles() + { + + global $pathtologs, $pfileprev, $ifileprev; + + if(empty($pfileprev) || empty($ifileprev)) + { + return false; + } + + /* ok, we're finished with the log file now, we can empty it ... */ + if(!unlink($pathtologs.$pfileprev)) + { + $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62); + + if($handle = fopen($pathtologs.$pfileprev, 'w')) + { + fwrite($handle, $data); + } + + fclose($handle); + } + + + if(!unlink($pathtologs.$ifileprev)) + { + $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG INFO FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62); + + if($handle = fopen($pathtologs.$ifileprev, 'w')) + { + fwrite($handle, $data); + } + + fclose($handle); + } + + + + } +} + + +$lgc = new logConsolidate(); + + + if(file_exists($pathtologs.$pfile)) /* log file is up to date, no consolidation required */ { return; } else if(!file_exists($pathtologs.$pfileprev)) // See if any older log files { - if (($retvalue = check_for_old_files($pathtologs)) === FALSE) /* no logfile found at all - create - this will only ever happen once ... */ + if (($retvalue = $lgc->check_for_old_files($pathtologs)) === FALSE) /* no logfile found at all - create - this will only ever happen once ... */ { - createLog($pathtologs); + $lgc->createLog($pathtologs); return FALSE; } @@ -228,178 +714,20 @@ else } -/* collate page total information */ -if($sql->select("logstats", "*", "log_id='pageTotal' ")) -{ - $tmp = $sql->fetch(); - $pageTotal = unserialize($tmp['log_data']); - unset($tmp); -} -else -{ - $pageTotal = array(); -} - -foreach($pageInfo as $key => $info) -{ - $pageTotal[$key]['url'] = $info['url']; - $pageTotal[$key]['ttlv'] += $info['ttl']; - $pageTotal[$key]['unqv'] += $info['unq']; -} - -$pagetotal = serialize($pageTotal); - -$insertPageTotal = array('log_data'=> $pageTotal, 'WHERE' => "log_id='pageTotal'"); -$sql->replace('logstats', $insertPageTotal); - -/* -if(!$sql->update("logstats", "log_data='{$pagetotal}' WHERE log_id='pageTotal' ")) -{ - $sql->insert("logstats", "0, 'pageTotal', '{$pagetotal}' "); -}*/ -/* now we need to collate the individual page information into an array ... */ -$data = ""; -$dailytotal = 0; -$uniquetotal = 0; -foreach($pageInfo as $key => $value) -{ - $data .= $value['url']."|".$value['ttl']."|".$value['unq'].chr(1); - $dailytotal += $value['ttl']; - $uniquetotal += $value['unq']; -} -$data = $dailytotal.chr(1).$uniquetotal.chr(1) . $data; -$sql->insert("logstats", "0, '$date2', '".$tp -> toDB($data, true)."'"); +$lgc->collatePageTotal($pageInfo); + +$lgc->collatePageInfo($pageInfo, $date2); + +$lgc->resetLogFiles(); - -/* ok, we're finished with the log file now, we can empty it ... */ -if(!unlink($pathtologs.$pfileprev)) -{ - $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62); - if ($handle = fopen($pathtologs.$pfileprev, 'w')) { - fwrite($handle, $data); - } - fclose($handle); -} -if(!unlink($pathtologs.$ifileprev)) -{ - $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n\n\n".chr(47)."* THE INFORMATION IN THIS LOG INFO FILE HAS BEEN CONSOLIDATED INTO THE DATABASE - YOU CAN SAFELY DELETE IT. *". chr(47)."\n\n\n?". chr(62); - if ($handle = fopen($pathtologs.$ifileprev, 'w')) { - fwrite($handle, $data); - } - fclose($handle); -} /* and finally, we need to create new logfiles for today ... */ -createLog($pathtologs); -/* done! */ +$lgc->createLog($pathtologs,$statTotal,$statUnique); -function createLog($pathtologs) -{ - global $statTotal, $statUnique, $pfile, $ifile; - if(!is_writable($pathtologs)) - { - echo "Log directory is not writable - please CHMOD ".e_LOG." to 777"; - echo '
Path to logs: '.$pathtologs; - return FALSE; - } - - $varStart = chr(36); - $quote = chr(34); - - $data = chr(60)."?php\n". chr(47)."* e107 website system: Log file: ".date("z:Y", time())." *". chr(47)."\n\n". - $varStart."refererData = ".$quote.$quote.";\n". - $varStart."ipAddresses = ".$quote.$quote.";\n". - $varStart."hosts = ".$quote.$quote.";\n". - $varStart."siteTotal = ".$quote."0".$quote.";\n". - $varStart."siteUnique = ".$quote."0".$quote.";\n". - $varStart."screenInfo = array();\n". - $varStart."browserInfo = array();\n". - $varStart."osInfo = array();\n". - $varStart."pageInfo = array(\n"; - - $data .= "\n);\n\n?". chr(62); - - if(!touch($pathtologs.$pfile)) { - return FALSE; - } - - if(!touch($pathtologs.$ifile)) { - return FALSE; - } - - if(!is_writable($pathtologs.$pfile)) { - $old = umask(0); - chmod($pathtologs.$pfile, 0777); - umask($old); - // return FALSE; - } - - if(!is_writable($pathtologs.$ifile)) { - $old = umask(0); - chmod($pathtologs.$ifile, 0777); - umask($old); - // return FALSE; - } - - if ($handle = fopen($pathtologs.$pfile, 'w')) - { - fwrite($handle, $data); - } - fclose($handle); - - -$data = ""; - - if ($handle = fopen($pathtologs.$ifile, 'w')) - { - fwrite($handle, $data); - } - fclose($handle); - return; -} - -// Called if both today's and yesterday's log files missing, to see -// if there are any older files we could process. Return FALSE if nothing -// Otherwise return a string of relevant information -function check_for_old_files($pathtologs) -{ - $no_files = TRUE; - if ($dir_handle = opendir($pathtologs)) - { - while (false !== ($file = readdir($dir_handle))) - { - // Do match on #^logp_(\d{1,3})\.php$#i - if (preg_match('#^logp_(\d{1,3}\.\d{4})\.php$#i',$file,$match) == 1) - { // got a matching file - $yesterday = $match[1]; // Day of year - zero is 1st Jan - $pfileprev = "logp_".$yesterday.".php"; // Yesterday's log file - $ifileprev = "logi_".$yesterday.".php"; - list($day,$year) = explode('.',$yesterday); - $tstamp = mktime(0,0,0,1,1,$year) + ($day*86400); - $date2 = date("Y-m-j", $tstamp); // Yesterday's date for the database summary - $temp = array($pfileprev,$ifileprev,$date2,$tstamp); - return implode('|',$temp); - } - } - } - return FALSE; -} ?> \ No newline at end of file diff --git a/e107_plugins/log/e_meta.php b/e107_plugins/log/e_meta.php index 9474a2fec..cceb6a8be 100644 --- a/e107_plugins/log/e_meta.php +++ b/e107_plugins/log/e_meta.php @@ -2,14 +2,13 @@ /* * e107 website system * -* Copyright 2001-2010 e107 Inc (e107.org) +* Copyright 2001-2015 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Site access logging * -* $URL$ -* $Id$ + * */ if (!defined('e107_INIT')) { exit; } @@ -37,36 +36,7 @@ if (vartrue($pref['statActivate'])) } } - /* - $logJS = " -function rstr2b64(input) -{ - var b64pad = \"=\"; // base-64 pad character. \"=\" for strict RFC compliance - var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"; - var output = \"\"; - var len = input.length; - for(var i = 0; i < len; i += 3) - { - var triplet = (input.charCodeAt(i) << 16) - | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) - | (i + 2 < len ? input.charCodeAt(i+2) : 0); - for(var j = 0; j < 4; j++) - { - if(i * 8 + j * 6 > input.length * 8) output += b64pad; - else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); - } - } - return output; -} -var ref=\"\"+escape(top.document.referrer); -var colord = window.screen.colorDepth; -var res = window.screen.width + \"x\" + window.screen.height; -var logString = 'referer=' + ref + '&colour=' + colord + '&eself=' + eself + '&res=' + res + '".$err_flag."'; -logString = rstr2b64(logString); -document.write('' ); -"; -*/ if(USER_AREA) { $logJS = " @@ -98,9 +68,11 @@ document.write('addDebug("Loading Log File: ".$logfile); + } + + + if($sql->select('logstats', 'log_data', "log_id='pageTotal'")) /* get main stat info from database */ + { + $row = $sql->fetch(); + $this->dbPageInfo = unserialize($row['log_data']); + // e107::getMessage()->addDebug("Loading Logstats from DB: ".print_a($this->dbPageInfo,true)); + } + else + { + $this->dbPageInfo = array(); + } + + /* temp consolidate today's info (if it exists)... */ + if(is_array($pageInfo)) + { + foreach($pageInfo as $key => $info) + { + $key = preg_replace("/\?.*/", "", $key); + if(array_key_exists($key, $this -> dbPageInfo)) + { + $this -> dbPageInfo[$key]['ttlv'] += $info['ttl']; + $this -> dbPageInfo[$key]['unqv'] += $info['unq']; + } + else + { + $this -> dbPageInfo[$key]['url'] = $info['url']; + $this -> dbPageInfo[$key]['ttlv'] = $info['ttl']; + $this -> dbPageInfo[$key]['unqv'] = $info['unq']; + } + } + } + + + } + + + private function getKey($self) + { + $base = basename($self); + list($url,$qry) = explode(".",$base, 2); + return $url; + } + + + function sc_log_pagecounter($parm) + { + $url = str_replace("www.", "", e_REQUEST_URL); + $id = $this->getKey(e_REQUEST_URL); + + if(isset($this->dbPageInfo[$id]['url']) && ($this->dbPageInfo[$id]['url'] == e_REQUEST_URL || $this->dbPageInfo[$id]['url'] == $url)) + { + return ($parm == 'unique') ? number_format($this->dbPageInfo[$id]['unqv']) : number_format($this->dbPageInfo[$id]['ttlv']); + } + + } + +} + + + +?> \ No newline at end of file diff --git a/e107_plugins/log/e_url.php b/e107_plugins/log/e_url.php index 9fe0c8b2e..9571f0e63 100644 --- a/e107_plugins/log/e_url.php +++ b/e107_plugins/log/e_url.php @@ -32,6 +32,13 @@ class log_url // plugin-folder + '_url' ); + $config['others'] = array( + 'regex' => '^stats/\?([\d]*)$', // matched against url, and if true, redirected to 'redirect' below. + 'sef' => 'stats', // used by e107::url(); to create a url from the db table. + 'redirect' => '{e_PLUGIN}log/stats.php?$1', // file-path of what to load when the regex returns true. + + ); + return $config; } diff --git a/e107_plugins/log/log.php b/e107_plugins/log/log.php index 0281355a5..7630368ae 100644 --- a/e107_plugins/log/log.php +++ b/e107_plugins/log/log.php @@ -1,13 +1,13 @@ 1, 'content' => array('content')); +//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING'])); +//$logVals = urldecode(base64_decode($_GET['lv'])); -//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING'])); -$logVals = urldecode(base64_decode($_GET['lv'])); + +// --------------- Reworked for v2.x ------------------------ + + +$logVals = base64_decode($_GET['lv']); + + +$logVals .= "&ip=".USERIP; +$logVals .= "&iphost=". @gethostbyaddr(USERIP); +$logVals .= "&lan=".e_LAN; +$logVals .= "&agent=".$_SERVER['HTTP_USER_AGENT']; + +parse_str($logVals, $vals); + +$vals['referer'] = urldecode($vals['referer']); +$vals['eself'] = urldecode($vals['eself']); + +if(empty($_SESSION['log_userLoggedPages']) || !in_array($vals['eself'],$_SESSION['log_userLoggedPages'])) +{ + $_SESSION['log_userLoggedPages'][] = $vals['eself']; + $logVals .= "&unique=1"; +} +else +{ + $logVals .= "&unique=0"; +} + + +$logVals = str_replace('%3A',':',$logVals); // make the URLs a bit cleaner, while keeping any urlqueries encoded. $lg = e107::getAdminLog(); $lg->addDebug(print_r($logVals, true)); $lg->toFile('SiteStats','Statistics Log', true); - -parse_str($logVals, $vals); + +e107::getEvent()->trigger('user_log_stats',$vals); + + +// ------------------------------------ --------------------- // We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1: // @todo may be able to remove this check once minimum PHP version finalised @@ -84,7 +107,6 @@ if (function_exists('date_default_timezone_get')) } - //$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logVals."\n"); fclose($logfp); //$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, print_r($vals, TRUE)."\n"); fclose($logfp); @@ -136,7 +158,7 @@ if(strstr($ref, 'admin')) $screenstats = $res.'@'.$colour; $agent = $_SERVER['HTTP_USER_AGENT']; -$ip = getip(); +$ip = e107::getIPHandler()->ipDecode(USERIP); $oldref = $ref; // backup for search string being stripped off for referer if($ref && !strstr($ref, $_SERVER['HTTP_HOST'])) @@ -152,21 +174,51 @@ $pageDisallow = "cache|file|eself|admin"; $tagRemove = "(\\\)|(\s)|(\')|(\")|(eself)|( )|(\.php)|(\.html)"; $tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|( )"; -preg_match("#/(.*?)(\?|$)(.*)#si", $self, $match); -$match[1] = isset($match[1]) ? $match[1] : ''; -$pageName = substr($match[1], (strrpos($match[1], "/")+1)); -$PN = $pageName; -$pageName = preg_replace("/".$tagRemove."/si", "", $pageName); -if($pageName == "") $pageName = "index"; -if(preg_match("/".$pageDisallow."/i", $pageName)) return; - - -if ($logQry) +function logGetPageKey($url,$logQry=false,$err_code='') { - $pageName .= '+'.$match[3]; // All queries match + global $pageDisallow, $tagRemove; + + preg_match("#/(.*?)(\?|$)(.*)#si", $url, $match); + $match[1] = isset($match[1]) ? $match[1] : ''; + $pageName = substr($match[1], (strrpos($match[1], "/")+1)); + + $pageName = preg_replace("/".$tagRemove."/si", "", $pageName); + if($pageName == "") + { + return "index"; + } + + if(preg_match("/".$pageDisallow."/i", $pageName)) + { + return false; + } + + if ($logQry) + { + $pageName .= '+'.$match[3]; // All queries match + } + + $pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely + + + return $pageName; } -$pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely + + + + +if(!$pageName = logGetPageKey($self,$logQry,$err_code)) +{ + if(LOG_DEBUG == true) + { + echo 'pageName was empty'; + } + return; +} + + + //$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $pageName."\n"); fclose($logfp); $p_handle = fopen($logPfile, 'r+'); @@ -203,6 +255,8 @@ else $flag = TRUE; } + + if(!strstr($ipAddresses, $ip)) { /* unique visit */ if(!$flag) @@ -215,6 +269,10 @@ if(!strstr($ipAddresses, $ip)) } + + + + $siteTotal ++; $info_data = var_export($pageInfo, true); //$date_stamp = date("z:Y", time()); // Same as '$date' variable @@ -239,66 +297,10 @@ if ($p_handle) fclose($p_handle); } - -// Get current IP address - return as a hex-encoded string -/* -function getip() +if(LOG_DEBUG == true) { - $ip = $_SERVER['REMOTE_ADDR']; - if (getenv('HTTP_X_FORWARDED_FOR')) - { - if (preg_match("#^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})#", getenv('HTTP_X_FORWARDED_FOR'), $ip3)) - { - $ip2 = array('#^0\..*#', - '#^127\..*#', // Local loopbacks - '#^192\.168\..*#', // RFC1918 - Private Network - '#^172\.(?:1[6789]|2\d|3[01])\..*#', // RFC1918 - Private network - '#^10\..*#', // RFC1918 - Private Network - '#^169\.254\..*#', // RFC3330 - Link-local, auto-DHCP - '#^2(?:2[456789]|[345][0-9])\..*#' // Single check for Class D and Class E - ); - $ip = preg_replace($ip2, $ip, $ip3[1]); - } - } - if ($ip == "") - { - $ip = "x.x.x.x"; - } - if (strpos($ip, ':') === FALSE) - { // Its an IPV4 address - return it as 32-character packed hex string - $ipa = explode(".", $ip); - return str_repeat('0000',5).'ffff'.sprintf('%02x%02x%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]); - } - else - { // Its IPV6 - if (strpos($ip,'.') !== FALSE) - { // IPV4 'tail' to deal with - $temp = strrpos($ip,':') +1; - $ipa = explode('.',substr($ip,$temp)); - $ip = substr($ip,0, $temp).sprintf('%02x%02x:%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]); - } - // Now 'normalise' the address - $temp = explode(':',$ip); - $s = 8 - count($temp); // One element will of course be the blank - foreach ($temp as $f) - { - if ($f == '') - { - $ret .= '0000'; // Always put in one set of zeros for the blank - if ($s > 0) - { - $ret .= str_repeat('0000',$s); - $s = 0; - } - } - else - { - $ret .= sprintf('%04x',hexdec($f)); - } - } - return $ret; - } + echo '
Script Completed'; } -*/ + ?> \ No newline at end of file diff --git a/e107_plugins/log/stats.php b/e107_plugins/log/stats.php index 1001684dc..9d825b10b 100644 --- a/e107_plugins/log/stats.php +++ b/e107_plugins/log/stats.php @@ -742,7 +742,8 @@ class siteStats function renderNav($action) { - $path = e_PLUGIN_ABS.'log/stats.php'; + // $path = e_PLUGIN_ABS.'log/stats.php'; + $path = e_REQUEST_SELF; $links = array( 1 => array('label' => ADSTAT_L8, 'pref' => null), @@ -872,10 +873,11 @@ class siteStats function renderAlltimeVisits($action, $do_errors = FALSE) { $sql = e107::getDB(); + $tp = e107::getParser(); $text = ''; $sql->select("logstats", "*", "log_id='pageTotal' "); - $row = $sql -> db_Fetch(); + $row = $sql->fetch(); $pageTotal = unserialize($row['log_data']); $total = 0; @@ -925,7 +927,7 @@ class siteStats $text .= " ".($can_delete ? "".ADSTAT_L39." " : "")." - ".$key." + ".$tp->text_truncate($key,50)." "; $text .= " ".$this->bar($percentage, $info['ttlv'])." @@ -933,7 +935,7 @@ class siteStats \n"; } } - $text .= "".ADSTAT_L21."{$total}\n"; + $text .= "".ADSTAT_L21."".number_format($total)."\n"; $uniqueArray = array(); @@ -950,7 +952,13 @@ class siteStats $uniqueArray = $this -> arraySort($uniqueArray, "unqv"); $text .= "
- \n\n\n\n\n\n"; +
Page".ADSTAT_L24."%
+ + + + + \n"; + foreach($uniqueArray as $key => $info) { if ($info['ttlv']) @@ -958,13 +966,13 @@ class siteStats if (!$info['url'] && (($key == 'index') || (strpos($key,':index') !== FALSE))) $info['url'] = e_HTTP.'index.php'; // Avoids empty link $percentage = round(($info['unqv']/$totalv) * 100, 2); $text .= " - + \n"; } } - $text .= "\n
".ADSTAT_L19."".ADSTAT_L24."%
".$key." ".$tp->text_truncate($key, 50)." ".$this -> bar($percentage, $info['unqv'])." ".$percentage."%
".ADSTAT_L21."$totalv
"; + $text .= "".ADSTAT_L21."".number_format($totalv)."\n"; return $text; } @@ -1964,7 +1972,7 @@ class siteStats * * @return string text to be displayed */ - function bar($percen, $val,$name) + function bar($percen, $val,$name='') { if(deftrue('BOOTSTRAP')) { @@ -1979,7 +1987,7 @@ class siteStats $text .= " - ".$val; + ".number_format($val); return $text; } diff --git a/e107_plugins/tinymce4/e_footer.php b/e107_plugins/tinymce4/e_footer.php index 023ad961d..10fd5ce90 100644 --- a/e107_plugins/tinymce4/e_footer.php +++ b/e107_plugins/tinymce4/e_footer.php @@ -17,10 +17,7 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL { if(e_PAGE != 'image.php') { - //e107::js('tinymce','tiny_mce.js','jquery'); - //e107::js('tinymce','wysiwyg.php','jquery',5); - // e107::js('footer', "https://tinymce.cachefly.net/4.2/tinymce.min.js"); - e107::js('footer', "https://tinymce.cachefly.net/4.0/tinymce.min.js"); // 4.1 and 4.2 have issues with saving under Firefox. http://www.tinymce.com/develop/bugtracker_view.php?id=7655 + e107::js('footer', "https://tinymce.cachefly.net/4.2/tinymce.min.js"); e107::js('footer',e_PLUGIN.'tinymce4/wysiwyg.php','jquery',5); // Add to e107_config.php to view hidden content when TinyMce not saving correctly @@ -48,8 +45,8 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL if(ADMIN) { $insert = "$('#'+id).after('
"; - $insert .= "Switch to bbcode<\/a>"; - + + if(e_PAGE == 'mailout.php') { $insert .= "  ".LAN_MAILOUT_16."<\/a>"; @@ -83,9 +80,7 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL $('.e-wysiwyg').each(function() { var id = $(this).attr('id'); // 'e-wysiwyg'; - console.log(id); ".SWITCH_TO_BB." - // alert(id); $('#bbcode-panel-'+id+'--preview').hide(); }); @@ -98,27 +93,6 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL }); - - /* - $('img.tinyInsertEmote').live('click',function() { - - var src = $(this).attr('src'); - // alert(src); - // var html = '\'emote\''; - tinyMCE.execCommand('mceInsertRawHTML',false, 'hi there'); - ; - $('.mceContentBody', window.top.document).tinymce().execCommand('mceInsertContent',false,src); - - // tinyMCE.selectedInstance.execCommand('mceInsertContent',0,src); - - $('#uiModal').modal('hide'); - return true; - }); - */ - - - - // When new tab is added - convert textarea to TinyMce. $('.e-tabs-add').on('click',function(){ @@ -133,28 +107,6 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL }); - $('a.e-wysiwyg-toggle').toggle(function(){ - - var id = $(this).attr('id'); // eg. news-body - - $('#bbcode-panel-'+id+'--preview').show(); - $(this).text('Switch to wysiwyg'); - - tinymce.EditorManager.execCommand('mceRemoveEditor',true, id); //v4.x - - // tinymce.remove('#'+id); - // tinymce.activeEditor.execCommand('mceRemoveControl', false, id); - // $('#'+id).tinymce().remove(); - - }, function () { - var id = $(this).attr('id'); - $('#bbcode-panel-'+id+'--preview').hide(); - $(this).text('Switch to bbcode'); - tinymce.EditorManager.execCommand('mceAddEditor',true, id); //v4.x - // tinymce.remove('#'+id); - // tinymce.activeEditor.execCommand('mceAddControl', false, id); - }); - $(document).on('click','.e-dialog-save', function(){ // var html = $('#html_holder').val(); diff --git a/e107_plugins/tinymce4/plugins/e107/editor_plugin.js b/e107_plugins/tinymce4/plugins/e107/editor_plugin.js deleted file mode 100644 index ff24d4f35..000000000 --- a/e107_plugins/tinymce4/plugins/e107/editor_plugin.js +++ /dev/null @@ -1,323 +0,0 @@ -/** - * $Id$ - * - * @author Moxiecode - * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. - */ - -(function() { - tinymce.create('tinymce.plugins.e107BBCodePlugin', { - init : function(ed, url) { - - // Bootstrap - ed.addCommand('mceBoot', function() { - ed.windowManager.open({ - file : url + '/dialog.php', - width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)), - height : 450, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)), - inline : 1 - }, { - plugin_url : url, // Plugin absolute URL - some_custom_arg : 'custom arg' // Custom argument - }); - }); - - // Register button - ed.addButton('bootstrap', { - title : 'Insert Bootstrap Elements', - cmd : 'mceBoot', - image : url + '/img/bootstrap.png' - }); - - // e107 Bbcode - ed.addCommand('mcee107', function() { - ed.windowManager.open({ - file : url + '/dialog.php?bbcode', - width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)), - height : 450, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)), - inline : 1 - }, { - plugin_url : url, // Plugin absolute URL - some_custom_arg : 'custom arg' // Custom argument - }); - }); - - // Register button - ed.addButton('e107bbcode', { - title : 'Insert e107 Bbcode', - cmd : 'mcee107', - image : url + '/img/bbcode.png' - }); - - - - // Add a node change handler, selects the button in the UI when a image is selected - // ed.onNodeChange.add(function(ed, cm, n) { - // cm.setActive('example', n.nodeName == 'IMG'); - // }); - - - // ------------ - - - var t = this, dialect = ed.getParam('bbcode_dialect', 'e107').toLowerCase(); - - ed.onBeforeSetContent.add(function(ed, o) { - - o.content = t['_' + dialect + '_bbcode2html'](o.content,url); - }); - - ed.onPostProcess.add(function(ed, o) { - if (o.set) - o.content = t['_' + dialect + '_bbcode2html'](o.content,url); - - if (o.get) - o.content = t['_' + dialect + '_html2bbcode'](o.content,url); - }); - }, - - getInfo : function() { - return { - longname : 'e107 BBCode Plugin', - author : 'Moxiecode Systems AB - Modified by e107 Inc', - authorurl : 'http://e107.org', - infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/bbcode', - version : tinymce.majorVersion + "." + tinymce.minorVersion - }; - }, - - // Private methods - - // HTML -> BBCode in PunBB dialect - _e107_html2bbcode : function(s,url) { - s = tinymce.trim(s); - - - var p = $.ajax({ - type: "POST", - url: url + "/parser.php", - data: { content: s, mode: 'tobbcode' }, - async : false, - - dataType: "html", - success: function(html) { - return html; - } - }).responseText; - - return p; - - - - - function rep(re, str) { - s = s.replace(re, str); - } - - // return s; - - rep(//gim, "[table]"); - rep(/<\/table>/gim, "[/table]"); - rep(//gim, "[td]"); - rep(/<\/td>/gim, "[/td]"); - rep(//gim, "[tr]"); - rep(/<\/tr>/gim, "[/tr]"); - rep(//gim, "[tbody]"); - rep(/<\/tbody>/gim, "[/tbody]"); - - - rep(/
([\s\S]*)<\/div>/gi,"[center]$1[/center]"); // verified - - rep(/
  • /gi, "[*]"); // verified - rep(/<\/li>/gi, ""); // verified - rep(/