protected function connect()
 {
     global $sae_config;
     if (empty($sae_config['db_name'])) {
         die(Imit_L('_SAE_PLEASE_CONFIG_DB_'));
     }
     self::$link = mysql_connect(SAE_MYSQL_HOST_M, SAE_MYSQL_USER, SAE_MYSQL_PASS) or die(Imit_L('_SAE_CONNECT_DB_ERR_'));
     mysql_select_db(SAE_MYSQL_DB, self::$link);
     mysql_query("set names " . self::$charset, self::$link);
     if (!mysql_select_db(SAE_MYSQL_DB, self::$link)) {
         //如果数据库不存在,自动建立
         mysql_query('create database ' . SAE_MYSQL_DB, self::$link);
         mysql_select_db(SAE_MYSQL_DB, self::$link) or Imit_L('_SAE_DATABASE_NOT_EXIST_');
     }
 }
Пример #2
0
 public function __construct()
 {
     $this->errmsg = Imit_L("_SAE_OK_");
     static $inited = false;
     //只初始化一次
     if ($inited) {
         return;
     }
     if (extension_loaded('sqlite3')) {
         self::$db = new ImitSqlite();
     } else {
         self::$db = get_class($this) == "SaeMysql" ? $this : new SaeMysql();
         $this->createTable();
     }
     $inited = true;
 }
 public function write($domain, $destFileName, $content, $size = -1, $attr = array(), $compress = false)
 {
     if (empty($domain) || empty($destFileName)) {
         $this->errmsg = Imit_L("_SAE_STORAGE_PARAM_EMPTY_") . "[the value of parameter (domain,destFileName,content) can not be empty!]";
         $this->errno = -101;
         return false;
     }
     //定义文件路径
     $filepath = $this->domainDir . $domain . "/" . $destFileName;
     $this->mkdir(dirname($filepath));
     //设置长度
     if ($size > -1) {
         $content = substr($content, 0, $size);
     }
     //写入文件
     if (file_put_contents($filepath, $content)) {
         return true;
     } else {
         $this->errmsg = Imit_L('_SAE_STORAGE_SERVER_ERR_');
         $this->errno = -12;
         return false;
     }
 }
Пример #4
0
<?php

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2010 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: luofei614 <www.3g4k.com>
// +----------------------------------------------------------------------
// $Id$
Imit_L(array('_SAE_DATABASE_NOT_EXIST_' => '数据库[' . SAE_MYSQL_DB . ']不存在', '_SAE_NOT_IN_BILLBOARD_' => '查找元素没有在排行榜中[not in billboard]', '_SAE_BILLBOARD_NOT_EXISTS_' => '排行榜不存在[billboard not exists]', '_SAE_THE_RANK_IS_EXISTED_' => '排行榜已存在[the rank is existed]', '_SAE_ERR_' => 'SAE内部错误', '_SAE_OK_' => '操作成功[OK]', '_SAE_ERRPARAMTER_' => '参数错误[Unavailable tasks]', '_SAE_TASKQUEUE_SERVICE_FAULT_' => '服务内部错误[taskqueue service segment fault]', '_SAE_TASKQUEUE_SERVICE_ERROR_' => '服务内部错误[taskqueue service internal error]', '_SAE_UNKNOWN_ERROR_' => '未知错误[unknown error]', '_SAE_STORAGE_PARAM_EMPTY_' => '参数错误', '_SAE_STORAGE_SERVER_ERR_' => '存储服务器返回错误', '_SAE_STORAGE_DELETE_ERR_' => '删除失败[deleted failed!...]', '_SAE_STORAGE_FILE_NOT_EXISTS_' => '文件不存在', '_SAE_MAIL_SIZE_lARGER_' => '邮件内容过大[mail size cannot larger than 1048576 bytes]', '_SAE_CONNECT_DB_ERR_' => '数据库连接失败', '_SAE_PLEASE_CONFIG_DB_' => '请配置数据库'));
Пример #5
0
 public function setOpt($options)
 {
     if (isset($options['subject']) && strlen($options['subject']) > self::subject_limitsize) {
         $this->errno = SAE_ErrParameter;
         $this->errmsg = Imit_L("_SAE_MAIL_SIZE_lARGER_");
         return false;
     }
     if (isset($options['content'])) {
         $this->_count = $this->_attachSize + strlen($options['content']);
     }
     if ($this->_count > self::mail_limitsize) {
         $this->errno = SAE_ErrParameter;
         $this->errmsg = Imit_L("_SAE_MAIL_SIZE_lARGER_");
         return false;
     }
     $this->_post = array_merge($this->_post, $options);
     return true;
 }
Пример #6
0
 private function emptyName($name)
 {
     $num = self::$db->getVar("select count(*) from sae_rank where namespace='{$name}'");
     if ($num == 0) {
         return true;
     } else {
         $this->errno = -4;
         $this->errmsg = Imit_L("_SAE_BILLBOARD_NOT_EXISTS_");
         return false;
     }
 }
Пример #7
0
 public function push()
 {
     //todu, 当用户环境不支持curl时用socket发送。
     if (empty($this->queue)) {
         return false;
     }
     $s = curl_init();
     foreach ($this->queue as $k => $v) {
         curl_setopt($s, CURLOPT_URL, $v['url']);
         //curl_setopt($s,CURLOPT_TIMEOUT,5);
         curl_setopt($s, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($s, CURLOPT_HEADER, 1);
         curl_setopt($s, CURLINFO_HEADER_OUT, true);
         curl_setopt($s, CURLOPT_POST, true);
         curl_setopt($s, CURLOPT_POSTFIELDS, $v['postdata']);
         $ret = curl_exec($s);
         $info = curl_getinfo($s);
         // print_r($info);
         if (empty($info['http_code'])) {
             $this->errno = SAE_ErrInternal;
             $this->errmsg = Imit_L("_SAE_TASKQUEUE_SERVICE_FAULT_");
             return false;
         } else {
             if ($info['http_code'] != 200) {
                 $this->errno = SAE_ErrInternal;
                 $this->errmsg = Imit_L("_SAE_TASKQUEUE_SERVICE_ERROR_");
                 return false;
             } else {
                 //todu 这里好像有些问题
                 if ($info['size_download'] == 0) {
                     // get MailError header
                     $this->errno = SAE_ErrUnknown;
                     $this->errmsg = Imit_L("_SAE_UNKNOWN_ERROR_");
                     return false;
                 }
             }
         }
     }
     //循环结束
     $this->queue = array();
     //清空列队
     return true;
 }