示例#1
0
文件: notify.php 项目: noikiy/ecmall
 function _send($nid, $appid)
 {
     $myApp = $this->base->load('app');
     $applist = $myApp->applist();
     if (!($app = $applist[$appid])) {
         return false;
     }
     if ($nid) {
         $data = $this->get_by_id($nid);
     } else {
         $data = $this->get_by_one($appid);
         if (!$data) {
             $this->db->query("UPDATE " . UC_DBTABLEPRE . "config SET db_value='0' WHERE db_name=" . UC::escape('uc_notifyexists' . $appid));
         }
         $nid = $data['nid'];
     }
     if (!$data) {
         return false;
     }
     $field = 'app' . $appid;
     if ($appid == $this->base->appid && file_exists(SHOPNC_ROOT . 'api/pw_api/class_base.php')) {
         include_once SHOPNC_ROOT . 'api/pw_api/class_base.php';
         $api = new api_client();
         $resp = $api->dataFormat($api->callback($this->operations[$data['action']][0], $this->operations[$data['action']][1], $data['param'] ? unserialize($data['param']) : array()));
         $success = isset($resp['result']);
     } else {
         $resp = $myApp->ucfopen($app['siteurl'], $app['interface'], $app['secretkey'], $this->operations[$data['action']][0], $this->operations[$data['action']][1], $data['param'] ? unserialize($data['param']) : array());
         $success = isset($resp['result']);
     }
     if ($success) {
         $data[$field] = 1;
         $pwSQL = array($field => 1, 'complete' => $this->isComplete($data, $applist) ? 1 : 0);
         $this->db->query_unbuffered("UPDATE " . UC_DBTABLEPRE . "ucnotify SET " . UC::sqlSingle($pwSQL) . ' WHERE nid=' . UC::escape($nid));
     }
 }
示例#2
0
 function _synupdate($appid, $u_arr)
 {
     $myApp = $this->base->load('app');
     $applist = $myApp->applist();
     if (!($app = $applist[$appid])) {
         return false;
     }
     $field = 'app' . $appid;
     if ($u_arr) {
         $query = $this->db->query("SELECT * FROM " . UC_DBTABLEPRE . "ucsyncredit WHERE uid IN(" . UC::implode($u_arr) . ')');
     } else {
         $query = $this->db->query("SELECT * FROM " . UC_DBTABLEPRE . "ucsyncredit WHERE {$field} < '1' LIMIT 10");
         if ($this->db->num_rows($query) == 0) {
             $this->db->query("UPDATE " . UC_DBTABLEPRE . "config SET db_value='0' WHERE db_name=" . UC::escape('uc_syncreditexists' . $appid));
             return false;
         }
     }
     $us = array();
     while ($rt = $this->db->fetch_array($query)) {
         $us[$rt['uid']] = $rt;
     }
     if (empty($us)) {
         return false;
     }
     $uids = array_keys($us);
     $ucds = $this->get($uids);
     $ucds = $this->exchange($ucds, $appid);
     if ($appid == $this->base->appid && file_exists(SHOPNC_ROOT . 'api/pw_api/class_base.php')) {
         include SHOPNC_ROOT . 'api/pw_api/class_base.php';
         $api = new api_client();
         $resp = $api->dataFormat($api->callback('Credit', 'syncredit', array($ucds)));
         $success = isset($resp['result']);
     } else {
         $resp = $myApp->ucfopen($app['siteurl'], $app['interface'], $app['secretkey'], 'Credit', 'syncredit', array($ucds));
         $success = isset($resp['result']);
     }
     if ($success) {
         $cls = array();
         foreach ($us as $key => $data) {
             $data[$field] = 1;
             if ($this->isComplete($data, $applist)) {
                 $cls[] = $key;
             }
         }
         $cls && $this->db->update("DELETE FROM " . UC_DBTABLEPRE . "ucsyncredit WHERE uid IN(" . UC::implode($cls) . ')');
         $this->db->update("UPDATE " . UC_DBTABLEPRE . "ucsyncredit SET {$field}='1' WHERE uid IN(" . UC::implode($uids) . ')');
     }
 }
示例#3
0
// UCenter 数据库主机
define('UC_DBUSER', $data['ucenter_mysql_username']);
// UCenter 数据库用户名
define('UC_DBPW', $data['ucenter_mysql_passwd']);
// UCenter 数据库密码
define('UC_DBNAME', $data['ucenter_mysql_name']);
// UCenter 数据库名称
define('UC_DBCHARSET', strtoupper($dbcharset) == 'UTF-8' ? 'utf8' : 'gbk');
// UCenter 数据库字符集
define('UC_DBTABLEPRE', '`' . $data['ucenter_mysql_name'] . '`.' . $data['ucenter_mysql_pre']);
// UCenter 数据库表前缀
//通信相关
define('UC_KEY', $data['ucenter_app_key']);
// 与 UCenter 的通信密钥, 要与 UCenter 保持一致
define('UC_API', $data['ucenter_url']);
// UCenter 的 URL 地址, 在调用头像时依赖此常量
define('UC_CHARSET', $dbcharset);
// UCenter 的字符集
define('UC_IP', $data['ucenter_ip']);
// UCenter 的 IP, 当 UC_CONNECT 为非 mysql 方式时, 并且当前应用服务器解析域名有问题时, 请设置此值
define('UC_APPID', $data['ucenter_app_id']);
// 当前应用的 ID
require_once SHOPNC_ROOT . 'pw_client/class_db.php';
$GLOBALS['db'] = new UcDB($dbserver, $dbuser, $dbpasswd, $dbname, 0, $dbcharset);
$GLOBALS['tablepre'] = '`' . $dbname . '`.' . $db_pre;
unset($dbserver, $dbuser, $dbpasswd, $dbpasswd, $dbname, $db_pre);
$api = new api_client();
$response = $api->run($_POST + $_GET);
if ($response) {
    echo $api->dataFormat($response);
}