public function debugHelper() { echo "<pre>"; echo "<b>Kajona V4 Debug Subsystem</b>\n\n"; if (getGet("debugfile") != "") { echo "Loading path for " . getGet("debugfile") . "\n"; $strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"))); if ($strPath !== false) { echo "Passing request to " . $strPath . "\n\n"; include _realpath_ . $strPath; } } else { echo "Searching for debug-scripts available...\n"; $arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")); echo "<ul>"; foreach ($arrFiles as $strPath => $strOneFile) { echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>"; } echo "</ul>"; } $arrTimestampEnde = gettimeofday(); $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000; echo "\n\n<b>PHP-Time:</b> " . number_format($intTimeUsed, 6) . " sec \n"; echo "<b>Queries db/cachesize/cached/fired:</b> " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n"; echo "<b>Templates cached:</b> " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n"; echo "<b>Memory/Max Memory:</b> " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n"; echo "<b>Classes Loaded:</b> " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n"; echo "<b>Cache requests/hits/saves/cachesize:</b> " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n"; echo "</pre>"; }
/** * * Does the hard work: installs the module and registers needed constants * * @return string */ public function install() { $strReturn = ""; $strReturn .= "Assigning null-properties and elements to the default language.\n"; if ($this->strContentLanguage == "de") { $strReturn .= " Target language: de\n"; if (class_exists("class_module_pages_page", false) || class_classloader::getInstance()->loadClass("class_module_pages_page") !== false) { class_module_pages_page::assignNullProperties("de", true); } if (class_exists("class_module_pages_pageelement", false) || class_classloader::getInstance()->loadClass("class_module_pages_pageelement") !== false) { class_module_pages_pageelement::assignNullElements("de"); } $objLang = new class_module_languages_language(); $objLang->setStrAdminLanguageToWorkOn("de"); } else { $strReturn .= " Target language: en\n"; if (class_exists("class_module_pages_page", false) || class_classloader::getInstance()->loadClass("class_module_pages_page") !== false) { class_module_pages_page::assignNullProperties("en", true); } if (class_exists("class_module_pages_pageelement", false) || class_classloader::getInstance()->loadClass("class_module_pages_pageelement") !== false) { class_module_pages_pageelement::assignNullElements("en"); } $objLang = new class_module_languages_language(); $objLang->setStrAdminLanguageToWorkOn("en"); } return $strReturn; }
protected function printDebugValues() { $strDebug = ""; $arrTimestampEnde = gettimeofday(); $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTestStartDate['sec'] * 1000000 + $this->arrTestStartDate['usec'])) / 1000000; $strDebug .= "PHP-Time: " . number_format($intTimeUsed, 6) . " sec \n"; //Hows about the queries? $strDebug .= "Queries db/cachesize/cached/fired: " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . " \n"; //anything to say about the templates? $strDebug .= "Templates cached: " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n"; //memory $strDebug .= "Memory/Max Memory: " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n"; $strDebug .= "Classes Loaded: " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n"; //and check the cache-stats $strDebug .= "Cache requests/hits/saves/cachesize: " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n"; //echo get_called_class()."\n".$strDebug."\n"; }
/** * The real "download" or "upload" should be handled right here. * All packages have to be downloaded to /project/temp in order to be processed afterwards. * * @return string the filename of the package downloaded */ public function processPackageUpload() { //fetch the upload, validate a few settings and copy the package to /project/temp $arrSource = class_carrier::getInstance()->getParam("provider_local_file"); $strTarget = "/project/temp/" . generateSystemid() . ".zip"; $objFilesystem = new class_filesystem(); //Check file for correct filters $strSuffix = uniStrtolower(uniSubstr($arrSource["name"], uniStrrpos($arrSource["name"], "."))); if (in_array($strSuffix, array(".zip"))) { if ($objFilesystem->copyUpload($strTarget, $arrSource["tmp_name"])) { class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("uploaded package " . $arrSource["name"] . " to " . $strTarget, class_logger::$levelInfo); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); return $strTarget; } } class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("error in uploaded package " . $arrSource["name"] . " either wrong format or not writeable target folder", class_logger::$levelInfo); @unlink($arrSource["tmp_name"]); return null; }
/** * @permissions edit * @return string */ protected function actionCopyPack() { $objForm = $this->getPackAdminForm(); $strPackName = $this->getParam("pack_name"); $strPackName = createFilename($strPackName, true); if ($strPackName != "" && is_dir(_realpath_ . _templatepath_ . "/" . $strPackName)) { $objForm->addValidationError("name", $this->getLang("pack_folder_existing")); } if (!$objForm->validateForm()) { return $this->actionNew($objForm); } $objFilesystem = new class_filesystem(); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/tpl"); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/css"); $objFilesystem->folderCreate(_templatepath_ . "/" . $strPackName . "/js"); $arrModules = $this->getParam("pack_modules"); foreach ($arrModules as $strName => $strValue) { if ($strValue != "") { $objFilesystem->folderCopyRecursive(class_resourceloader::getInstance()->getCorePathForModule($strName) . "/" . $strName . "/templates/default", _templatepath_ . "/" . $strPackName); } } class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); $this->adminReload(class_link::getLinkAdminHref($this->getArrModule("modul"), "listTemplates")); return ""; }
protected function tearDown() { unlink(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/class_module_genericeventdispatcher_test.php"); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); parent::tearDown(); }
rawIncludeError("global exception handler"); } //register global exception handler for exceptions thrown but not catched (bad style ;) ) @set_exception_handler(array("class_exception", "globalExceptionHandler")); //Include the logging-engine if (!@(include_once _corepath_ . "/module_system/system/class_logger.php")) { rawIncludeError("logging engine"); } //---The Path on web------------------------------------------------------------------------------------- require_once _corepath_ . "/module_system/system/class_config.php"; $strHeaderName = class_config::readPlainConfigsFromFilesystem("https_header"); $strHeaderValue = strtolower(class_config::readPlainConfigsFromFilesystem("https_header_value")); if (strpos($_SERVER['SCRIPT_FILENAME'], "/debug/")) { //Determine the current path on the web $strWeb = dirname((isset($_SERVER[$strHeaderName]) && strtolower($_SERVER[$strHeaderName]) == $strHeaderValue ? "https://" : "http://") . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']); define("_webpath_", saveUrlEncode(substr_replace($strWeb, "", strrpos($strWeb, "/")))); } else { //Determine the current path on the web $strWeb = dirname((isset($_SERVER[$strHeaderName]) && strtolower($_SERVER[$strHeaderName]) == $strHeaderValue ? "https://" : "http://") . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : "localhost") . $_SERVER['SCRIPT_NAME']); define("_webpath_", saveUrlEncode($strWeb)); } //---Include Section 2----------------------------------------------------------------------------------- //load module-ids bootstrapIncludeModuleIds(); //---Auto-Loader for classes----------------------------------------------------------------------------- require_once _corepath_ . "/module_system/system/class_classloader.php"; spl_autoload_register(array(class_classloader::getInstance(), "loadClass")); //The Carrier-Class if (!@(include_once _corepath_ . "/module_system/system/class_carrier.php")) { rawIncludeError("carrier-class"); }
/** * Deletes all cached resource-information, * so the .cache-files. * @return void */ public function flushCache() { $objFilesystem = new class_filesystem(); $objFilesystem->fileDelete($this->strTemplatesCacheFile); $objFilesystem->fileDelete($this->strFoldercontentCacheFile); $objFilesystem->fileDelete($this->strFoldercontentLangFile); $this->arrModules = class_classloader::getInstance()->getArrModules(); $this->arrFoldercontent = array(); $this->arrTemplates = array(); $this->arrLangfiles = array(); }
protected function tearDown() { unlink(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/class_module_pluginmanager_test.php"); unlink(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/class_module_pluginmanager2_test.php"); unlink(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system/class_module_pluginmanager3_test.php"); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); parent::tearDown(); }
/** * Generates debugging-infos, but only in non-xml mode * * @param string $strReturn * * @return string */ private function getDebugInfo($strReturn) { $strDebug = ""; if (_timedebug_ || _dbnumber_ || _templatenr_ || _memory_) { //Maybe we need the time used to generate this page if (_timedebug_ === true) { $arrTimestampEnde = gettimeofday(); $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000; $strDebug .= "<b>PHP-Time:</b> " . number_format($intTimeUsed, 6) . " sec "; } //Hows about the queries? if (_dbnumber_ === true) { $strDebug .= "<b>Queries db/cachesize/cached/fired:</b> " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . " "; } //anything to say about the templates? if (_templatenr_ === true) { $strDebug .= "<b>Templates cached:</b> " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " "; } //memory if (_memory_ === true) { $strDebug .= "<b>Memory/Max Memory:</b> " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " "; $strDebug .= "<b>Classes Loaded:</b> " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " "; } //and check the cache-stats if (_cache_ === true) { $strDebug .= "<b>Cache requests/hits/saves/cachesize:</b> " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " "; } if (_xmlLoader_ === true) { class_response_object::getInstance()->addHeader("Kajona Debug: " . $strDebug); } else { $strDebug = "<pre style='z-index: 2000000; position: fixed; background-color: white; width: 100%; top: 0px; font-size: 10px; padding: 0; margin: 0;'>Kajona Debug: " . $strDebug . "</pre>"; $intBodyPos = uniStrpos($strReturn, "</body>"); if ($intBodyPos !== false) { $strReturn = uniSubstr($strReturn, 0, $intBodyPos) . $strDebug . uniSubstr($strReturn, $intBodyPos); } else { $strReturn = $strDebug . $strReturn; } } } return $strReturn; }
private function update_43_431() { $strReturn = "Updating 4.3 to 4.3.1...\n"; $strReturn .= "This update removes the flot chart module and replaces it with the jqplot chart module...\n\n"; //1. install module jqplot $strReturn .= "Installing module jqplot if not exist...\n"; $objManager = new class_module_packagemanager_manager(); $objExistingJqPlotPackage = $objManager->getPackage("jqplot"); //if jqplot is not installed, install it if ($objExistingJqPlotPackage === null) { $objContentProvider = new class_module_packagemanager_contentprovider_kajona(); $arrPackageMetaData = $objContentProvider->searchPackage("jqplot"); //if a package was found if ($arrPackageMetaData !== null && count($arrPackageMetaData) == 1) { //upload the package to projects/temp class_carrier::getInstance()->setParam("systemid", $arrPackageMetaData[0]["systemid"]); $strFile = $objContentProvider->processPackageUpload(); if ($objManager->validatePackage($strFile)) { if (uniSubstr($strFile, -4) == ".zip") { //now extract the zip file and...... $objHandler = $objManager->extractPackage($strFile); $objFilesystem = new class_filesystem(); $objFilesystem->fileDelete($strFile); //move the created folder to /core $objHandler->move2Filesystem(); } } else { $strReturn .= "Package file is not valid...\n"; $strReturn .= "Update to version 4.3.1 cancelled...\n"; return $strReturn; } } else { $strReturn = "Module jqplot was not found via the packagemanager...\n"; $strReturn .= "Update to version 4.3.1 cancelled...\n"; return $strReturn; } } //2. uninstall module flot $strReturn .= "Removing module flotchart if exists...\n"; $objFlotPackage = $objManager->getPackage("flotchart"); if ($objFlotPackage !== null) { //uninstall flot $class_filesystem = new class_filesystem(); $class_filesystem->folderDeleteRecursive($objFlotPackage->getStrPath()); } //3. set jqplot as standard chart library $strReturn .= "Set jqplot as standard chart library if flot was selected standard chart library...\n"; $objSetting = class_module_system_setting::getConfigByName("_system_graph_type_"); if ($objSetting->getStrValue() == "flot") { $objSetting->setStrValue("jqplot"); $objSetting->updateObjectToDb(); } //4. update version to 4.3.1 $strReturn .= "Updating module-versions...\n"; $this->updateModuleVersion("", "4.3.1"); //5. reload classloader etc. class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); return $strReturn; }
* (c) 2004-2006 by MulchProductions, www.mulchprod.de * * (c) 2007-2015 by Kajona, www.kajona.de * * Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt * *-------------------------------------------------------------------------------------------------------* * $Id$ * ********************************************************************************************************/ echo "+-------------------------------------------------------------------------------+\n"; echo "| Kajona Debug Subsystem |\n"; echo "| |\n"; echo "| Format Lang Files |\n"; echo "| |\n"; echo "| Use this script to format all language files. |\n"; echo "| The formatter is based on the Kajona language editor, so you need Java >= 1.6.|\n"; echo "+-------------------------------------------------------------------------------+\n"; if (issetPost("format")) { foreach (class_classloader::getInstance()->getCoreDirectories() as $strOneCore) { $strJavaCommand = "java -jar '" . _realpath_ . "/" . $strOneCore . "/_debugging/debug/KajonaLanguageEditorCore.jar' --formatLangfiles --projectFolder '" . _realpath_ . "' "; echo "starting formatting...\n"; echo "\rcalling " . $strJavaCommand . "\n"; $intTemp = ""; $arrOuput = array(); exec($strJavaCommand, $arrOuput, $intTemp); echo "\n\texit code: " . $intTemp . "\n\n"; foreach ($arrOuput as $strOneLine) { echo "\t" . $strOneLine . "\n"; } echo "\n...finished\n"; echo "\nIf you encounter an exit code of 127, provide the full path to java in the header of the file.\n"; } } else { echo "<form method=\"post\">";
/** * Load Plugins from a given folder filtered by an interface * * @param $strPath * @param $strInterfaceExtensionPoint */ public function loadPluginsFiltered($strPath, $strInterfaceExtensionPoint) { $arrPlugins = class_resourceloader::getInstance()->getFolderContent($strPath, array(".php")); // Register new Folder to Classloader class_classloader::getInstance()->addClassFolder($strPath); if ($strInterfaceExtensionPoint != null) { $this->setFilterExtensionPoints($strInterfaceExtensionPoint); } foreach ($arrPlugins as $strOnePlugin) { $strClassName = str_replace(".php", "", $strOnePlugin); /** @var $objPlugin interface_admininterface_plugin */ $objPlugin = new $strClassName($this->objDB, $this->objToolkit, $this->objLang); if ($objPlugin instanceof interface_admininterface_plugin && $this->matchFilter($objPlugin)) { $objPlugin->registerPlugin($this); } } }
/** * The real "download" or "upload" should be handled right here. * All packages have to be downloaded to /project/temp in order to be processed afterwards. * * @return string the filename of the package downloaded */ public function processPackageUpload() { $strFilename = generateSystemid() . ".zip"; //stream the original package $objRemoteloader = $this->getRemoteloader(); $objRemoteloader->setBitCacheEnabled(false); $objRemoteloader->setStrQueryParams($this->STR_DOWNLOAD_URL . "?systemid=" . $this->getParam("systemid")); $strResponse = $objRemoteloader->getRemoteContent(); file_put_contents(_realpath_ . _projectpath_ . "/temp/" . $strFilename, $strResponse); class_resourceloader::getInstance()->flushCache(); class_classloader::getInstance()->flushCache(); class_reflection::flushCache(); return _projectpath_ . "/temp/" . $strFilename; }
/** * A general helper to flush the systems various caches. * * @param int $intCacheType A bitmask of caches to be flushed, e.g. class_carrier::INT_CACHE_TYPE_DBQUERIES | class_carrier::INT_CACHE_TYPE_ORMCACHE */ public function flushCache($intCacheType = 0) { if ($intCacheType & self::INT_CACHE_TYPE_DBQUERIES) { $this->getObjDB()->flushQueryCache(); } if ($intCacheType & self::INT_CACHE_TYPE_DBSTATEMENTS) { $this->getObjDB()->flushPreparedStatementsCache(); } if ($intCacheType & self::INT_CACHE_TYPE_DBTABLES) { $this->getObjDB()->flushTablesCache(); } if ($intCacheType & self::INT_CACHE_TYPE_ORMCACHE) { class_orm_rowcache::flushCache(); } if ($intCacheType & self::INT_CACHE_TYPE_OBJECTFACTORY) { class_objectfactory::getInstance()->flushCache(); } if ($intCacheType & self::INT_CACHE_TYPE_MODULES) { class_module_system_module::flushCache(); } if ($intCacheType & self::INT_CACHE_TYPE_CLASSLOADER) { class_classloader::getInstance()->flushCache(); } if ($intCacheType & self::INT_CACHE_TYPE_APC) { class_apc_cache::getInstance()->flushCache(); } if ($intCacheType & self::INT_CACHE_TYPE_CHANGELOG) { $objChangelog = new class_module_system_changelog(); $objChangelog->processCachedInserts(); } }
/** * Makes a few checks on files and settings for a correct webserver */ public function checkPHPSetting() { $strReturn = ""; $arrFilesAndFolders = array("/project/system/config", "/project/dbdumps", "/project/log", "/project/temp", "/files/cache", "/files/images", "/files/public", "/files/downloads", "/templates/default"); $arrFilesAndFolders = array_merge($arrFilesAndFolders, array_map(function ($strValue) { return "/" . $strValue; }, class_classloader::getInstance()->getCoreDirectories())); $arrModules = array("mbstring", "gd", "xml", "zip", "openssl"); $strReturn .= $this->getLang("installer_phpcheck_intro"); $strReturn .= $this->getLang("installer_phpcheck_lang"); //link to different languages $arrLangs = explode(",", class_carrier::getInstance()->getObjConfig()->getConfig("adminlangs")); $intLangCount = 1; foreach ($arrLangs as $strOneLang) { $strReturn .= "<a href=\"" . _webpath_ . "/installer.php?language=" . $strOneLang . "\">" . class_carrier::getInstance()->getObjLang()->getLang("lang_" . $strOneLang, "user") . "</a>"; if ($intLangCount++ < count($arrLangs)) { $strReturn .= " | "; } } $strReturn .= "<br />" . $this->getLang("installer_phpcheck_intro2") . "<ul>"; foreach ($arrFilesAndFolders as $strOneFile) { $strReturn .= "<li>" . $this->getLang("installer_phpcheck_folder") . $strOneFile . " "; if (is_writable(_realpath_ . $strOneFile)) { $strReturn .= "<span class=\"label label-success\">" . $this->getLang("installer_given") . "</span>."; } else { $strReturn .= "<span class=\"label label-danger\">" . $this->getLang("installer_missing") . "</span>!"; } $strReturn .= "</li>"; } foreach ($arrModules as $strOneModule) { $strReturn .= "<li>" . $this->getLang("installer_phpcheck_module") . $strOneModule . " "; if (in_array($strOneModule, get_loaded_extensions())) { $strReturn .= " <span class=\"label label-success\">" . $this->getLang("installer_loaded") . "</span>."; } else { $strReturn .= " <span class=\"label label-danger\">" . $this->getLang("installer_nloaded") . "</span>!"; } $strReturn .= "</li>"; } $strReturn .= "</ul>"; $this->strForwardLink = $this->getForwardLink(_webpath_ . "/installer.php?step=config"); $this->strBackwardLink = ""; $this->strOutput = $strReturn; }