diff --git a/.codeclimate.yml b/.codeclimate.yml index cbdf341fd..72d1a0307 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -25,14 +25,14 @@ engines: enabled: false CleanCode/StaticAccess: enabled: false - CleanCode/BooleanArgumentFlag: - enabled: false UnusedFormalParameter: enabled: false Design/TooManyFields: enabled: false CleanCode/BooleanArgumentFlag: enabled: false + CleanCode/ElseExpression: + enabled: false config: file_extensions: "php" rulesets: "cleancode,unusedcode,codesize" diff --git a/class2.php b/class2.php index 4eea8597a..b955b305d 100644 --- a/class2.php +++ b/class2.php @@ -749,6 +749,8 @@ define('SITECONTACTINFO', $tp->toHTML($pref['sitecontactinfo'], true, 'emotes_of define('SITEEMAIL', vartrue($pref['replyto_email'],$pref['siteadminemail'])); define('USER_REGISTRATION', vartrue($pref['user_reg'],false)); // User Registration System Active or Not. define('e_DEVELOPER', $developerMode); +define('e_VERSION', varset($pref['version'],'')); + unset($developerMode); if(!empty($pref['xurl']) && is_array($pref['xurl'])) @@ -2669,7 +2671,7 @@ class e_http_header { $this->setHeader("X-Powered-By: e107", true); // no less secure than e107-specific html. } - + if($this->compression_server_support == true) { $this->setHeader('Vary: Accept-Encoding'); diff --git a/e107.htaccess b/e107.htaccess index a2d147762..7b029135a 100644 --- a/e107.htaccess +++ b/e107.htaccess @@ -13,6 +13,8 @@ ### Security ServerSignature Off +#Header unset Pragma + # secure htaccess file order allow,deny @@ -42,6 +44,7 @@ SetEnv HTTP_MOD_REWRITE On SetEnv HTTP_MOD_REWRITE_MEDIA On + SetEnv HTTP_MOD_REWRITE_STATIC On ### enable rewrites @@ -65,6 +68,9 @@ RewriteRule ^media\/img\/([-A-Za-z0-9+/]*={0,3})\.(jpg|gif|png)?$ thumb.php?id=$1 [NC,L] ReWriteRule ^theme\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)?$ thumb.php?src=e_THEME/$5&$1w=$2&$3h=$4 [NC,L] +### Rewrite for Static Scripts + ReWriteRule ^static\/[0-9]*\/(.*)$ $1 [NC,L] + ### send 404 on missing files in these folders RewriteCond %{REQUEST_URI} !^/(e107_images|e107_files)/ @@ -99,6 +105,13 @@ AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css text/javascript application/x-javascript application/javascript application/xml text/xml application/rss+xml + + Header set Cache-Control "public" + Header unset Cookie + Header unset Set-Cookie + # Header set Access-Control-Allow-Origin "http://mydomain.com" + + ### Enable when developing locally. ### SetEnv E_DEV true diff --git a/e107_admin/admin.php b/e107_admin/admin.php index b3828b41b..0902c064a 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -144,18 +144,18 @@ class admin_start e_PLUGIN."pm/sendpm.sc", e_PLUGIN."pm/shortcodes/", e_PLUGIN."social/e_header.php", - e_PLUGIN."download/url/url.php", - e_PLUGIN."download/url/sef_url.php", + // e_PLUGIN."download/url/url.php", + // e_PLUGIN."download/url/sef_url.php", ); - + $this->checkCoreVersion(); if(!empty($_POST['delete-deprecated'])) { $this->deleteDeprecated(); } - + unset($_SESSION['lancheck']); e107::getDb()->db_Mark_Time('Check Paths'); @@ -253,6 +253,28 @@ class admin_start } + private function checkCoreVersion() + { + + $e107info = array(); + + require(e_ADMIN."ver.php"); + + if(!empty($e107info['e107_version']) && (e_VERSION !== $e107info['e107_version'])) + { + e107::getConfig()->set('version', $e107info['e107_version'])->save(false,true,false); + + // When version has changed, clear plugin/theme version cache. + e107::getPlug()->clearCache(); + e107::getTheme()->clearCache(); + + e107::getDebug()->log("Updating core version pref"); + } + + } + + + private function checkCoreUpdate() { // auto db update @@ -577,11 +599,13 @@ TMPO; if(@unlink($file)) { - $mes->addSuccess("Deleted ".$file); + $message = e107::getParser()->lanVars(LAN_UI_FILE_DELETED, array('x'=>$file)); + $mes->addSuccess($message); } else { - $mes->addError("Unable to delete ".$file.". Please remove the file manually."); + $message = e107::getParser()->lanVars(LAN_UI_FILE_DELETED_FAILED, array('x'=>$file)); + $mes->addError($message); } } diff --git a/e107_admin/db.php b/e107_admin/db.php index cdd9bda27..9389dbe18 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -359,89 +359,18 @@ class system_tools // Developer Mode ONly.. No LANS. private function githubSyncProcess() { + $result = e107::getFile()->unzipGithubArchive('core'); - // Delete any existing file. - if(file_exists(e_TEMP."e107-master.zip")) - { - unlink(e_TEMP."e107-master.zip"); - } - - $result = e107::getFile()->getRemoteFile('https://codeload.github.com/e107inc/e107/zip/master', 'e107-master.zip', 'temp'); - - if($result == false) + if($result === false) { e107::getMessage()->addError( DBLAN_118 ); + return null; } + $success = $result['success']; + $error = $result['error']; - $localfile = 'e107-master.zip'; - - chmod(e_TEMP.$localfile, 0755); - require_once(e_HANDLER."pclzip.lib.php"); - -// $base = realpath(dirname(__FILE__)); - - - $newFolders = array( - 'e107-master/e107_admin/' => e_BASE.e107::getFolder('ADMIN'), - 'e107-master/e107_core/' => e_BASE.e107::getFolder('CORE'), - 'e107-master/e107_docs/' => e_BASE.e107::getFolder('DOCS'), - 'e107-master/e107_handlers/' => e_BASE.e107::getFolder('HANDLERS'), - 'e107-master/e107_images/' => e_BASE.e107::getFolder('IMAGES'), - 'e107-master/e107_languages/' => e_BASE.e107::getFolder('LANGUAGES'), - 'e107-master/e107_media/' => e_BASE.e107::getFolder('MEDIA'), - 'e107-master/e107_plugins/' => e_BASE.e107::getFolder('PLUGINS'), - 'e107-master/e107_system/' => e_BASE.e107::getFolder('SYSTEM'), - 'e107-master/e107_themes/' => e_BASE.e107::getFolder('THEMES'), - 'e107-master/e107_web/' => e_BASE.e107::getFolder('WEB'), - 'e107-master/' => e_BASE - ); - - $srch = array_keys($newFolders); - $repl = array_values($newFolders); - - $archive = new PclZip(e_TEMP.$localfile); - $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_TEMP, PCLZIP_OPT_SET_CHMOD, 0755)); // Store in TEMP first. - - $error = array(); - $success = array(); - $skipped = array(); -// print_a($unarc); - - - $excludes = array('e107-master/','e107-master/install.php','e107-master/favicon.ico'); - - foreach($unarc as $k=>$v) - { - if(in_array($v['stored_filename'],$excludes)) - { - continue; - } - - $oldPath = $v['filename']; - $newPath = str_replace($srch,$repl, $v['stored_filename']); - - $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath)); - - if($v['folder'] ==1 && is_dir($newPath)) - { - // $skipped[] = $newPath. " (already exists)"; - continue; - } - - if(!rename($oldPath,$newPath)) - { - $error[] = $message; - } - else - { - $success[] = $message; - } - - - // echo $message."
"; - - } + // $message = e107::getParser()->lanVars(DBLAN_121, array('x'=>$oldPath, 'y'=>$newPath)); if(!empty($success)) { @@ -458,9 +387,6 @@ class system_tools e107::getMessage()->addError(print_a($error,true)); } - - - e107::getRender()->tablerender(DBLAN_10.SEP.DBLAN_112, e107::getMessage()->render()); } diff --git a/e107_admin/eurl.php b/e107_admin/eurl.php index b2940820b..ef0f792ec 100644 --- a/e107_admin/eurl.php +++ b/e107_admin/eurl.php @@ -469,8 +469,8 @@ class eurl_admin_ui extends e_admin_controller_ui if(!empty($_POST['eurl_profile'])) { e107::getConfig()->set('url_profiles', $_POST['eurl_profile']); - unset($locations['download']); - unset($config['download']); + // unset($locations['download']); + // unset($config['download']); } e107::getConfig() diff --git a/e107_admin/includes/flexpanel.php b/e107_admin/includes/flexpanel.php index 65aeb6140..f830747fa 100644 --- a/e107_admin/includes/flexpanel.php +++ b/e107_admin/includes/flexpanel.php @@ -212,11 +212,11 @@ class adminstyle_flexpanel extends adminstyle_infopanel // --------------------- Website Status --------------------------- - $ns->setStyle('flexpanel'); + /* $ns->setStyle('flexpanel'); $ns->setUniqueId('core-infopanel_website_status'); - $coreInfoPanelWebsiteStatus = $ns->tablerender(LAN_WEBSITE_STATUS, $this->renderWebsiteStatus(), "core-infopanel_website_status", true); + $coreInfoPanelWebsiteStatus = '';// 'hi';/// "
".$this->renderAddonDashboards()."
"; $ns->tablerender(LAN_WEBSITE_STATUS, $this->renderAddonDashboards(), "core-infopanel_website_status", true); $info = $this->getMenuPosition('core-infopanel_website_status'); - $panels[$info['area']][$info['weight']] .= $coreInfoPanelWebsiteStatus; + $panels[$info['area']][$info['weight']] .= $coreInfoPanelWebsiteStatus;*/ // --------------------- Latest Comments -------------------------- @@ -254,6 +254,26 @@ class adminstyle_flexpanel extends adminstyle_infopanel } } + + // --------------------- Plugin Addon Dashboards ---------------------- eg. e107_plugin/user/e_dashboard.php + $dashboards = $this->getAddonDashboards(); + if(!empty($dashboards)) + { + $ns->setStyle('flexpanel'); + foreach($dashboards as $val) + { + $id = $val['mode']; + $ns->setUniqueId($id); + $inc = $ns->tablerender($val['caption'], $val['text'], $val['mode'], true); + + $info = $this->getMenuPosition($id); + + $panels[$info['area']][$info['weight']] .= $inc; + } + + } + + // Sorting panels. foreach($panels as $key => $value) { @@ -292,7 +312,7 @@ class adminstyle_flexpanel extends adminstyle_infopanel { $user_pref = $this->getUserPref(); - if(varset($user_pref['core-flexpanel-order'][$id])) + if(!empty($user_pref['core-flexpanel-order'][$id])) { return $user_pref['core-flexpanel-order'][$id]; } @@ -311,6 +331,14 @@ class adminstyle_flexpanel extends adminstyle_infopanel return $positions[$layout][$id]; } + if(strpos($id,'plug-infopanel-') === 0) // addon dashboards default to area 2. + { + $default = array( + 'area' => 'menu-area-02', + 'weight' => 1000, + ); + } + return $default; } diff --git a/e107_admin/includes/infopanel.php b/e107_admin/includes/infopanel.php index f7866925a..d0a88b90b 100644 --- a/e107_admin/includes/infopanel.php +++ b/e107_admin/includes/infopanel.php @@ -264,7 +264,7 @@ class adminstyle_infopanel - $text3 .= $ns->tablerender(LAN_WEBSITE_STATUS, $this->renderWebsiteStatus(),"",true); + // $text3 .= $ns->tablerender(LAN_WEBSITE_STATUS, $this->renderWebsiteStatus(),"",true); @@ -364,7 +364,7 @@ class adminstyle_infopanel } } - +/* private function renderChart() { @@ -374,51 +374,62 @@ class adminstyle_infopanel { return $this->renderStats('log'); } - /* elseif(e107::isInstalled('awstats')) - { - return $this->renderStats('awstats'); - }*/ + else { return $this->renderStats('demo'); } - } + }*/ function renderWebsiteStatus() { - $tp = e107::getParser(); + return; + /* $tp = e107::getParser(); $tab = array(); $tab['e-stats'] = array('caption'=>$tp->toGlyph('fa-signal').' '.LAN_STATS, 'text'=>$this->renderChart()); $tab['e-online'] = array('caption'=>$tp->toGlyph('fa-user').' '.LAN_ONLINE.' ('.$this->renderOnlineUsers('count').')', 'text'=>$this->renderOnlineUsers()); - return e107::getForm()->tabs($tab); + return e107::getForm()->tabs($tab);*/ } - function renderAddonDashboards() + function getAddonDashboards() { - $panel = array(); - $ns = e107::getRender(); + $arr = array(); - $text = ''; if($plugs = e107::getAddonConfig('e_dashboard',null, 'chart')) { foreach($plugs as $plug => $val) { + $adg = e107::getAddon($plug,'e_dashboard'); + + if(!empty($adg->chartCaption)) + { + $cap = $adg->chartCaption; + } + else + { + $cap = defset('LAN_PLUGIN_'.strtoupper($plug).'_NAME', ucfirst($plug)); + } + foreach($val as $k=>$item) { + + if(!empty($item)) { // $var[] = $item; - $renderMode = 'plug-infopanel-'.$plug; + $renderMode = 'plug-infopanel-'.$plug."-".intval($k); - if(isset($item[$k]['text'])) + + if(!isset($item['text'])) { + foreach ($item as $key => $v) // make sure the ids are unique. { $newkey = eHelper::dasherize($plug.'-'.$k.'-'.$key); @@ -427,12 +438,16 @@ class adminstyle_infopanel } $t = e107::getForm()->tabs($item); - $cap = defset('LAN_PLUGIN_'.strtoupper($plug).'_NAME', ucfirst($plug)); - $text .= $ns->tablerender($cap, $t, $renderMode, true); + + + + // $text .= $ns->tablerender($cap, $t, $renderMode, true); + $arr[] = array('caption'=>$cap, 'text'=>$t, 'mode'=>$renderMode); } else { - $text .= $ns->tablerender($item['caption'], $item['text'], $renderMode, true); + // $text .= $ns->tablerender($item['caption'], $item['text'], $renderMode, true); + $arr[] = array('caption'=>$item['caption'], 'text'=>$item['text'], 'mode'=>$renderMode); } } } @@ -440,129 +455,29 @@ class adminstyle_infopanel } } + + return $arr; + } + + + + function renderAddonDashboards() + { + $ns = e107::getRender(); + $arr = $this->getAddonDashboards(); + $text = ''; + + foreach($arr as $val) + { + $text .= $ns->tablerender($val['caption'], $val['text'], $val['mode'], true); + + } + return $text; } - function renderOnlineUsers($data=false) - { - - $ol = e107::getOnline(); - $tp = e107::getParser(); - $multilan = e107::getPref('multilanguage'); - - $panelOnline = " - - - - - - - - "; - - - $panelOnline .= (!empty($multilan)) ? "" : ""; - - - $panelOnline .= " - - - - - - - - - "; - - $panelOnline .= (!empty($multilan)) ? "" : ""; - - $panelOnline .= " - - - "; - - - - $online = $ol->userList() + $ol->guestList(); - - if($data == 'count') - { - return count($online); - } - - // echo "Users: ".print_a($online); - - $lng = e107::getLanguage(); - - foreach ($online as $val) - { - $panelOnline .= " - - - - - - "; - - $panelOnline .= (!empty($multilan)) ? "" : ""; - - - $panelOnline .= " - - "; - } - - - $panelOnline .= "
".LAN_TIMESTAMP."".LAN_USER."".LAN_IP."".LAN_PAGE."".LAN_AGENT."".LAN_LANG."
".e107::getDateConvert()->convert_date($val['user_currentvisit'],'%H:%M:%S')."".$this->renderOnlineName($val['online_user_id'])."".e107::getIPHandler()->ipDecode($val['user_ip'])."".$tp->html_truncate(basename($val['user_location']),50,"...")."".$this->browserIcon($val)."convert($val['user_language'])."\">".$val['user_language']."
"; - - return $panelOnline; - } - - - function browserIcon($row) - { - - $types = array( - "ie" => "MSIE", - 'chrome' => 'Chrome', - 'firefox' => 'Firefox', - 'seamonkey' => 'Seamonkey', - // 'Chromium/xyz - 'safari' => "Safari", - 'opera' => "Opera" - ); - - - if($row['user_bot'] === true) - { - return ""; - } - - foreach($types as $icon=>$b) - { - if(strpos($row['user_agent'], $b)!==false) - { - return ""; - } - } - - return ""; // FIXME find a default icon. - } - - - function renderOnlineName($val) - { - if($val==0) - { - return LAN_GUEST; - } - return $val; - } - - function renderLatestComments() { $sql = e107::getDb(); @@ -768,202 +683,11 @@ class adminstyle_infopanel return $text; } - - private function getStats($type) - { - /* - - if(file_exists(e_PLUGIN."awstats/awstats.graph.php")) - { - require_once(e_PLUGIN."awstats/awstats.graph.php"); - $stat = new awstats; - - if($data = $stat->getData()) - { - return $data; - } - - // return; - } - */ if($type == 'demo') - { - $data = array(); - - $months = e107::getDate()->terms('month'); - - $data['labels'] = array($months[0], //"January", - $months[1], //"February", - $months[2], //"March", - $months[3], //"April", - $months[4], //"May", - $months[5], //"June", - $months[6] //"July" - ); - - $data['datasets'][] = array( - 'fillColor' => "rgba(220,220,220,0.5)", - 'strokeColor' => "rgba(220,220,220,1)", - 'pointColor ' => "rgba(220,220,220,1)", - 'pointStrokeColor' => "#fff", - 'data' => array(65,59,90,81,56,55,40), - 'title' => ADLAN_168// "Visits" - ); - - $data['datasets'][] = array( - 'fillColor' => "rgba(151,187,205,0.5)", - 'strokeColor' => "rgba(151,187,205,1)", - 'pointColor ' => "rgba(151,187,205,1)", - 'pointStrokeColor' => "#fff", - 'data' => array(28,48,40,19,96,27,100), - 'title' => ADLAN_169 //"Unique Visits" - ); - - return $data; - } - - - - $sql = e107::getDB(); - - $td = date("Y-m-j", time()); - $dayarray[$td] = array(); - $pagearray = array(); - - $qry = " - SELECT * from #logstats WHERE log_id REGEXP('[[:digit:]]+\-[[:digit:]]+\-[[:digit:]]+') - ORDER BY CONCAT(LEFT(log_id,4), SUBSTRING(log_id, 6, 2), LPAD(SUBSTRING(log_id, 9), 2, '0')) - DESC LIMIT 0,9 - "; - - if($amount = $sql->gen($qry)) - { - $array = $sql->db_getList(); - - $ttotal = 0; - $utotal = 0; - - foreach($array as $key => $value) - { - extract($value); - $log_id = substr($log_id, 0, 4).'-'.substr($log_id, 5, 2).'-'.str_pad(substr($log_id, 8), 2, '0', STR_PAD_LEFT); - if(is_array($log_data)) { - $entries[0] = $log_data['host']; - $entries[1] = $log_data['date']; - $entries[2] = $log_data['os']; - $entries[3] = $log_data['browser']; - $entries[4] = $log_data['screen']; - $entries[5] = $log_data['referer']; - } - else - { - $entries = explode(chr(1), $log_data); - } - - $dayarray[$log_id]['daytotal'] = $entries[0]; - $dayarray[$log_id]['dayunique'] = $entries[1]; - - unset($entries[0]); - unset($entries[1]); - - foreach($entries as $entry) - { - if($entry) - { - list($url, $total, $unique) = explode("|", $entry); - if(strstr($url, "/")) - { - $urlname = preg_replace("/\.php|\?.*/", "", substr($url, (strrpos($url, "/")+1))); - } - else - { - $urlname = preg_replace("/\.php|\?.*/", "", $url); - } - $dayarray[$log_id][$urlname] = array('url' => $url, 'total' => $total, 'unique' => $unique); - if (!isset($pagearray[$urlname]['total'])) $pagearray[$urlname]['total'] = 0; - if (!isset($pagearray[$urlname]['unique'])) $pagearray[$urlname]['unique'] = 0; - $pagearray[$urlname]['total'] += $total; - $pagearray[$urlname]['unique'] += $unique; - $ttotal += $total; - $utotal += $unique; - } - } - } - } - - $logfile = e_LOG.'logp_'.date('z.Y', time()).'.php'; // was logi_ ?? - if(is_readable($logfile)) - { - require($logfile); - } - - - - if(vartrue($pageInfo)) - { - foreach($pageInfo as $fkey => $fvalue) - { - $dayarray[$td][$fkey]['total'] += $fvalue['ttl']; - $dayarray[$td][$fkey]['unique'] += $fvalue['unq']; - $dayarray[$td]['daytotal'] += $fvalue['ttl']; - $dayarray[$td]['dayunique'] += $fvalue['unq']; - $pagearray[$fkey]['total'] += $fvalue['ttl']; - $pagearray[$fkey]['unique'] += $fvalue['unq']; - $ttotal += $fvalue['ttl']; - $utotal += $fvalue['unq']; - } - } - - - $visitors = array(); - $unique = array(); - - - ksort($dayarray); - foreach($dayarray as $k=>$v) - { - $unix = strtotime($k); - - $visitors[] = intval(vartrue($v['daytotal'])); - $unique[] = intval(vartrue($v['dayunique'])); - $label[] = "'".date("D",$unix)."'"; - } - - $data = array(); - - $data['labels'] = $label; - - //visitors - $data['datasets'][] = array( - 'fillColor' => "rgba(220,220,220,0.5)", - 'strokeColor' => "rgba(220,220,220,1)", - 'pointColor ' => "rgba(220,220,220,1)", - 'pointStrokeColor' => "#fff", - 'data' => $visitors - - ); - - - //Unique Visitors - $data['datasets'][] = array( - 'fillColor' => "rgba(151,187,205,0.5)", - 'strokeColor' => "rgba(151,187,205,1)", - 'pointColor ' => "rgba(151,187,205,1)", - 'pointStrokeColor' => "#fff", - 'data' => $unique - ); - - - - return $data; - - - } - - private function renderStats($type) +/* private function renderStats($type) { $data = $this->getStats($type); @@ -994,7 +718,7 @@ class adminstyle_infopanel return $text; - } + }*/ } ?> diff --git a/e107_admin/includes/layouts/flexpanel_default.php b/e107_admin/includes/layouts/flexpanel_default.php index fa4159ffb..46ba26a30 100644 --- a/e107_admin/includes/layouts/flexpanel_default.php +++ b/e107_admin/includes/layouts/flexpanel_default.php @@ -37,7 +37,7 @@ $FLEXPANEL_LAYOUT = ' -
+
-
+