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; }
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); } }
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); }
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); }
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; }
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; }
function assign_rs($name, $rs) { $items = array(); while ($r = sql_fetch_assoc($rs)) { $items[] = $r; } $this->assign($name, $items); }
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); }
function geodb_setAllCacheLocations() { $rs = sqll("SELECT `caches`.`cache_id` FROM `caches` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE ISNULL(`cache_location`.`cache_id`) OR `cache_location`.`last_modified`!=`caches`.`last_modified`"); while ($r = sql_fetch_assoc($rs)) { geodb_setCacheLocation($r['cache_id']); } sql_free_result($rs); sqll("DELETE FROM `cache_location` WHERE `cache_id` NOT IN (SELECT `cache_id` FROM `caches`)"); }
public static function setAllCacheLocations() { $rs = sqll("SELECT `caches`.`cache_id`\n FROM `caches`\n LEFT JOIN `cache_location`\n ON `caches`.`cache_id`=`cache_location`.`cache_id`\n WHERE\n ISNULL (`cache_location`.`cache_id`)\n OR `cache_location`.`last_modified`!=`caches`.`last_modified`"); while ($r = sql_fetch_assoc($rs)) { self::setCacheLocation($r['cache_id']); } sql_free_result($rs); sqll("\n DELETE FROM `cache_location`\n WHERE `cache_id` NOT IN (SELECT `cache_id` FROM `caches`)"); }
/** * Returns the requested comment * * @static */ function getComment($commentid) { $query = 'SELECT `cnumber` AS commentid, `cbody` AS body, `cuser` AS user, `cmail` AS userid, `cemail` AS email, `cmember` AS memberid, `ctime`, `chost` AS host, `mname` AS member, `cip` AS ip, `cblog` AS blogid' . ' FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON `cmember` = `mnumber`' . ' WHERE `cnumber` = ' . intval($commentid); $comments = sql_query($query); $aCommentInfo = sql_fetch_assoc($comments); if ($aCommentInfo) { $aCommentInfo['timestamp'] = strtotime($aCommentInfo['ctime']); } return $aCommentInfo; }
function get_cache_size_from_database() { global $dblink; $cache_size = array(); $resp = sql("SELECT * FROM cache_size ORDER BY id ASC"); while ($row = sql_fetch_assoc($resp)) { $cache_size[] = $row; } return $cache_size; }
public function getHistoryConference() { $query = "SELECT id, idCal, idCourse, name, room_type, starttime, endtime, meetinghours, maxparticipants" . " FROM conference_room" . " WHERE idCourse IN(" . implode(',', $this->getUserCourse()) . ")" . " AND endtime < '" . fromDatetimeToTimestamp(date('Y-m-d H:i:s')) . "'" . " ORDER BY starttime, name"; $result = sql_query($query); $res = array(); while ($row = sql_fetch_assoc($result)) { $res[$row['id']] = $row; } return $res; }
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); }
function ForumAdmin() { global $hlpfile, $NPDS_Prefix, $f_meta_nom, $f_titre, $adminimg; include "header.php"; GraphicAdmin($hlpfile); adminhead($f_meta_nom, $f_titre, $adminimg); echo ' <h3>' . adm_translate("Catégories de Forum") . '</h3> <table data-toggle="table" data-striped="true" data-search="true" data-show-toggle="true" data-mobile-responsive="true" data-icons="icons" data-icons-prefix="fa"> <thead> <tr> <th data-sortable="true">' . adm_translate("Index") . ' </th> <th data-sortable="true">' . adm_translate("Nom") . ' </th> <th>' . adm_translate("Nombre de Forum(s)") . ' </th> <th>' . adm_translate("Fonctions") . ' </th> </tr> </thead> <tbody>'; $result = sql_query("SELECT cat_id, cat_title FROM " . $NPDS_Prefix . "catagories ORDER BY cat_id"); while (list($cat_id, $cat_title) = sql_fetch_row($result)) { $gets = sql_query("SELECT COUNT(*) AS total FROM " . $NPDS_Prefix . "forums WHERE cat_id='{$cat_id}'"); $numbers = sql_fetch_assoc($gets); echo ' <tr> <td align="left">' . $cat_id . '</td> <td align="left">' . StripSlashes($cat_title) . '</td> <td align="center">' . $numbers['total'] . ' <a href="admin.php?op=ForumGo&cat_id=' . $cat_id . '"><i class="fa fa-eye fa-lg" title="' . adm_translate("Voir les forums de cette catégorie") . ': ' . StripSlashes($cat_title) . '." data-toggle="tooltip"></i></a></td> <td align="right"></a><a href="admin.php?op=ForumCatEdit&cat_id=' . $cat_id . '"><i class="fa fa-edit fa-lg" title="' . adm_translate("Editer") . '" data-toggle="tooltip"></i></a> <a href="admin.php?op=ForumCatDel&cat_id=' . $cat_id . '&ok=0"><i class="fa fa-trash-o fa-lg text-danger" title="' . adm_translate("Effacer") . '" data-toggle="tooltip" ></i></a></td> </tr>'; } echo ' </tbody> </table> <h3>' . adm_translate("Ajouter une catégorie") . '</h3> <form action="admin.php" method="post"> <div class="form-group"> <div class="row"> <label class="form-control-label col-sm-4 col-md-4" for="catagories">' . adm_translate("Nom") . '</label> <div class="col-sm-8"> <textarea class="form-control" type="text" name="catagories" id="catagories" rows="3" required="required"></textarea> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-sm-offset-4 col-sm-8"> <input type="hidden" name="op" value="ForumCatAdd" /> <button class="btn btn-primary col-xs-12" type="submit"><i class="fa fa-plus-square fa-lg"></i> ' . adm_translate("Ajouter une catégorie") . '</button> </div> </div> </div> </form>'; adminfoot('fv', '', '', ''); }
public function archive_events() { // To prevent archiving events that were accidentally published with a wrong // event date - before the owner notices it - we also apply a limit of one month // to the publication date. $rs = sql("SELECT `cache_id`\n FROM `caches`\n WHERE `caches`.`type`=6 AND `caches`.`status`=1\n AND GREATEST(`date_hidden`,`date_created`) < NOW() - INTERVAL 35 DAY\n ORDER BY `date_hidden`\n LIMIT 1"); while ($rCache = sql_fetch_assoc($rs)) { $this->archive_cache($rCache['cache_id'], 'This event took place more than five weeks ago; therefore it is ' . 'being archived automatically. The owner may re-enable the listing ' . 'if it should stay active for some exceptional reason.'); } sql_free_result($rs); }
public function getDateInfoForPublicPresence($array_date) { $query = "SELECT dt.*, MIN(dy.date_begin) AS date_begin, MAX(dy.date_end) AS date_end, dy.pause_begin, dy.pause_end, COUNT(dy.id_day) as num_day, COUNT(DISTINCT du.id_user) as user_subscribed" . " FROM %lms_course_date as dt" . " JOIN %lms_course_date_day as dy ON dy.id_date = dt.id_date" . " LEFT JOIN %lms_course_date_user as du ON du.id_date = dt.id_date" . " WHERE dt.id_date IN (" . implode(',', $array_date) . ")" . " GROUP BY dt.id_date" . " ORDER BY date_begin DESC"; $result = sql_query($query); $res = array(); while ($row = sql_fetch_assoc($result)) { $row['classroom'] = $this->getDateClassrooms($row['id_date']); $res[] = $row; } return $res; }
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); }
function pAppendSites($parentId, $viewall, $sublevel, &$aItems) { global $opt; $rs = sql("SELECT `sys_menu`.`id`, \r\n\t IF(`sys_menu`.`title`='', \r\n\t IFNULL(`ttMenu`.`text`, `sys_menu`.`menustring`), \r\n\t IFNULL(`ttTitle`.`text`, `sys_menu`.`title`)) AS `name`, \r\n\t `sys_menu`.`href`, \r\n\t `sys_menu`.`sitemap` \r\n\t FROM `sys_menu` \r\n\t LEFT JOIN `sys_trans` AS `tTitle` ON `sys_menu`.`title_trans_id`=`tTitle`.`id` AND `sys_menu`.`title`=`tTitle`.`text` \r\n\t LEFT JOIN `sys_trans_text` AS ttTitle ON `tTitle`.`id`=`ttTitle`.`trans_id` AND `ttTitle`.`lang`='&2' \r\n\t LEFT JOIN `sys_trans` AS `tMenu` ON `sys_menu`.`menustring_trans_id`=`tMenu`.`id` AND `sys_menu`.`menustring`=`tMenu`.`text` \r\n\t LEFT JOIN `sys_trans_text` AS `ttMenu` ON `tMenu`.`id`=`ttMenu`.`trans_id` AND `ttMenu`.`lang`='&2' \r\n\t WHERE `sys_menu`.`access`=0 AND `sys_menu`.`parent`='&1' AND (&3=1 OR `sys_menu`.`sitemap`=1)\r\n\t ORDER BY `sys_menu`.`parent` ASC, `sys_menu`.`position` ASC", $parentId, $opt['template']['locale'], $viewall ? 1 : 0); while ($r = sql_fetch_assoc($rs)) { $r['sublevel'] = $sublevel; $aItems[] = $r; pAppendSites($r['id'], $viewall, $sublevel + 1, &$aItems); } sql_free_result($rs); }
function showstats($header, $condition, $limit) { echo "<h3>{$header}</h3>\n"; echo "<table>\n"; $rs = sql("SELECT COUNT(*) as `count`, `username` as `name`\n FROM `caches`\n LEFT JOIN `user` ON `user`.`user_id`=`caches`.`user_id`\n LEFT JOIN `caches_attributes` `ca` ON `ca`.`cache_id`=`caches`.`cache_id` AND `ca`.`attrib_id`=6\n WHERE status=1 AND " . $condition . "\n GROUP BY `caches`.`user_id`\n HAVING COUNT(*) >= {$limit}\n ORDER BY COUNT(*) DESC"); $n = 1; while ($r = sql_fetch_assoc($rs)) { echo " <tr><td style='text-align:right'> " . $n++ . ". </td><td style='text-align:right'>" . $r['count'] . "</td><td> " . $r['name'] . "</td></tr>\n"; } sql_free_result($rs); echo "</table>\n"; }
static function CreateCacheFile() { global $opt; $f = fopen($opt['rootpath'] . 'cache2/labels-' . $opt['template']['locale'] . '.inc.php', 'w'); fwrite($f, "<?php\n"); $a = array(); $rs = sql("SELECT `cache_attrib`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_attrib`.`name`) AS `name`\n\t\t FROM `cache_attrib`\n\t\t LEFT JOIN `sys_trans` ON `cache_attrib`.`trans_id`=`sys_trans`.`id` AND `cache_attrib`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("cache_attrib", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $a = array(); $rs = sql("SELECT `cache_size`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_size`.`name`) AS `name`\n\t\t FROM `cache_size`\n\t\t LEFT JOIN `sys_trans` ON `cache_size`.`trans_id`=`sys_trans`.`id` AND `cache_size`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("cache_size", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $a = array(); $rs = sql("SELECT `cache_status`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_status`.`name`) AS `name`\n\t\t FROM `cache_status`\n\t\t LEFT JOIN `sys_trans` ON `cache_status`.`trans_id`=`sys_trans`.`id` AND `cache_status`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("cache_status", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $a = array(); $rs = sql("SELECT `cache_type`.`id`, IFNULL(`sys_trans_text`.`text`, `cache_type`.`name`) AS `name`\n\t\t FROM `cache_type`\n\t\t LEFT JOIN `sys_trans` ON `cache_type`.`trans_id`=`sys_trans`.`id` AND `cache_type`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("cache_type", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $a = array(); $rs = sql("SELECT `log_types`.`id`, IFNULL(`sys_trans_text`.`text`, `log_types`.`name`) AS `name`\n\t\t FROM `log_types`\n\t\t LEFT JOIN `sys_trans` ON `log_types`.`trans_id`=`sys_trans`.`id` AND `log_types`.`name`=`sys_trans`.`text`\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $a[$r['id']] = $r['name']; } sql_free_result($rs); fwrite($f, 'labels::addLabels("log_types", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); $nLastGroup = 1; $a = array(); $rs = sql("SELECT `countries_options`.`country`, \n\t\t IF(`countries_options`.`nodeId`='&1', 1, IF(`countries_options`.`nodeId`!=0, 2, 3)) AS `group`, \n\t\t IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name` \n\t\t FROM `countries_options` \n\t\t INNER JOIN `countries` ON `countries_options`.`country`=`countries`.`short`\n\t\t LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` \n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2' \n\t\t WHERE `countries_options`.`display`=1 \n\t\t ORDER BY `group` ASC,\n\t\t IFNULL(`sys_trans_text`.`text`, `countries`.`name`) ASC", $opt['logic']['node']['id'], $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $r['begin_group'] = $r['group'] != $nLastGroup; $nLastGroup = $r['group']; $a[] = $r; } sql_free_result($rs); fwrite($f, 'labels::addLabels("usercountrieslist", "' . str_replace('"', '\\"', serialize($a)) . '");' . "\n"); fwrite($f, "?>"); fclose($f); }
function query_to_assoc_list($query) { $ret = array(); $result = sql_query_dbg($query); if (!$result) { return FALSE; } while ($row = sql_fetch_assoc($result)) { $ret[] = $row; } return $ret; }
public function __construct() { global $opt; $this->translator = new Language_Translator(); // read available types from DB $rs = sql("SELECT `coordinates_type`.`id`, IFNULL(`trans`.`text`, `coordinates_type`.`name`) AS `name`, `coordinates_type`.`image`, IFNULL(`trans_pp`.`text`, `coordinates_type`.`preposition`) AS `preposition`\n\t\t FROM `coordinates_type`\n\t\t\t\t\t\tLEFT JOIN `sys_trans_text` `trans` ON `coordinates_type`.`trans_id`=`trans`.`trans_id` AND `trans`.`lang`='&1'\n\t\t\t\t\t\tLEFT JOIN `sys_trans_text` `trans_pp` ON `coordinates_type`.`pp_trans_id`=`trans_pp`.`trans_id` AND `trans_pp`.`lang`='&1'", $opt['template']['locale']); while ($r = sql_fetch_assoc($rs)) { $type = new ChildWp_Type($r['id'], $r['name'], $r['preposition'], $r['image']); $this->childWpTypes[$type->getId()] = $type; } sql_free_result($rs); }
function get_table_def($table) { global $dbname, $crlf, $crlf2; $k = 0; $result = sql_query("SELECT * FROM {$table} limit 1"); $count = sql_num_fields($result); $schema_create = ""; $schema_create .= "DROP TABLE IF EXISTS {$table};{$crlf}"; $schema_create .= "CREATE TABLE {$table} ({$crlf}"; $result = sql_query("SHOW FIELDS FROM {$table}"); while ($row = sql_fetch_assoc($result)) { $schema_create .= " " . $row['Field'] . " " . $row['Type']; if (isset($row['Default']) && (!empty($row['Default']) || $row['Default'] == "0")) { $schema_create .= " DEFAULT '" . $row['Default'] . "'"; } if ($row["Null"] != "YES") { $schema_create .= " NOT NULL"; } if ($row["Extra"] != "") { $schema_create .= " " . $row['Extra']; } if ($k < $count - 1) { $schema_create .= ",{$crlf}"; } $k++; } $result = sql_query("SHOW KEYS FROM {$table}"); while ($row = sql_fetch_assoc($result)) { $kname = $row['Key_name']; if ($kname != "PRIMARY" && $row['Non_unique'] == 0) { $kname = "UNIQUE|{$kname}"; } if (!isset($index[$kname])) { $index[$kname] = array(); } $index[$kname][] = $row['Column_name']; } while (list($x, $columns) = @each($index)) { $schema_create .= ",{$crlf}"; if ($x == "PRIMARY") { $schema_create .= " PRIMARY KEY (" . implode($columns, ", ") . ")"; } elseif (substr($x, 0, 6) == "UNIQUE") { $schema_create .= " UNIQUE " . substr($x, 7) . " (" . implode($columns, ", ") . ")"; } else { $schema_create .= " KEY {$x} (" . implode($columns, ", ") . ")"; } } $schema_create .= "{$crlf})"; $schema_create = stripslashes($schema_create); $schema_create .= ";"; sql_free_result($result); return $schema_create; }
function get_logs($table) { global $grid, $liste, $years; $rs = sql("SELECT latitude, longitude, date\n\t \t\t\t\t FROM {$table}\n\t\t \t\t\t INNER JOIN caches ON {$table}.cache_id=caches.cache_id"); while ($cache = sql_fetch_assoc($rs)) { $lat = floor($cache["latitude"] / $grid); $long = floor($cache["longitude"] / $grid); $year = substr($cache["date"], 0, 4); if ($year >= 2005 && $year <= date("Y") && ($lat != 0 || $long != 0)) { $years[$year] = true; $liste[$lat][$long]["logs"][$year]++; } } mysql_free_result($rs); }
function showAdoptScreen($cacheid, $touerror) { global $tpl, $login; $rs = sql("SELECT `caches`.`name`, `user`.`username`, `cache_adoption`.`date_created`\n\t FROM `caches`\n\t INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`\n\t INNER JOIN `cache_adoption` ON `caches`.`cache_id`=`cache_adoption`.`cache_id`\n\t WHERE `caches`.`cache_id`='&1'\n\t AND `cache_adoption`.`user_id`='&2'", $cacheid, $login->userid); $r = sql_fetch_assoc($rs); if ($r === false) { $tpl->error(ERROR_NO_ACCESS); } $tpl->assign('cache', $r); sql_free_result($rs); if ($touerror != 0) { $tpl->assign('error', 'tou'); } $tpl->display(); }
function get_cache_condition_history($cache_id) { $rs = sql("SELECT `date`, `needs_maintenance`, `listing_outdated`\n\t\t FROM `cache_logs`\n\t\t WHERE `cache_id`='&1' AND (`needs_maintenance` IS NOT NULL OR `listing_outdated` IS NOT NULL)\n\t\t ORDER BY `date`, `id`", $cache_id); $nm = $lo = 0; $cond = array(array('needs_maintenance' => $nm, 'listing_outdated' => $lo, 'date' => '0000-00-00 00:00:00')); while ($r = sql_fetch_assoc($rs)) { if ($r['needs_maintenance'] != $nm || $r['listing_outdated'] != $lo) { $nm = $r['needs_maintenance']; $lo = $r['listing_outdated']; $cond[] = array('needs_maintenance' => $nm, 'listing_outdated' => $lo, 'date' => $r['date']); } } sql_free_result($rs); $cond[] = array('needs_maintenance' => $nm, 'listing_outdated' => $lo, 'date' => '9999-12-31 23:59:59'); return $cond; }
function run() { $nIds = array(); $rs = sqlf("SHOW PROCESSLIST"); while ($r = sql_fetch_assoc($rs)) { $nIds[$r['Id']] = $r['Id']; } sql_free_result($rs); $rs = sqlf("SELECT DISTINCT `threadid` FROM `sys_temptables`"); while ($r = sql_fetch_assoc($rs)) { if (!isset($nIds[$r['threadid']])) { sqlf("DELETE FROM `sys_temptables` WHERE `threadid`='&1'", $r['threadid']); } } sql_free_result($rs); }
function api_getdownload() { // data (*) de download categorie x ou tout global $dna; if ($dna == 'Tous') { $where = ''; } else { $where = " where dcategory='" . $dna . "'"; } settype($ap_dows, 'array'); $res = sql_query("select * from " . $NPDS_Prefix . "downloads " . $where); while ($ap_dow = sql_fetch_assoc($res)) { $ap_dows[] = $ap_dow; } $ap_dows = stripslashes_deep($ap_dows); print json_encode($ap_dows); }
function form_blocks($codename = 'module') { if ($codename) { $query = sql_query('SELECT id, codename FROM ' . DB_PREFIX . 'blocks WHERE side = "L" AND type != 0 ORDER BY position'); while ($db = sql_fetch_assoc($query)) { $left .= '<label><input type="checkbox" name="blocks[]" value="' . $db['id'] . '"' . (!$GLOBALS[$codename]['blocks'] || in_array($db['id'], (array) $GLOBALS['form']['blocks']) ? ' checked="checked"' : '') . ' /> ' . $db['codename'] . '</label> '; $x++; } $query = sql_query('SELECT id, codename FROM ' . DB_PREFIX . 'blocks WHERE side = "R" AND type != 0 ORDER BY position'); while ($db = sql_fetch_assoc($query)) { $right .= '<label><input type="checkbox" name="blocks[]" value="' . $db['id'] . '"' . (!$GLOBALS[$codename]['blocks'] || in_array($db['id'], (array) $GLOBALS['form']['blocks']) ? ' checked="checked"' : '') . ' /> ' . $db['codename'] . '</label> '; $x++; } $right .= '<input type="hidden" name="blocks_count" value="' . $x . '" />'; return array('left' => $left, 'right' => $right); } }