1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 11:50:30 +02:00

Merge branch 'master' of github.com:e107inc/e107

This commit is contained in:
SecretR
2015-10-02 13:40:56 +03:00
17 changed files with 838 additions and 713 deletions

View File

@@ -0,0 +1,60 @@
<?php
/**
* Copyright (C) e107 Inc (e107.org), Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* DIV block bbcode
*/
if (!defined('e107_INIT')) { exit; }
// This is a generic and 'responsive' video bbcode. Handles Youtube and eventually html5 video tags.
class bb_alert extends e_bb_base
{
/**
* Called prior to save
* Re-assemble the bbcode
*/
function toDB($code_text, $parm)
{
if(!empty($parm))
{
$ins = '='.$parm;
}
else
{
$ins = '';
}
return '[alert'.$ins.']'.$code_text.'[/alert]';
}
/**
* Bootstrap Alert container.
* @param $code_text :
*/
function toHTML($code_text, $parm='')
{
if(!empty($parm))
{
$style = "alert alert-".$parm;
}
else
{
$style = "alert alert-info";
}
return "<div class='".$style."'>".$code_text."</div>";
}
}
?>

View File

@@ -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 '<a class="cpage btn btn-primary btn-cpage'.$inc.'" href="'.$buttonUrl.'">'.$text.'</a>';
return '<a class="cpage btn btn-primary btn-cpage'.$inc.'" href="'.$buttonUrl.'" '.$buttonTarget.'>'.$text.'</a>';
}
@@ -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='')

View File

@@ -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',

View File

@@ -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 = '<iframe width="560" height="315" src="//www.youtube.com/embed/'.$id.'?'.$ytqry.'" style="background-size: 100%;background-image: url('.$thumbSrc.');border:0px" allowfullscreen></iframe>';
$video = '<iframe class="embed-responsive-item" width="560" height="315" src="//www.youtube.com/embed/'.$id.'?'.$ytqry.'" style="background-size: 100%;background-image: url('.$thumbSrc.');border:0px" allowfullscreen></iframe>';
if($thumb == 'tag')
@@ -3326,13 +3336,15 @@ class e_parser
{
return $thumbSrc;
}
if($thumb == 'video')
{
return '<div class="video-responsive video-thumbnail thumbnail">'.$video.'</div>';
return '<div class="'.$defClass.' video-thumbnail thumbnail">'.$video.'</div>';
}
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
return '<div class="'.$defClass.' '.vartrue($parm['class']).'">'.$video.'</div>';
}
@@ -3352,7 +3364,7 @@ class e_parser
}
$video = '<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list='.$id.'" style="border:0" allowfullscreen></iframe>';
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
return '<div class="'.$defClass.' '.vartrue($parm['class']).'">'.$video.'</div>';
}
if($type == 'mp4') //TODO FIXME

View File

@@ -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 '<br />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 = "<?php
/* e107 website system: Log info file: ".date("z:Y", time())." */
";
$data .= '$domainInfo'." = array();\n\n";
$data .= '$screenInfo'." = array();\n\n";
$data .= '$browserInfo'." = array();\n\n";
$data .= '$osInfo'." = array();\n\n";
$data .= '$refInfo'." = array();\n\n";
$data .= '$searchInfo'." = array();\n\n";
$data .= '$visitInfo'." = array();\n\n";
$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)|(&nbsp;)|(\.php)|(\.html)";
$tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
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 "<h3>".$file."</h3>";
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 "<br />Data saved to database with id: ".$datestamp;
}
else
{
echo "<br />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 "<h3>".$values['log_id']."</h3>";
// 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 "<h2>Total</h2>";
// 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 "<h3>DB Totals</h3>";
// print_a($pageTotal);
// echo "<h3>From File</h3>";
// print_a($pageInfo);
foreach($pageInfo as $key => $info)
{
$pageTotal[$key]['url'] = $info['url'];
$pageTotal[$key]['ttlv'] += $info['ttl'];
$pageTotal[$key]['unqv'] += $info['unq'];
}
// echo "<h3>Consilidated</h3>";
// 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 '<br />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 = "<?php
/* e107 website system: Log info file: ".date("z:Y", time())." */
";
$data .= '$domainInfo'." = array();\n\n";
$data .= '$screenInfo'." = array();\n\n";
$data .= '$browserInfo'." = array();\n\n";
$data .= '$osInfo'." = array();\n\n";
$data .= '$refInfo'." = array();\n\n";
$data .= '$searchInfo'." = array();\n\n";
$data .= '$visitInfo'." = array();\n\n";
$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;
}
?>

View File

@@ -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('<link rel=\"stylesheet\" type=\"text/css\" href=\"".e_PLUGIN_ABS."log/log.php?lv='+logString + '\">' );
";
*/
if(USER_AREA)
{
$logJS = "
@@ -98,9 +68,11 @@ document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"".e_PLUGIN_ABS
var ref =\"\"+escape(top.document.referrer);
var eeself = escape(window.location.href);
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."';
var logString = 'referer=' + ref + '&colour=' + colord + '&eself=' + eeself + '&res=' + res + '".$err_flag."';
logString = rstr2b64(logString);
var url = '".SITEURLBASE.e_PLUGIN_ABS."log/log.php';

View File

@@ -0,0 +1,95 @@
<?php
/*
* Copyright (c) e107 Inc 2015 e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
*
* Log Stats shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/
if (!defined('e107_INIT')) { exit; }
class log_shortcodes extends e_shortcode
{
private $dbPageInfo;
function __construct()
{
$sql = e107::getDB();
$logfile = e_LOG.'logp_'.date('z.Y', time()).'.php'; /* get today's logfile ... */
$pageInfo = array();
if(is_readable($logfile)) // populate $pageInfo
{
require($logfile);
}
$logfile = e_LOG.'logi_'.date('z.Y', time()).'.php'; // $logfile = e_PLUGIN.'log/logs/logi_'.date('z.Y', time()).'.php';
if(is_readable($logfile))
{
require($logfile);
// e107::getMessage()->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']);
}
}
}
?>

View File

@@ -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;
}

View File

@@ -1,13 +1,13 @@
<?php
/*
* e107 website system
*
* Copyright 2001-2013 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 - 'receiver'
* e107 website system
*
* Copyright 2001-2013 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 - 'receiver'
*/
/* File to log page accesses - called with
@@ -29,52 +29,75 @@ require_once("../../class2.php"); // More secure to include it.
header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
define('LOG_DEBUG', false);
// @example url: e107_plugins/log/log.php?lv=cmVmZXJlcj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL3N0YXRzJmNvbG91cj0yNCZlc2VsZj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL2UxMDdfcGx1Z2lucy9sb2cvc3RhdHMucGhwJTNGMiZyZXM9MTkyMHgxMjAw
if(LOG_DEBUG == true)
{
echo "Debug is Active";
}
if (!vartrue($pref['statActivate']))
{
if(LOG_DEBUG == true)
{
echo "Stats log is inactive";
}
exit();
}
/**
* Set up path to log files.
* The log file directory contains a flag file which defines whether logging is enabled.
*/
/*
function setLogPath()
{
$siteRoot = realpath(dirname(__FILE__).'./../../').'/';
@include_once($siteRoot.'e107_config.php');
if (!isset($mySQLdefaultdb)) return FALSE;
if (!isset($mySQLprefix)) return FALSE;
$hash = substr(md5($mySQLdefaultdb.".".$mySQLprefix),0,10);
$logDir = $siteRoot.$SYSTEM_DIRECTORY.$hash.'/logs/';
$logEnable = 0;
@include_once($logDir.'LogFlag.php'); // See if logging enabled
define('e_LOG', $logDir);
return $logEnable;
}
*/
// if (!setLogPath()) exit(); // Could be logging disabled, missing files, all sorts of things. Just do nothing.
//print_r(base64_decode($_GET['lv']));
define('log_INIT', TRUE);
// Array of page names which should have individual query values recorded.
// The top level array index is the page name.
// If the top level value is an array, it must be an array of query string beginnings to match.
$pageUnique = array('page' => 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)|(&nbsp;)|(\.php)|(\.html)";
$tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
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 '<br />Script Completed';
}
*/
?>

View File

@@ -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 .= "<tr>
<td class='forumheader3' >
".($can_delete ? "<a href='".e_SELF."?{$action}.rem.".rawurlencode($key)."'><img src='".e_PLUGIN_ABS."log/images/remove.png' alt='".ADSTAT_L39."' title='".ADSTAT_L39."' style='vertical-align: middle;' /></a> " : "")."
<img src='".e_PLUGIN_ABS."log/images/html.png' alt='' style='vertical-align: middle;' /> <a href='".$info['url']."'>".$key."</a>
<img src='".e_PLUGIN_ABS."log/images/html.png' alt='' style='vertical-align: middle;' /> <a href='".$info['url']."' title=\"".$key."\" >".$tp->text_truncate($key,50)."</a>
";
$text .= "</td>
<td class='forumheader3' >".$this->bar($percentage, $info['ttlv'])."</td>
@@ -933,7 +935,7 @@ class siteStats
</tr>\n";
}
}
$text .= "<tr><td class='forumheader' colspan='2'>".ADSTAT_L21."</td><td class='forumheader' style='text-align: center;'>{$total}</td><td class='forumheader'></td></tr>\n</table>";
$text .= "<tr><td class='forumheader' colspan='2'>".ADSTAT_L21."</td><td class='forumheader' style='text-align: center;'>".number_format($total)."</td><td class='forumheader'></td></tr>\n</table>";
$uniqueArray = array();
@@ -950,7 +952,13 @@ class siteStats
$uniqueArray = $this -> arraySort($uniqueArray, "unqv");
$text .= "<br />
<table class='table table-striped fborder' style='width: 100%;'>\n<tr>\n<td class='fcaption' style='width: 20%;'>Page</td>\n<td class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L24."</td>\n<td class='fcaption' style='width: 10%; text-align: center;'>%</td>\n</tr>\n";
<table class='table table-striped fborder' style='width: 100%;'>
<tr>
<th class='fcaption' style='width: 20%;'>".ADSTAT_L19."</th>
<th class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L24."</th>
<th class='fcaption' style='width: 10%; text-align: center;'>%</th>
</tr>\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 .= "<tr>
<td class='forumheader3' style='width: 20%;'><img src='".e_PLUGIN_ABS."log/images/html.png' alt='' style='vertical-align: middle;' /> <a href='".$info['url']."'>".$key."</a></td>
<td class='forumheader3' style='width: 20%;'><img src='".e_PLUGIN_ABS."log/images/html.png' alt='' style='vertical-align: middle;' /> <a href='".$info['url']."'>".$tp->text_truncate($key, 50)."</a></td>
<td class='forumheader3' style='width: 70%;'>".$this -> bar($percentage, $info['unqv'])."</td>
<td class='forumheader3' style='width: 10%; text-align: center;'>".$percentage."%</td>
</tr>\n";
}
}
$text .= "<tr><td class='forumheader' colspan='2'>".ADSTAT_L21."</td><td class='forumheader' style='text-align: center;'>$totalv</td><td class='forumheader'></td></tr>\n</table>";
$text .= "<tr><td class='forumheader' colspan='2'>".ADSTAT_L21."</td><td class='forumheader' style='text-align: center;'>".number_format($totalv)."</td><td class='forumheader'></td></tr>\n</table>";
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 .= "
</td>
<td style='width:10%; text-align:center' class='forumheader3'>".$val;
<td style='width:10%; text-align:right' class='forumheader3'>".number_format($val);
return $text;
}

View File

@@ -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('<div>";
$insert .= "<a href=\"#\" id=\"' + id + '\" class=\"e-wysiwyg-toggle btn btn-xs btn-default btn-inverse btn-mini\">Switch to bbcode<\/a>";
if(e_PAGE == 'mailout.php')
{
$insert .= "&nbsp;&nbsp;<a href=\"#\" class=\"btn btn-mini tinyInsert\" data-value=\"|USERNAME|\" >".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 = '<img src=\''+src +'\' alt=\'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();

View File

@@ -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(/<table(.*)>/gim, "[table]");
rep(/<\/table>/gim, "[/table]");
rep(/<td>/gim, "[td]");
rep(/<\/td>/gim, "[/td]");
rep(/<tr>/gim, "[tr]");
rep(/<\/tr>/gim, "[/tr]");
rep(/<tbody>/gim, "[tbody]");
rep(/<\/tbody>/gim, "[/tbody]");
rep(/<div style="text-align: center;">([\s\S]*)<\/div>/gi,"[center]$1[/center]"); // verified
rep(/<li>/gi, "[*]"); // verified
rep(/<\/li>/gi, ""); // verified
rep(/<ul>([\s\S]*?)<\/ul>\n/gim, "[list]$1[/list]"); // verified
rep(/<ol .* style=\'list-style-type:\s*([\w]*).*\'>([\s\S]*)<\/ol>/gim,"[list=$1]$2[/list]\n"); // verified
rep(/<ol>([\s\S]*?)<\/ol>/gim,"[list=decimal]$1[/list]\n"); // verified
rep(/<span style="color: (#?.*?);">([\s\S]*)<\/span>/gi,"[color=$1]$2[/color]"); // verified
rep(/<h2>/gim, "[h]"); // verified
rep(/<\/h2>/gim, "[/h]"); // verified
// example: <strong> to [b]
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[link=$1]$2[/link]");
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
rep(/<font.*?class=\"quoteStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
rep(/<span style=\"color: ?(.*?);\">(.*?)<\/span>/gi,"[color=$1]$2[/color]");
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
rep(/<font>(.*?)<\/font>/gi,"$1");
// rep(/<img.*?style=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img style=$1]$2[/img]");
// New Image Handler // verified
// rep(/<img(?:\s*)?(?:style="(.*)")?\s?(?:src="([^;"]*)")(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?(?:alt="(\S*)")? (?:\s*)?\/>/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" );
//rep(/<img(?:\s*)?(?:style="(.*)")?\s?(?:src="([\S ]*)")(?:\s*)?(?:alt="(\S*)")?(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?\/>/gi,"[img style=$1;width:$4px;height:$5px]$2[/img]" )
rep(/<img(?:\s*)?(?:style="([^"]*)")?\s?(?:src="([^"]*)")(?:\s*)?(?:alt="(\S*)")?(?:\s*)?(?:width="([\d]*)")?\s*(?:height="([\d]*)")?(?:\s*)?\/>/gm,"[img style=width:$4px;height:$5px;$1]$2[/img]" );
rep(/;width:px;height:px/gi, ""); // Img cleanup.
// rep(/<img\s*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
rep(/<blockquote[^>]*>/gi,"[blockquote]");
rep(/<\/blockquote>/gi,"[/blockquote]");
rep(/<code[^>]*>/gi,"[code]");
rep(/<\/code>/gi,"[/code]");
// rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
// rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
// rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
// rep(/<strong class=\"quoteStyle\">(.*?)<\/strong>/gi,"[quote][b]$1[/b][/quote]");
// rep(/<em class=\"codeStyle\">(.*?)<\/em>/gi,"[code][i]$1[/i][/code]");
// rep(/<em class=\"quoteStyle\">(.*?)<\/em>/gi,"[quote][i]$1[/i][/quote]");
// rep(/<u class=\"codeStyle\">(.*?)<\/u>/gi,"[code][u]$1[/u][/code]");
// rep(/<u class=\"quoteStyle\">(.*?)<\/u>/gi,"[quote][u]$1[/u][/quote]");
rep(/<\/(strong|b)>/gi,"[/b]");
rep(/<(strong|b)>/gi,"[b]");
rep(/<\/(em|i)>/gi,"[/i]");
rep(/<(em|i)>/gi,"[i]");
rep(/<\/u>/gi,"[/u]");
rep(/<span style=\"text-decoration: ?underline;\">(.*?)<\/span>/gi,"[u]$1[/u]");
rep(/<u>/gi,"[u]");
// Compromise - but BC issues for sure.
// rep(/<br \/>/gi,"[br]");
// rep(/<br\/>/gi,"[br]");
// rep(/<br>/gi,"[br]");
rep(/<br \/>/gi,"\n");
rep(/<br\/>/gi,"\n");
rep(/<br>/gi,"\n");
rep(/<p>/gi,"");
rep(/<\/p>/gi,"\n");
rep(/&nbsp;/gi," ");
rep(/&quot;/gi,"\"");
rep(/&lt;/gi,"<");
rep(/&gt;/gi,">");
rep(/&amp;/gi,"&");
// e107
return s;
},
// BBCode -> HTML from PunBB dialect
_e107_bbcode2html : function(s,url) {
s = tinymce.trim(s);
var p = $.ajax({
type: "POST",
url: url + "/parser.php",
data: { content: s, mode: 'tohtml' },
async : false,
dataType: "html",
success: function(html) {
return html;
}
}).responseText;
return p;
return s;
function rep(re, str) {
s = s.replace(re, str);
}
// example: [b] to <strong>
// rep(/<ul>(\r|\n)?/gim, "<ul>"); // remove line-breaks
// rep(/<\/li>(\r|\n)?/gim, "</li>"); // remove line-breaks
// rep(/<\/ul>(\r|\n)?/gim, "</ul>"); // remove line-breaks
rep(/\[table]/gim, "<table>");
rep(/\[\/table]/gim, "</table>");
rep(/\[td]/gim, "<td>");
rep(/\[\/td]/gim, "</td>");
rep(/\[tr]/gim, "<tr>");
rep(/\[\/tr]/gim, "</tr>");
rep(/\[tbody]/gim, "<tbody>");
rep(/\[\/tbody]/gim, "</tbody>");
rep(/\[h]/gim, "<h2>"); // verified
rep(/\[\/h]/gim, "</h2>"); // verified
rep(/\[list](?:\n)/gim, "<ul>\n"); // verified
// rep(/\[list]/gim, "<ul>"); // verified
rep(/\[\/list](?:\n)?/gim, "</ul>\n"); // verified
rep(/^ *?(?:\*|\[\*\])([^\*[]*)/gm,"<li>$1</li>\n");
// return s;
// rep(/(\[list=.*\])\\*([\s\S]*)(\[\/list])(\n|\r)/gim,"<ol>$2</ol>"); // verified
// rep(/(\[list\])\\*([\s\S]*)(\[\/list])(\n|\r)?/gim,"<ul>$2</ul>");// verified
rep(/\[center\]([\s\S]*)\[\/center\]/gi,"<div style=\"text-align:center\">$1</div>"); // verified
rep(/\[color=(.*?)\]([\s\S]*)\[\/color\]/gi,"<span style=\"color: $1;\">$2<\/span>"); // verified
// rep(/\[br]/gi,"<br />"); // compromise
rep(/\[blockquote\]/gi,"<blockquote>");
rep(/\[\/blockquote\]/gi,"</blockquote>");
rep(/\[code\]/gi,"<code>");
rep(/\[\/code\]/gi,"</code>");
//rep( /(?<!(\[list]))\r|\n/gim,"<br />" )
rep(/\[b\]/gi,"<strong>");
rep(/\[\/b\]/gi,"</strong>");
rep(/\[i\]/gi,"<em>");
rep(/\[\/i\]/gi,"</em>");
rep(/\[u\]/gi,"<u>");
rep(/\[\/u\]/gi,"</u>");
rep(/\[link=([^\]]+)\](.*?)\[\/link\]/gi,"<a href=\"$1\">$2</a>");
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
// rep(/\[img.*?style=(.*?).*?\](.*?)\[\/img\]/gi,"<img style=\"$1\" src=\"$2\" />");
// When Width and Height are present:
rep(/\[img\s*?style=(?:width:(\d*)px;height:(\d*)px;)([^\]]*)]([\s\S]*?)\[\/img]/gm, "<img style=\"$3\" src=\"$4\" alt=\"\" width=\"$1\" height=\"$2\" />");
// No width/height but style is present
rep(/\[img\s*?style=([^\]]*)]([\s\S]*?)\[\/img]/gi,"<img style=\"$1\" src=\"$2\" />");
rep(/\[img\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
// rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
// rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span>&nbsp;");
// rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span>&nbsp;");
// rep(/<br \/>/gm, "<br />\n");
rep(/(\r|\n)$/gim,"<br />");
// rep(/(\r|\n)/gim,"<br />\n"); // this will break bullets.
// e107 FIXME!
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
//
return s;
}
});
// Register plugin
tinymce.PluginManager.add('e107bbcode', tinymce.plugins.e107BBCodePlugin);
})();

View File

@@ -27,7 +27,7 @@
ed.on('postProcess', function(e) {
// console.log(e);
// alert(e.content); // remove comment to test Firefox issue: http://www.tinymce.com/develop/bugtracker_view.php?id=7655
// alert(e.content); // remove comment to test.
if (e.set) {
e.content = t['_' + dialect + '_bbcode2html'](e.content, url);

View File

@@ -450,6 +450,7 @@ class wysiwyg
{title: 'Float Clear', block: 'div', classes: 'clearfix'},
{title: 'Lead', block: 'p', classes: 'lead'},
{title: 'Well', block: 'div', classes: 'well'},
{title: 'Row', block: 'div', classes: 'row'},
{title: '1/4 Width Block', block: 'div', classes: 'col-md-3 col-sm-12'},
{title: '3/4 Width Block', block: 'div', classes: 'col-md-9 col-sm-12'},
{title: '1/3 Width Block', block: 'div', classes: 'col-md-4 col-sm-12'},

View File

@@ -1106,8 +1106,9 @@ li.rssRow > div {
.core-mainpanel-link-icon img { margin-bottom: 5px }
.sidebar-toggle { width: 50px; display: inline-block; position: absolute; margin-left: -20px; }
.sidebar-toggle a {color:#C6C6C6;}
.sidebar-toggle { width: 14px; height:300px; display: block; position: absolute; margin-left: -25px; margin-top:130px }
.sidebar-toggle a {color:#C6C6C6; height:300px; display:block; width:100%; border-right:7px double #77ACD9; opacity: 0; transition:.5s; z-index:5000; outline:0 }
.sidebar-toggle a:hover { opacity: .8; outline:0 }
#left-panel.toggled { display: none }

View File

@@ -268,6 +268,7 @@ $ADMIN_MODAL = '<div id="uiModal" class="modal hide fade" tabindex="-1" role="d
$ADMIN_HEADER .= '<div class="container-fluid">
<div class="row">
<div class="col-md-2" id="left-panel">
{SETSTYLE=admin_menu}
@@ -297,6 +298,7 @@ $ADMIN_HEADER .= '<div class="container-fluid">
</div>
<div class="col-md-10" id="right-panel" >
<div class="sidebar-toggle"><a href="#" title="Toggle Sidebar" data-toggle-sidebar="true">&nbsp;</a></div>
<div>
';

View File

@@ -156,7 +156,7 @@ $(document).ready(function()
e.preventDefault();
$("#left-panel").toggle(1000);
$("#right-panel").toggleClass("span10",0);
$("#right-panel").toggleClass("col-md-10 col-md-12"); //XXX Control animation direction?
});