diff --git a/class2.php b/class2.php index 6494efb7a..3543ed63a 100644 --- a/class2.php +++ b/class2.php @@ -690,6 +690,9 @@ function getip() return e107::getIPHandler()->ipDecode(USERIP); } + +$developerMode = (vartrue($pref['developer'],false) || E107_DEBUG_LEVEL > 0); + // for multi-language these definitions needs to come after the language loaded. define('SITENAME', trim($tp->toHTML($pref['sitename'], '', 'USER_TITLE,er_on,defs'))); define('SITEBUTTON', $tp->replaceConstants($pref['sitebutton'],'abs')); @@ -701,7 +704,8 @@ define('SITEDISCLAIMER', $tp->toHTML($pref['sitedisclaimer'], '', 'emotes_off,de define('SITECONTACTINFO', $tp->toHTML($pref['sitecontactinfo'], true, 'emotes_off,defs')); 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', vartrue($pref['developer'],false)); +define('e_DEVELOPER', $developerMode); +unset($developerMode); if(is_array($pref['xurl'])) { diff --git a/e107_admin/db.php b/e107_admin/db.php index 33ef42385..b9cd8a624 100644 --- a/e107_admin/db.php +++ b/e107_admin/db.php @@ -183,8 +183,11 @@ class system_tools if(deftrue('e_DEVELOPER')) { $this->_options['multisite'] = array('diz'=>"Developer Mode Only", 'label'=> 'Multi-Site' ); + $this->_options['github'] = array('diz'=>"Developer Mode Only Overwrite local files with the latest from github.", 'label'=> 'Sync with Github' ); } + + $this->_options = multiarray_sort($this->_options, 'label'); if(isset($_POST['delplug'])) @@ -211,7 +214,7 @@ class system_tools return; } - + // ----------------- Processes ------------------ // if(isset($_POST['verify_sql_record']) || varset($_GET['mode'])=='verify_sql_record' || isset($_POST['check_verify_sql_record']) || isset($_POST['delete_verify_sql_record'])) // { @@ -263,17 +266,28 @@ class system_tools $this->plugin_viewscan('refresh'); } - if(isset($_POST['create_multisite'])) + if(!empty($_POST['create_multisite'])) { $this->multiSiteProcess(); } - if(vartrue($_POST['perform_utf8_convert'])) + if(!empty($_POST['perform_utf8_convert'])) { $this->perform_utf8_convert(); return; } - + + if(!empty($_POST['githubSyncProcess'])) + { + $this->githubSyncProcess(); + return; + } + + + + // --------------------- Modes --------------------------------. + + if(varset($_GET['mode'])=='correct_perms') { $this->correct_perms(); @@ -285,6 +299,11 @@ class system_tools $this->multiSite(); return; } + + if(varset($_GET['mode']) == 'github') + { + $this->githubSync(); + } if(varset($_GET['mode']) == 'backup') { @@ -302,6 +321,153 @@ class system_tools } + + + + // Developer Mode ONly.. No LANS. + private function githubSync() + { + + $frm = e107::getForm(); + $mes = e107::getMessage(); + + // $message = DBLAN_70; + // $message .= "
".LAN_CREATE.""; + + $message = $frm->open('githubSync'); + $message .= "

This will download the latest .zip file from github to ".e_SYSTEM."/temp and then unzip it, overwriting any existing files that it finds on your server. It will take into account any custom folders you may have set in e107_config.php.

"; + $message .= $frm->button('githubSyncProcess',1,'delete', "Overwrite Files"); + $message .= $frm->close(); + + + $mes->addInfo($message); + + // $text = "
"; + + + e107::getRender()->tablerender(DBLAN_10.SEP."Sync with Github", $mes->render()); + + + + } + + + + + + // Developer Mode ONly.. No LANS. + private function githubSyncProcess() + { + + // 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) + { + e107::getMessage()->addError( "Couldn't download .zip file"); + } + + + $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 = "Moving ".$oldPath." to ".$newPath; + + if($v['folder'] ==1 && is_dir($newPath)) + { + // $skipped[] = $newPath. " (already exists)"; + continue; + } + + if(!rename($oldPath,$newPath)) + { + $error[] = $message; + } + else + { + $success[] = $message; + } + + + // echo $message."
"; + + } + + if(!empty($success)) + { + e107::getMessage()->addSuccess(print_a($success,true)); + } + + if(!empty($skipped)) + { + e107::getMessage()->setTitle("Skipped",E_MESSAGE_INFO)->addInfo(print_a($skipped,true)); + } + + if(!empty($error)) + { + e107::getMessage()->addError(print_a($error,true)); + } + + + + + e107::getRender()->tablerender(DBLAN_10.SEP."Sync with Github", e107::getMessage()->render()); + + } + + + + + private function backup() { diff --git a/e107_core/templates/footer_default.php b/e107_core/templates/footer_default.php index 209c5f48a..8f9347bfc 100644 --- a/e107_core/templates/footer_default.php +++ b/e107_core/templates/footer_default.php @@ -300,8 +300,10 @@ if (is_array($pref['e_footer_list'])) // Load Footer CSS // -echo "\n\n"; - +if(deftrue('e_DEVELOPER')) +{ + echo "\n\n"; +} $CSSORDER = deftrue('CSSORDER') ? explode(",",CSSORDER) : array('other','core','plugin','theme'); // INLINE CSS in Body not supported by HTML5. . foreach($CSSORDER as $val) @@ -312,8 +314,10 @@ foreach($CSSORDER as $val) unset($CSSORDER); -echo "\n\n"; - +if(deftrue('e_DEVELOPER')) +{ + echo "\n\n"; +} // [JSManager] Load JS Footer Includes by priority e107::getJs()->renderJs('footer', true); diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index c304f3780..f3e17ed75 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -23,8 +23,7 @@ $sql = e107::getDb(); $sql->db_Mark_Time('(Header Top)'); -e107::css('core', 'bootstrap-datetimepicker/css/datetimepicker.css', 'jquery'); -e107::js('core', 'bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js', 'jquery', 2); + e107::js('core', 'bootstrap/js/bootstrap-tooltip.js','jquery'); e107::css('core', 'bootstrap/css/tooltip.css','jquery'); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 04711f614..7f0a5b4bc 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -1035,7 +1035,12 @@ class e_form // $text .= "ValueFormat: ".$dateFormat." Value: ".$value; // $text .= " ({$dformat}) type:".$dateFormat." ".$value; - + + // Load it in the footer. + e107::css('core', 'bootstrap-datetimepicker/css/datetimepicker.css', 'jquery'); + e107::js('core', 'bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js', 'jquery', 2); + + return $text;