Esempio n. 1
0
 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));
     }
 }
Esempio n. 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) . ')');
     }
 }