当前位置: 首页>>代码示例>>PHP>>正文


PHP sql_free_result函数代码示例

本文整理汇总了PHP中sql_free_result函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_free_result函数的具体用法?PHP sql_free_result怎么用?PHP sql_free_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sql_free_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cleanup_mapresult2

 function cleanup_mapresult2($slaveId)
 {
     global $opt;
     // cleanup old entries
     $rs = sql("SELECT SQL_BUFFER_RESULT `result_id` FROM `map2_result` WHERE DATE_ADD(`date_created`, INTERVAL '&1' SECOND)<NOW()", $opt['map']['maxcacheage']);
     while ($r = sql_fetch_assoc($rs)) {
         sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $r['result_id']);
     }
     sql_free_result($rs);
     // now reduce table size? (29 bytes is the average row size)
     if (sql_value_slave("SELECT COUNT(*) FROM `map2_data`", 0) > $opt['map']['maxcachesize'] / 29) {
         while (sql_value_slave("SELECT COUNT(*) FROM `map2_data`", 0) > $opt['map']['maxcachereducedsize'] / 29) {
             $resultId = sql_value("SELECT `result_id` FROM `map2_result` WHERE `slave_id`='&1' ORDER BY `date_lastqueried` DESC LIMIT 1", 0, $slaveId);
             if ($resultId == 0) {
                 return;
             }
             sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $resultId);
         }
     }
     $nMinId = sql_value("SELECT MIN(`result_id`) FROM `map2_result`", 0);
     if ($nMinId == 0) {
         sql("DELETE FROM `map2_data`");
     } else {
         sql("DELETE FROM `map2_data` WHERE `result_id`<'&1'", $nMinId);
     }
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:26,代码来源:slave_cleanup.class.php

示例2: getAttrbutesListArrayInternal

 public static function getAttrbutesListArrayInternal($cacheId, $bOnlySelectable, $firstLetterUppercase)
 {
     global $opt;
     $attributes = array();
     $rsAttrGroup = sql("SELECT `attribute_groups`.`id`,\n\t\t             IFNULL(`tt1`.`text`, `attribute_groups`.`name`) AS `name`,\n\t\t             IFNULL(`tt2`.`text`, `attribute_categories`.`name`) AS `category`,\n\t\t             `attribute_categories`.`color`\n\t\t\tFROM `attribute_groups`\n\t\t\tINNER JOIN `attribute_categories` \n\t\t\t    ON `attribute_groups`.`category_id`=`attribute_categories`.`id`\n\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t    ON `attribute_groups`.`trans_id`=`t1`.`id` \n\t\t\t    AND `attribute_groups`.`name`=`t1`.`text`\n\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t    AND `tt1`.`lang`='&1'\n\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t    ON `attribute_categories`.`trans_id`=`t2`.`id` \n\t\t\t    AND `attribute_categories`.`name`=`t2`.`text`\n\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t    ON `t2`.`id`=`tt2`.`trans_id` \n\t\t\t    AND `tt2`.`lang`='&1'\n\t\t\tORDER BY `attribute_groups`.`id` ASC", $opt['template']['locale']);
     while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
         $attr = array();
         $bFirst = true;
         $bSearchGroupDefault = false;
         if ($cacheId == 0) {
             $sAddWhereSql = '';
             if ($bOnlySelectable == true) {
                 $sAddWhereSql .= ' AND `cache_attrib`.`selectable`=1';
             }
             $rsAttr = sql("SELECT `cache_attrib`.`id`, \n                            IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\n\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`,\n\t\t\t\t\t\t\t`cache_attrib`.`icon`, `cache_attrib`.`search_default`\n\t\t\t\t\tFROM `cache_attrib`\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t\t\t    ON `cache_attrib`.`trans_id`=`t1`.`id` \n\t\t\t\t\t    AND `cache_attrib`.`name`=`t1`.`text`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t\t\t    AND `tt1`.`lang`='&1'\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t\t\t    ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t\t\t    ON `t2`.`id`=`tt2`.`trans_id` \n\t\t\t\t\t    AND `tt2`.`lang`='&1'\n\t\t\t\t\tWHERE `cache_attrib`.`group_id`='&2'" . $sAddWhereSql . "\n\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t\t\t\tORDER BY `cache_attrib`.`group_id` ASC", $opt['template']['locale'], $rAttrGroup['id']);
         } else {
             $rsAttr = sql("SELECT `cache_attrib`.`id`, \n                            IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\n\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`,\n\t\t\t\t\t\t\t`cache_attrib`.`icon`, `cache_attrib`.`search_default`\n\t\t\t\t\tFROM `caches_attributes`\n\t\t\t\t\tINNER JOIN `cache_attrib` \n\t\t\t\t\t    ON `caches_attributes`.`attrib_id`=`cache_attrib`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` \n\t\t\t\t\t    ON `cache_attrib`.`trans_id`=`t1`.`id` \n\t\t\t\t\t    AND `cache_attrib`.`name`=`t1`.`text`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` \n\t\t\t\t\t    ON `t1`.`id`=`tt1`.`trans_id` \n\t\t\t\t\t    AND `tt1`.`lang`='&2'\n\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` \n\t\t\t\t\t    ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id`\n\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` \n\t\t\t\t\t    ON `t2`.`id`=`tt2`.`trans_id`\n\t\t\t\t\t    AND `tt2`.`lang`='&2'\n\t\t\t\t\tWHERE `caches_attributes`.`cache_id`='&1' \n\t\t\t\t\tAND `cache_attrib`.`group_id`='&3'\n\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\n\t\t\t\t\tORDER BY `cache_attrib`.`group_id` ASC", $cacheId, $opt['template']['locale'], $rAttrGroup['id']);
         }
         while ($rAttr = sql_fetch_assoc($rsAttr)) {
             if ($firstLetterUppercase) {
                 $rAttr['name'] = mb_strtoupper(mb_substr($rAttr['name'], 0, 1)) . mb_substr($rAttr['name'], 1);
             }
             $attr[] = $rAttr;
             if ($rAttr['search_default']) {
                 $bSearchGroupDefault = true;
             }
         }
         sql_free_result($rsAttr);
         if (count($attr) > 0) {
             $attributes[] = array('id' => $rAttrGroup['id'], 'name' => $rAttrGroup['name'], 'color' => $rAttrGroup['color'], 'category' => $rAttrGroup['category'], 'search_default' => $bSearchGroupDefault, 'attr' => $attr);
         }
     }
     sql_free_result($rsAttrGroup);
     return $attributes;
 }
开发者ID:kirstenko,项目名称:oc-server3,代码行数:35,代码来源:attribute.class.php

示例3: t

 function t($message, $style, $resource_name, $line, $plural = '', $count = 1, $lang = null)
 {
     global $opt, $locale;
     // $locale is for lib1 compatibility
     if ($message == '') {
         return '';
     }
     if ($plural != '' && $count != 1) {
         $message = $plural;
     }
     $search = $this->prepare_text($message);
     $loc = isset($opt['template']['locale']) ? $opt['template']['locale'] : $locale;
     if (!$lang || $lang == $loc) {
         $trans = gettext($search);
     } else {
         // do not use sql_value(), as this is also used from lib1
         $rs = sql("SELECT IFNULL(`sys_trans_text`.`text`, '&3')\n\t\t\t             FROM `sys_trans` \n\t\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\n\t\t\t\t\t\t\t\t\tWHERE `sys_trans`.`text`='&2' LIMIT 1", $lang, $search, $message);
         if ($r = sql_fetch_array($rs)) {
             $trans = $r[0];
         } else {
             $trans = '';
         }
         sql_free_result($rs);
     }
     // safe w/o mb because asc(%) < 128
     if (strpos($trans, "%") >= 0) {
         $trans = $this->v($trans);
     }
     return $trans;
 }
开发者ID:PaulinaKowalczuk,项目名称:oc-server3,代码行数:30,代码来源:translate.class.php

示例4: getAttrbutesListArrayInternal

 static function getAttrbutesListArrayInternal($cacheId, $bOnlySelectable)
 {
     global $opt;
     $attributes = array();
     $rsAttrGroup = sql("SELECT `attribute_groups`.`id`, \r\n\t\t                           IFNULL(`tt1`.`text`, `attribute_groups`.`name`) AS `name`, \r\n\t\t                           IFNULL(`tt2`.`text`, `attribute_categories`.`name`) AS `category`, \r\n\t\t                           `attribute_categories`.`color`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `attribute_groups` \r\n\t\t\t\t\t\t\t\t\t\tINNER JOIN `attribute_categories` ON `attribute_groups`.`category_id`=`attribute_categories`.`id`\r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans` AS `t1` ON `attribute_groups`.`trans_id`=`t1`.`id` AND `attribute_groups`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans` AS `t2` ON `attribute_categories`.`trans_id`=`t2`.`id` AND `attribute_categories`.`name`=`t2`.`text` \r\n\t\t\t\t\t\t\t\t\t\t LEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t\tORDER BY `attribute_groups`.`id` ASC", $opt['template']['locale']);
     while ($rAttrGroup = sql_fetch_assoc($rsAttrGroup)) {
         $attr = array();
         $bFirst = true;
         if ($cacheId == 0) {
             $sAddWhereSql = '';
             if ($bOnlySelectable == true) {
                 $sAddWhereSql = ' AND `cache_attrib`.`selectable`=1';
             }
             $rsAttr = sql("SELECT `cache_attrib`.`id`, IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`, `cache_attrib`.`icon`\r\n\t\t\t\t\t\t\t\t\t\t\t\t FROM `cache_attrib`\r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` ON `cache_attrib`.`trans_id`=`t1`.`id` AND `cache_attrib`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&1' \r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `cache_attrib`.`group_id`='&2'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\r\n\t\t\t\t\t\t\t\t\t\t ORDER BY `cache_attrib`.`group_id` ASC", $opt['template']['locale'], $rAttrGroup['id']);
         } else {
             $rsAttr = sql("SELECT `cache_attrib`.`id`, IFNULL(`tt1`.`text`, `cache_attrib`.`name`) AS `name`,\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(`tt2`.`text`, `cache_attrib`.`html_desc`) AS `html_desc`, `cache_attrib`.`icon`\r\n\t\t\t\t\t\t\t\t\t\t\t\t FROM `caches_attributes` \r\n\t\t\t\t\t\t\t\t\t INNER JOIN `cache_attrib` ON `caches_attributes`.`attrib_id`=`cache_attrib`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t1` ON `cache_attrib`.`trans_id`=`t1`.`id` AND `cache_attrib`.`name`=`t1`.`text` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt1` ON `t1`.`id`=`tt1`.`trans_id` AND `tt1`.`lang`='&2' \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` AS `t2` ON `cache_attrib`.`html_desc_trans_id`=`t2`.`id` \r\n\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` AS `tt2` ON `t2`.`id`=`tt2`.`trans_id` AND `tt2`.`lang`='&2' \r\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE `caches_attributes`.`cache_id`='&1' AND `cache_attrib`.`group_id`='&3'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND NOT IFNULL(`cache_attrib`.`hidden`, 0)=1\r\n\t\t\t\t\t\t\t\t\t\t ORDER BY `cache_attrib`.`group_id` ASC", $cacheId, $opt['template']['locale'], $rAttrGroup['id']);
         }
         while ($rAttr = sql_fetch_assoc($rsAttr)) {
             $attr[] = $rAttr;
         }
         sql_free_result($rsAttr);
         if (count($attr) > 0) {
             $attributes[] = array('name' => $rAttrGroup['name'], 'color' => $rAttrGroup['color'], 'category' => $rAttrGroup['category'], 'attr' => $attr);
         }
     }
     sql_free_result($rsAttrGroup);
     return $attributes;
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:28,代码来源:attribute.class.php

示例5: showlist

function showlist($query, $type, $template)
{
    if (is_array($query)) {
        if (sizeof($query) == 0) {
            return 0;
        }
        call_user_func('listplug_' . $type, $template, 'HEAD');
        foreach ($query as $currentObj) {
            $template['current'] = $currentObj;
            call_user_func('listplug_' . $type, $template, 'BODY');
        }
        call_user_func('listplug_' . $type, $template, 'FOOT');
        return sizeof($query);
    } else {
        $res = sql_query($query);
        // don't do anything if there are no results
        $numrows = sql_num_rows($res);
        if ($numrows == 0) {
            return 0;
        }
        call_user_func('listplug_' . $type, $template, 'HEAD');
        while ($template['current'] = sql_fetch_object($res)) {
            call_user_func('listplug_' . $type, $template, 'BODY');
        }
        call_user_func('listplug_' . $type, $template, 'FOOT');
        sql_free_result($res);
        // return amount of results
        return $numrows;
    }
}
开发者ID:hatone,项目名称:Nucleus-v3.64,代码行数:30,代码来源:showlist.php

示例6: run

 public function run()
 {
     $rsDuplicatePic = sql('SELECT `object_id`, `title`
          FROM `pictures`
          WHERE `object_type`=1
          GROUP BY `object_id`, `title`
          HAVING COUNT(*) > 1');
     while ($rDuplicatePic = sql_fetch_assoc($rsDuplicatePic)) {
         $rsInstances = sql(" SELECT `pictures`.`id` `picid`, `cache_logs`.`cache_id` `cache_id`\n                 FROM `pictures`\n                 LEFT JOIN `cache_logs` ON `cache_logs`.`id` = `pictures`.`object_id`\n                 WHERE `pictures`.`object_type`=1 AND `pictures`.`object_id`='&1' AND `pictures`.`title`='&2'\n                 ORDER BY `pictures`.`date_created`", $rDuplicatePic['object_id'], $rDuplicatePic['title']);
         $instances = sql_fetch_assoc_table($rsInstances);
         foreach ($instances as &$instance) {
             $instance['pic'] = new picture($instance['picid']);
             $instance['filesize'] = @filesize($instance['pic']->getFilename());
         }
         $countInstances = count($instances);
         for ($n = 1; $n < $countInstances; ++$n) {
             if ($instances[$n]['filesize'] !== false) {
                 // ensure that pic is stored locally
                 for ($nn = $n - 1; $nn >= 0; --$nn) {
                     if ($instances[$nn]['filesize'] === $instances[$n]['filesize']) {
                         if (file_get_contents($instances[$nn]['pic']->getFilename()) == file_get_contents($instances[$n]['pic']->getFilename())) {
                             $picture = $instances[$n]['pic'];
                             echo 'deleting duplicate picture ' . $picture->getPictureId() . ' ("' . $picture->getTitle() . '")' . ' from log ' . $rDuplicatePic['object_id'] . ' of cache ' . $instances[$n]['cache_id'] . "\n";
                             $picture->delete(false);
                             $instances[$n]['filesize'] = false;
                             break;
                         }
                     }
                 }
             }
         }
     }
     sql_free_result($rsDuplicatePic);
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:34,代码来源:picture_cleanup.class.php

示例7: assignFromDB

function assignFromDB($userid)
{
    global $tpl, $opt;
    $rs = sql("SELECT `p`.`id`, IFNULL(`tt`.`text`, `p`.`name`) AS `name`, `p`.`default_value`, `p`.`check_regex`, `p`.`option_order`, `u`.`option_visible`, `p`.`internal_use`, `p`.`option_input`, IFNULL(`u`.`option_value`, `p`.`default_value`) AS `option_value`\r\n\t\t           FROM `profile_options` AS `p`\r\n\t\t      LEFT JOIN `user_options` AS `u` ON `p`.`id`=`u`.`option_id` AND (`u`.`user_id` IS NULL OR `u`.`user_id`='&1')\r\n\t\t      LEFT JOIN `sys_trans` AS `st` ON `p`.`trans_id`=`st`.`id` AND `p`.`name`=`st`.`text`\r\n\t\t      LEFT JOIN `sys_trans_text` AS `tt` ON `st`.`id`=`tt`.`trans_id` AND `tt`.`lang`='&2'\r\n\t\t       ORDER BY `p`.`internal_use` DESC, `p`.`option_order`", $userid + 0, $opt['template']['locale']);
    $tpl->assign_rs('useroptions', $rs);
    sql_free_result($rs);
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:7,代码来源:mydetails.php

示例8: run

 public function run()
 {
     $rsCache = sql("SELECT `cache_id`, `latitude`, `longitude` FROM `caches` WHERE `need_npa_recalc`=1");
     while ($rCache = sql_fetch_assoc($rsCache)) {
         sql("DELETE FROM `cache_npa_areas` WHERE `cache_id`='&1' AND `calculated`=1", $rCache['cache_id']);
         $rsLayers = sql("SELECT `id`, `type_id`, AsText(`shape`) AS `geometry` \n                FROM `npa_areas` WHERE `exclude`=0 AND MBRWITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = sql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $bExclude = false;
                 // prüfen, ob in ausgesparter Fläche
                 $rsExclude = sql("SELECT `id`, AsText(`shape`) AS `geometry`\n                        FROM `npa_areas`\n                        WHERE `exclude` = 1\n                        AND `type_id`='&1'\n                        AND MBRWITHIN(GeomFromText('&2'), `shape`)", $rLayers['type_id'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
                 while (($rExclude = sql_fetch_assoc($rsExclude)) && $bExclude == false) {
                     if (gis::ptInLineRing($rExclude['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                         $bExclude = true;
                     }
                 }
                 sql_free_result($rsExclude);
                 if ($bExclude == false) {
                     sql("INSERT INTO `cache_npa_areas` (`cache_id`, `npa_id`, `calculated`)\n                            VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 }
             }
         }
         sql_free_result($rsLayers);
         sql("UPDATE `caches` SET `need_npa_recalc`=0 WHERE `cache_id`='&1'", $rCache['cache_id']);
     }
     sql_free_result($rsCache);
 }
开发者ID:kirstenko,项目名称:oc-server3,代码行数:27,代码来源:cache_npa_areas.class.php

示例9: CheckThrottle

function CheckThrottle()
{
    global $opt, $tpl;
    $ip_string = $_SERVER['REMOTE_ADDR'];
    $ip_blocks = mb_split('\\.', $ip_string);
    $ip_numeric = $ip_blocks[3] + $ip_blocks[2] * 256 + $ip_blocks[1] * 65536 + $ip_blocks[0] * 16777216;
    sql('CREATE TABLE IF NOT EXISTS &tmpdb.`sys_accesslog`
        (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `ip` INT UNSIGNED NOT NULL,
         `access_time` TIMESTAMP NOT NULL, INDEX (`access_time`), INDEX (`ip`)) ENGINE = MEMORY');
    $rsStaus = sql("SHOW STATUS LIKE 'Threads_connected'");
    $rStatus = sql_fetch_array($rsStaus);
    sql_free_result($rsStaus);
    if ($rStatus) {
        if ($rStatus[1] > $opt['db']['throttle_connection_count']) {
            $access_count = sql_value("SELECT COUNT(*) FROM &tmpdb.`sys_accesslog` WHERE ip ='&1'", 0, $ip_numeric);
            if ($access_count > $opt['db']['throttle_access_count']) {
                $tpl->error(ERROR_THROOTLE);
            }
        }
    }
    // remove old entries every 100st call
    if (mt_rand(0, 100) == 50) {
        sql("DELETE FROM &tmpdb.`sys_accesslog` WHERE `access_time`<CURRENT_TIMESTAMP()-'&2'", $ip_numeric, $opt['db']['throttle_access_time']);
    }
    sql("INSERT INTO &tmpdb.`sys_accesslog` (`ip`, `access_time`) VALUES ('&1', CURRENT_TIMESTAMP())", $ip_numeric);
}
开发者ID:kratenko,项目名称:oc-server3,代码行数:26,代码来源:throttle.inc.php

示例10: fill

 public function fill($max_inserts_count)
 {
     global $opt;
     $rowCount = 0;
     $nInsertCount = 0;
     if ($opt['logic']['waypoint_pool']['fill_gaps'] == true) {
         // query the first unused waypoint (between other waypoints)
         $rsStartWp = sql("SELECT SQL_BUFFER_RESULT DECTOWP(WPTODEC(`c`.`wp_oc`, '&1')+1, '&1') AS `free_wp`\n                               FROM `caches` AS `c`\n                          LEFT JOIN `caches` AS `cNext` ON DECTOWP(WPTODEC(`c`.`wp_oc`, '&1')+1, '&1')=`cNext`.`wp_oc`\n                          LEFT JOIN `cache_waypoint_pool` ON DECTOWP(WPTODEC(`c`.`wp_oc` ,'&1')+1, '&1')=`cache_waypoint_pool`.`wp_oc`\n                              WHERE `c`.`wp_oc` REGEXP '&2'\n                                AND ISNULL(`cNext`.`wp_oc`)\n                                AND ISNULL(`cache_waypoint_pool`.`wp_oc`)\n                           ORDER BY `free_wp` ASC\n                              LIMIT 250", $opt['logic']['waypoint_pool']['prefix'], '^' . $opt['logic']['waypoint_pool']['prefix'] . '[' . $opt['logic']['waypoint_pool']['valid_chars'] . ']{1,}$');
     } else {
         // query the last used waypoint
         $rsStartWp = sql("SELECT SQL_BUFFER_RESULT DECTOWP(MAX(dec_wp)+1, '&2') AS `free_wp`\n                           FROM (\n                                   SELECT MAX(WPTODEC(`wp_oc`, '&2')) AS dec_wp\n                                     FROM `caches`\n                                    WHERE `wp_oc` REGEXP '&1'\n                              UNION\n                                   SELECT MAX(WPTODEC(`wp_oc`, '&2')) AS dec_wp\n                                     FROM `cache_waypoint_pool`\n                                 ) AS tbl", '^' . $opt['logic']['waypoint_pool']['prefix'] . '[' . $opt['logic']['waypoint_pool']['valid_chars'] . ']{1,}$', $opt['logic']['waypoint_pool']['prefix']);
     }
     while (($rStartWp = sql_fetch_assoc($rsStartWp)) && $nInsertCount < $max_inserts_count) {
         $free_wp = $rStartWp['free_wp'];
         if ($free_wp == '') {
             $free_wp = $opt['logic']['waypoint_pool']['prefix'] . '0001';
         }
         $nInsertCount += $this->fill_turn($free_wp, $max_inserts_count - $nInsertCount);
         $rowCount++;
     }
     sql_free_result($rsStartWp);
     if ($rowCount == 0) {
         // new database ...
         $nInsertCount += $this->fill_turn($opt['logic']['waypoint_pool']['prefix'] . '0001', $max_inserts_count);
     }
     return $nInsertCount;
 }
开发者ID:kirstenko,项目名称:oc-server3,代码行数:27,代码来源:cache_waypoint_pool.class.php

示例11: geodb_setCacheLocation

function geodb_setCacheLocation($cache_id)
{
    echo $cache_id . "\n";
    $rs = sqll("SELECT `latitude`, `longitude`, `last_modified` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
    if ($r = sql_fetch_array($rs)) {
        $nLocId = geodb_locidFromCoords($r['longitude'], $r['latitude']);
        if ($nLocId != 0) {
            $sAdm1 = geodb_landFromLocid($nLocId);
            $sAdm2 = geodb_regierungsbezirkFromLocid($nLocId);
            $sAdm3 = geodb_landkreisFromLocid($nLocId);
        } else {
            $sAdm1 = null;
            $sAdm2 = null;
            $sAdm3 = null;
        }
        if ($sAdm1 == '') {
            $sAdm1 = null;
        }
        if ($sAdm2 == '') {
            $sAdm2 = null;
        }
        if ($sAdm3 == '') {
            $sAdm3 = null;
        }
        sqll("INSERT INTO `cache_location` (`cache_id`, `last_modified`, `adm1`, `adm2`, `adm3`) VALUES ('&1', '&2', '&3', '&4', '&5') ON DUPLICATE KEY UPDATE `cache_id`='&1', `last_modified`='&2', `adm1`='&3', `adm2`='&4', `adm3`='&5'", $cache_id, $r['last_modified'], $sAdm1, $sAdm2, $sAdm3);
    }
    sql_free_result($rs);
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:28,代码来源:geodb.inc.php

示例12: run

 function run()
 {
     global $opt;
     $rsCache = sql("SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE ISNULL(`cache_location`.`cache_id`) UNION SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` INNER JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE `caches`.`last_modified`>`cache_location`.`last_modified`");
     while ($rCache = sql_fetch_assoc($rsCache)) {
         $sCode = '';
         $rsLayers = sql("SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE WITHIN(GeomFromText('&1'), `shape`) ORDER BY `level` DESC", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = sql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sCode = $rLayers['code'];
                 break;
             }
         }
         sql_free_result($rsLayers);
         if ($sCode != '') {
             $adm1 = null;
             $code1 = null;
             $adm2 = null;
             $code2 = null;
             $adm3 = null;
             $code3 = null;
             $adm4 = null;
             $code4 = null;
             if (mb_strlen($sCode) > 5) {
                 $sCode = mb_substr($sCode, 0, 5);
             }
             if (mb_strlen($sCode) == 5) {
                 $code4 = $sCode;
                 $adm4 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
                 $sCode = mb_substr($sCode, 0, 4);
             }
             if (mb_strlen($sCode) == 4) {
                 $code3 = $sCode;
                 $adm3 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
                 $sCode = mb_substr($sCode, 0, 3);
             }
             if (mb_strlen($sCode) == 3) {
                 $code2 = $sCode;
                 $adm2 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
                 $sCode = mb_substr($sCode, 0, 2);
             }
             if (mb_strlen($sCode) == 2) {
                 $code1 = $sCode;
                 // try to get localised name first
                 $adm1 = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM `countries`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` AND `countries`.`name`=`sys_trans`.`text`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `countries`.`short`='&1'", null, $sCode, $opt['template']['default']['locale']);
                 if ($adm1 == null) {
                     $adm1 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
                 }
             }
             sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `adm2`, `adm3`, `adm4`, `code1`, `code2`, `code3`, `code4`) VALUES ('&1', '&2', '&3', '&4', '&5', '&6', '&7', '&8', '&9') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`='&3', `adm3`='&4', `adm4`='&5', `code1`='&6', `code2`='&7', `code3`='&8', `code4`='&9'", $rCache['cache_id'], $adm1, $adm2, $adm3, $adm4, $code1, $code2, $code3, $code4);
         } else {
             $sCountry = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)\r\n\t\t\t\t                         FROM `caches` \r\n\t\t\t\t                   INNER JOIN `countries` ON `caches`.`country`=`countries`.`short`\r\n\t\t\t\t                    LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` AND `countries`.`name`=`sys_trans`.`text`\r\n\t\t\t\t                    LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\r\n\t\t\t\t                        WHERE `caches`.`cache_id`='&1'", null, $rCache['cache_id'], $opt['template']['default']['locale']);
             $sCode1 = sql_value("SELECT `caches`.`country` FROM `caches` WHERE `caches`.`cache_id`='&1'", null, $rCache['cache_id']);
             sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `code1`) VALUES ('&1', '&2', '&3') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`=NULL, `adm3`=NULL, `adm4`=NULL, `code1`='&3', `code2`=NULL, `code3`=NULL, `code4`=NULL", $rCache['cache_id'], $sCountry, $sCode1);
         }
     }
     sql_free_result($rsCache);
 }
开发者ID:RH-Code,项目名称:opencaching,代码行数:58,代码来源:cache_location.class.php

示例13: get_npas

function get_npas($cache_id)
{
    $rsNPA = sql("SELECT `npa_areas`.`name` AS `npaName`, `npa_types`.`name` AS `npaTypeName`\n\t             FROM `cache_npa_areas`\n\t       INNER JOIN `npa_areas` ON `cache_npa_areas`.`npa_id`=`npa_areas`.`id`\n\t       INNER JOIN `npa_types` ON `npa_areas`.`type_id`=`npa_types`.`id`\n\t            WHERE `cache_npa_areas`.`cache_id`='&1'\n\t         GROUP BY `npa_areas`.`type_id`, `npa_areas`.`name`\n\t         ORDER BY `npa_types`.`ordinal` ASC", $cache_id);
    $npas = array();
    while ($rNPA = sql_fetch_array($rsNPA)) {
        $npas[] = $rNPA;
    }
    sql_free_result($rsNPA);
    return $npas;
}
开发者ID:4Vs,项目名称:oc-server3,代码行数:10,代码来源:npas.inc.php

示例14: CreateCacheFile

 function CreateCacheFile()
 {
     global $opt, $translate;
     $f = fopen($this->sMenuFilename, 'w');
     fwrite($f, "<?php\n");
     fwrite($f, 'global $menuitem;' . "\n");
     fwrite($f, "\n");
     $rsDefines = sqlf("SELECT `id`, `id_string` FROM `sys_menu`");
     while ($rDefine = sql_fetch_assoc($rsDefines)) {
         fwrite($f, 'if (!defined(\'' . addslashes($rDefine['id_string']) . '\')) define(\'' . addslashes($rDefine['id_string']) . '\', ' . $rDefine['id'] . ");\n");
     }
     sql_free_result($rsDefines);
     fwrite($f, "\n");
     $aMenu = array();
     $nPos = 0;
     $rsSubmenu = sqlf("SELECT `id` FROM `sys_menu` WHERE `parent`=0 ORDER BY `parent` ASC, `position` ASC");
     while ($rSubmenu = sql_fetch_assoc($rsSubmenu)) {
         $aMenu[MNU_ROOT]['subitems'][$nPos] = $rSubmenu['id'];
         $nPos++;
     }
     sql_free_result($rsSubmenu);
     fwrite($f, "\n");
     $rs = sqlf('SELECT `item`.`id`, `item`.`title`, `item`.`menustring`, `item`.`access`, `item`.`href`, `item`.`visible`, `item`.`parent` AS `parentid`, `item`.`color` AS `color` FROM `sys_menu` AS `item` LEFT JOIN `sys_menu` AS `parentitem` ON `item`.`parent`=`parentitem`.`id`');
     while ($r = sql_fetch_assoc($rs)) {
         $aMenu[$r['id']]['title'] = $translate->t($r['title'], '', basename(__FILE__), __LINE__);
         $aMenu[$r['id']]['menustring'] = $translate->t($r['menustring'], '', basename(__FILE__), __LINE__);
         $aMenu[$r['id']]['authlevel'] = $r['access'] == 0 ? AUTH_LEVEL_ALL : AUTH_LEVEL_ADMIN;
         if (substr($r['href'], 0, 1) == '!') {
             $aMenu[$r['id']]['href'] = substr($r['href'], 1);
             $aMenu[$r['id']]['target'] = 'target="_blank"';
         } else {
             $aMenu[$r['id']]['href'] = $r['href'];
             $aMenu[$r['id']]['target'] = '';
         }
         $aMenu[$r['id']]['visible'] = $r['visible'];
         $aMenu[$r['id']]['sublevel'] = $this->pGetMenuSublevel($r['id']);
         if ($r['parentid'] != 0) {
             $aMenu[$r['id']]['parent'] = $r['parentid'];
         }
         if ($r['color'] != null) {
             $aMenu[$r['id']]['color'] = $r['color'];
         }
         $nPos = 0;
         $rsSubmenu = sqlf("SELECT `id` FROM `sys_menu` WHERE `parent`='&1' ORDER BY `parent` ASC, `position` ASC", $r['id']);
         while ($rSubmenu = sql_fetch_assoc($rsSubmenu)) {
             $aMenu[$r['id']]['subitems'][$nPos] = $rSubmenu['id'];
             $nPos++;
         }
         sql_free_result($rsSubmenu);
     }
     sql_free_result($rs);
     fwrite($f, '$menuitem = unserialize("' . str_replace('"', '\\"', serialize($aMenu)) . '");' . "\n");
     fwrite($f, "?>");
     fclose($f);
 }
开发者ID:4Vs,项目名称:oc-server3,代码行数:55,代码来源:menu.class.php

示例15: sql_dropProcedure

function sql_dropProcedure($name)
{
    $rs = sql("SHOW PROCEDURE STATUS LIKE '&1'", $name);
    while ($r = sql_fetch_assoc($rs)) {
        if ($r['Name'] == $name && $r['Type'] == 'PROCEDURE') {
            sql('DROP PROCEDURE `&1`', $name);
            return;
        }
    }
    sql_free_result($rs);
}
开发者ID:RH-Code,项目名称:opencaching,代码行数:11,代码来源:sql_root.inc.php


注:本文中的sql_free_result函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。