Exemple #1
0
 /**
  * Update/serve a cached file
  *
  * @access	public
  * @param 	object	config class
  * @param 	object	uri class
  * @return	void
  */
 function _display_cache(&$CFG, &$URI)
 {
     $cache_adapter;
     $cach_model = $CFG->item('sae_output_cache');
     $status;
     switch ($cach_model) {
         case '':
             return FALSE;
             break;
         case 'kvdb':
             $cache_adapter = new SaeKV();
             $status = $cache_adapter->init();
             break;
         case 'memcache':
             $cache_adapter = memcache_init();
             $status = $cache_adapter;
             break;
     }
     if (!$status) {
         return FALSE;
     }
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     $cache_key = md5($uri);
     $cache = $cache_adapter->get($cache_key);
     if ($cache === FALSE) {
         //缓存已过期
         log_message('debug', "Cache has expired.");
         return FALSE;
     } else {
         //输出缓存
         log_message('debug', "Cache is current. Sending it to browser.");
         $this->_display($cache);
         return TRUE;
     }
 }
Exemple #2
0
 function pagelogin($inPath)
 {
     $kv = new SaeKV();
     $ret = $kv->init();
     if (!$ret) {
         $this->ShowMsg("你没有初始化KVDB!");
     }
     if (!file_exists('saekv://' . $_SERVER['HTTP_APPVERSION'] . '/install.lock')) {
         $this->ShowMsg("你还没有安装smpss!", base_Constant::ROOT_DIR . '/install/index.php');
     }
     $urlParams = $this->getUrlParams($inPath);
     if (!$_POST) {
         $this->params['head_title'] = "管理登录-" . $this->params['head_title'];
         return $this->render("main/login.html", $this->params);
     } else {
         $_POST = base_Utils::shtmlspecialchars($_POST);
         //session_start();
         //if(!SCaptcha::check($_POST['captcha'])){
         $modelAdmin = new m_admin();
         $loginInfo = $modelAdmin->checkLogin($_POST['username'], $_POST['pwd'], (int) $_POST['timeout']);
         if ($loginInfo) {
             $this->redirect($this->createUrl('/'));
         } else {
             $this->ShowMsg("用户名或者密码错误!");
         }
         //}else{
         //$this->ShowMsg("验证码错误!");
         //}
     }
 }
Exemple #3
0
 /**
  * 获得SaeKv对象
  */
 private function getKv()
 {
     static $kv;
     if (!$kv) {
         $kv = new \SaeKV();
         if (!$kv->init()) {
             E('您没有初始化KVDB,请在SAE管理平台初始化KVDB服务');
         }
     }
     return $kv;
 }
Exemple #4
0
function kset($key, $value)
{
    if (has_saekv()) {
        $kv = new SaeKV();
        $kv->init();
        return $kv->set($key, $value);
    } else {
        $keyfile = AROOT . '__lr3_kv' . DS . 'kv-' . md5($key);
        return @file_put_contents($keyfile, serialize($value));
    }
}
Exemple #5
0
function getSaeKvInstance()
{
    static $kv;
    if (!is_object($kv)) {
        $kv = new SaeKV();
        if (!$kv->init()) {
            halt('您没有初始化KVDB,请在SAE管理平台初始化KVDB服务');
        }
    }
    return $kv;
}
 /**
  * Update/serve a cached file
  *
  * @access  public
  * @param   object  config class
  * @param   object  uri class
  * @return  void
  */
 function _display_cache(&$CFG, &$URI)
 {
     $path = $CFG->item('cache_path');
     $prefixKey = $path == '' ? 'system_cache_' : $path;
     $cache_adapter = null;
     $cache_model = $CFG->item('sae_output_cache');
     switch ($cache_model) {
         case '':
             return FALSE;
             break;
         case 'kvdb':
             $cache_adapter = new SaeKV();
             $status = $cache_adapter->init();
             break;
         case 'memcache':
             $cache_adapter = memcache_init();
             $status = $cache_adapter;
             break;
     }
     if (!$status) {
         return FALSE;
     }
     $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string;
     $cache_key = md5($uri);
     $cache = $cache_adapter->get($prefixKey . $cache_key);
     if ($cache === FALSE) {
         //缓存已过期
         log_message('debug', "Cache has expired.");
         return FALSE;
     } else {
         if ($cache_model == 'kvdb') {
             $stored = unserialize($cache);
             if ($stored['ttl'] > 0) {
                 if (time() > $stored['time'] + $stored['ttl']) {
                     $cache_adapter->delete($prefixKey . $cache_key);
                     log_message('debug', "Cache has expired.");
                     return FALSE;
                 }
             }
             $cache = $stored['data'];
         } else {
             if ($cache_model == 'memcache') {
                 $cache = $cache[0];
             }
         }
         //输出缓存
         log_message('debug', "Cache is current. Sending it to browser.");
         $this->_display($cache);
         return TRUE;
     }
 }
function selectChess()
{
    $kv = new SaeKV();
    $kv->init();
    $ret = $kv->pkrget('chess_', 100);
    $_return;
    foreach ($ret as $key => $value) {
        $_return[] = $value;
    }
    if (isset($_return)) {
        echo json_encode($_return);
    } else {
        echo "[]";
    }
}
 public function DelCookie($id)
 {
     if (!test_user()) {
         echo json_encode(array('error' => '删除失败', 'status' => false));
         return;
     }
     if (M('Cookie')->where('id=%d', $id)->delete()) {
         M('SignList')->where('cookieid=%d', $id)->delete();
         $kv = new \SaeKV();
         $kv->init();
         $kv->delete('Cookie' . $id);
         echo json_encode(array('info' => '删除成功', 'status' => true));
     } else {
         echo json_encode(array('error' => '删除失败', 'status' => false));
     }
 }
function clearkvfolder($folder)
{
    //data/template
    $kv = new SaeKV();
    $kv->init();
    $ret = $kv->pkrget($folder, 100);
    while (true) {
        foreach ($ret as $k => $v) {
            $kv->delete($k);
        }
        $start_key = $k;
        $i = count($ret);
        if ($i < 100) {
            break;
        }
        $ret = $kv->pkrget($folder, 100, $start_key);
    }
}
Exemple #10
0
                if (!empty($_GET['k'])) {
                    $v = $kv->delete($_GET['k']);
                    echo "<p>saekv://{$_GET['k']}删除成功!</p>";
                } else {
                    ?>
			<form action="saekv.php?a=del" name="setform" method="post">
				<p>&nbsp;&nbsp;saekv://<input type="text" name="k" value="" /></p>
				<p>&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit"  value="删除" /></p>
			</form>

<?php 
                }
            }
        } else {
            if ($a == 'allkv') {
                $kv = new SaeKV();
                $ret = $kv->init();
                $ret = $kv->pkrget('', 100);
                while (true) {
                    foreach ($ret as $k => $v) {
                        echo "<p>saekv://{$k} &nbsp;&nbsp;&nbsp;&nbsp; \n                \t<a href=\"saekv.php?a=get&k={$k}\" style='color:red;'>VIEW</a> &nbsp;&nbsp; \n                \t<a href=\"saekv.php?a=del&k={$k}\" onclick=\"return confirm('确认删除?');\" style='color:red;'>DEL</a></p>";
                    }
                    end($ret);
                    $start_key = key($ret);
                    $i = count($ret);
                    if ($i < 100) {
                        break;
                    }
                    $ret = $kv->pkrget('', 100, $start_key);
                }
            }
Exemple #11
0
 public function lp3()
 {
     // 首先获取所有表
     if ($tables = get_table_list(db())) {
         $data['tables'] = $tables;
     }
     $data['actions'] = $actions = array('list', 'insert', 'remove', 'update');
     $kv = new SaeKV();
     $kv->init();
     foreach ($tables as $table) {
         foreach ($actions as $action) {
             $data['in_code'][$table][$action] = $kv->get('iosetting_input_' . $table . '_' . $action);
             $data['out_code'][$table][$action] = $kv->get('iosetting_output_' . $table . '_' . $action);
             $data['ainfo'][$table][$action] = unserialize($kv->get('msetting_' . $table . '_' . $action));
             $data['in_code'][$table][$action] = $kv->get('iosetting_input_' . $table . '_' . $action);
             $data['out_code'][$table][$action] = $kv->get('iosetting_output_' . $table . '_' . $action);
             $fields = get_fields($table);
             foreach ($fields as $field) {
                 $finfo = unserialize($kv->get('msetting_' . $table . '_' . $action . '_' . $field));
                 if ($finfo['required'] == 1) {
                     $data['requires'][$table][$action][] = $field;
                 }
                 if ($finfo['input'] == 1) {
                     $data['inputs'][$table][$action][] = $field;
                 }
                 if ($finfo['output'] == 1) {
                     $data['outputs'][$table][$action][] = $field;
                 }
                 if ($finfo['like'] == 1) {
                     $data['likes'][$table][$action][] = $field;
                 }
                 if ($finfo['equal'] == 1) {
                     $data['equals'][$table][$action][] = $field;
                 }
             }
         }
         // 取得自定义接口
         $data['my_actions'] = get_data("SELECT * FROM `__meta_code` WHERE `table` = '" . s($table) . "' ORDER BY `id` DESC");
     }
     ob_start();
     @extract($data);
     require AROOT . 'meta/api.sample.php';
     $code = ob_get_contents();
     ob_end_clean();
     $code = "<?php \r\n" . $code . '?>';
     include AROOT . 'function/phpbeautifier/PhpBeautifier.inc';
     $beautify = new PhpBeautifier();
     $beautify->tokenSpace = true;
     //put space between tokens
     $beautify->blockLine = true;
     //put empty lines between blocks of code (if, while etc)
     $beautify->optimize = false;
     //optimize strings (for now), if a double quoted string does not contain variables of special carachters transform it to a single quoted string to save parsing time
     if (v('read') == 1) {
         highlight_string($beautify->process($code));
     } else {
         echo $beautify->process($code);
     }
     //echo $code;
     /*
     $smarty->assign( 'data' ,  $data  );
     echo $smarty->fetch( AROOT . 'meta/api.sample.php' );
     */
     //echo 'lp3';
 }
Exemple #12
0
<?php

define("SUMMETA", "<!--this is the first view page created at " . date("Y-m-d H:i:s") . " by summer  -->");
$kv = new SaeKV();
$kv->init();
if ($_GET['s']) {
    $url = $_SERVER['SCRIPT_URI'] . '?s=' . $_GET['s'];
    echo fetchUrl($url);
    exit;
}
$sitemap = $kv->get($_SERVER['SCRIPT_URI'] . 'index.html');
if ($sitemap) {
    header('Content-type:text/html; charset=utf-8');
    echo $sitemap;
} else {
    echo fetchUrl($_SERVER['SCRIPT_URI']) . SUMMETA;
}
function fetchUrl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
    curl_setopt($ch, CURLOPT_REFERER, 'staticindex');
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ret = curl_exec($ch);
    curl_close($ch);
    if ($ret) {
        return $ret;
    } else {
        return false;
    }
Exemple #13
0
<?
$kv = new SaeKV();
$ekv = new SaeKV();
$kv->init();
$ekv->init();
$d=date('Y-m-d H:i:s');
$mail = new SaeMail(); 
$smtp_user='******';
$smtp_pass='******';
$ret = $kv->pkrget('web_', 3);
foreach($ret as $arr => $url){
$url='http://'.$url;
$tags = @get_meta_tags( $url );  
if($tags['saecheckweb'] == 'www.lijingquan.net'){  
	$ret=$ekv->get('fail_'.$url);
	if ($ret == '1'){
	echo $ret;
	}else{
    $mto=$kv->get('mail_'.$url);
    $mail->quickSend($mto,'网站恢复正常!','你的网站'.$url.'已经进入正常状态,并处于监控模式!更多功能,正在开发!欢迎访问我的博客:www.lijingquan.net',$smtp_user,$smtp_pass);
    $mail->clean();
    $ekv->set('fail_'.$url, '1');
    }
}else{  
	$ret=$ekv->get('fail_'.$url);
	if ($ret == '0'){
	echo $ret;
	}else{
    $mto=$kv->get('mail_'.$url);
    $mail->quickSend($mto,'网站发现异常!','你的网站'.$url.'已经进入正常状态,并处于监控模式!更多功能,正在开发!欢迎访问我的博客:www.lijingquan.net',$smtp_user,$smtp_pass);
    $mail->clean();  
Exemple #14
0
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>设置</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">
    </head>
    <body>
        <?php 
$kv = new SaeKV();
$ret = $kv->init();
$increaseRate = $kv->get('increaseRate');
if ($increaseRate === FALSE) {
    $increaseRate = 0.0;
}
$salesTarget = $kv->get('salesTarget');
if ($salesTarget === FALSE) {
    $salesTarget = 0.0;
}
$manTarget = $kv->get('manTarget');
if ($manTarget === FALSE) {
    $manTarget = 0.0;
}
$cosmeticsTarget = $kv->get('cosmeticsTarget');
if ($cosmeticsTarget === FALSE) {
function fetch_and_store_images(array $img_urls)
{
    $return_arr = array('valid_images' => array(), 'invalid_image_urls' => array());
    $valid_status = array(200, 301, 304);
    $kvdb = new SaeKV();
    $kvdb->init();
    foreach ($img_urls as $hash_size_name => $img_url) {
        list($hash, $size, $filename) = explode('#', $hash_size_name);
        if ($filename !== 'none' && file_exists("saestor://tumblrlikes/{$filename}")) {
            $img = file_get_contents("saestor://tumblrlikes/{$filename}");
        } else {
            $filename = basename($img_url);
            $img = @file_get_contents($img_url);
            $fetch_succeed = in_array(parse_header($http_response_header, 'status'), $valid_status);
            $img_info = array('date' => date('Y-m-d'), 'size' => $size, 'read_counter' => 1, 'remark' => $fetch_succeed ? '' : 'inaccessible');
            $kvdb->set($filename, $img_info);
            if ($img === false || !$fetch_succeed) {
                $return_arr['invalid_image_urls'][] = $img_url;
                continue;
            } else {
                file_put_contents("saestor://tumblrlikes/{$filename}", $img);
            }
        }
        $return_arr['valid_images'][$img_url] = $img;
    }
    return $return_arr;
}
Exemple #16
0
 private function getUserfulInfoFromReport($content)
 {
     $city = substr($content, 0, 9);
     $confirmed_area = "EMPTY";
     $areas = array("江苏南", "江苏北", "浙江西", "浙江东", "福建", "安徽", "江西");
     foreach ($areas as $area) {
         if (strpos($city, $area) !== FALSE) {
             $confirmed_area = $area;
             break;
         }
     }
     if ($confirmed_area != "EMPTY") {
         $elements = $this->generateElements($content, $confirmed_area);
         $kv = new SaeKV();
         $kv->init();
         $kv->set($confirmed_area, $elements);
         return $this->generateInfoFromReport($elements);
     } else {
         return $this->getHelpInfo();
     }
 }
Exemple #17
0
$val = $addr . $port;
$needtest = true;
//官服
$official = file_get_contents('official');
$oflen = 0;
if ($official && $official % 10 == 0) {
    $oflen = strlen($official);
    for ($i = 0; $i < $oflen; $i += 10) {
        $addrport = substr($official, $i, 6);
        if ($val === $addrport) {
            die('0');
        }
    }
}
//读取数据
$kv = new SaeKV();
if (!$kv->init()) {
    die('3');
}
for ($i = 0; $i < 5; $i++) {
    $file = $kv->get('servers');
    if ($file !== false) {
        break;
    }
}
if ($file !== false && strlen($file) % 10 == 0) {
    for ($i = 0; $i < strlen($file); $i += 10) {
        if (substr($file, $i, 6) === $val) {
            $needtest = false;
            break;
        }
Exemple #18
0
$Title = "ThinkCMF";
$Powered = "Powered by www.thinkcmf.com";
$steps = array('1' => '安装许可协议', '2' => '运行环境检测', '3' => '安装参数设置', '4' => '安装详细过程', '5' => '安装完成');
$step = isset($_GET['step']) ? $_GET['step'] : 1;
//地址
$scriptName = !empty($_SERVER["REQUEST_URI"]) ? $scriptName = $_SERVER["REQUEST_URI"] : ($scriptName = $_SERVER["PHP_SELF"]);
$rootpath = @preg_replace("/\\/(I|i)nstall\\/index_sae\\.php(.*)\$/", "", $scriptName);
$domain = empty($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
if ((int) $_SERVER['SERVER_PORT'] != 80) {
    $domain .= ":" . $_SERVER['SERVER_PORT'];
}
$domain = $domain . $rootpath;
// mysql
$conn = @mysql_connect(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS);
// kvdb
$kv = new SaeKV();
$kv_ini = $kv->init();
// memcache
$mmc = @memcache_init();
// storage
$s = new SaeStorage();
switch ($step) {
    case '1':
        include_once "./templates/s1.php";
        exit;
    case '2':
        if (phpversion() < 5) {
            die('本系统需要PHP5+MYSQL >=4.1环境,当前PHP版本为:' . phpversion());
        }
        $phpv = @phpversion();
        $err = 0;
Exemple #19
0
			    
				<input id="saveForm" class="button_text" type="submit" name="submit" value="OK" />
		</li>
			</ul>
		</form>	
		<div id="footer">
                  Generated by <a href="http://www.phpform.org">pForm</a> & Code by <a href="http://www.lijingquan.net">Tater</a>
		</div>
	</div>
	<img id="bottom" src="bottom.png" alt="">
	</body>
</html>

<?
if($_POST[submit] == 'OK'){
if ($_POST[element_2] == gethostbyname($_POST[element_1])){
preg_match("/^([a-zA-Z0-9_-])+@(?:gmail.com|139.com|189.cn|wo.com.cn)/",$_POST[element_3],$m);
  if ($m[0] == NULL){
  echo '邮箱地址非法!(反机器人系统)';
  }else
  {
    $kv = new SaeKV();
    $ret = $kv->init();
    $kv->set('web_'.$_POST[element_1], $_POST[element_1]);
    $kv->set('mail_http://'.$_POST[element_1], $_POST[element_3]);  echo '邮箱地址合法!';
  }
}else{
  echo '验证信息处应该填写你网站的IP地址,请再次填写!(反机器人系统)';}
}
?>
Exemple #20
0
function initKv()
{
    global $kv;
    global $hasKvInited;
    if (!$hasKvInited) {
        $kv = new SaeKV();
        if ($kv->init()) {
            $hasKvInited = true;
        } else {
            sae_debug('KVDB加载错误。');
            throw new Exception('KVDB加载错误。');
            $hasKvInited = false;
        }
    }
}
Exemple #21
0
<?php

define("SUMMETA", "<!--this is the first view page created at " . date("Y-m-d H:i:s") . " by summer  -->");
$kv = new SaeKV();
$kv->init();
$sitemap = $kv->get($_SERVER['SCRIPT_URI']);
if ($sitemap) {
    header('Content-type:text/html; charset=utf-8');
    echo $sitemap;
} else {
    echo fetchUrl($_SERVER['SCRIPT_URI']) . SUMMETA;
}
function fetchUrl($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, 0);
    curl_setopt($ch, CURLOPT_REFERER, 'static');
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $ret = curl_exec($ch);
    curl_close($ch);
    if ($ret) {
        return $ret;
    } else {
        return false;
    }
}
Exemple #22
0
 public function index()
 {
     //print_r( $_REQUEST );
     $table = z(t(v('_table')));
     $action = z(t(v('_interface')));
     if (strlen($table) < 1 || strlen($action) < 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'BAD ARGS');
     }
     // user define code
     if ($my_code = get_var("SELECT `code` FROM `__meta_code` WHERE `table` = '" . s($table) . "' AND `action` = '" . s($action) . "' LIMIT 1")) {
         return eval($my_code);
         exit;
     }
     // check table
     $tables = get_table_list(db());
     if (!in_array($table, $tables)) {
         return $this->send_error(LR_API_ARGS_ERROR, 'TABLE NOT EXISTS');
     }
     if ($table == c('token_table_name') && $action == 'get_token') {
         return $this->get_token();
     }
     $fields = get_fields($table);
     $kv = new SaeKV();
     $kv->init();
     $ainfo = unserialize($kv->get('msetting_' . $table . '_' . $action));
     $in_code = $kv->get('iosetting_input_' . $table . '_' . $action);
     $out_code = $kv->get('iosetting_output_' . $table . '_' . $action);
     // run user defined input fliter
     if (strlen($in_code) > 0) {
         eval($in_code);
     }
     if ($ainfo['on'] != 1) {
         return $this->send_error(LR_API_ARGS_ERROR, 'API NOT  AVAILABLE');
     }
     if ($ainfo['public'] != 1) {
         $this->check_token();
     }
     $requires = array();
     $inputs = array();
     $outs = array();
     $likes = array();
     $equal = array();
     foreach ($fields as $field) {
         $finfo = unserialize($kv->get('msetting_' . $table . '_' . $action . '_' . $field));
         if ($finfo['required'] == 1) {
             $requires[] = $field;
         }
         if ($finfo['input'] == 1) {
             $inputs[] = $field;
         }
         if ($finfo['output'] == 1) {
             $outputs[] = $field;
         }
         if ($finfo['like'] == 1) {
             $likes[] = $field;
         }
         if ($finfo['equal'] == 1) {
             $equals[] = $field;
         }
     }
     // check require
     if (count($requires) > 0) {
         foreach ($requires as $require) {
             if (strlen(v($require)) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, z(t($require)) . ' FIELD REQUIRED');
             }
         }
     }
     // build sql
     switch ($action) {
         case 'insert':
             if (count($inputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($outputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'OUTPUT MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 $dsql[] = "'" . s(v($input)) . "'";
             }
             $sql = "INSERT INTO `" . s($table) . "` ( " . rjoin(' , ', '`', $inputs) . " ) VALUES ( " . join(' , ', $dsql) . " )";
             //echo $sql;
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             $lid = last_id();
             if ($lid < 1) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             if (!($data = get_data("SELECT " . rjoin(' , ', '`', $outputs) . " FROM `" . s($table) . "` WHERE `id` = '" . intval($lid) . "'", db()))) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 $this->send_result($data);
             }
             break;
         case 'update':
             if (count($inputs) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($requires) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'REQUIRE MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 if (!in_array($input, $likes) && !in_array($input, $equals)) {
                     if (isset($_REQUEST[$input])) {
                         $dsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                     }
                 } else {
                     if (in_array($input, $likes)) {
                         $wsql[] = " `" . s($input) . "` LIKE '%" . s(v($input)) . "%' ";
                     } else {
                         $wsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                     }
                 }
             }
             if (!isset($dsql) || !isset($wsql)) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT AND LIKE/EQUALS MUST HAS 1 FIELD AT LEAST');
             }
             $sql = "UPDATE `" . s($table) . "` SET " . join(' , ', $dsql) . ' WHERE ' . join(' AND ', $wsql);
             //echo $sql ;
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             $lid = intval(v('id'));
             if ($lid < 1) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             }
             if (!($data = get_data("SELECT " . rjoin(' , ', '`', $outputs) . " FROM `" . s($table) . "` WHERE `id` = '" . intval($lid) . "'"))) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 $this->send_result($data);
             }
             break;
         case 'remove':
             if (count($inputs) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT MUST HAS 1 FIELD AT LEAST');
             }
             if (count($requires) < 1) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'REQUIRE MUST HAS 1 FIELD AT LEAST');
             }
             foreach ($inputs as $input) {
                 if (in_array($input, $likes)) {
                     $wsql[] = " `" . s($input) . "` LIKE '%" . s(v($input)) . "%' ";
                 } elseif (in_array($input, $equals)) {
                     $wsql[] = " `" . s($input) . "` = '" . s(v($input)) . "' ";
                 }
             }
             if (!isset($wsql)) {
                 return $this->send_error(LR_API_ARGS_ERROR, 'INPUT AND LIKE/EQUALS MUST HAS 1 FIELD AT LEAST');
             }
             if (count($outputs) > 0) {
                 $sql = "SELECT " . rjoin(',', '`', $outputs) . " FROM `" . s($table) . "` WHERE  " . join(' AND ', $wsql);
                 $data = get_line($sql);
                 if (mysql_errno() != 0) {
                     return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
                 }
             }
             $sql = "DELETE FROM `" . s($table) . "` WHERE " . join(' AND ', $wsql);
             run_sql($sql);
             if (mysql_errno() != 0) {
                 $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (count($outputs) < 1) {
                     return $this->send_result(array('msg' => 'ok'));
                 } else {
                     if (strlen($out_code) > 0) {
                         eval($out_code);
                     }
                     return $this->send_result($data);
                 }
             }
             break;
         case 'list':
         default:
             $since_id = intval(v('since_id'));
             $max_id = intval(v('max_id'));
             $count = intval(v('count'));
             $order = strtolower(z(t(v('ord'))));
             $by = strtolower(z(t(v('by'))));
             if ($order == 'asc') {
                 $ord = ' ASC ';
             } else {
                 $ord = ' DESC ';
             }
             if (strlen($by) > 0) {
                 $osql = ' ORDER BY `' . s($by) . '` ' . $ord . ' ';
             } else {
                 $osql = '';
             }
             if ($count < 1) {
                 $count = 10;
             }
             if ($count > 100) {
                 $count = 100;
             }
             if (count($outputs) < 1) {
                 $this->send_error(LR_API_ARGS_ERROR, 'OUTPUT MUST HAS 1 FIELD AT LEAST');
             }
             $sql = "SELECT " . rjoin(',', '`', $outputs) . " FROM `" . s($table) . "` WHERE 1 ";
             if ($since_id > 0) {
                 $wsql = " AND `id` > '" . intval($since_id) . "' ";
             } elseif ($max_id > 0) {
                 $wsql = " AND `id` < '" . intval($max_id) . "' ";
             }
             if (count($inputs) > 0 && count($likes) + count($equals) > 0) {
                 // AND `xxx` == $xxx
                 if (count($likes) > 0) {
                     foreach ($likes as $like) {
                         if (z(t(v($like))) != '') {
                             $wwsql[] = " AND `" . s($like) . "` LIKE '%" . s(v($like)) . "%' ";
                         }
                     }
                 }
                 if (count($equals) > 0) {
                     foreach ($equals as $equal) {
                         if (z(t(v($equal))) != '') {
                             $wwsql[] = " AND `" . s($equal) . "` = '" . s(v($equal)) . "' ";
                         }
                     }
                 }
                 if (isset($wwsql)) {
                     $wsql = $wsql . join(' ', $wwsql);
                 }
             }
             $sql = $sql . $wsql . $osql . " LIMIT " . $count;
             //echo $sql;
             if ($idata = get_data($sql)) {
                 $first = reset($idata);
                 $max_id = $first['id'];
                 $min_id = $first['id'];
                 foreach ($idata as $item) {
                     if ($item['id'] > $max_id) {
                         $max_id = $item['id'];
                     }
                     if ($item['id'] < $min_id) {
                         $min_id = $item['id'];
                     }
                 }
                 $data = array('items' => $idata, 'max_id' => $max_id, 'min_id' => $min_id);
             } else {
                 $data = $idata;
             }
             if (mysql_errno() != 0) {
                 return $this->send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error());
             } else {
                 if (strlen($out_code) > 0) {
                     eval($out_code);
                 }
                 return $this->send_result($data);
             }
     }
     //return $this->send_error( LR_API_ARGS_ERROR , 'FIELD NOT EXISTS' );
 }
Exemple #23
0
function sp_set_dynamic_config($data)
{
    if (sp_is_sae()) {
        $kv = new SaeKV();
        $ret = $kv->init();
        $configs = $kv->get("THINKCMF_DYNAMIC_CONFIG");
        $configs = empty($configs) ? array() : unserialize($configs);
        $configs = array_merge($configs, $data);
        $result = $kv->set('THINKCMF_DYNAMIC_CONFIG', serialize($configs));
    } elseif (defined('IS_BAE') && IS_BAE) {
        $bae_mc = new BaeMemcache();
        $configs = $bae_mc->get("THINKCMF_DYNAMIC_CONFIG");
        $configs = empty($configs) ? array() : unserialize($configs);
        $configs = array_merge($configs, $data);
        $result = $bae_mc->set("THINKCMF_DYNAMIC_CONFIG", serialize($configs), MEMCACHE_COMPRESSED, 0);
    } else {
        $config_file = "./data/conf/config.php";
        if (file_exists($config_file)) {
            $configs = (include $config_file);
        } else {
            $configs = array();
        }
        $configs = array_merge($configs, $data);
        $result = file_put_contents($config_file, "<?php\treturn " . var_export($configs, true) . ";?>");
    }
    sp_clear_cache();
    return $result;
}
Exemple #24
0
 /**
  * 
  */
 public function __construct()
 {
     parent::__construct();
     $this->init();
 }
Exemple #25
0
 public function kv()
 {
     $k = new SaeKV();
     $k->init();
     $k->set('a', 'aaa');
     //建立一条字符串数据
     $ret = $k->get('a');
     //获得a的值
     dump($ret);
     $k->set('b', array('a', 'b', 'c'));
     //可存储数组或对象
     $ret = $k->get("b");
     //获得b的值
     dump($ret);
     $k->delete("a");
     //删除a
 }
Exemple #26
0
<?php

$kv = new SaeKV();
// 初始化SaeKV对象
$ret = $kv->init();
$ret = $kv->get('THINKCMF_DYNAMIC_CONFIG');
$runtime_config = $ret ? unserialize($ret) : array();
$_msaestorage = new SaeStorage();
$sae = array('DB_TYPE' => 'mysql', 'DB_DEPLOY_TYPE' => 1, 'DB_RW_SEPARATE' => true, 'DB_HOST' => SAE_MYSQL_HOST_M, 'DB_NAME' => SAE_MYSQL_DB, 'DB_USER' => SAE_MYSQL_USER, 'DB_PWD' => SAE_MYSQL_PASS, 'DB_PORT' => SAE_MYSQL_PORT, 'DB_PREFIX' => 'sp_', "COOKIE_PREFIX" => 'U49dZ1_', 'FILE_UPLOAD_TYPE' => 'Sae', 'TMPL_PARSE_STRING' => array('__UPLOAD__' => $_msaestorage->getUrl('data', 'upload') . "/"));
//print_r($runtime_config); die;
return array_merge($sae, $runtime_config);
function do_cos_html_cache_action()
{
    if ($_POST['indexHtmlCacheDelbt']) {
        $kv = new SaeKV();
        $kv->init();
        $ret = $kv->get(CosSiteHome . '/index.html');
        if ($ret) {
            if ($kv->delete(CosSiteHome . '/index.html')) {
                $msg = __('Index Caches were deleted successfully', 'cosbeta');
            } else {
                $msg = '存在首页缓存,但是删除失败';
            }
        } else {
            $msg = '不存在首页缓存';
        }
    }
    if (!empty($_POST['htmlCacheDelbt'])) {
        // @rename(CosBlogPath."index.html",CosBlogPath."index.bak");
        // @chmod( CosBlogPath."index.bak", 0666 );
        $kv = new SaeKV();
        $kv->init();
        $ret = $kv->get(CosSiteHome . '/index.html');
        if ($ret) {
            //$kv->set(CosBlogPath.'index.bak',$ret);
            $kv->delete(CosSiteHome . '/index.html');
        }
        global $wpdb;
        if ($_POST['cache_id'] * 1 > 0) {
            //delete cache by id
            DelCacheByUrl(get_permalink($_POST['cache_id']));
            $msg = __('the post cache was deleted successfully: ID=', 'cosbeta') . $_POST['cache_id'];
        } else {
            if (strlen($_POST['cache_id']) > 2) {
                $postRes = $wpdb->get_results("SELECT `ID`  FROM `" . $wpdb->posts . "` WHERE post_title like '%" . $_POST['cache_id'] . "%' LIMIT 0,1 ");
                DelCacheByUrl(get_permalink($postRes[0]->ID));
                $msg = __('the post cache was deleted successfully: Title=', 'cosbeta') . $_POST['cache_id'];
            } else {
                $postRes = $wpdb->get_results("SELECT `ID`  FROM `" . $wpdb->posts . "` WHERE post_status = 'publish' AND ( post_type='post' OR  post_type='page' )  ORDER BY post_modified DESC ");
                foreach ($postRes as $post) {
                    DelCacheByUrl(get_permalink($post->ID));
                }
                $msg = __('HTML Caches were deleted successfully', 'cosbeta');
            }
        }
    }
    if ($msg) {
        echo '<div class="updated"><strong><p>' . $msg . '</p></strong></div>';
    }
}
Exemple #28
0
 /**
  * Remove an item from the cache.
  *
  * @param  string  $key
  * @return void
  */
 public function forget($key)
 {
     $this->kvdb->delete($this->prefix . $key);
 }
Exemple #29
0
<?php

$kv = new SaeKV();
// 初始化SaeKV对象
$ret = $kv->init("zzz041ymx2");
//访问授权应用的数据
var_dump($ret);
// 增加key-value
$ret = $kv->add('pv', '0');
var_dump($ret);
 public function ClearSignStatus()
 {
     $cookieArr = M('Cookie')->where('overdue=0')->select();
     // 查询是否过期
     foreach ($cookieArr as $value) {
         // 双重查询确认
         if (GetTbName('BDUSS=' . $value['cookies'] . ';') == false && GetTbName('BDUSS=' . $value['cookies'] . ';') == false) {
             // 标记过期
             M('Cookie')->where('id=%d', $value['id'])->setField('overdue', 1);
             // 删除Cookie缓存
             $kv = new \SaeKV();
             $kv->init();
             $cookies = $kv->delete('Cookie' . $value['id']);
             // 删除该Cookie的贴吧
             M('SignList')->where('cookieid=%d', $value['id'])->delete();
             $email = M('User')->where('username="******"', $value['username'])->getField('email');
             // 通知用户
             send_mail($email, '【C云签】您的百度账户Cookie已失效', '您的百度账户【' . $value['name'] . '】Cookie已失效,请到 http://signtb.sinaapp.com 查看与重置');
         }
     }
     M('SignList')->where('id>0')->setField('issign', 0);
 }