Beispiel #1
0
 public static function write($messages, $loggroup = 'common')
 {
     $baseDir = Directory::siteRoot();
     $backtrace = debug_backtrace();
     $callerFileName = str_replace($baseDir, '', $backtrace[0]['file']) . " (" . $backtrace[0]['line'] . ")";
     $self = self::getInstance();
     //        $messages = $self->convertCharset($messages, 'utf8');
     if (is_array($messages)) {
         $messages = json_encode($messages);
         $messages = $self->unicode_decode($messages);
     }
     $messages = "[" . $callerFileName . "] - " . $messages;
     $debugMode = Configure::site('debugMode');
     if ($debugMode) {
         $self->_log($messages, $loggroup);
     }
     $displayErrors = Configure::site('displayErrors');
     if ($displayErrors == 'on' || $displayErrors == '1') {
         if (php_sapi_name() == "cli") {
             echo "(" . $loggroup . ")" . $messages . "\n";
         } else {
             echo "<pre style='background-color:black;color:#eee;'>(" . $loggroup . ")" . $messages . "<br></pre>";
         }
     }
 }
Beispiel #2
0
 public static function ruleStart()
 {
     //firewall 가동
     $firewallFlag = Configure::site('firewall');
     if (empty($firewallFlag)) {
         $firewallFlag = 0;
     }
     if ($firewallFlag == 1 || strtolower($firewallFlag) == 'on') {
         $allowIPs = Configure::site('allowIps');
         if (!in_array($_SERVER['REMOTE_ADDR'], $allowIPs)) {
             throw new FirewallException("Access Denied - " . $_SERVER['REMOTE_ADDR']);
         }
     }
 }
Beispiel #3
0
 /**
  * 백그라운드로 시스템파일 처리
  * @param bool $blockRedundancy 중복실행 불가 Default:true, 기존 명령실행이 종료되지 않았으면 중복실행불가
  * @return bool
  */
 public function bg($cmd, $blockRedundancy = true)
 {
     $this->setPidFilePath($cmd);
     if ($this->isRunning() && $blockRedundancy) {
         return false;
     } else {
         $cmdFile = $this->cmdFile . " " . implode(' ', $this->params);
         $return = exec("whereis php", $result);
         //            $return = "php: /usr/bin/php /etc/php.d /etc/php.ini /usr/lib64/php /usr/include/php /usr/local/php /usr/share/php /usr/share/man/man1/php.1.gz";
         $whereIsPhpList = explode(' ', str_replace("php:", "", $return));
         $phpScriptFile = '';
         foreach ($whereIsPhpList as $phpFile) {
             if (is_file($phpFile)) {
                 $phpScriptFile = $phpFile;
                 break;
             }
         }
         $result = exec(sprintf($phpScriptFile . ' "' . Directory::html() . '/index.php"' . " %s >> \"%s\" 2>&1 & echo \$! > \"%s\"", 'http://' . Configure::site('host') . '/' . $cmd, $this->logFile, $this->pidFile));
         return true;
     }
 }
Beispiel #4
0
 public function __construct()
 {
     ob_start();
     $this->config = Configure::site();
     $this->tpl = new Template();
 }
Beispiel #5
0
 /**
  * URI 와 Class 매칭
  * @param $currentUri
  * @throws ConfigureException
  * @throws RouterException
  */
 protected function callClassByUri($currentUri)
 {
     $siteNamespace = Configure::site('namespace');
     $loadClassName = $siteNamespace . '\\' . implode('\\', $this->ucfirstArray($currentUri));
     if (class_exists($loadClassName)) {
         $callClass = new $loadClassName();
         $methodList = get_class_methods($callClass);
         $START_METHOD = 'main';
         if (in_array($START_METHOD, $methodList)) {
             call_user_func_array(array($callClass, $START_METHOD), array());
         }
     } else {
         $method = array_pop($currentUri);
         $loadClassName = $siteNamespace . '\\' . implode('\\', $this->ucfirstArray($currentUri));
         if (class_exists($loadClassName)) {
             $callClass = new $loadClassName();
             $callClass->{$method}();
         } else {
             throw new RouterException("Not Found Class File - " . $loadClassName);
         }
     }
 }
Beispiel #6
0
 protected function sitePath($dir)
 {
     $siteConfig = Configure::site('dirs');
     if (preg_match('/[.]/i', $dir, $tmpMatch)) {
         $dirs = explode('.', $dir);
         if (empty($siteConfig[$dirs[0]][$dirs[1]])) {
             throw new DirectoryException("site " . $dir . " 디렉토리 설정이 잘못되었습니다.");
         }
         $dir = $this->siteRoot() . DIRECTORY_SEPARATOR . $siteConfig[$dirs[0]][$dirs[1]];
     } else {
         if (empty($siteConfig[$dir])) {
             throw new DirectoryException("site " . $dir . " 디렉토리 설정이 잘못되었습니다.");
         }
         $dir = $this->siteRoot() . DIRECTORY_SEPARATOR . $siteConfig[$dir];
     }
     return $dir;
 }