Пример #1
0
                exit;
            }
        }
        $sql = "delete from {$sort_table} where id={$sort_id}";
        $dbo->exeUpdate($sql);
        break;
    case "change":
        if ($module == "group") {
            $is_check = check_rights("a08");
            if (!$is_check) {
                echo $m_langpackage->m_no_pri;
                exit;
            }
        } else {
            $is_check = check_rights("a12");
            if (!$is_check) {
                echo $m_langpackage->m_no_pri;
                exit;
            }
        }
        $sort_name = get_argp('sort_name');
        $sort_order = get_argp('sort_order');
        $sql = "update {$sort_table} set name='{$sort_name}',order_num={$sort_order} where id={$sort_id}";
        $dbo->exeUpdate($sql);
        break;
    default:
        echo "error";
        break;
}
updateCache($key_mt);
Пример #2
0
            $year = $year - 1;
            $month = 12;
        }
        $tries++;
        // Never try too hard to get game records. A player may not have played enough games to fill the quota, or may not even exist.
        if ($tries > 3) {
            break;
        }
    }
    // convert game records to json
    $games = json_encode($games);
    // Write contents of KGS Game Archives page to user-specified $gameFile
    echo $cacheFile;
    echo getcwd();
    $fh = fopen($cacheFile, 'w') or die('Can\'t open file.');
    fwrite($fh, $games);
    fclose($fh);
}
/* Outputs the contents of the cached archive file in JSON format */
function outputCache()
{
    global $cacheFile;
    $output = file_get_contents($cacheFile);
    echo $output;
}
// If checkCacheFreshness returns false, update the file from KGS
if (checkCacheFreshness() == false || $_GET[noCache] == 'true') {
    updateCache();
}
// Output the contents of the cached archive file
outputCache();
Пример #3
0
function addTopic()
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
    $topicpid = isset($_POST['topic_pid']) ? intval($_POST['topic_pid']) : 0;
    $xt = new NewsTopic();
    if (!$xt->topicExists($topicpid, $_POST['topic_title'])) {
        $xt->setTopicPid($topicpid);
        if (empty($_POST['topic_title']) || xoops_trim($_POST['topic_title']) == '') {
            redirect_header("index.php?op=topicsmanager", 2, _AM_ERRORTOPICNAME);
        }
        $xt->setTopicTitle($_POST['topic_title']);
        //$xt->Settopic_rssurl($_POST['topic_rssfeed']);
        $xt->setTopic_color($_POST['topic_color']);
        if (isset($_POST['topic_imgurl']) && $_POST['topic_imgurl'] != "") {
            $xt->setTopicImgurl($_POST['topic_imgurl']);
        }
        $xt->setMenu(intval($_POST['submenu']));
        $xt->setTopicFrontpage(intval($_POST['topic_frontpage']));
        if (isset($_POST['xoops_upload_file'])) {
            $fldname = $_FILES[$_POST['xoops_upload_file'][0]];
            $fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
            if (xoops_trim($fldname != '')) {
                $sfiles = new sFiles();
                $dstpath = XOOPS_ROOT_PATH . "/modules/" . $xoopsModule->dirname() . '/images/topics';
                $destname = $sfiles->createUploadName($dstpath, $fldname, true);
                $permittedtypes = array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png');
                $uploader = new XoopsMediaUploader($dstpath, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
                $uploader->setTargetFileName($destname);
                if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
                    if ($uploader->upload()) {
                        $xt->setTopicImgurl(basename($destname));
                    } else {
                        echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
                    }
                } else {
                    echo $uploader->getErrors();
                }
            }
        }
        $xt->setTopicDescription($_POST['topic_description']);
        $xt->store();
        updateCache();
        $notification_handler =& xoops_gethandler('notification');
        $tags = array();
        $tags['TOPIC_NAME'] = $_POST['topic_title'];
        $notification_handler->triggerEvent('global', 0, 'new_category', $tags);
        redirect_header('index.php?op=topicsmanager', 1, _AM_DBUPDATED);
    } else {
        redirect_header('index.php?op=topicsmanager', 2, _AM_ADD_TOPIC_ERROR);
    }
    exit;
}
Пример #4
0
 public function del()
 {
     $where = array('self' => $this->oUser['id'], 'other' => $this->para['uid']);
     $this->model = D('Friend');
     $res = $this->model->delete($where);
     if ($res === false) {
         $this->resultFormat(null, 0, $this->model->getLastSql());
     }
     $type = D('User')->where(array('id' => $this->oUser['id']))->getField('type');
     switch ($type) {
         case '1':
             $this->model = D('User_owner');
             break;
         case '2':
             $this->model = D('User_designer');
             break;
         case '3':
             $this->model = D('Company');
             break;
     }
     $res = updateCache($this->model, array('uid' => $this->oUser['id']), array('friend_count' => '--'));
     if ($res === false) {
         $this->resultFormat(null, 0, 'SQL:' . $this->model->getLastSql());
     }
     $type = D('User')->where(array('id' => $this->para['uid']))->getField('type');
     switch ($type) {
         case '1':
             $this->model = D('User_owner');
             break;
         case '2':
             $this->model = D('User_designer');
             break;
         case '3':
             $this->model = D('Company');
             break;
     }
     $res = updateCache($this->model, array('uid' => $this->para['uid']), array('fensi_count' => '--'));
     if ($res === false) {
         $this->resultFormat(null, 0, 'SQL:' . $this->model->getLastSql());
     }
     $this->resultFormat(null, 1);
 }
Пример #5
0
function getConversionRate($from, $to)
{
    global $cache_tolerance, $cache_conversion, $webServiceURL;
    $cache_file = $cache_conversion . md5($from) . "-" . md5($to);
    if (isCacheValid($cache_file, $cache_tolerance)) {
        return file_get_contents($cache_file);
    }
    $url = $webServiceURL . "?from=" . $from . "&to=" . $to;
    $cache_contents = updateCache($cache_file, $url);
    if (strlen($cache_contents) > 0) {
        $cache_file_reverse = $cache_conversion . md5($to) . "-" . md5($from);
        $reverse_response = getReverseResponse($cache_contents);
        if (strlen($reverse_response) > 0) {
            writeCache($cache_file_reverse, $reverse_response);
        }
    } else {
        $cache_contents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<response>\n<conversion-rate>0.0</conversion-rate>\n<date>:-(</date>\n</response>";
    }
    return $cache_contents;
}
Пример #6
0
function updateCache(&$broadcaster)
{
    file_put_contents("./cache/{$broadcaster['twitch']}", serialize($broadcaster));
}
$broadcastersOnline = array();
$broadcastersOffline = array();
$broadcasters = array(array('twitch' => 'aureusknightstv', 'twitter' => 'aureusknights', 'name' => 'Aureus Knights TV'), array('twitch' => 'okaria', 'twitter' => 'okaria', 'name' => 'Okaria Dragon'), array('twitch' => 'gagtech', 'twitter' => 'Gagtech', 'name' => 'Gagtech'), array('twitch' => 'chux81', 'twitter' => '', 'name' => 'Chux'), array('twitch' => 'ryath', 'twitter' => '', 'name' => 'Ryath'));
foreach ($broadcasters as &$broadcaster) {
    if (!$broadcaster) {
        continue;
    }
    if (!hasCache($broadcaster)) {
        if (!getTwitchStream($broadcaster)) {
            getTwitchChannel($broadcaster);
        }
        updateCache($broadcaster);
    }
    if ($broadcaster['online']) {
        $broadcastersOnline[] = $broadcaster;
        if ($startupChannel == null) {
            $startupChannel = (object) $broadcaster;
        }
    } else {
        $broadcastersOffline[] = $broadcaster;
    }
    if (is_string($startupChannel) && $startupChannel == $broadcaster['twitch']) {
        $startupChannel = (object) $broadcaster;
    }
}
if (!is_object($startupChannel)) {
    if (isset($broadcastersOnline[0])) {
Пример #7
0
    if (file_exists($cachefile)) {
        $content = file_get_contents("{$cachefile}");
        $content = preg_replace('/^[^\\(]+/', "{$callback}", $content);
        echo $content;
        return true;
    }
    return false;
}
// Try to update the 'cachefile'
function updateCache($cachefile)
{
    // URL to access
    $query = $_SERVER['QUERY_STRING'];
    $url = "http://query.yahooapis.com/v1/public/yql?{$query}";
    system("echo \"{$url}\" >> /tmp/debug");
    system("wget -T3 -q -O {$cachefile}.tmp '{$url}' && mv {$cachefile}.tmp {$cachefile} 2>&1 &");
    return true;
}
// Configure Timeout
$context = stream_context_create(array('http' => array('timeout' => 5)));
// Get callback ID
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'undefined';
$hash = "/tmp/" . md5($_SERVER['HTTP_REFERER']);
$displayed = sendWeather("{$hash}.weather", $callback);
$updated = false;
if (!file_exists("{$hash}.weather") || time() - filemtime("{$hash}.weather") > $cachetime) {
    $updated = updateCache("{$hash}.weather");
}
if (!$displayed && $updated) {
    sendWeather("{$hash}.weather", $callback);
}