Exemple #1
0
 function onrequest()
 {
     $uid = intval($this->input('uid'));
     $from = intval($this->input('from'));
     $to = intval($this->input('to'));
     $toappid = intval($this->input('toappid'));
     $amount = intval($this->input('amount'));
     $status = 0;
     if (isset($this->settings['creditexchange'][$this->app['appid'] . '_' . $from . '_' . $toappid . '_' . $to])) {
         $toapp = $app = $this->cache['apps'][$toappid];
         $apifilename = isset($toapp['apifilename']) && $toapp['apifilename'] ? $toapp['apifilename'] : 'uc.php';
         if ($toapp['extra']['apppath'] && @(include $toapp['extra']['apppath'] . './api/' . $apifilename)) {
             $uc_note = new uc_note();
             $status = $uc_note->updatecredit(array('uid' => $uid, 'credit' => $to, 'amount' => $amount), '');
         } else {
             $url = $_ENV['note']->get_url_code('updatecredit', "uid={$uid}&credit={$to}&amount={$amount}", $toappid);
             $status = trim($_ENV['misc']->dfopen($url, 0, '', '', 1, $toapp['ip'], UC_NOTE_TIMEOUT));
         }
     }
     echo $status ? 1 : 0;
     exit;
 }
Exemple #2
0
 function ongetcredit($arr)
 {
     $this->init_input();
     $appid = $this->input('appid');
     $uid = $this->input('uid');
     $credit = $this->input('credit');
     $this->load('note');
     $this->load('misc');
     $app = $this->cache['apps'][$appid];
     $apifilename = isset($app['apifilename']) && $app['apifilename'] ? $app['apifilename'] : 'uc.php';
     if ($app['extra']['apppath'] && @(include $app['extra']['apppath'] . './api/' . $apifilename)) {
         $uc_note = new uc_note();
         return $uc_note->getcredit(array('uid' => $uid, 'credit' => $credit), '');
     } else {
         $url = $_ENV['note']->get_url_code('getcredit', "uid={$uid}&credit={$credit}", $appid);
         return $_ENV['misc']->dfopen($url, 0, '', '', 1, $app['ip'], UC_NOTE_TIMEOUT);
     }
 }
Exemple #3
0
 function onping()
 {
     $ip = getgpc('ip');
     $url = getgpc('url');
     $appid = intval(getgpc('appid'));
     $app = $_ENV['app']->get_app_by_appid($appid);
     $status = '';
     if ($app['extra']['apppath'] && @(include $app['extra']['apppath'] . './api/' . $app['apifilename'])) {
         $uc_note = new uc_note();
         $status = $uc_note->test($note['getdata'], $note['postdata']);
     } else {
         $this->load('note');
         $url = $_ENV['note']->get_url_code('test', '', $appid);
         $status = $_ENV['app']->test_api($url, $ip);
     }
     if ($status == '1') {
         echo 'document.getElementById(\'status_' . $appid . '\').innerHTML = "<img src=\'images/correct.gif\' border=\'0\' class=\'statimg\' \\/><span class=\'green\'>' . $this->lang['app_connent_ok'] . '</span>";testlink();';
     } else {
         echo 'document.getElementById(\'status_' . $appid . '\').innerHTML = "<img src=\'images/error.gif\' border=\'0\' class=\'statimg\' \\/><span class=\'red\'>' . $this->lang['app_connent_false'] . '</span>";testlink();';
     }
 }
Exemple #4
0
 function onsync()
 {
     $this->load('note');
     $this->load('misc');
     $this->load('cache');
     $step = intval(getgpc('step', 'G'));
     if (!$step && is_array($this->cache['apps'])) {
         $credits = array();
         $stepapp = intval(getgpc('stepapp', 'G'));
         $testrelease = intval(getgpc('testrelease', 'G'));
         $appids = array_keys($this->cache['apps']);
         $appid = $appids[$stepapp];
         if (!$stepapp) {
             $_CACHE['credits'] = array();
         } else {
             include UC_DATADIR . 'cache/credits.php';
         }
         if ($app = $this->cache['apps'][$appid]) {
             $apifilename = isset($app['apifilename']) && $app['apifilename'] ? $app['apifilename'] : 'uc.php';
             if ($app['extra']['apppath'] && @(include $app['extra']['apppath'] . './api/' . $apifilename)) {
                 $uc_note = new uc_note();
                 $data = trim($uc_note->getcreditsettings('', ''));
             } else {
                 $url = $_ENV['note']->get_url_code('getcreditsettings', '', $appid);
                 $data = trim($_ENV['misc']->dfopen($url, 0, '', '', 1));
             }
             if (!$testrelease) {
                 if (!($data = $this->sync_unserialize($data, ''))) {
                     header('location: ' . UC_API . '/admin.php?m=credit&a=sync&step=0&stepapp=' . $stepapp . '&testrelease=1&sid=' . $this->view->sid);
                     exit;
                 } else {
                     $stepapp++;
                 }
             } else {
                 $data = $this->sync_unserialize($data, 'release/20080429/');
                 $stepapp++;
             }
             if ($data) {
                 $_CACHE['credits'][$appid] = $data;
                 $s = "<?php\r\n";
                 $s .= '$_CACHE[\'credits\'] = ' . var_export($_CACHE['credits'], TRUE) . ";\r\n";
                 $s .= "\r\n?>";
                 $fp = @fopen(UC_DATADIR . 'cache/credits.php', 'w');
                 @fwrite($fp, $s);
                 @fclose($fp);
             }
             header('location: ' . UC_API . '/admin.php?m=credit&a=sync&step=0&stepapp=' . $stepapp . '&sid=' . $this->view->sid);
         } else {
             header('location: ' . UC_API . '/admin.php?m=credit&a=sync&step=1&sid=' . $this->view->sid);
         }
         exit;
     }
     include_once UC_DATADIR . 'cache/credits.php';
     $credits = $_CACHE['credits'];
     $this->set_setting('credits', $credits, TRUE);
     $this->load('cache');
     $_ENV['cache']->updatedata('settings');
     $this->writelog('credit_sync', 'succeed');
     $settings = $this->get_setting(array('creditexchange'), TRUE);
     $creditexchange = is_array($settings['creditexchange']) ? $settings['creditexchange'] : array();
     $updaterequest = array();
     $i = 0;
     foreach ($creditexchange as $set => $ratio) {
         $tmp = array();
         list($tmp['appsrc'], $tmp['creditsrc'], $tmp['appdesc'], $tmp['creditdesc']) = explode('_', $set);
         list($tmp['ratiosrc'], $tmp['ratiodesc']) = explode("\t", $ratio);
         $updaterequest[$tmp['appsrc']][] = '&credit[' . $tmp['appsrc'] . '][' . $i . '][creditsrc]=' . intval($tmp['creditsrc']) . '&credit[' . $tmp['appsrc'] . '][' . $i . '][appiddesc]=' . urlencode($tmp['appdesc']) . '&credit[' . $tmp['appsrc'] . '][' . $i . '][creditdesc]=' . intval($tmp['creditdesc']) . '&credit[' . $tmp['appsrc'] . '][' . $i . '][title]=' . urlencode($this->cache['apps'][$tmp['appdesc']]['name'] . ' ' . $credits[$tmp['appdesc']][$tmp['creditdesc']][0]) . '&credit[' . $tmp['appsrc'] . '][' . $i . '][unit]=' . urlencode($credits[$tmp['appdesc']][$tmp['creditdesc']][1]) . '&credit[' . $tmp['appsrc'] . '][' . $i . '][ratiosrc]=' . $tmp['ratiosrc'] . '&credit[' . $tmp['appsrc'] . '][' . $i . '][ratiodesc]=' . $tmp['ratiodesc'] . '&credit[' . $tmp['appsrc'] . '][' . $i . '][ratio]=' . $tmp['ratiosrc'] / $tmp['ratiodesc'];
         $i++;
     }
     $data = array();
     foreach ($updaterequest as $appid => $value) {
         $data[] = implode('', $updaterequest[$appid]);
     }
     $_ENV['note']->add('updatecreditsettings', implode('', $data));
     $_ENV['note']->send();
     $this->message('syncappcredits_updated', 'admin.php?m=credit&a=ls');
 }