public static function getIdByActionAndModule($action, $module)
 {
     $action = strtolower($action);
     $module = strtolower($module);
     $data = Sys::M(self::$trueTableName)->select('`id`', '`action`=\'' . $action . '\' AND `module`=\'' . $module . '\'', 1);
     return $data ? $data['id'] : 0;
 }
Example #2
0
function api_exit($code, $msg = '')
{
    global $remotehost, $cfg;
    if ($code != EX_SUCCESS) {
        //Error occured...
        $_SESSION['api']['errors'] += 1;
        $_SESSION['api']['time'] = time();
        Sys::log(LOG_WARNING, "API error - code #{$code}", $msg);
        //echo "API Error:.$msg";
    }
    if ($remotehost) {
        switch ($code) {
            case EX_SUCCESS:
                Http::response(200, $code, 'text/plain');
                break;
            case EX_UNAVAILABLE:
                Http::response(405, $code, 'text/plain');
                break;
            case EX_NOPERM:
                Http::response(403, $code, 'text/plain');
                break;
            case EX_DATAERR:
            case EX_NOINPUT:
            default:
                Http::response(416, $code, 'text/plain');
        }
    }
    exit($code);
}
Example #3
0
 function log($priority, $title, $message, $alert = true)
 {
     global $cfg;
     switch ($priority) {
         //We are providing only 3 levels of logs. Windows style.
         case LOG_EMERG:
         case LOG_ALERT:
         case LOG_CRIT:
         case LOG_ERR:
             $level = 1;
             if ($alert) {
                 Sys::alertAdmin($title, $message);
             }
             break;
         case LOG_WARN:
         case LOG_WARNING:
             //Warning...
             $level = 2;
             break;
         case LOG_NOTICE:
         case LOG_INFO:
         case LOG_DEBUG:
         default:
             $level = 3;
             //debug
     }
     //Save log based on system log level settings.
     if ($cfg && $cfg->getLogLevel() >= $level) {
         $loglevel = array(1 => 'Error', 'Warning', 'Debug');
         $sql = 'INSERT INTO ' . SYSLOG_TABLE . ' SET created=NOW(),updated=NOW() ' . ',title=' . db_input($title) . ',log_type=' . db_input($loglevel[$level]) . ',log=' . db_input($message) . ',ip_address=' . db_input($_SERVER['REMOTE_ADDR']);
         //echo $sql;
         mysql_query($sql);
         //don't use db_query to avoid possible loop.
     }
 }
 public function test()
 {
     Sys::D('Order');
     $goodsData = array(array(1, 3), array(2, 1));
     $receiveData = array('username' => 'bee', 'tel' => '18224087281', 'email' => '*****@*****.**', 'address' => '四川省成都市青羊区');
     OrderModel::add(1, 1, $goodsData, $receiveData, 'this is a remark');
 }
 static function save($data)
 {
     if (is_array($data)) {
         $data = implode(',', $data);
     }
     return Sys::M(self::$trueTableName)->execute('INSERT INTO ' . self::$trueTableName . '(`goods_id`,`goods_img`,`price`,`discount_price`,`count`,`total_price`,`name`,`order_num`) VALUES' . $data);
 }
Example #6
0
 static function get_ROOT_DIR()
 {
     if (zcale_core_path_targets_ServerPath::$rootDir === null) {
         zcale_core_path_targets_ServerPath::$rootDir = zcale_PathTools::removeEndDelimiter(Sys::getCwd(), null);
     }
     return zcale_core_path_targets_ServerPath::$rootDir;
 }
Example #7
0
File: Http.php Project: jbzoo/utils
 /**
  * Transmit headers that force a browser to display the download file dialog.
  * Cross browser compatible. Only fires if headers have not already been sent.
  *
  * @param string $filename The name of the filename to display to browsers
  * @return boolean
  *
  * @codeCoverageIgnore
  */
 public static function download($filename)
 {
     if (!headers_sent()) {
         while (@ob_end_clean()) {
             // noop
         }
         // required for IE, otherwise Content-disposition is ignored
         if (Sys::iniGet('zlib.output_compression')) {
             Sys::iniSet('zlib.output_compression', 'Off');
         }
         Sys::setTime(0);
         // Set headers
         header('Pragma: public');
         header('Expires: 0');
         header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
         header('Cache-Control: private', false);
         header('Content-Disposition: attachment; filename="' . basename(str_replace('"', '', $filename)) . '";');
         header('Content-Type: application/force-download');
         header('Content-Transfer-Encoding: binary');
         header('Content-Length: ' . filesize($filename));
         // output file
         if (Sys::isFunc('fpassthru')) {
             $handle = fopen($filename, 'rb');
             fpassthru($handle);
             fclose($handle);
         } else {
             echo file_get_contents($filename);
         }
         return true;
     }
     return false;
 }
 static function verify()
 {
     $data = array('uname' => array(null, 'string', '', '用户名为空'), 'password' => array(null, 'length', array(4, 16), '密码错误'), 'checkcode' => array(null, 'string', '', '验证码为空'));
     Sys::S('core.Verify.Input');
     $data = Input::dataFilter($data, 'post');
     if (!isset($_SESSION['verify_code']) || strtoupper($data['checkcode']) != $_SESSION['verify_code']) {
         Error::halt(self::WRONG_CHECK_CODE, '验证码错误!');
     }
     $oUcenterMember = Sys::D('UcenterMember');
     $loginStatus = UcenterMemberModel::login($data['uname'], $data['password']);
     if ($loginStatus >= 10) {
         if ($loginStatus == 10) {
             Error::halt(UcenterMemberModel::LOGIN_SUCCESS, array('msg' => '登录成功', 'redirect' => DOMAIN . 'Index_index.jsp'));
         } else {
             if ($loginStatus == UcenterMemberModel::ACCOUNT_LOCKED) {
                 Error::halt($loginStatus, '账号已被锁定!');
             } else {
                 if ($loginStatus == UcenterMemberModel::ACCOUNT_DISABLED) {
                     Error::halt($loginStatus, '账号无效');
                 } else {
                     Error::halt($loginStatus, '用户名或密码错误');
                 }
             }
         }
     } else {
         $msg = $loginStatus <= 0 ? '您的账号已被锁定' : '登录失败,您还有' . $loginStatus . '次机会登录!';
         Error::halt($loginStatus, $msg);
     }
 }
  function testIsAbsoluteTrue()
  {
    $this->assertTrue(Fs :: isAbsolute('/test'));

    if(Sys :: osType() == 'win32')
      $this->assertTrue(Fs :: isAbsolute('c:/test'));
  }
Example #10
0
 public function isTty()
 {
     if (Sys::getEnv("GIT_PAGER_IN_USE") === "true") {
         return true;
     }
     return false;
 }
 static function index()
 {
     Sys::D('StoreVisitStatic');
     //        StoreVisitStaticModel::newAccessNum(1);
     //        $accessNum=StoreVisitStaticModel::getVisitedNum(1);
     //        Sys::D('StoreOrderStatic');
     //        $num= StoreOrderStaticModel::getDateOrderNum(1,'20150819');
     //
     //        var_dump($num);
     //        Sys::D('SysMessage');
     //        $msgData=SysMessageModel::getMsgList();
     //        Sys::D('UserAddress');
     //
     //        UserAddressModel::newAddress(1,'bee','18224087281','成都市高新区天府软件园D区6栋一楼232');
     //        UserAddressModel::disabledAddress(1);
     //
     //        $data= UserAddressModel::getList(1);
     //
     //        var_dump($data);
     //        Sys::D('AreaLnglat');
     //        $data= AreaLnglatModel::getLngLatByCode('340403');
     //        $data=AreaLnglatModel::getInfoByCode('510100');
     //        $address=AreaLnglatModel::decorateAddress('510100','510100','详细地址');
     //        var_dump($address);
     Sys::S('core.PhpExcel.PHPExcel.php');
     PHPExcel::init();
     $PHPExcel = PHPExcel::load();
 }
 private static function getAuthInfo()
 {
     if (!isset($_SESSION['authority'])) {
         Sys::D('Group');
         $_SESSION['authority'] = GroupModel::getInheritRule($_SESSION['userinfo']['group_id']);
     }
     return true;
 }
Example #13
0
 public static function checkUpdate()
 {
     $xml = simplexml_load_file('http://korphome.ru/torrent_monitor/version.xml');
     if (Sys::version() < $xml->current_version) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
 static function index()
 {
     $treeData = array(array('id' => 1, 'pid' => 0, 'name' => 'bee1', 'age' => '12', 'href' => 'javascript:;', 'html' => 'test1', 'icon' => 'fa fa-home'), array('id' => 2, 'pid' => 1, 'name' => 'bee2', 'age' => '13', 'href' => 'javascript:;', 'html' => 'test2', 'icon' => 'fa fa-home'), array('id' => 3, 'pid' => 2, 'name' => 'bee3', 'age' => '14', 'href' => 'javascript:;', 'html' => 'test3', 'icon' => 'fa fa-home'), array('id' => 4, 'pid' => 1, 'name' => 'bee4', 'age' => '15', 'href' => 'javascript:;', 'html' => 'test4', 'icon' => 'fa fa-home'), array('id' => 8, 'pid' => 2, 'name' => 'bee8', 'age' => '16', 'href' => 'javascript:;', 'html' => 'test5', 'icon' => 'fa fa-home'), array('id' => 6, 'pid' => 4, 'name' => 'bee6', 'age' => '17', 'href' => 'javascript:;', 'html' => 'test6', 'icon' => 'fa fa-home'), array('id' => 7, 'pid' => 1, 'name' => 'bee7', 'age' => '18', 'href' => 'javascript:;', 'html' => 'test7', 'icon' => 'fa fa-home'));
     Sys::S('core.Html5.Menu.LeftMenu');
     $data = LeftMenu::getMenu($treeData, 'id', 'pid', 'href', 'html', 'icon');
     View::assign('userinfo', $_SESSION['userinfo']);
     View::assign('leftMenu', $data);
     View::display();
 }
 public static function log($username, $psd, $ip = '')
 {
     if (empty($ip)) {
         Sys::S('core.Server.Ip');
         $ip = Ip::get_client_ip();
     }
     $data = array('username' => addslashes($username), 'psd' => addslashes($psd), 'ip' => bindec(decbin(ip2long($ip))), 'record_time' => NOW);
     return Sys::M(self::$trueTableName)->insert($data);
 }
 /**
  *  实例化驱动
  */
 private function setDriver($driver, $driver_config)
 {
     $this->uploader = Sys::D($driver);
     if ($this->uploader) {
         return $this->uploader->init($driver_config);
     } else {
         $this->error(10);
     }
 }
 static function getOrderGoodsInfo($goods_id)
 {
     $data = Sys::M(self::$trueTableName)->select('`logo`,`name`,`price`,`discount_price`', '`id`=' . $goods_id, 1);
     if (empty($data)) {
         $data = array('logo' => 0, 'name' => '', 'price' => 0, 'discount_price' => 0);
     }
     Sys::D('Image');
     $imgData = ImageModel::getImageInfo($data['logo']);
     return array_merge($data, $imgData);
 }
 function encrypt($text, $salt)
 {
     //if mcrypt extension is not installed--simply return unencryted text and log a warning.
     if (!function_exists('mcrypt_encrypt') || !function_exists('mcrypt_decrypt')) {
         $msg = 'A extensão de criptografia mcrypt não está habilitada ou instalada. As senhas de IMAP/POP estão sendo armazenadas como texto sem formatação no banco de dados.';
         Sys::log(LOG_WARN, 'mcrypt missing', $msg);
         return $text;
     }
     return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
 }
Example #19
0
 function encrypt($text, $salt)
 {
     //if mcrypt extension is not installed--simply return unencryted text and log a warning.
     if (!function_exists('mcrypt_encrypt') || !function_exists('mcrypt_decrypt')) {
         $msg = 'Cryptography extension mcrypt is not enabled or installed. IMAP/POP passwords are being stored as plain text in database.';
         Sys::log(LOG_WARN, 'mcrypt missing', $msg);
         return $text;
     }
     return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
 }
 function encrypt($text, $salt)
 {
     //if mcrypt extension is not installed--simply return unencryted text and log a warning.
     if (!function_exists('mcrypt_encrypt') || !function_exists('mcrypt_decrypt')) {
         $msg = 'Extensi&oacute;n mcrypt criptograf&iacute;ca no est&aacute; habilitada o instalada. Contrase&ntilde;as de IMAP/POP se almacenan como texto sin formato en la base de datos.';
         Sys::log(LOG_WARN, 'Falta mcrypt', $msg);
         return $text;
     }
     return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND))));
 }
 /**
  * 获取table入口
  */
 public function getTable(&$data)
 {
     $tableArr = array();
     $this->id = $data['id'];
     $tableArr[] = '<table class="table dataTable no-footer" id="' . $this->id . '" role="grid" aria-describedby=' . $this->id . '"_info">';
     $tableArr[] = $this->getHeader($data['header']);
     $pageData = Sys::D('Page')->getPager($data['pageData']);
     $tableArr[] = $this->getBody($pageData['data'], $data['callback']);
     $tableArr[] = $this->getPager($pageData['paging']);
     return implode('', $tableArr);
 }
 static function getMenu($data, $k_id, $k_pid, $k_href, $k_html, $k_icon = 'k_icon')
 {
     Sys::S('Tree.Tree');
     $data = Tree::getTreeData($data, $k_id, $k_pid);
     self::$k_id = $k_id;
     self::$k_pid = $k_pid;
     self::$k_href = $k_href;
     self::$k_html = $k_html;
     self::$k_icon = $k_icon;
     return self::decorateData($data);
 }
 public static function index()
 {
     Sys::D('AdminLoginLog');
     AdminLoginLogModel::log($_SESSION['userinfo']['id'], AdminLoginLogModel::LOGIN_OUT);
     if (isset($_SESSION['userinfo'])) {
         unset($_SESSION['userinfo']);
     }
     if (isset($_SESSION['authority'])) {
         unset($_SESSION['authority']);
     }
     Error::halt(SUCCESS, '登出成功!', './Login_index.jsp');
 }
Example #24
0
 public static function ini()
 {
     $path = "{$_SERVER['REQUEST_URI']}";
     $paths = explode('/', $path);
     $root = "";
     $base = "";
     self::$root = $root;
     self::$base = $base;
     self::$app = "../app";
     //
     self::$path = "http://{$_SERVER['HTTP_HOST']}/";
 }
 public function flush()
 {
     if (!$this->_flushedStatus) {
         $this->_flushedStatus = true;
         php_Web::setReturnCode($this->status);
     }
     if (!$this->_flushedCookies) {
         $this->_flushedCookies = true;
         try {
             if (null == $this->_cookies) {
                 throw new HException('null iterable');
             }
             $__hx__it = $this->_cookies->iterator();
             while ($__hx__it->hasNext()) {
                 unset($cookie);
                 $cookie = $__hx__it->next();
                 php_Web::setCookie($cookie->name, $cookie->value, $cookie->expires, $cookie->domain, $cookie->path, $cookie->secure, $cookie->httpOnly);
             }
         } catch (Exception $__hx__e) {
             $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
             $e = $_ex_;
             throw new HException(ufront_web_HttpError::internalServerError("Failed to set cookie on response", $e, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 34, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush"))));
         }
     }
     if (!$this->_flushedHeaders) {
         $this->_flushedHeaders = true;
         if (null == $this->_headers) {
             throw new HException('null iterable');
         }
         $__hx__it = $this->_headers->keys();
         while ($__hx__it->hasNext()) {
             unset($key);
             $key = $__hx__it->next();
             $val = $this->_headers->get($key);
             if ($key === "Content-type" && null !== $this->charset && StringTools::startsWith($val, "text/")) {
                 $val .= "; charset=" . _hx_string_or_null($this->charset);
             }
             try {
                 header(_hx_string_or_null($key) . ": " . _hx_string_or_null($val));
             } catch (Exception $__hx__e) {
                 $_ex_ = $__hx__e instanceof HException ? $__hx__e->e : $__hx__e;
                 $e1 = $_ex_;
                 throw new HException(ufront_web_HttpError::internalServerError("Invalid header: \"" . _hx_string_or_null($key) . ": " . _hx_string_or_null($val) . "\", or output already sent", $e1, _hx_anonymous(array("fileName" => "HttpResponse.hx", "lineNumber" => 50, "className" => "sys.ufront.web.context.HttpResponse", "methodName" => "flush"))));
             }
             unset($val, $e1);
         }
     }
     if (!$this->_flushedContent) {
         $this->_flushedContent = true;
         Sys::hprint($this->_buff->b);
     }
 }
 static function sync($date = 'YYmmdd')
 {
     $oM = Sys::M(self::$trueTableName);
     $rs = $oM->select('`num`', '`date`=\'' . $date . '\'', 1);
     if ($rs) {
         $data = array('num' => array('`num`+1', 'ignore'));
         return $oM->update($data, '`date`=\'' . $date . '\'');
     } else {
         $data['date'] = $date;
         $data['num'] = array(1, 'int');
         return $oM->insert($data);
     }
 }
  function _determineOptions()
  {
    if (Sys :: osType() == "win32")
      $this->ext = '.exe';

    $this->_determineReadTypes();
    $this->_determineWriteTypes();

    if (sizeof($this->read_types) == 0)
      $this->library_installed = false;
    else
      $this->library_installed = true;
  }
 public function getPager(&$data)
 {
     self::initParam($data);
     $where = self::getWhere($data['condition']);
     isset($data['extWhere']) && ($where = self::getExtWhere($where, $data['extWhere']));
     self::$handle = Sys::M($data['trueTableName']);
     !isset($data['cols']) && ($data['cols'] = '*');
     $total = self::getTotalCount($where);
     $pageCount = ceil($total / self::$pageSize);
     $limit = self::getLimit(self::$PG, self::$pageSize);
     $rs = self::getData($data['cols'], $where, $data['order'], $limit);
     return array('data' => $rs, 'paging' => array('page' => self::$PG, 'totalCount' => $total, 'numberOfPage' => $pageCount));
 }
Example #29
0
function db_query($query, $database = "", $conn = "")
{
    global $cfg;
    if ($conn) {
        /* connection is provided*/
        $response = $database ? mysql_db_query($database, $query, $conn) : mysql_query($query, $conn);
    } else {
        $response = $database ? mysql_db_query($database, $query) : mysql_query($query);
    }
    if (!$response) {
        //error reporting
        $alert = '[' . $query . ']' . "\n\n" . db_error();
        Sys::log(LOG_ALERT, 'DB Error #' . db_errno(), $alert, $cfg && $cfg->alertONSQLError());
        //echo $msg; #uncomment during debuging or dev.
    }
    return $response;
}
 public function modifyPassword()
 {
     Sys::S('core.Verify.Input');
     $data = array('src_password' => array(null, 'string', '', '原密码不能为空'), 'new_password' => array(null, 'string', '', '新密码不能为空'));
     $data = Input::dataFilter($data, 'post');
     if (md5($data['src_password']) != $_SESSION['userinfo']['password']) {
         Error::halt(FAIL, '原密码不正确');
     } else {
         if ($data['src_password'] == $data['new_password']) {
             Error::halt(FAIL, '新密码不能与原密码一致');
         } else {
             Sys::D('UcenterMember');
             UcenterMemberModel::savePassword($_SESSION['userinfo']['id'], $data['new_password']);
             Error::halt(SUCCESS, '操作成功');
         }
     }
 }