Exemple #1
0
 public function __construct($class, $msg = NULL)
 {
     if ($msg != NULL) {
         $this->message = $msg . " в файле " . $this->file . " в строке #" . $this->line;
     }
     if (CApp::settings("APPLICATION")->settings['logs_on']) {
         $log = new CLog();
         $log->logging($class, $this->message);
     }
 }
Exemple #2
0
 public function __construct($class, $msg = NULL)
 {
     if ($msg != NULL) {
         $this->message = $msg . " в файле " . $this->file;
     }
     if (LOGS_ON) {
         $log = new CLog();
         $log->logging($class, $this->message);
     }
 }
/**
 *
 *
 * @file modifier.domain.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:47
 */
function smarty_modifier_domain($string, $encodeURI = false)
{
    $logArr['smarty_modifier'] = "modifier_domain";
    $status = 0;
    $logArr['url'] = $string;
    $domain = $string;
    if (strncasecmp($domain, "http://", 7) == 0) {
        $domain = substr($domain, 7);
    } elseif (strncasecmp($domain, "url:", 4) == 0) {
        $pos = strspn($domain, " ", 4);
        $domain = substr($domain, 4 + $pos);
        if (strncasecmp($domain, "http://", 7) == 0) {
            $domain = substr($domain, 7);
        }
    }
    if (strlen($domain) == 0) {
        $domain = $string;
    }
    if ($encodeURI) {
        $result = hilight_encodeURI($domain);
        $logArr['result'] = $result;
        if (false === $result) {
            $status = -1;
            CLog::warning("fail to call hilight_domain", $status, $logArr, 1);
            return $domain;
        }
    } else {
        $result = $domain;
    }
    return $result;
}
Exemple #4
0
 /**
  * @param Account $oAccount
  * @return CSieveStorage
  */
 public function __construct(Account $oAccount)
 {
     $this->_oLog =& CLog::CreateInstance();
     $this->_sLogin = $oAccount->MailIncLogin;
     $this->_sPassword = $oAccount->MailIncPassword;
     $this->_oSieve = null;
 }
/**
 *
 *
 * @file modifier.url_bold_html.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:40
 */
function smarty_modifier_url_bold_html($string)
{
    $logArr['smarty_modifier'] = "modifier_url_bold_html";
    $status = 0;
    $logArr['string'] = $string;
    if (strlen($string) == 0) {
        $result = $string;
        return $result;
    }
    $prefix = $GLOBALS['DISPLAY']['BOLD_PREFIX'];
    $suffix = $GLOBALS['DISPLAY']['BOLD_SUFFIX'];
    $logArr['prefix'] = $prefix;
    $logArr['suffix'] = $suffix;
    $result = hilight_url_bold_html($string, $prefix, $suffix);
    if (false === $result) {
        $result = $string;
        $status = -1;
        $logArr['result'] = $result;
        CLog::warning("fail to call hilight_url_bold_html", $status, $logArr, 1);
        return $result;
    }
    $logArr['result'] = $result;
    CLog::debug("success to call url_bold_html modifier", $status, $logArr, 1);
    return $result;
}
/**
 *
 *
 * @file modifier.url_limit.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:40
 */
function smarty_modifier_url_limit($string, $length, $escaped = false)
{
    $logArr['smarty_modifier'] = "modifier_url_limit";
    $status = 0;
    $logArr['url'] = $string;
    $logArr['limit_len'] = $length;
    $logArr['escaped'] = $escaped;
    if (strlen($string) == 0) {
        $result = $string;
        return $result;
    }
    $result = trim(hilight_url_limit($string, $length, $escaped));
    $resultTmp = explode(" ", $result);
    $result = implode("", $resultTmp);
    if (false === $result) {
        $result = $string;
        $status = -1;
        $logArr['result'] = $result;
        CLog::warning("fail to call hilight_url_limit", $status, $logArr, 1);
        return $string;
    }
    $logArr['result'] = $result;
    CLog::debug("success to call url_limit", $status, $logArr, 1);
    return $result;
}
 /**
  * @access private
  * @param string $errorDesc
  */
 function _setError($errorDesc, $line = null)
 {
     $this->_error = $this->_error ? $this->_error : $errorDesc;
     $file = __FILE__;
     $line = $line !== null ? ' (~' . $line . ')' : '';
     $this->_log->WriteLine('WMSERVER Error: ' . $file . $line . CRLFCHARS . $errorDesc);
 }
/**
 *
 *
 * @file modifier.strlen_character.php
 * @package plugins
 * @purpose: Calculate the number of characters of a string
 * @author chenchen20@baidu.com
 * @date 2014-03-07 14:02
 */
function smarty_modifier_strlen_character($string)
{
    $logArr['smarty_modifier'] = "modifier_strlen_character";
    $status = 0;
    $intI = 0;
    $intCount = 0;
    $logArr['string'] = $string;
    $intLength = strlen($string);
    if ($intLength == 0) {
        $status = -1;
        CLog::warning("string is empty", $status, $logArr, 1);
        return 0;
    }
    while ($intI < $intLength) {
        $chrAscii = ord($string[$intI]);
        //按字节转成ascii码
        $intCount++;
        $intI++;
        if ($intI >= $intLength) {
            break;
        }
        if ($chrAscii & 0x80) {
            //汉字的两个字符ascii码都大于0x80,此处判断是否为汉字
            $chrAscii <<= 1;
            while ($chrAscii & 0x80) {
                //判断为汉字,$intCount自增1.
                $intI++;
                $chrAscii <<= 1;
            }
        }
    }
    return $intCount;
}
/**
 *
 *
 * @file function.widget.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:47
 */
function smarty_function_widget($params, Smarty_Internal_Template $template)
{
    $logArr['smarty_function'] = "function_widget";
    $name = $params['name'];
    $tpl_path = $params['path'];
    $fn = 'smarty_template_function_' . $name;
    $type = $template->smarty->getTemplateVars('_TEMPLATE_TYPE');
    $logArr['widget_name'] = $name;
    $logArr['widget_type'] = $type;
    $logArr['widget_path'] = $tpl_path;
    if (!function_exists($fn)) {
        //$tpl_path = CSmarty::getWidgetPath($type, $name);
        if (!$template->smarty->templateExists($tpl_path)) {
            $log_str = "widget not found :{$tpl_path}";
            CSmarty::addError($log_str);
            CLog::warning($log_str, -1, $logArr, 1);
            return false;
        }
        $template->smarty->fetch($tpl_path);
    }
    if (!function_exists($fn)) {
        $log_str = "template function {$fn} not found";
        CSmarty::addError($log_str);
        CLog::warning($log_str, -1, $logArr, 1);
        return false;
    } else {
        $result = $fn($template, $params);
    }
    return $result;
}
Exemple #10
0
 function setGlobalErrorAndWriteLog()
 {
     if (strlen($this->error) > 0) {
         setGlobalError($this->error);
         $this->_log->WriteLine('POP3 Error: ' . $this->error);
     }
 }
/**
 *
 *
 * @file modifier.format_int.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:47
 */
function smarty_modifier_format_int($number)
{
    $logArr['smarty_modifier'] = "modifier_format_int";
    $status = 0;
    $number = sprintf("%F", $number);
    $logArr['number'] = $number;
    $size = strlen($number);
    for ($i = $size - 1, $j = 1; $i >= 0; $i--, $j++) {
        $word = substr($number, $i, 1);
        if ($word === ".") {
            $result = "";
            $j = 0;
            continue;
        }
        if ($i < 3) {
            $result = $word . $result;
        } else {
            $result = "0" . $result;
        }
        if ($j % 3 == 0 && $i != 0) {
            $result = "," . $result;
        }
    }
    $logArr['result'] = $result;
    CLog::debug("success to call format_int", $status, $logArr, 1);
    return $result;
}
Exemple #12
0
 /**
  * @param string $customConnectionString
  * @return DbOdbc
  */
 function DbOdbc($customConnectionString, $dbType, $user = '', $pass = '')
 {
     $this->_dbCustomConnectionString = $customConnectionString;
     $this->_dbType = $dbType;
     $this->_user = $user;
     $this->_pass = $pass;
     $this->_log =& CLog::CreateInstance();
 }
 /**
  * 单例对象
  */
 public function getInstance($params = null)
 {
     if (!empty(self::$instance) && is_object(self::$instance)) {
         return self::$instance;
     }
     self::$instance = new self($params);
     return self::$instance;
 }
Exemple #14
0
 /**
  * @param string $host
  * @param string $user
  * @param string $password
  * @param string $dbName
  * @return DbMySql
  */
 function DbMySql($host, $user, $password, $dbName)
 {
     $this->_host = $host;
     $this->_user = $user;
     $this->_password = $password;
     $this->_dbName = $dbName;
     $this->_log =& CLog::CreateInstance();
 }
Exemple #15
0
 public function __construct()
 {
     $this->account = null;
     $this->userId = null;
     $this->responseStatus = X_WMP_RESPONSE_STATUS_OK;
     $this->response = '';
     $this->log = null;
     $this->log =& CLog::CreateInstance();
 }
Exemple #16
0
 /**
  * @access private
  * @param string $errorDesc
  */
 function _setError($errorDesc, $line = null)
 {
     $this->_error = $this->_error ? $this->_error : $errorDesc;
     if ($this->_log->Enabled) {
         $file = __FILE__;
         $line = $line !== null ? ' (~' . $line . ')' : '';
         $this->_log->WriteLine('WMSERVER Error: ' . $file . $line . CRLFCHARS . $errorDesc, LOG_LEVEL_ERROR);
     }
 }
 /**
  * @access public
  * @param Account $account
  * @return XmailStorage
  */
 function WMserverStorage(&$account)
 {
     MailServerStorage::MailServerStorage($account);
     $email = $account->Email;
     $basePath = $this->_settings->WmServerRootPath;
     $this->_wmserver = new WMserverFS($basePath, $email);
     $this->_wmadmin = new CWmServerConsole();
     $this->_log =& CLog::CreateInstance();
 }
 public function mux($logged)
 {
     $session = new USession();
     $VIndex = new VIndex();
     switch ($VIndex->getController()) {
         case 'log':
             $CLog = new CLog();
             $log = $CLog->mux();
             if ($VIndex->getTask() == 'in' || $VIndex->getTask() == 'out') {
                 $VIndex->deleteController();
                 $VIndex->deleteTask();
                 return $this->setPage();
             } else {
                 return $log;
             }
         case 'rent':
             if ($logged >= 0) {
                 $CRent = new CRent();
                 return $CRent->mux();
             } else {
                 return $VIndex->fetch('forbidden_user.tpl');
             }
         case 'user':
             if ($logged >= 0) {
                 $CUser = new CUser();
                 return $CUser->mux();
             } else {
                 return $VIndex->fetch('forbidden_user.tpl');
             }
         case 'admin':
             if ($logged >= 1) {
                 $CAdmin = new CAdmin();
                 return $CAdmin->mux();
             } else {
                 return $VIndex->fetch('forbidden_admin.tpl');
             }
         case 'static':
             $CStatic = new CStatic();
             return $CStatic->mux($logged);
         default:
             $CStatic = new CStatic();
             return $CStatic->mux($logged);
     }
 }
Exemple #19
0
 public function setItem($key, $val, $expiration = 0)
 {
     //$val = implode(' ',$val);
     $val = serialize($val);
     $rc = $this->_cacheBase->set($key, $val, $expiration);
     if (false === $rc) {
         CLog::warning("ImgPredict setItem failed," . $this->_cacheBase->getErrMsg());
     }
     return $rc;
 }
Exemple #20
0
 function execute($query)
 {
     $log =& CLog::CreateInstance();
     $log->WriteLine('calendar MYSQL: ' . $query);
     $res = mysql_query($query);
     if ($res === false) {
         die(mysql_error());
     }
     return $res;
 }
 /**
  * @param Account $account
  * @return MailStorage
  */
 function MailStorage(&$account, $settings = null)
 {
     if (null === $settings) {
         $this->_settings =& Settings::CreateInstance();
     } else {
         $this->_settings =& $settings;
     }
     $this->_log =& CLog::CreateInstance($this->_settings);
     $this->Account =& $account;
 }
Exemple #22
0
 function execute($query)
 {
     $log =& CLog::CreateInstance();
     $log->WriteLine('calendar MSSQL: ' . $query);
     $res = mssql_query($query);
     if ($res === false) {
         die(mssql_get_last_message());
     }
     return $res;
 }
Exemple #23
0
 public static function getCssJs($type, $arrTplNames, $arrCSSUI)
 {
     $cssStr = '';
     $jsStr = '';
     $cssUI = '';
     $strLog = '';
     $uiArr = array();
     // 必须去重
     $arrTplNames = array_keys(array_flip($arrTplNames));
     $arrSmartyConf = CSmarty::getConf();
     // 预处理CSS、JS合并,读取文件
     foreach ($arrTplNames as $tpl) {
         $cssjsPath = CSmarty::getHeadCssFootJsPath(VUI_TEMPLATE_PATH, $arrSmartyConf['platform'], $arrSmartyConf['language'], $type, $tpl);
         if (!file_exists($cssjsPath)) {
             continue;
         }
         require "{$cssjsPath}";
         $strLog .= $tpl . '(';
         $className = 'CssJs_Util_' . $tpl;
         if (class_exists($className) && method_exists($className, 'getHeadCss')) {
             $cssStr .= call_user_func(array($className, 'getHeadCss'));
             if (!empty($cssStr)) {
                 $strLog .= 'css,';
             }
         }
         if (class_exists($className) && method_exists($className, 'getFootJs')) {
             $jsStr .= call_user_func(array($className, 'getFootJs'));
             if (!empty($jsStr)) {
                 $strLog .= 'js,';
             }
         }
         if (class_exists($className) && method_exists($className, 'getCssUI')) {
             $arrUis = call_user_func(array($className, 'getCssUI'));
             if (!empty($arrUis) && is_array($arrUis)) {
                 $uiArr = array_merge($uiArr, $arrUis);
                 $strLog .= implode('_', $arrUis);
             }
         }
         $strLog .= ')';
     }
     $uiArr = array_unique($uiArr);
     if (!empty($uiArr)) {
         // 通用组件的位置放在大搜索目录下
         foreach ($uiArr as $ui) {
             if (empty($arrCSSUI[$ui]['common'])) {
                 CLog::warning("Invalid UiCss:{$ui}");
             } else {
                 $cssUI .= $arrCSSUI[$ui]['common'];
             }
         }
     }
     $GLOBALS['logArr']['merge'] = $strLog;
     return array('cssMerge' => $cssUI . ' ' . $cssStr, 'jsMerge' => $jsStr);
 }
 /**
  * @covers MarketMeSuite\Phranken\Commandline\CLog::out
  */
 public function testOut()
 {
     // make protected method accessible for testing
     $method = new \ReflectionMethod('MarketMeSuite\\Phranken\\Commandline\\CLog', 'out');
     $method->setAccessible(true);
     // test output
     $expected = 'message';
     // capture actual
     ob_start();
     $method->invoke($this->object, $expected);
     $actual = ob_get_clean();
     $this->assertEquals($expected, $actual);
     // test output suppression
     $this->object->suppressOutput(true);
     $expected = false;
     // capture actual
     ob_start();
     $method->invoke($this->object, 'message');
     $actual = ob_get_clean();
     $this->assertEquals($expected, $actual);
 }
Exemple #25
0
 public function queryFromSug(&$arrData)
 {
     //sug接口wiki:http://wiki.babel.baidu.com/twiki/bin/view/Ps/Rank/InterActionTopic/OpensugInterfaceIntroduction
     //json=1表示返回标准的json格式数据
     //cb=空 表示返回的数据中没有“window.baidu.sug”回调
     $arrUrlParams = array();
     $strReferWord = '';
     if (!empty($arrData['uiData']['queryinfo']['refer'])) {
         $strUrlParams = parse_url($arrData['uiData']['queryinfo']['refer'], PHP_URL_QUERY);
         if (!empty($strUrlParams)) {
             parse_str($strUrlParams, $arrUrlParams);
             if (!empty($arrUrlParams)) {
                 $strReferWord = isset($arrUrlParams['wd']) ? $arrUrlParams['wd'] : (isset($arrUrlParams['word']) ? $arrUrlParams['word'] : (isset($arrUrlParams['w']) ? $arrUrlParams['w'] : ''));
             }
         }
     }
     $arrHeader['pathinfo'] = 'su';
     $arrHeader['querystring'] = 'wd=' . $arrData['uiData']['queryInfo']['queryWord'] . "&ie=utf-8&json=2&cb=";
     $arrHeader['Referer'] = $_SERVER['HTTP_REFERER'];
     $arrHeader['Cookie'] = $_SERVER['HTTP_COOKIE'];
     $arrData['uiData']['queryInfo']['isParams']['sug_status'] = SUG_STATUS_NORMAL;
     $arrSugInfo = array();
     if (!isset($_ENV['HHVM'])) {
         ral_set_logid(CLog::logId());
         $ret = ral('sug', 'get', '', Volatile::rand(), $arrHeader);
     } else {
         $ral = new RalClass();
         $ral->ral_set_logid(CLog::logId());
         $ret = $ral->ral_curl_sug('sug', '', $arrHeader);
     }
     //ral请求失败
     if ($ret === false) {
         $arrData['uiData']['queryInfo']['isParams']['sug_status'] = SUG_STATUS_RAL_ERROR;
         return $arrSugInfo;
     }
     $arrRst = json_decode($ret, true);
     //json_decode失败
     if ($arrRst === false) {
         $arrData['uiData']['queryInfo']['isParams']['sug_status'] = SUG_STATUS_JSON_FAIL;
         return $arrSugInfo;
     }
     if (empty($arrRst['q'])) {
         $arrData['uiData']['queryInfo']['isParams']['sug_status'] = SUG_STATUS_ERROR_REQ;
         return $arrSugInfo;
     }
     //sug为空
     if (empty($arrRst['s']) || !is_array($arrRst['s'])) {
         $arrData['uiData']['queryInfo']['isParams']['sug_status'] = SUG_STATUS_NO_SUG;
         return $arrSugInfo;
     }
     $arrSugInfo = $arrRst['s'];
     return $arrSugInfo;
 }
/**
 *
 *
 * @file modifier.limitlen.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:51
 */
function smarty_modifier_string_display_len($string)
{
    $logArr['smarty_modifier'] = "modifier_string_display_len";
    $status = 0;
    $logArr['string'] = $string;
    if (strlen($string) == 0) {
        $result = 0;
        return $result;
    }
    $result = hilight_stringDisplayLen($string);
    $logArr['result'] = $result;
    CLog::debug("success to call limitlen", $status, $logArr, 1);
    return $result;
}
 private function _importIcal()
 {
     $icsText = implode('', file('php://input'));
     if (class_exists('CLog')) {
         $log =& CLog::CreateInstance();
         $log->WriteLine('Sync: Import Calendar[Body] / LENGTH = ' . strlen($icsText));
         $log->WriteLine('Sync: Import Calendar[Body] / RAW = ' . "\r\n" . $icsText);
     }
     $tmpfname = tempnam('/tmp', '');
     file_put_contents($tmpfname, $icsText);
     $result = $this->manager->ImportIcs($tmpfname);
     unlink($tmpfname);
     $this->responseStatus = $result ? X_WMP_RESPONSE_STATUS_OK : X_WMP_RESPONSE_STATUS_ERROR_DB_FAULT;
     $this->response = $result;
 }
Exemple #28
0
 private static function ExecCmd($file, $cmd, $functionName)
 {
     $log =& CLog::CreateInstance();
     $log->WriteLine('Exim: ' . $functionName . ' / exec(\'' . $file . ' ' . $cmd . '\');');
     if (@file_exists($file)) {
         $output = array();
         @exec($file . ' ' . $cmd, $output);
         if (is_array($output) && count($output) > 0) {
             $log->WriteLine('Exim: ' . $functionName . ' / $output = ' . print_r($output, true));
         }
     } else {
         $log->WriteLine('Exim [error]: ' . $file . ' not exist!');
         return false;
     }
     return true;
 }
Exemple #29
0
 function IMAPMAIL()
 {
     $this->host = null;
     $this->port = 143;
     $this->user = '';
     $this->password = '';
     $this->state = 'DISCONNECTED';
     $this->lastSelect = '';
     $this->proxyuser = null;
     $this->error = '';
     $this->must_update = false;
     $this->UpdateTag();
     $this->_oLog =& CLog::CreateInstance();
     if ($this->_oLog && $this->_oLog->Enabled) {
         $this->_bLogEnable = true;
     }
 }
/**
 *
 *
 * @file modifier.firstpart.php
 * @package plugins
 * @author liyudong@baidu.com
 * @date 2011-11-03 10:49
 */
function smarty_modifier_firstpart($string, $part)
{
    $logArr['smarty_modifier'] = "modifier_firstpart";
    $status = 0;
    $logArr['string'] = $string;
    $logArr['part'] = $part;
    $pos = strrpos($string, $part);
    $string_size = strlen($string);
    $part_size = strlen($part);
    $result = $string;
    if ($pos !== false && $string_size === $part_size + $pos) {
        $result = substr($string, 0, $string_size - $part_size);
    }
    $logArr['result'] = $result;
    CLog::debug("success to call firstpart", $status, $logArr, 1);
    return $result;
}