コード例 #1
0
 public function ShowLogin($is_https, &$msg)
 {
     $timedout = UIBase::GrabInput('get', 'timedout', 'int');
     $logoff = UIBase::GrabInput('get', 'logoff', 'int');
     $msg = '';
     if ($timedout == 1 || $logoff == 1) {
         $this->clear();
         if ($timedout == 1) {
             $msg = DMsg::Err('err_sessiontimeout');
         } else {
             $msg = DMsg::Err('err_loggedoff');
         }
     } else {
         if ($this->IsValid()) {
             return FALSE;
         }
     }
     $userid = NULL;
     $pass = NULL;
     if (isset($_POST['jCryption'])) {
         $jCryption = new jCryption();
         $var = $jCryption->decrypt($_POST['jCryption'], $_SESSION['d_int'], $_SESSION['n_int']);
         unset($_SESSION['d_int']);
         unset($_SESSION['n_int']);
         parse_str($var, $result);
         $userid = $result['userid'];
         $pass = $result['pass'];
     } else {
         if ($is_https && isset($_POST['userid'])) {
             $userid = UIBase::GrabGoodInput('POST', 'userid');
             $pass = UIBase::GrabInput('POST', 'pass');
         }
     }
     if ($userid != NULL) {
         if ($this->authenticate($userid, $pass) === TRUE) {
             return FALSE;
         } else {
             $msg = DMsg::Err('err_login');
         }
     }
     return TRUE;
 }
コード例 #2
0
 private static function loadErrorLog($filter)
 {
     $logfile = $filter->Get(LogFilter::FLD_LOGFILE);
     if (($fd = fopen($logfile, 'r')) == FALSE) {
         $filter->SetMesg(DMsg::Err('err_failreadfile') . ': ' . $filter->Get(LogFilter::FLD_LOGFILE));
         return;
     }
     $frominput = $filter->Get(LogFilter::FLD_FROMINPUT);
     $block = $filter->Get(LogFilter::FLD_BLKSIZE) * 1024;
     $file_size = filesize($logfile);
     $filter->Set(LogFilter::FLD_FILE_SIZE, $file_size);
     $frompos = $frominput == LogFilter::POS_FILEEND ? $file_size - $block : $frominput * 1024;
     if ($frompos < 0) {
         $frompos = 0;
         $endpos = $file_size;
     } else {
         $endpos = $frompos + $block;
     }
     fseek($fd, $frompos);
     $filter->Set(LogFilter::FLD_FROMPOS, $frompos);
     $found = false;
     $totalLine = 0;
     $newlineTag = '[ERR[WAR[NOT[INF[DEB';
     $levels = array('E' => 1, 'W' => 2, 'N' => 3, 'I' => 4, 'D' => 5);
     $filterlevel = $filter->Get(LogFilter::FLD_LEVEL);
     $cur_level = '';
     $cur_time = '';
     $cur_mesg = '';
     while ($buffer = fgets($fd)) {
         // check if new line
         $c25 = substr($buffer, 25, 3);
         if ($c25 && strstr($newlineTag, $c25)) {
             // is new line
             $totalLine++;
             if ($found) {
                 // finish prior line
                 $filter->AddLogEntry($cur_level, $cur_time, $cur_mesg);
                 $found = false;
             }
             $cur_level = $levels[$c25[0]];
             if ($cur_level <= $filterlevel && preg_match("/^\\d{4}-\\d{2}-\\d{2} /", $buffer)) {
                 // start a new line
                 $found = true;
                 $cur_time = substr($buffer, 0, 23);
                 $cur_mesg = htmlspecialchars(substr($buffer, strpos($buffer, ']', 24) + 2));
             }
         } elseif ($found) {
             // multi-line output
             $cur_mesg .= '<br>' . htmlspecialchars($buffer);
         }
         $curpos = ftell($fd);
         if ($curpos >= $endpos) {
             break;
         }
     }
     fclose($fd);
     if ($found) {
         $filter->AddLogEntry($cur_level, $cur_time, $cur_mesg);
     }
     $filter->Set(LogFilter::FLD_TOTALSEARCHED, $totalLine);
 }
コード例 #3
0
 public function GenerateScript(&$error, &$optionsaved)
 {
     if ($this->progress_file == NULL) {
         if (!$this->init($error, $optionsaved)) {
             return FALSE;
         }
     }
     $params = array();
     $params['__php_version__'] = $this->options->GetValue('PHPVersion');
     $params['__progress_f__'] = $this->progress_file;
     $params['__log_file__'] = $this->log_file;
     $processUser = posix_getpwuid(posix_geteuid());
     $gidinfo = posix_getgrgid($processUser['gid']);
     $params['__php_usr__'] = $processUser['name'];
     $params['__php_usrgroup__'] = $gidinfo['name'];
     $params['__extra_path_env__'] = $this->options->GetValue('ExtraPathEnv');
     $params['__php_build_dir__'] = BuildConfig::Get(BuildConfig::BUILD_DIR);
     $params['__dl_method__'] = $this->dlmethod;
     $params['__install_dir__'] = $this->options->GetValue('InstallPath');
     $params['__compiler_flags__'] = $this->options->GetValue('CompilerFlags');
     $params['__enable_mailheader__'] = $this->options->GetValue('AddOnMailHeader') ? 1 : 0;
     $params['__lsapi_version__'] = BuildConfig::GetVersion(BuildConfig::LSAPI_VERSION);
     $params['__php_conf_options__'] = $this->options->GetValue('ConfigParam');
     $params['__lsws_home__'] = SERVER_ROOT;
     $params['__install_script__'] = $this->build_install_script;
     $search = array_keys($params);
     $replace = array_values($params);
     //common header
     $template_file = 'build_common.template';
     $template = file_get_contents($template_file, true);
     if ($template === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file;
         return false;
     }
     $template_script = str_replace($search, $replace, $template);
     $prepare_script = $template_script;
     $install_script = $template_script;
     // prepare php
     $template_file = 'build_prepare.template';
     $template = file_get_contents($template_file, true);
     if ($template === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file;
         return false;
     }
     $template_script = str_replace($search, $replace, $template);
     $prepare_script .= $template_script;
     // install php
     $template_file2 = 'build_install.template';
     $template2 = file_get_contents($template_file2, true);
     if ($template2 === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file2;
         return false;
     }
     $template_script2 = str_replace($search, $replace, $template2);
     $install_script .= $template_script2;
     //prepare extension
     $template_file = 'build_prepare_ext.template';
     $template = file_get_contents($template_file, true);
     if ($template === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file;
         return false;
     }
     //install extension
     $template_file2 = 'build_install_ext.template';
     $template2 = file_get_contents($template_file2, true);
     if ($template2 === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file2;
         return false;
     }
     $extList = array();
     if ($this->options->GetValue('AddOnSuhosin')) {
         $extList[] = 'Suhosin';
     }
     if ($this->options->GetValue('AddOnAPC')) {
         $extList[] = 'APC';
     }
     if ($this->options->GetValue('AddOnXCache')) {
         $extList[] = 'XCache';
     }
     if ($this->options->GetValue('AddOnMemCache')) {
         $extList[] = 'MemCache';
     }
     //		if ($this->options->GetValue('AddOnMemCached')) {
     //			$extList[] = 'MemCached';
     //		}
     if ($this->options->GetValue('AddOnOPcache')) {
         $extList[] = 'OPcache';
     }
     foreach ($extList as $extName) {
         $newparams = array_merge($params, $this->ext_options[$extName]);
         $search = array_keys($newparams);
         $replace = array_values($newparams);
         $template_script = str_replace($search, $replace, $template);
         $prepare_script .= $template_script;
         $template_script2 = str_replace($search, $replace, $template2);
         $install_script .= $template_script2;
     }
     $this->extension_used = implode('.', $extList);
     $prepare_script .= 'main_msg "**DONE**"' . "\n";
     $install_script .= 'main_msg "**DONE**"' . "\n";
     if (file_put_contents($this->build_prepare_script, $prepare_script) === FALSE) {
         $error = DMsg::Err('buildphp_errcreatescript') . $this->build_prepare_script;
         return false;
     }
     if (chmod($this->build_prepare_script, 0700) == FALSE) {
         $error = DMsg::Err('buildphp_errchmod') . $this->build_prepare_script;
         return false;
     }
     if (file_put_contents($this->build_install_script, $install_script) === FALSE) {
         $error = DMsg::Err('buildphp_errcreatescript') . $this->build_install_script;
         return false;
     }
     if (chmod($this->build_install_script, 0700) == FALSE) {
         $error = DMsg::Err('buildphp_errchmod') . $this->build_install_script;
         return false;
     }
     // final manual run script
     $template_file = 'build_manual_run.template';
     $template = file_get_contents($template_file, true);
     if ($template === false) {
         $error = DMsg::Err('err_failreadfile') . $template_file;
         return false;
     }
     $template_script = str_replace($search, $replace, $template);
     if (file_put_contents($this->build_manual_run_script, $template_script) === FALSE) {
         $error = DMsg::Err('buildphp_errcreatescript') . $this->build_manual_run_script;
         return false;
     }
     if (chmod($this->build_manual_run_script, 0700) == FALSE) {
         $error = DMsg::Err('buildphp_errchmod') . $this->build_manual_run_script;
         return false;
     }
     return true;
 }