Ejemplo n.º 1
0
 public static function debug($message)
 {
     logger::log($message, LOG_SYS_DEBUG);
 }
Ejemplo n.º 2
0
 /**
 +----------------------------------------------------------
 * 日志保存
 +----------------------------------------------------------
 * @static
 * @access public
 +----------------------------------------------------------
 * @param integer $type 日志记录方式
 * @param string $destination  写入目标
 * @param string $extra 额外参数
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 static function save($type = self::FILE, $destination = '', $extra = '')
 {
     if (empty($destination)) {
         if (!is_dir(APP_ROOT_PATH . "public/logger/")) {
             if (!mkdir(APP_ROOT_PATH . "public/logger/")) {
                 return false;
             }
         }
         $destination = APP_ROOT_PATH . "public/logger/" . date('y_m_d') . ".logger";
     }
     if (self::FILE == $type) {
         // 文件方式记录日志信息
         //检测日志文件大小,超过配置大小则备份日志文件重新生成,日志大小2MB
         if (is_file($destination) && floor(2000000) <= filesize($destination)) {
             rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
         }
     }
     error_log(implode("", self::$log), $type, $destination, $extra);
     // 保存后清空日志缓存
     self::$log = array();
     //clearstatcache();
 }
Ejemplo n.º 3
0
 /**
  * @author Ignacio Vazquez - elpepe.uy@gmail.com
  * @param array of string $pluginNames
  * TODO avoid using mysql functions - (copied from installer)
  */
 static function executeInstaller($name)
 {
     $table_prefix = TABLE_PREFIX;
     tpl_assign('table_prefix', $table_prefix);
     $default_charset = 'DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
     tpl_assign('default_charset', $default_charset);
     $default_collation = 'collate utf8_unicode_ci';
     tpl_assign('default_collation', $default_collation);
     $engine = DB_ENGINE;
     tpl_assign('engine', $engine);
     $path = ROOT . "/plugins/{$name}/info.php";
     if (file_exists($path)) {
         DB::beginWork();
         $pluginInfo = (include_once $path);
         //0. Check if exists in plg table
         $sql = "SELECT id FROM " . TABLE_PREFIX . "plugins WHERE name = '{$name}' ";
         $res = @mysql_query($sql);
         if (!$res) {
             DB::rollback();
             return false;
         }
         $plg_obj = mysql_fetch_object($res);
         if (!$plg_obj) {
             //1. Insert into PLUGIN TABLE
             $cols = "name, is_installed, is_activated, version";
             $values = "'{$name}', 1, 1 ,'" . array_var($pluginInfo, 'version') . "'";
             if (is_numeric(array_var($pluginInfo, 'id'))) {
                 $cols = "id, " . $cols;
                 $values = array_var($pluginInfo, 'id') . ", " . $values;
             }
             $sql = "INSERT INTO " . TABLE_PREFIX . "plugins ({$cols}) VALUES ({$values}) ";
             if (@mysql_query($sql)) {
                 $id = @mysql_insert_id();
                 $pluginInfo['id'] = $id;
             } else {
                 echo "ERROR: " . mysql_error();
                 @mysql_query('ROLLBACK');
                 return false;
             }
         } else {
             $id = $plg_obj->id;
             $pluginInfo['id'] = $id;
         }
         //2. IF Plugin defines types, INSERT INTO ITS TABLE
         if (count(array_var($pluginInfo, 'types'))) {
             foreach ($pluginInfo['types'] as $k => $type) {
                 if (isset($type['name'])) {
                     $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "object_types (name, handler_class, table_name, type, icon, plugin_id)\n\t\t\t\t\t\t\t \tVALUES (\n\t\t\t\t\t\t\t \t'" . array_var($type, "name") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "handler_class") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "table_name") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "type") . "', \n\t\t\t\t\t\t\t \t'" . array_var($type, "icon") . "', \n\t\t\t\t\t\t\t\t{$id}\n\t\t\t\t\t\t\t)";
                     if (@mysql_query($sql)) {
                         $pluginInfo['types'][$k]['id'] = @mysql_insert_id();
                         $type['id'] = @mysql_insert_id();
                     } else {
                         echo $sql . "<br/>";
                         echo mysql_error() . "<br/>";
                         DB::rollback();
                         return false;
                     }
                 }
             }
         }
         //2. IF Plugin defines tabs, INSERT INTO ITS TABLE
         if (count(array_var($pluginInfo, 'tabs'))) {
             foreach ($pluginInfo['tabs'] as $k => $tab) {
                 if (isset($tab['title'])) {
                     $type_id = array_var($type, "id");
                     $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panels (\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\ttitle, \n\t\t\t\t\t\t\t\ticon_cls, \n\t\t\t\t\t\t\t\trefresh_on_context_change, \n\t\t\t\t\t\t\t\tdefault_controller, \n\t\t\t\t\t\t\t\tdefault_action, \n\t\t\t\t\t\t\t\tinitial_controller, \n\t\t\t\t\t\t\t\tinitial_action, \n\t\t\t\t\t\t\t\tenabled, \n\t\t\t\t\t\t\t\ttype,  \n\t\t\t\t\t\t\t\tplugin_id, \n\t\t\t\t\t\t\t\tobject_type_id )\n\t\t\t\t\t\t \tVALUES (\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'id') . "', \n\t\t\t\t\t\t \t\t'" . array_var($tab, 'title') . "', \n\t\t\t\t\t\t \t\t'" . array_var($tab, 'icon_cls') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'refresh_on_context_change') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_controller') . "',\n\t\t\t\t\t\t \t\t'" . array_var($tab, 'default_action') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_controller') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'initial_action') . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'enabled', 1) . "',\n\t\t\t\t\t\t\t\t'" . array_var($tab, 'type') . "',\n\t\t\t\t\t\t\t\t{$id},\n\t\t\t\t\t\t\t\t" . array_var($tab, 'object_type_id') . "\n\t\t\t\t\t\t\t)";
                     if (!@mysql_query($sql)) {
                         echo $sql;
                         echo mysql_error();
                         DB::rollback();
                         return false;
                     }
                     // INSERT INTO TAB PANEL PERMISSSION
                     $sql = "\n\t\t\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "tab_panel_permissions (\n\t\t\t\t\t\t\t\tpermission_group_id,\n\t\t\t\t\t\t\t\ttab_panel_id \n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t \tVALUES ( 1,'" . array_var($tab, 'id') . "' ),  ( 2,'" . array_var($tab, 'id') . "' )  ON DUPLICATE KEY UPDATE permission_group_id = permission_group_id ";
                     if (!@mysql_query($sql)) {
                         echo $sql;
                         echo mysql_error();
                         @mysql_query('ROLLBACK');
                         DB::rollback();
                         return false;
                     }
                 }
             }
         }
         // Create schema sql query
         $schema_creation = ROOT . "/plugins/{$name}/install/sql/mysql_schema.php";
         if (file_exists($schema_creation)) {
             $total_queries = 0;
             $executed_queries = 0;
             if (executeMultipleQueries(tpl_fetch($schema_creation), $total_queries, $executed_queries)) {
                 logger::log("Schema created for plugin {$name} ");
             } else {
                 //echo tpl_fetch ( $schema_creation );
                 echo mysql_error();
                 echo "llega <br>";
                 DB::rollback();
                 return false;
             }
         }
         // Create schema sql query
         $schema_query = ROOT . "/plugins/{$name}/install/sql/mysql_initial_data.php";
         if (file_exists($schema_query)) {
             $total_queries = 0;
             $executed_queries = 0;
             if (executeMultipleQueries(tpl_fetch($schema_query), $total_queries, $executed_queries)) {
                 logger::log("Initial data loaded for plugin  '{$name}'." . mysql_error());
             } else {
                 echo mysql_error();
                 DB::rollback();
                 return false;
             }
         }
         $install_script = ROOT . "/plugins/{$name}/install/install.php";
         if (file_exists($install_script)) {
             include_once $install_script;
         }
         DB::commit();
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
//directory for additional languages
$langDir = PIMCORE_WEBSITE_PATH . "/var/config/texts";
if (!is_dir($langDir)) {
    mkdir($langDir, 0755, true);
}
$success = is_dir($langDir);
if ($success) {
    $language = "de";
    $src = "http://www.pimcore.org/?controller=translation&action=download&language=" . $language;
    $data = @file_get_contents($src);
    if (!empty($language) and !empty($data)) {
        try {
            $languageFile = $langDir . "/" . $language . ".csv";
            $fh = fopen($languageFile, 'w');
            fwrite($fh, $data);
            fclose($fh);
        } catch (Exception $e) {
            logger::log("could not download language file", Zend_Log::WARN);
            logger::log($e);
            $success = false;
        }
    }
}
?>
<b>Release Notes (545):</b>
<br/>
- Added system languages download<br/>
- Removed german from core languages, moved additional system languages to website/var/config/texts

Ejemplo n.º 5
0
 protected function checkAndPrepareIndex()
 {
     if (!$this->index) {
         $indexDir = SearchPhp_Plugin::getFrontendSearchIndex();
         //switch to tmpIndex
         $indexDir = str_replace("/index", "/tmpindex", $indexDir);
         try {
             Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive());
             $this->index = Zend_Search_Lucene::open($indexDir);
         } catch (Exception $e) {
             logger::log(get_class($this) . ": could not open frontend index, creating new one.", Zend_Log::WARN);
             Zend_Search_Lucene::create($indexDir);
             $this->index = Zend_Search_Lucene::open($indexDir);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * 初始化
  * @param unknown $config
  */
 public static function init($config)
 {
     $logger_class = isset($config["logger_class"]) ? $config["logger_class"] : "log_file_logger";
     self::$log = new $logger_class();
     self::$log->init($config);
 }
Ejemplo n.º 7
0
logger::log("SearchPhp_Plugin: Starting crawl", Zend_Log::DEBUG);
//TODO nix specific
exec("rm -Rf " . str_replace("/index", "/tmpindex", $indexDir) . " " . $indexDir);
$confArray = SearchPhp_Plugin::getSearchConfigArray();
$urls = explode(",", $confArray['search']['frontend']['urls']);
$validLinkRegexes = explode(",", $confArray['search']['frontend']['validLinkRegexes']);
$invalidLinkRegexes = explode(",", $confArray['search']['frontend']['invalidLinkRegexes']);
$rawConfig = new Zend_Config_Xml(PIMCORE_PLUGINS_PATH . SearchPhp_Plugin::$configFile);
$rawConfigArray = $rawConfig->toArray();
$rawConfigArray['search']['frontend']['crawler']['running'] = 1;
$rawConfigArray['search']['frontend']['crawler']['started'] = time();
$config = new Zend_Config($rawConfigArray, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . SearchPhp_Plugin::$configFile));
$writer->write();
$crawler = new SearchPhp_Frontend_Crawler($validLinkRegexes, $invalidLinkRegexes, 10, 30, $confArray['search']['frontend']['crawler']['contentStartIndicator'], $confArray['search']['frontend']['crawler']['contentEndIndicator']);
$crawler->findLinks($urls);
$rawConfig = new Zend_Config_Xml(PIMCORE_PLUGINS_PATH . SearchPhp_Plugin::$configFile);
$rawConfigArray = $rawConfig->toArray();
$rawConfigArray['search']['frontend']['crawler']['running'] = 0;
$rawConfigArray['search']['frontend']['crawler']['finished'] = time();
$config = new Zend_Config($rawConfigArray, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . SearchPhp_Plugin::$configFile));
$writer->write();
logger::log("SearchPhp_Plugin: replacing old index ...", Zend_Log::DEBUG);
$indexDir = SearchPhp_Plugin::getFrontendSearchIndex();
//TODO nix specific
exec("rm -Rf " . $indexDir);
exec("mv " . str_replace("/index", "/tmpindex", $indexDir) . " " . $indexDir);
logger::log("Search_PluginPhp: replaced old index", Zend_Log::DEBUG);
logger::log("Search_PluginPhp: Finished crawl", Zend_Log::DEBUG);
<?php

require_once 'logger.inc';
require_once 'path.inc';
require_once 'get_host_info.inc';
require_once 'rabbitMQLib.inc';
$logger = new logger("logger.inc");
if (isset($argv[1])) {
    $msg = $argv[1];
} else {
    $msg = "test message";
}
$logger->log("This should fail!");
Ejemplo n.º 9
0
$vars = array('title', 'keywords', 'description', 'padding_top', 'body');
$cache = new cache();
if ($cached = $cache->get()) {
    foreach ($vars as $var) {
        ${$var} = $cached[$var];
    }
} else {
    // initialization
    $db = new db();
    $db->connect($dsn);
    $db->msg = $msg;
    // authentication & and logging
    $auth = new Auth('MDB2', array('dsn' => $db->dsn, 'table' => "sys_user", 'usernamecol' => "user_id", 'passwordcol' => "pass_key"), 'login');
    $auth->start();
    $logger = new logger($db, $auth);
    $logger->log();
    // define mod
    $mods = array('user', 'dictionary', 'glossary', 'home', 'doc', 'proverb', 'abbr', 'dict2');
    $_GET['mod'] = strtolower($_GET['mod']);
    if ($_GET['mod'] == 'dict') {
        $_GET['mod'] = 'dictionary';
    }
    // backward
    if ($_GET['mod'] == 'glo') {
        $_GET['mod'] = 'glossary';
    }
    // backward
    if (!in_array($_GET['mod'], $mods)) {
        $_GET['mod'] = 'home';
    }
    $mod = $_GET['mod'];
#!/usr/bin/php
<?php 
require_once 'path.inc';
require_once 'get_host_info.inc';
require_once 'rabbitMQLib.inc';
require_once 'logger.inc';
$logger = new logger("logger.inc");
try {
    $client = new rabbitMQClient("testRabbitMQ.ini", "testServer");
    if (isset($argv[1])) {
        $msg = $argv[1];
    } else {
        $msg = "test message";
    }
    $request = array();
    $request[0] = "login";
    $request[1] = array("agoldman", "bodypillow");
    $response = $client->send_request($request);
    $logger->log("received", $response);
    echo "client received response: " . PHP_EOL;
    print_r($response);
    echo "\n\n";
    echo $argv[0] . " END" . PHP_EOL;
} catch (Exception $e) {
    $logger->log("error", $e->geMessage());
}
Ejemplo n.º 11
0
<?php

require_once 'logger.inc';
$test = new logger('logger.inc');
$test->log("sent", "words");
Ejemplo n.º 12
0
 /**
  * Deletes all comments for the current target
  *
  * @return void
  */
 public function deleteAllForTarget()
 {
     if ($this->model != null) {
         $targetId = $this->model->getTargetId();
         if (!empty($targetId)) {
             try {
                 $this->db->delete("plugin_ratingscomments_ratings", "targetId='" . $targetId . "'");
             } catch (Exception $e) {
                 logger::log(get_class($this) . ": Could not delete ratings for target id [" . $targetId . "]");
                 throw $e;
             }
         }
     }
 }
Ejemplo n.º 13
0
<?php

if (!defined('PROPER_START')) {
    header("HTTP/1.0 403 Forbidden");
    exit;
}
if (preg_match("/^[0-9]{2,30}\$/", $_POST['id']) != 1) {
    raise(new SecurityException(iSeverity::CRITICAL, $lang['ABNORMAL_PARAMETER_VALUE']));
}
$form = new form('edit_domain');
$form->checkReferer();
$form->reset();
$form->importValues($_POST);
$form->setCheck('dir', $lang['check_dir'], formCheck::ALLTEXT, 2, 30, true);
if (preg_match("/(^\\/?\\.\\.|\\/\\.\\.\\/?\$|\\/\\.\\.\\/|\\\\|\\s)/", $_POST['dir']) > 0) {
    $form->setError('dir', $lang['check_dir']);
}
$form->validate();
$home = '/dns/com/olympe-network/' . security::get('user') . '/' . $form->getValue('dir');
$sql = "UPDATE domain SET homeDirectory = '" . security::encode($home, false) . "' WHERE uid = '{$_POST['id']}'";
$userapi->query($sql, iDatabase::NO_ROW);
// LOG ACTION IN HISTORY
$sql = "SELECT Hostname FROM domain WHERE uid = '{$_POST['id']}'";
$domain = $userapi->query($sql);
$data = array('domain' => $domain['Hostname'], 'dir' => $form->getValue('dir'));
$logger = new logger();
$logger->log($data);
$form->cleanup();
$template->redirect('/panel/domains/edit?done&id=' . $_POST['id']);
Ejemplo n.º 14
0
 /**
  *
  * @param integer $value
  * @param integer $date
  * @param Pimcore_Model_WebResource_Interface $target
  * @param Object_Abstract $user
  */
 public static function postRating($value, $comment, $title, $name, $target, $metadata = null, $spamCheck = null)
 {
     if (!$spamCheck) {
         $type = self::getTypeFromTarget($target);
         if (!empty($type)) {
             $comment = htmlentities(strip_tags($comment), ENT_COMPAT | ENT_HTML401, "UTF-8");
             $title = htmlentities(strip_tags($title), ENT_COMPAT | ENT_HTML401, "UTF-8");
             $name = htmlentities(strip_tags($name), ENT_COMPAT | ENT_HTML401, "UTF-8");
             $comment = $comment == '' ? null : $comment;
             $title = $title == '' ? null : $title;
             $name = $name == '' ? null : $name;
             $rating = new RatingsComments();
             $rating->setTarget($target);
             $rating->setRating(intval($value));
             $rating->setDate(time());
             $rating->setType($type);
             $rating->setComment($comment);
             $rating->setTitle($title);
             $rating->setName($name);
             $rating->setMetadata($metadata);
             if ($target instanceof Object_Abstract) {
                 $rating->setClassname($target->getO_className());
             }
             $rating->save();
         } else {
             logger::log("Rating_Plugin: Could not post rating, unknown resource", Zend_Log::ERR);
         }
     }
 }
Ejemplo n.º 15
0
 /**
  * Write to log
  *
  * @param   mixed $object
  * @param   int   $level
  * @return  void
  */
 public function write($object, $level)
 {
     $this->logger->log($this->get_log_level($level, \Analog::WARNING), $object);
 }
Ejemplo n.º 16
0
$permissions = permissions::checkPerms($node);
if (!empty($_SESSION['debugging']) && $_SESSION['debugging']) {
    print_r($permissions);
}
// DO NOT MESS WITH THIS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//creating neural network
if (preg_match('/id\\/(\\d+)/', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "", $match)) {
    $referer_id = $match[1];
} elseif (preg_match('/k\\/([a-z0-9]{1,7})/', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "", $match)) {
    $referer_id = base_convert($match[1], 36, 10);
} elseif (preg_match('/name\\/(.*?)\\/?$/', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "", $match)) {
    $referer_id = nodes::getNodeIdByName($match[1]);
}
$db->update("update nodes set node_views=node_views+1 where node_id='" . $node['node_id'] . "'");
if (isset($referer_id) && is_numeric($referer_id)) {
    $q = "update neurons set synapse=synapse+1 where dst='" . $node['node_id'] . "' and src='{$referer_id}'";
    $result = $db->update($q);
    if (!$result) {
        $q = "insert into neurons set synapse_creator='" . $_SESSION['user_id'] . "',dst='" . $node['node_id'] . "',src='{$referer_id}',synapse=1";
        $db->query($q);
    }
} else {
    logger::log('enter', $node['node_id'], 'failed');
}
//entering the node (executing the eventz)
if ($permissions['r'] || $event != 'register') {
    //performing node_events (based on update/insert/delete db queries)
    if ($event) {
        require INCLUDE_DIR . 'eventz.inc';
    }
}