if (isset($_POST['submitform'])) {
         // prüfen, ob sprache nicht schon vorhanden
         $rs = sql("SELECT COUNT(*) `count` FROM `cache_desc` WHERE `cache_id`='&1' AND `id` != '&2' AND `language`='&3'", $desc_record['cache_id'], $descid, $desclang);
         $r = sql_fetch_array($rs);
         if ($r['count'] > 0) {
             tpl_errorMsg('editdesc', $error_desc_exists);
         }
         mysql_free_result($rs);
         /* Prevent binary data in cache descriptions, e.g. <img src='data:...'> tags. */
         if (strlen($desc) > 300000) {
             tpl_errorMsg('editdesc', tr('error3KCharsExcedeed'));
         }
         mysql_query("SET NAMES 'utf8'");
         sql("UPDATE `cache_desc` SET\n                                        `last_modified`=NOW(),\n                                        `desc_html`='&1',\n                                        `desc_htmledit`='&2',\n                                        `desc`='&3',\n                                        `short_desc`='&4',\n                                        `hint`='&5',\n                                        `language`='&6'\n                                  WHERE `id`='&7'", '2', '1', $desc, $short_desc, nl2br($hints), $desclang, $descid);
         // beschreibungssprachen im cache-record aktualisieren
         setCacheDefaultDescLang($desc_record['cache_id']);
         // redirect to cachepage
         tpl_redirect('editcache.php?cacheid=' . urlencode($desc_record['cache_id']));
         exit;
     } else {
         if (isset($_POST['show_all_langs'])) {
             $show_all_langs = true;
         }
     }
 } else {
     //here we read all used information from the DB
     $short_desc = strip_tags($desc_record['short_desc']);
     $hints = strip_tags($desc_record['hint']);
     $desc_lang = $desc_record['language'];
     $desc = $desc_record['desc'];
 }
     $adm3 = sqlValue("SELECT `name` FROM `nuts_codes` WHERE `code`='" . sql_escape($sel_region) . "'", 0);
 } else {
     $code3 = null;
     $adm3 = null;
 }
 sql("INSERT INTO `cache_location` (cache_id,adm1,adm3,code1,code3) VALUES ('&1','&2','&3','&4','&5')", $cache_id, $adm1, $adm3, $code1, $code3);
 // update cache last modified, it is for work of cache_locations update information
 sql("UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`='&1'", $cache_id);
 // waypoint erstellen
 setCacheWaypoint($cache_id, $oc_waypoint);
 $desc_uuid = create_uuid();
 //add record to cache_desc table
 $desc = userInputFilter::purifyHtmlString($desc);
 $query = "INSERT INTO `cache_desc` (\n                                                `cache_id`,\n                                                `language`,\n                                                `desc`,\n                                                `hint`,\n                                                `short_desc`,\n                                                `last_modified`,\n                                                `uuid`,\n                                                `node`\n                                            ) VALUES (:1, :2, :3, :4, :5, NOW(), :6, :7)";
 $db->multiVariableQuery($query, $cache_id, $sel_lang, $desc, nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')), $short_desc, $desc_uuid, $oc_nodeid);
 setCacheDefaultDescLang($cache_id);
 // insert cache-attributes
 for ($i = 0; $i < count($cache_attribs); $i++) {
     if ($cache_attribs[$i] + 0 > 0) {
         sql("INSERT INTO `caches_attributes` (`cache_id`, `attrib_id`) VALUES ('&1', '&2')", $cache_id, $cache_attribs[$i] + 0);
     }
 }
 // only if no approval is needed and cache is published NOW or activate_date is in the past
 if (!$needs_approvement && ($publish == 'now' || $publish == 'later' && mktime($activate_hour, 0, 0, $activate_month, $activate_day, $activate_year) <= $today)) {
     //do event handling
     include_once $rootpath . '/lib/eventhandler.inc.php';
     event_notify_new_cache($cache_id + 0);
     event_new_cache($usr['userid'] + 0);
 }
 if ($needs_approvement) {
     // notify RR that new cache has to be verified
Beispiel #3
0
<?php

$rootpath = '../../';
require_once $rootpath . 'lib/settings.inc.php';
require_once $rootpath . 'lib/clicompatbase.inc.php';
/* begin db connect */
$bFail = false;
$dblink = mysql_connect($dbserver, $dbusername, $dbpasswd);
if ($dblink != false) {
    //database connection established ... set the used database
    if (@mysql_select_db($dbname, $dblink) == false) {
        $bFail = true;
        mysql_close($dblink);
        $dblink = false;
    }
} else {
    $bFail = true;
}
if ($bFail == true) {
    echo 'Unable to connect to database';
    exit;
}
/* end db connect */
$rs = sql('SELECT `cache_id` FROM `caches`');
while ($r = mysql_fetch_array($rs)) {
    setCacheDefaultDescLang($r['cache_id']);
}
mysql_free_result($rs);