Exemplo n.º 1
0
 private function getMem()
 {
     if ($this->_mem == null) {
         $this->_mem = memcache_connect(getC("MEMCACHE_SERVER"), getC("MEMCACHE_PORT"));
     }
     return $this->_mem;
 }
Exemplo n.º 2
0
 /**
  * 检测执行任务,SAE和BAE平台会自动执行,本地环境需要调用该方法执行任务 
  */
 static function checkAndDo()
 {
     $plat = getC("SERVER_PLAT");
     if ($plat == "OWN") {
         return My_TaskQuery::checkAndDo();
     }
 }
 /**
  *
  * @param type $data
  * @param type $type
  * @return string
  */
 public static function upImg($data, $type = 'jpg')
 {
     if (!self::isImg(strtolower($type))) {
         return FALSE;
     }
     $server = getC("upload_server");
     $sign = getC("upload_sign");
     $file_url = upload_file($server, $data, $type, $sign);
     return $file_url;
 }
Exemplo n.º 4
0
 public function display($data = '', $tpl = '')
 {
     if (!$tpl) {
         $tpl = str_replace("Action", '', getC()) . '/' . getM();
     }
     if ($data) {
         extract($data);
     }
     include './view/' . $tpl . '.php';
 }
Exemplo n.º 5
0
 private function getConn()
 {
     if ($this->conn == null) {
         $this->conn = new mysqli(getC("DB_HOST"), getC("DB_USER"), getC("DB_PWD"), getC("DB_NAME"));
     }
     if ($this->conn->connect_errno) {
         die("db connect_errno: {$this->conn->connect_errno}");
     }
     return $this->conn;
 }
Exemplo n.º 6
0
 /**
  * [getDES get请求 放回数据DES加密接口]
  * @param {String} $api 必须传,api名 用于获取相应配置
  * @param {String} $act 必须传,请求的api接口
  * @param {Array} $para 请求参数
  * @return {Json} 请求返回数据
  */
 function getDES($api, $act, $para)
 {
     $apiconfig = getC($api);
     $url = @$apiconfig['url'];
     $token = @$apiconfig['apitoken'];
     $para = self::getPara($para);
     $url = $url . "/" . $act . "?" . $para . "&apitoken=" . $token;
     $res = CURLHandler::share()->query($url);
     $res = MyDes::share()->decode($res, @$apiconfig['DES_KEY']);
     $res = json_decode($res);
     return $res;
 }
Exemplo n.º 7
0
 static function getLoginUser()
 {
     $str = get_cookie(getC('LOGIN_KEY'));
     $arr = explode("###", $str);
     $mc = MC();
     $mk = getC('LOGIN_KEY') . "_" . $arr[0];
     $obj = $mc->get($mk);
     if ($str && $obj->SIMULATION_LOGIN_STR == $str) {
         return $obj;
     }
     return null;
 }
 /**
  * @return ApiServiceFacade
  */
 static function share($apiname, $act)
 {
     static $ins = null;
     $config = getC($apiname);
     self::$act = $act;
     self::$key = @$config['DES_KEY'];
     self::$token = @$config["token"];
     if (!$ins) {
         self::$url = @$config['url'];
         $ins = new ApiServiceFacade();
     }
     return $ins;
 }
Exemplo n.º 9
0
 public function upload_do()
 {
     if (isset($_FILES['file'])) {
         $tArr = explode(".", $_FILES["file"]["name"]);
         $type = $tArr[count($tArr) - 1];
         $filename = $_FILES["file"]["tmp_name"];
         $handle = fopen($filename, "r");
         $data = fread($handle, filesize($filename));
         fclose($handle);
         $server = getC("upload_server");
         $sign = getC("upload_sign");
         echo upload_file($server, $data, $type, $sign);
     }
 }
Exemplo n.º 10
0
 /**
  * 礼物中心
  *
  */
 function index()
 {
     //获取分组好的礼物列表
     $giftList = $this->gift_category->GiftToCategory();
     //获取当前用户的积分
     $money = getCredit($this->mid, $this->api);
     $moneyType = getC('creditName');
     $this->assign('money', $money[$moneyType]);
     //把用户姓名和头像赋值给模板
     $this->__assignNameAndFace(intval($_GET['uid']));
     //赋值给模板
     $this->assign('categorys', $giftList);
     $this->display();
 }
Exemplo n.º 11
0
 /**
  * 多条短信用 ',' 分隔 
  * @param type $phones
  * @param type $content
  */
 public function send($phones, $content)
 {
     if (!ereg("^.*\$", $phones)) {
         return false;
     }
     if (strlen($phones) < 3) {
         return false;
     }
     $key = getC("SMS_KEY");
     $sucretKey = getC("SMS_SUCRET");
     $url = "http://sms.bechtech.cn/Api/send/data/json?accesskey={$key}&secretkey={$sucretKey}&mobile={$phones}&content=" . urlencode($content);
     //my_log($url);
     if (CURLHandler::share()->query($url) === FALSE) {
         return false;
     }
     return true;
 }
Exemplo n.º 12
0
 function sendmail($to, $subject = "", $body = "", $mailtype, $cc = "", $bcc = "", $additional_headers = "")
 {
     $from = getC("SMTP_FROMMAIL");
     $mail_from = $this->get_address($this->strip_comment($from));
     $body = ereg_replace("(^|(\r\n))(\\.)", ".", $body);
     $header .= "MIME-Version:1.0\r\n";
     if ($mailtype == "HTML") {
         $header .= "Content-Type:text/html\r\n";
     }
     $header .= "To: " . $to . "\r\n";
     if ($cc != "") {
         $header .= "Cc: " . $cc . "\r\n";
     }
     $header .= "From: {$from}<" . $from . ">\r\n";
     $header .= "Subject: " . $subject . "\r\n";
     $header .= $additional_headers;
     $header .= "Date: " . date("r") . "\r\n";
     $header .= "X-Mailer:By Redhat (PHP/" . phpversion() . ")\r\n";
     list($msec, $sec) = explode(" ", microtime());
     $header .= "Message-ID: <" . date("YmdHis", $sec) . "." . $msec * 1000000 . "." . $mail_from . ">\r\n";
     $TO = explode(",", $this->strip_comment($to));
     if ($cc != "") {
         $TO = array_merge($TO, explode(",", $this->strip_comment($cc)));
     }
     if ($bcc != "") {
         $TO = array_merge($TO, explode(",", $this->strip_comment($bcc)));
     }
     $sent = TRUE;
     foreach ($TO as $rcpt_to) {
         $rcpt_to = $this->get_address($rcpt_to);
         if (!$this->smtp_sockopen($rcpt_to)) {
             $this->log_write("Error: Cannot send email to " . $rcpt_to . "\n");
             $sent = FALSE;
             continue;
         }
         if ($this->smtp_send($this->host_name, $mail_from, $rcpt_to, $header, $body)) {
             $this->log_write("E-mail has been sent to <" . $rcpt_to . ">\n");
         } else {
             $this->log_write("Error: Cannot send email to <" . $rcpt_to . ">\n");
             $sent = FALSE;
         }
         fclose($this->sock);
         $this->log_write("Disconnected from remote host\n");
     }
     return $sent;
 }
Exemplo n.º 13
0
 function __construct()
 {
     $dbname = getC("BAE_FOR_MYKV_REDIS_NAME");
     $host = getenv('HTTP_BAE_ENV_ADDR_REDIS_IP');
     $port = getenv('HTTP_BAE_ENV_ADDR_REDIS_PORT');
     $user = getenv('HTTP_BAE_ENV_AK');
     $pwd = getenv('HTTP_BAE_ENV_SK');
     try {
         $redis = new Redis();
         $ret = $redis->connect($host, $port);
         if ($ret === false) {
             die($redis->getLastError());
         }
         $ret = $redis->auth($user . "-" . $pwd . "-" . $dbname);
         if ($ret === false) {
             die($redis->getLastError());
         }
         $this->redis = $redis;
     } catch (RedisException $e) {
         die("Uncaught exception " . $e->getMessage());
     }
 }
 /**
  * sendGift
  * 发送礼物
  * 
  * @param array $toUid  接收礼品人的ID(可以多个,以,分隔)
  * @param $fromUid  送礼者ID
  * @param $sendInfo  附加信息和发送方式
  * @param $giftInfo  礼品信息
  */
 public function sendGift($toUid, $fromUid, $fromName, array $sendInfo, array $giftInfo)
 {
     //判断参数是否合法.不合法返回false
     if (!is_numeric($fromUid)) {
         return '非法操作!';
     }
     $toUser = explode(',', $toUid);
     $userNum = count($toUser);
     //判断是否是自己给自己送礼物
     if (in_array($fromUid, $toUser)) {
         return '不能给自己送礼物!';
     }
     //判断是否有足够的礼物数
     if ($this->gift->assertNumAreEmpty($giftInfo['id'], $userNum)) {
         return '礼物库存不足,发送礼品失败!';
     }
     //扣除相应积分
     $giftPrice = intval($giftInfo['price']);
     $prices = $userNum * $giftPrice;
     $type = getC('creditType');
     $credit[$type] = '-' . $prices;
     if (!$this->__setScore($fromUid, $credit)) {
         return '您的' . getC('creditName') . '不足,发送礼品失败!';
     }
     $map['giftPrice'] = $giftPrice;
     $map['giftImg'] = t($giftInfo['img']);
     $map['sendInfo'] = t($sendInfo['sendInfo']);
     $map['sendWay'] = intval($sendInfo['sendWay']);
     $map['fromUserId'] = intval($fromUid);
     $map['fromUserName'] = t($fromName);
     $map['cTime'] = time();
     $res = $this->__insertData($toUser, $map);
     //如果入库过程成功.则做相应的处理
     if ($res) {
         //礼物数减1
         $this->gift->setDec('num', 'id=' . $giftInfo['id'], $userNum);
         //获取礼品应用在系统里的注册ID值,系统的动态和通知都需要这个ID进行相关应用信息的获取。
         $appId = $this->api->app_getChoiceId('gift');
         if (1 == $sendInfo['sendWay']) {
             //发送动态
             $this->__doFeed($sendInfo, $giftInfo, $toUser, $appId);
         }
         //给接收人发送通知
         $this->__doNotify($toUser, $sendInfo, $giftInfo, $fromUid, $appId);
         //更新个人空间的礼品统计
         $this->_gift_count($toUser);
         return 1;
     } else {
         return '发送礼品失败!';
     }
 }
Exemplo n.º 15
0
 /**
  * delAajax
  * 删除分享
  *
  * @param $_GET['id']  分享ID
  * @access public
  * @return -2 没权限删除 -1 不存在或已删除 0 失败 1 成功
  */
 function delAajax()
 {
     $id = intval($_REQUEST['id']);
     $share = $this->model->find($id);
     if (empty($share)) {
         echo -1;
         exit;
     }
     if ($share['toUid'] != $this->mid) {
         echo -2;
         exit;
     }
     if (getC('isDel')) {
         $result = $this->model->delete($id);
     } else {
         $result = $this->model->where("id='{$id}'")->setField('isDel', '1');
     }
     echo $result;
 }
Exemplo n.º 16
0
 public static function getUrlRoot()
 {
     $port = "";
     if ($_SERVER["SERVER_PORT"] != '80') {
         $port = ":" . $_SERVER["SERVER_PORT"];
     }
     $url = "http://" . $_SERVER["SERVER_NAME"] . $port . getC("APP_URL");
     return $url;
 }
Exemplo n.º 17
0
 /**
  * delete
  * 删除分享
  *
  * @param id  分享ID
  * @access public
  * @return void
  */
 function delete()
 {
     $id = $_REQUEST['id'];
     $ids = explode(',', $id);
     $where = " id IN (" . join(",", $ids) . ")";
     if (getC('isDel') || isset($_GET['delSure'])) {
         $result = $this->model->where($where)->delete();
     } else {
         $result = $this->model->where($where)->setField('isDel', '1');
     }
     if ($result) {
         $this->success('删除成功!');
     } else {
         $this->error('删除失败!');
     }
 }
Exemplo n.º 18
0
$example();
$message = "hello";
$example = function () use(&$message) {
    var_dump($message);
};
$example();
$message = "world";
$example();
class C
{
}
function getC()
{
    return new C();
}
var_dump(getC());
list($b, $a) = [1, 2, 3];
echo $a, $b;
function test_($a, $b)
{
    echo $a, $b;
    return;
}
$a = [1, 2, 3];
test_(...$a);
echo 'before : ' . $color . ' ' . $fruit . "\n";
// include 'vars.php' ;
require 'vars.php';
echo 'after  : ' . $color . ' ' . $fruit . "\n";
for ($i = 0; $i < 10; $i++) {
    for ($j = 0; $j < 10; $j++) {
Exemplo n.º 19
0
 static function load_class($class)
 {
     $cachetime = getC("AUTO_LOAD_CACHETIME");
     if ($cachetime > 0 && !in_array($class, array("MyCache"))) {
         $m = MC();
         $mk = md5(getC("APP_PATH")) . "_" . $class;
         $mget = $m->get($mk);
         if ($mget) {
             if (file_exists($mget)) {
                 require_once "{$mget}";
                 return;
             } else {
                 $m->delete($mk);
             }
         }
     }
     $arr = getC("AUTO_LOAD_PATH");
     $classFullPath = null;
     foreach ($arr as $path) {
         $file1 = $path . "/" . "{$class}.class.php";
         //my_log($file1);
         if (file_exists($file1)) {
             $classFullPath = $file1;
             break;
         }
         $file2 = $path . "/" . "class.{$class}.php";
         if (file_exists($file2)) {
             $classFullPath = $file2;
             break;
         }
     }
     if ($cachetime > 0 && $m && $classFullPath) {
         $m->set($mk, $classFullPath, $cachetime);
     }
     require_once "{$classFullPath}";
 }
Exemplo n.º 20
0
<?php

//应用zj_php框架
require_once './zj_php/zj_php.php';
//设置应用路径
setC("APP_PATH", dirname(__FILE__));
setC("TPL_PATH", getC("APP_PATH") . "/_Tpl/");
//设置 APP URL
$arr1 = explode("index.php", $_SERVER["SCRIPT_NAME"]);
setC("APP_URL", $arr1[0]);
setC("APP_URL_ACTIONTAG", "a/");
//添加应用自动加载类路径
add_autoload_path(getC("APP_PATH") . "/_Action/", true);
add_autoload_path(getC("APP_PATH") . "/_Business/", true);
add_autoload_path(getC("APP_PATH") . "/_Business/Entity/", true);
add_autoload_path(getC("APP_PATH") . "/_Server/", true);
add_autoload_path(getC("APP_PATH") . "/_Lib/", true);
add_autoload_path(getC("APP_PATH") . "/_Factory/", true);
//添加应用配置文件
add_app_config(getC("APP_PATH") . "/_Conf/app.config.php");
add_app_config(getC("APP_PATH") . "/_Conf/" . strtolower(getC("APP_STATE")) . ".config.php");
//加载自定义函数
//执行请求
Runtime::doQuery();
Exemplo n.º 21
0
error_reporting(7);
//set_magic_quotes_runtime(0);
require_once 'Common/Config.inc.php';
require_once 'Common/Common.inc.php';
require_once 'Common/Function.inc.php';
require_once 'Common/Runtime.inc.php';
//添加自动加载Class路径
add_autoload_path(ZJ_PHP_PATH . "Lib/", true);
add_autoload_path(ZJ_PHP_PATH . "Extend/", true);
$_POST = Add_S($_POST);
$_GET = Add_S($_GET);
$_COOKIE = Add_S($_COOKIE);
// 可以用 $q_xx 直接访问 $_REQUEST["aa"];
foreach ($_REQUEST as $key => $value) {
    $name1 = "q_" . $key;
    ${$name1} = $value;
}
//请求的Action和Method,在Runtime的Query对其赋值。
$_QueryAction = "";
$_QueryMethod = "";
ob_start();
//JS跨域
if (getC("CORS")) {
    @header('Access-Control-Allow-Origin: ' . getC("CORS"));
}
@header('Content-Type: text/html; charset=' . WEB_LANG);
//xxx/index.php?doTaskQueue
if (isset($q_doTaskQueue)) {
    MyTaskQueue::checkAndDo();
    exit;
}
Exemplo n.º 22
0
<?php

//应用zj_php框架
require_once '../../zj_php.php';
//设置应用路径
setC("APP_PATH", dirname(__FILE__));
setC("TPL_PATH", getC("APP_PATH") . "/Tpl/");
//设置 APP URL
$arr1 = explode("index.php", $_SERVER["SCRIPT_NAME"]);
setC("APP_URL", $arr1[0]);
setC("APP_URL_ACTIONTAG", "");
//添加应用自动加载类路径
add_autoload_path(getC("APP_PATH") . "/Action/");
//添加应用配置文件
add_app_config(getC("APP_PATH") . "/Conf/App1_Conf.php");
//加载自定义函数
require_once "./Conf/AppFunction.php";
//执行请求
Runtime::doQuery();
Exemplo n.º 23
0
<?php

/**
 * PHP SqlTrace
 * ============================================================================
 * * 版权所有 
 * 博客地址: http://gaozhongyi.sinaapp.com/;
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用;不允许对程序代码以任何形式任何目的的再发布。您也可以加入QQ群119286361做
 * 深层次的探讨
 * 注意:打开页面后,请勿频繁手动刷新页面。否则会产品额外sql记录。
 * ============================================================================
 * $Author: gaozhongyi 
 * $QQ : 673973036  $qq群:119286361
 * $Date 2015/12/19 $end
*/
require './lib/mysql.class.php';
require './common/function.php';
require './lib/Action.class.php';
define('__ROOT__', dirname($_SERVER['SCRIPT_FILENAME']));
define('TRACE_PATH', __ROOT__ . '/runtime/trace.log');
$controller = getC();
$method = getM();
include './controller/' . $controller . '.class.' . 'php';
$class = new $controller();
$class->{$method}();
//添加注释