mysql_free_result($rs);
                tpl_set_var('desclangs', $languages);
                if ($show_all_langs == false) {
                    $show_all_langs_submit = '&nbsp;<input type="submit" name="show_all_langs" value="' . tr('edDescShowAll') . '" />';
                    tpl_set_var('show_all_langs_submit', $show_all_langs_submit);
                } else {
                    tpl_set_var('show_all_langs_submit', '');
                }
                tpl_set_var('show_all_langs_value', $show_all_langs == false ? 0 : 1);
                tpl_set_var('short_desc', htmlspecialchars($short_desc, ENT_COMPAT, 'UTF-8'));
                tpl_set_var('hints', $hints);
                tpl_set_var('descid', $descid);
                tpl_set_var('cacheid', htmlspecialchars($desc_record['cache_id'], ENT_COMPAT, 'UTF-8'));
                tpl_set_var('desclang', htmlspecialchars($desc_lang, ENT_COMPAT, 'UTF-8'));
                tpl_set_var('desclang_name', htmlspecialchars(db_LanguageFromShort($desc_lang), ENT_COMPAT, 'UTF-8'));
                tpl_set_var('cachename', htmlspecialchars($desc_record['name'], ENT_COMPAT, 'UTF-8'));
                // TinyMCE
                $headers = tpl_get_var('htmlheaders') . "\n";
                //$headers .= '<script language="javascript" type="text/javascript" src="lib/phpfuncs.js"></script>' . "\n";
                tpl_set_var('htmlheaders', $headers);
            } else {
                tpl_redirect('');
            }
        } else {
            tpl_errorMsg('editdesc', $error_desc_not_found);
        }
    }
}
//make the template and send it out
tpl_set_var('language4js', $lang);
tpl_BuildTemplate();
Beispiel #2
0
 if ($usr === false) {
     $tplname = 'login';
     tpl_set_var('username', '');
     tpl_set_var('target', htmlspecialchars('removelog.php?logid=' . urlencode($log_id), ENT_COMPAT, 'UTF-8'));
     tpl_set_var('message', $login_required);
     tpl_set_var('message_start', '');
     tpl_set_var('message_end', '');
 } else {
     $log_rs = sql("SELECT\t`cache_logs`.`node` AS `node`, `cache_logs`.`uuid` AS `uuid`, `cache_logs`.`cache_id` AS `cache_id`, `caches`.`user_id` AS `cache_owner_id`,\n\t\t\t\t\t\t`caches`.`name` AS `cache_name`, `cache_logs`.`text` AS `log_text`, `cache_logs`.`text_html`, `cache_logs`.`type` AS `log_type`, `cache_logs`.`oc_team_comment` AS `oc_team_comment`,\n\t\t\t\t\t\t`cache_logs`.`user_id` AS `log_user_id`, `cache_logs`.`date` AS `log_date`,\n\t\t\t\t\t\t`log_types`.`icon_small` AS `icon_small`,\n\t\t\t\t\t\t`user`.`username` as `log_username`,\n\t\t\t\t\t\t`caches`.`wp_oc`,\n\t\t\t\t\t\t`cache_status`.`allow_user_view`,\n\t\t\t\t\t\tIFNULL(`sys_trans_text`.`text`,`log_types`.`en`) AS `logtype_name`\n\t\t\t\t\t FROM `cache_logs`, `caches`, `user`, `cache_status`, `log_types`\n\t\t\tLEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id`=`log_types`.`trans_id` AND `sys_trans_text`.`lang`='&2'\n\t\t\t\t\tWHERE `cache_logs`.`id`='&1'\n\t\t\t\t\t  AND `cache_logs`.`user_id`=`user`.`user_id`\n\t\t\t\t\t  AND `caches`.`cache_id`=`cache_logs`.`cache_id`\n\t\t\t\t\t  AND `caches`.`status`=`cache_status`.`id`\n\t\t\t\t\t  AND `log_types`.`id`=`cache_logs`.`type`\n\t\t\t\t\t\t", $log_id, $opt['template']['locale']);
     //log exists?
     if (mysql_num_rows($log_rs) == 1) {
         $log_record = sql_fetch_array($log_rs);
         mysql_free_result($log_rs);
         include $stylepath . '/removelog.inc.php';
         if ($log_record['node'] != $oc_nodeid) {
             tpl_errorMsg('removelog', $error_wrong_node);
             exit;
         }
         if ($log_record['allow_user_view'] != 1 && $log_record['cache_owner_id'] != $usr['userid'] && !($usr['admin'] && ADMIN_USER)) {
             exit;
         }
         // deleted allowed by cache-owner or log-owner
         if ($log_record['log_user_id'] == $usr['userid'] || $log_record['cache_owner_id'] == $usr['userid']) {
             $commit = isset($_REQUEST['commit']) ? $_REQUEST['commit'] : 0;
             $ownlog = $log_record['log_user_id'] == $usr['userid'];
             if ($ownlog) {
                 // we are the log-owner
                 $tplname = 'removelog_logowner';
             } else {
                 // we are the cache-owner
                 $tplname = 'removelog_cacheowner';
Beispiel #3
0
         $n++;
     }
     $sql_from[] = '`caches`';
     $sql_where[] = '`s1`.`cache_id`=`caches`.`cache_id`';
     $sqlFilter = 'SELECT DISTINCT ' . implode(',', $sql_select) . ' FROM ' . implode(',', $sql_from) . ' WHERE ' . implode(' AND ', $sql_where);
     $dbcSearch->simpleQuery('CREATE TEMPORARY TABLE `tmpFTCaches` (`cache_id` int (11) PRIMARY KEY) ' . $sqlFilter);
     $dbcSearch->reset();
     $sql_select = array();
     $sql_from = array();
     $sql_where = array();
     $sql_select[] = '`caches`.`cache_id` `cache_id`';
     $sql_from[] = '`tmpFTCaches`';
     $sql_from[] = '`caches`';
     $sql_where[] = '`caches`.`cache_id`=`tmpFTCaches`.`cache_id`';
 } else {
     tpl_errorMsg('search', tr("waypoint_error2"));
 }
 // additional options
 if (!isset($options['f_userowner'])) {
     $options['f_userowner'] = '0';
 }
 if ($options['f_userowner'] != 0) {
     $sql_where[] = '`caches`.`user_id`!=\'' . $usr['userid'] . '\'';
 }
 if (!isset($options['f_userfound'])) {
     $options['f_userfound'] = '0';
 }
 if ($options['f_userfound'] != 0) {
     $sql_where[] = '`caches`.`cache_id` NOT IN (SELECT `cache_logs`.`cache_id` FROM `cache_logs` WHERE `cache_logs`.`deleted`=0 AND `cache_logs`.`user_id`=\'' . sql_escape($usr['userid']) . '\' AND `cache_logs`.`type` IN (1, 7))';
 }
 if (!isset($options['f_geokret'])) {
function removelog($log_id, $language, $lang)
{
    global $tplname, $usr, $lang, $stylepath, $oc_nodeid, $error_wrong_node, $removed_message_title, $removed_message_end, $emailheaders, $rootpath, $cacheid, $log_record, $cache_types, $cache_size, $cache_status, $dblink, $octeamEmailsSignature;
    $log_rs = sql("SELECT   `cache_logs`.`node` AS `node`, `cache_logs`.`uuid` AS `uuid`, `cache_logs`.`cache_id` AS `cache_id`, `caches`.`user_id` AS `cache_owner_id`,\n                        `caches`.`name` AS `cache_name`, `cache_logs`.`text` AS `log_text`, `cache_logs`.`type` AS `log_type`,\n                        `cache_logs`.`user_id` AS `log_user_id`, `cache_logs`.`date` AS `log_date`,\n                        `log_types`.`icon_small` AS `icon_small`,\n                        `log_types_text`.`text_listing` AS `text_listing`,\n                        `user`.`username` as `log_username`\n                     FROM `log_types`, `log_types_text`, `cache_logs`, `caches`, `user`\n                    WHERE `cache_logs`.`id`='&1'\n                      AND `cache_logs`.`user_id`=`user`.`user_id`\n                      AND `caches`.`cache_id`=`cache_logs`.`cache_id`\n                      AND `log_types_text`.`log_types_id`=`log_types`.`id` AND `log_types_text`.`lang`='&2'\n                        AND `cache_logs`.`deleted` = &3\n                      AND `log_types`.`id`=`cache_logs`.`type`", $log_id, $lang, 0);
    //log exists?
    if (mysql_num_rows($log_rs) == 1) {
        $log_record = sql_fetch_array($log_rs);
        mysql_free_result($log_rs);
        include $stylepath . '/removelog.inc.php';
        if ($log_record['node'] != $oc_nodeid) {
            tpl_errorMsg('removelog', $error_wrong_node);
            exit;
        }
        //cache-owner or log-owner
        if ($log_record['log_user_id'] == $usr['userid'] || $log_record['cache_owner_id'] == $usr['userid'] || $usr['admin']) {
            if ($usr['admin'] && isset($_POST['userid'])) {
                $commit = 1;
            } else {
                $commit = isset($_REQUEST['commit']) ? $_REQUEST['commit'] : 0;
            }
            //we are the logger
            if ($log_record['log_user_id'] == $usr['userid']) {
                $tplname = 'removelog_logowner';
            } else {
                $tplname = 'removelog_cacheowner';
                if ($commit == 1) {
                    //send email to logowner schicken
                    $email_content = read_file($stylepath . '/email/removed_log.email');
                    $message = isset($_POST['logowner_message']) ? $_POST['logowner_message'] : '';
                    if ($message != '') {
                        //message to logowner
                        $message = $removed_message_title . "\n" . $message . "\n" . $removed_message_end;
                    }
                    //get cache owner name
                    $cache_owner_rs = sql("SELECT `username` FROM `user` WHERE `user_id`='&1'", $log_record['cache_owner_id']);
                    $cache_owner_record = sql_fetch_array($cache_owner_rs);
                    //get email address of logowner
                    $log_user_rs = sql("SELECT `email`, `username` FROM `user` WHERE `user_id`='&1'", $log_record['log_user_id']);
                    $log_user_record = sql_fetch_array($log_user_rs);
                    $email_content = mb_ereg_replace('{log_owner}', $log_user_record['username'], $email_content);
                    $email_content = mb_ereg_replace('{cache_owner}', $cache_owner_record['username'], $email_content);
                    $email_content = mb_ereg_replace('{cache_name}', $log_record['cache_name'], $email_content);
                    $email_content = mb_ereg_replace('{log_entry}', $log_record['log_text'], $email_content);
                    $email_content = mb_ereg_replace('{comment}', $message, $email_content);
                    $email_content = mb_ereg_replace('{removedLog_01}', tr('removedLog_01'), $email_content);
                    $email_content = mb_ereg_replace('{removedLog_02}', tr('removedLog_02'), $email_content);
                    $email_content = mb_ereg_replace('{removedLog_03}', tr('removedLog_03'), $email_content);
                    $email_content = mb_ereg_replace('{octeamEmailsSignature}', $octeamEmailsSignature, $email_content);
                    $email_content = mb_ereg_replace('{removedLog_04}', tr('removedLog_04'), $email_content);
                    //send email (only on single removement)
                    mb_send_mail($log_user_record['email'], $removed_log_title, $email_content, $emailheaders);
                }
            }
            if ($commit == 1) {
                // do not acually delete logs - just mark them as deleted.
                sql("UPDATE `cache_logs` SET deleted = 1, `del_by_user_id` =" . $usr['userid'] . " , `last_modified`=NOW(), `last_deleted`=NOW() WHERE `cache_logs`.`id`='&1' LIMIT 1", $log_id);
                recalculateUserStats($log_record['log_user_id']);
                // remove from cache_moved for log "MOVED" (mobilniaki by Łza)
                // (kod istniejący wcześniej, zaadaptowany)
                if ($log_record['log_type'] == 4) {
                    // jesli log jest ostatni - przywrocenie kordow z przedostatniego "przeniesiona"
                    $check_cml = sql("SELECT `latitude`,`longitude`,`id` FROM `cache_moved` WHERE `log_id`='&1'", $log_id);
                    if (mysql_num_rows($check_cml) != 0) {
                        $xy_log = sql_fetch_array($check_cml);
                        $check_cmc = sql("SELECT `latitude`,`longitude` FROM `caches` WHERE `cache_id`='&1'", $log_record['cache_id']);
                        if (mysql_num_rows($check_cmc) != 0) {
                            $xy_cache = sql_fetch_array($check_cmc);
                            if ($xy_cache['latitude'] == $xy_log['latitude'] && $xy_cache['longitude'] == $xy_log['longitude']) {
                                sql("DELETE FROM `cache_moved` WHERE `log_id`='&1' LIMIT 1", $log_id);
                                $get_xy = sql("SELECT `latitude`,`longitude` FROM `cache_moved` WHERE `cache_id`='&1' ORDER BY `date` DESC LIMIT 1", $log_record['cache_id']);
                                $old_xy = sql_fetch_array($get_xy);
                                if ($old_xy['longitude'] != '' && $old_xy['latitude'] != '') {
                                    sql("UPDATE `caches` SET `last_modified`=NOW(), `longitude`='&1', `latitude`='&2' WHERE `cache_id`='&3'", $old_xy['longitude'], $old_xy['latitude'], $log_record['cache_id']);
                                }
                            } else {
                                sql("DELETE FROM `cache_moved` WHERE `log_id`='&1' LIMIT 1", $log_id);
                            }
                        } else {
                            sql("DELETE FROM `cache_moved` WHERE `log_id`='&1' LIMIT 1", $log_id);
                        }
                    }
                }
                if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                    // remove cache from users top caches, because the found log was deleted for some reason
                    sql("DELETE FROM `cache_rating` WHERE `user_id` = '&1' AND `cache_id` = '&2'", $log_record['log_user_id'], $log_record['cache_id']);
                    // Notify OKAPI's replicate module of the change.
                    // Details: https://github.com/opencaching/okapi/issues/265
                    require_once $rootpath . 'okapi/facade.php';
                    \okapi\Facade::schedule_user_entries_check($log_record['cache_id'], $log_record['log_user_id']);
                    \okapi\Facade::disable_error_handling();
                    // recalc scores for this cache
                    sql("DELETE FROM `scores` WHERE `user_id` = '&1' AND `cache_id` = '&2'", $log_record['log_user_id'], $log_record['cache_id']);
                    $sql = "SELECT count(*) FROM scores WHERE cache_id='" . sql_escape($log_record['cache_id']) . "'";
                    $liczba = mysql_result(mysql_query($sql), 0);
                    $sql = "SELECT SUM(score) FROM scores WHERE cache_id='" . sql_escape($log_record['cache_id']) . "'";
                    $suma = @mysql_result(@mysql_query($sql), 0) + 0;
                    // obliczenie nowej sredniej
                    if ($liczba != 0) {
                        $srednia = $suma / $liczba;
                    } else {
                        $srednia = 0;
                    }
                    $sql = "UPDATE caches SET votes='" . sql_escape($liczba) . "', score='" . sql_escape($srednia) . "' WHERE cache_id='" . sql_escape($log_record['cache_id']) . "'";
                    mysql_query($sql);
                }
                //call eventhandler
                require_once $rootpath . 'lib/eventhandler.inc.php';
                event_remove_log($cacheid, $usr['userid'] + 0);
                //update cache-stat if type or log_date changed
                $cache_rs = sql("SELECT `founds`, `notfounds`, `notes` FROM `caches` WHERE `cache_id`='&1'", $log_record['cache_id']);
                $cache_record = sql_fetch_array($cache_rs);
                mysql_free_result($cache_rs);
                if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                    $cache_record['founds']--;
                } elseif ($log_record['log_type'] == 2 || $log_record['log_type'] == 8) {
                    $cache_record['notfounds']--;
                } elseif ($log_record['log_type'] == 3) {
                    $cache_record['notes']--;
                }
                //Update last found
                $last_tmp = $log_record['cache_id'];
                $lastfound_rs = sql("SELECT MAX(`cache_logs`.`date`) AS `date` FROM `cache_logs` WHERE ((cache_logs.`type`=1) AND (cache_logs.`cache_id`='{$last_tmp}'))");
                $lastfound_record = sql_fetch_array($lastfound_rs);
                if ($lastfound_record['date'] === NULL) {
                    $lastfound = 'NULL';
                } else {
                    $lastfound = $lastfound_record['date'];
                }
                sql("UPDATE `caches` SET `last_found`='&1', `founds`='&2', `notfounds`='&3', `notes`='&4' WHERE `cache_id`='&5'", $lastfound, $cache_record['founds'], $cache_record['notfounds'], $cache_record['notes'], $log_record['cache_id']);
                unset($cache_record);
                if (!isset($_POST['userid'])) {
                    //cache anzeigen
                    $_GET['cacheid'] = $log_record['cache_id'];
                    $_REQUEST['cacheid'] = $log_record['cache_id'];
                    require 'viewcache.php';
                }
            } else {
                tpl_set_var('cachename', htmlspecialchars($log_record['cache_name'], ENT_COMPAT, 'UTF-8'));
                tpl_set_var('cacheid', htmlspecialchars($log_record['cache_id'], ENT_COMPAT, 'UTF-8'));
                tpl_set_var('logid_urlencode', htmlspecialchars(urlencode($log_id), ENT_COMPAT, 'UTF-8'));
                tpl_set_var('logid', htmlspecialchars($log_id, ENT_COMPAT, 'UTF-8'));
                $log = read_file($stylepath . '/viewcache_log.tpl.php');
                $log = mb_ereg_replace('{date}', htmlspecialchars(strftime("%d %B %Y", strtotime($log_record['log_date'])), ENT_COMPAT, 'UTF-8'), $log);
                if (isset($log_record['recommended']) && $log_record['recommended'] == 1) {
                    $log = mb_ereg_replace('{ratingimage}', $rating_picture, $log);
                } else {
                    $log = mb_ereg_replace('{ratingimage}', '', $log);
                }
                $log = mb_ereg_replace('{username}', htmlspecialchars($log_record['log_username'], ENT_COMPAT, 'UTF-8'), $log);
                $log = mb_ereg_replace('{userid}', htmlspecialchars($log_record['log_user_id'] + 0, ENT_COMPAT, 'UTF-8'), $log);
                tpl_set_var('log_user_name', htmlspecialchars($log_record['log_username'], ENT_COMPAT, 'UTF-8'));
                $log = mb_ereg_replace('{type}', htmlspecialchars($log_record['text_listing'], ENT_COMPAT, 'UTF-8'), $log);
                $log = mb_ereg_replace('{logimage}', icon_log_type($log_record['icon_small'], ""), $log);
                $log = mb_ereg_replace('{logfunctions}', '', $log);
                $log = mb_ereg_replace('{logpictures}', '', $log);
                $log = mb_ereg_replace('{logtext}', $log_record['log_text'], $log);
                $log = mb_ereg_replace('{username_aktywnosc}', '', $log);
                $log = mb_ereg_replace('{kordy_mobilniaka}', '', $log);
                tpl_set_var('log', $log);
                //make the template and send it out
                tpl_BuildTemplate();
            }
        } else {
            //TODO: hm ... no permission to remove the log
            d('no permission to remove the log');
        }
    } else {
        //TODO: log doesn't exist
        d('log doesn\'t exist');
    }
}
     tpl_set_var('message_end', '');
     tpl_set_var('message', $login_required);
     tpl_set_var('helplink', helppagelink('login'));
 } else {
     $cache_rs = sql("SELECT `user_id`, `name` FROM `caches` WHERE `cache_id`='&1'", $cache_id);
     $cache_record = sql_fetch_array($cache_rs);
     sql_free_result($cache_rs);
     if ($cache_record !== false) {
         if ($cache_record['user_id'] == $usr['userid']) {
             $desc_rs = sql("SELECT `id`, `uuid`, `node` FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $desclang);
             if (mysql_num_rows($desc_rs) == 1) {
                 $desc_record = sql_fetch_array($desc_rs);
                 mysql_free_result($desc_rs);
                 require $stylepath . '/removedesc.inc.php';
                 if ($desc_record['node'] != $oc_nodeid) {
                     tpl_errorMsg('removedesc', $error_wrong_node);
                     exit;
                 }
                 if ($remove_commit == 1) {
                     //remove it from cache_desc
                     sql("DELETE FROM `cache_desc` WHERE `cache_id`='&1' AND `language`='&2'", $cache_id, $desclang);
                     // do not use slave server for the next time ...
                     db_slave_exclude();
                     tpl_redirect('editcache.php?cacheid=' . urlencode($cache_id));
                     exit;
                 } else {
                     //commit the removement
                     $tplname = 'removedesc';
                     tpl_set_var('desclang_name', db_LanguageFromShort($desclang));
                     tpl_set_var('cachename', htmlspecialchars($cache_record['name'], ENT_COMPAT, 'UTF-8'));
                     tpl_set_var('cacheid_urlencode', htmlspecialchars(urlencode($cache_id), ENT_COMPAT, 'UTF-8'));
Beispiel #6
0
    $str = mb_ereg_replace('ű', 'u', $str);
    $str = mb_ereg_replace('ó', 'o', $str);
    $str = mb_ereg_replace('ú', 'u', $str);
    $str = mb_ereg_replace('É', 'E', $str);
    $str = mb_ereg_replace('Á', 'A', $str);
    $str = mb_ereg_replace('Ö', 'O', $str);
    $str = mb_ereg_replace('Ő', 'O', $str);
    $str = mb_ereg_replace('Ü', 'U', $str);
    $str = mb_ereg_replace('Ű', 'U', $str);
    $str = mb_ereg_replace('Ó', 'O', $str);
    $str = mb_ereg_replace('Ú', 'U', $str);
    return $str;
}
$tplname = 'garmin';
require_once './lib/common.inc.php';
require $stylepath . '/garmin.inc.php';
if ($usr == false && $hide_coords) {
    tpl_errorMsg($tplname, tr('login_message_09'));
    exit;
}
$lat = isset($_REQUEST['lat']) ? $_REQUEST['lat'] : '';
$long = isset($_REQUEST['long']) ? $_REQUEST['long'] : '';
$wp = isset($_REQUEST['wp']) ? $_REQUEST['wp'] : '';
$name = isset($_REQUEST['name']) ? $_REQUEST['name'] : '';
$str = convert($name);
tpl_set_var('lat', $lat);
tpl_set_var('long', $long);
tpl_set_var('wp_oc', $wp);
tpl_set_var('cachename', $str);
//make the template and send it out
tpl_BuildTemplate();
Beispiel #7
0
     tpl_set_var('username', '');
     tpl_set_var('target', 'editcache.php?cacheid=' . urlencode($cache_id));
     tpl_set_var('message_start', "");
     tpl_set_var('message_end', "");
     tpl_set_var('message', $login_required);
     tpl_set_var('helplink', helppagelink('login'));
 } else {
     $cache_rs = sql("\n                SELECT\n                    `caches`.`uuid`,\n                    `caches`.`user_id`,\n                    `caches`.`name`,\n                    `caches`.`type`,\n                    `caches`.`size`,\n                    `caches`.`date_hidden`,\n                    `caches`.`date_activate`,\n                    `caches`.`longitude`,\n                    `caches`.`latitude`,\n                    `caches`.`country`,\n                    `caches`.`terrain`,\n                    `caches`.`difficulty`,\n                    `caches`.`desc_languages`,\n                    `caches`.`status`,\n                    `caches`.`search_time`,\n                    `caches`.`way_length`,\n                    `caches`.`logpw`,\n                    `caches`.`wp_oc`,\n                    `caches`.`wp_gc`,\n                    `caches`.`show_cachelists`,\n                    `caches`.`protect_old_coords`,\n                    `caches`.`node`,\n                    `user`.`username`,\n                    `stat_caches`.`picture`\n                FROM `caches`\n                INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`\n                LEFT JOIN `stat_caches` ON `caches`.`cache_id`=`stat_caches`.`cache_id`\n                WHERE `caches`.`cache_id`='&1'", $cache_id);
     $cache_record = sql_fetch_array($cache_rs);
     sql_free_result($cache_rs);
     if ($cache_record !== false) {
         if ($cache_record['user_id'] == $usr['userid'] || $login->listingAdmin()) {
             $tplname = 'editcache';
             require $stylepath . '/editcache.inc.php';
             if ($cache_record['node'] != $oc_nodeid) {
                 tpl_errorMsg('editcache', $error_wrong_node);
                 exit;
             }
             //here we read all used information from the form if submitted, otherwise from DB
             $cache_name = trim(isset($_POST['name']) ? $_POST['name'] : $cache_record['name']);
             // Ocprop
             $cache_type = isset($_POST['type']) ? $_POST['type'] : $cache_record['type'];
             if (!isset($_POST['size'])) {
                 if ($cache_type == 4 || $cache_type == 5) {
                     $sel_size = 7;
                 } else {
                     $sel_size = $cache_record['size'];
                 }
             } else {
                 $sel_size = isset($_POST['size']) ? $_POST['size'] : $cache_record['size'];
             }
Beispiel #8
0
         }
         $sql_innerjoin[] = '`cache_status` ON `caches`.`status`=`cache_status`.`id`';
         if (isset($usr['userid'])) {
             $sql_where[] = '(`cache_status`.`allow_user_view`=1 OR `caches`.`user_id`=' . sql_escape($usr['userid']) . ')';
         } else {
             $sql_where[] = '`cache_status`.`allow_user_view`=1';
         }
         //do the search
         $innerjoin = sizeof($sql_innerjoin) ? ' INNER JOIN ' . implode(' INNER JOIN ', $sql_innerjoin) : '';
         $leftjoin = sizeof($sql_leftjoin) ? ' LEFT JOIN ' . implode(' LEFT JOIN ', $sql_leftjoin) : '';
         $group = sizeof($sql_group) ? ' GROUP BY ' . implode(', ', $sql_group) : '';
         $having = sizeof($sql_having) ? ' HAVING ' . implode(' AND ', $sql_having) : '';
         $sqlFilter = 'SELECT ' . implode(',', $sql_select) . ' FROM ' . $sql_from . $innerjoin . $leftjoin . ' WHERE ' . implode(' AND ', $sql_where) . $group . $having;
         //echo "DEBUG ".$sqlFilter." DEBUG<br>";
     } else {
         tpl_errorMsg('search', 'Unbekannter Suchtyp');
     }
     //go to final output preparation
     if (!file_exists($rootpath . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php')) {
         tpl_set_var('tplname', $tplname);
         $tplname = 'error';
         tpl_set_var('error_msg', $outputformat_notexist);
     } else {
         //process and output the search result
         require $rootpath . 'lib/search.' . mb_strtolower($options['output']) . '.inc.php';
         exit;
     }
 } else {
     $options['show_all_countries'] = isset($_REQUEST['show_all_countries']) ? $_REQUEST['show_all_countries'] : 0;
     if (isset($_REQUEST['show_all_countries_submit'])) {
         $options['show_all_countries'] = 1;
Beispiel #9
0
     tpl_set_var('message_start', '');
     tpl_set_var('message_end', '');
     tpl_set_var('target', 'editlog.php?logid=' . urlencode($log_id));
     tpl_set_var('message', $login_required);
     tpl_set_var('helplink', helppagelink('login'));
 } else {
     $useradmin = $login->admin & ADMIN_USER ? 1 : 0;
     //does log with this logid exist?
     $log_rs = sql("\n                SELECT\n                    `cache_logs`.`id` AS `log_id`,\n                    `cache_logs`.`cache_id` AS `cache_id`,\n                    `cache_logs`.`node` AS `node`,\n                    `cache_logs`.`text` AS `text`,\n                    `cache_logs`.`date` AS `date`,\n                    `cache_logs`.`user_id` AS `user_id`,\n                    `cache_logs`.`type` AS `logtype`,\n                    `cache_logs`.`oc_team_comment` AS `oc_team_comment`,\n                    `cache_logs`.`text_html` AS `text_html`,\n                    `cache_logs`.`text_htmledit` AS `text_htmledit`,\n                    `caches`.`name` AS `cachename`,\n                    `caches`.`type` AS `cachetype`,\n                    `caches`.`user_id` AS `cache_user_id`,\n                    `caches`.`logpw` AS `logpw`,\n                    `caches`.`status` AS `status`,\n                    `log_types`.`cache_status` > 0 AS `is_status_log`\n                FROM `cache_logs`\n                JOIN `log_types` ON `log_types`.`id`=`cache_logs`.`type`\n                INNER JOIN `caches` ON `caches`.`cache_id`=`cache_logs`.`cache_id`\n                WHERE `cache_logs`.`id`='&1'", $log_id);
     $log_record = sql_fetch_array($log_rs);
     sql_free_result($log_rs);
     if ($log_record !== false && ($log_record['status'] != 6 || $log_record['cache_user_id'] == $login->userid && $log_record['user_id'] == $login->userid) && $log_record['status'] != 7 || $useradmin) {
         require $stylepath . '/editlog.inc.php';
         require $stylepath . '/rating.inc.php';
         if ($log_record['node'] != $oc_nodeid) {
             tpl_errorMsg('editlog', $error_wrong_node);
             exit;
         }
         //is this log from this user?
         if ($log_record['user_id'] == $usr['userid']) {
             $tplname = 'editlog';
             //load settings
             $cache_name = $log_record['cachename'];
             $cache_type = $log_record['cachetype'];
             $cache_user_id = $log_record['cache_user_id'];
             // Ocprop:
             //  logtype, logday, logmonth, logyear, rating, submitform
             $log_type = isset($_POST['logtype']) ? $_POST['logtype'] : $log_record['logtype'];
             $log_date_day = isset($_POST['logday']) ? trim($_POST['logday']) : date('d', strtotime($log_record['date']));
             $log_date_month = isset($_POST['logmonth']) ? trim($_POST['logmonth']) : date('m', strtotime($log_record['date']));
             $log_date_year = isset($_POST['logyear']) ? trim($_POST['logyear']) : date('Y', strtotime($log_record['date']));
function sql_error()
{
    global $debug_page;
    global $sql_errormail;
    global $emailheaders;
    global $absolute_server_URI;
    global $interface_output;
    global $dberrormsg;
    global $db_error;
    $db_error += 1;
    $msql_error = mysql_errno() . ": " . mysql_error();
    if ($db_error > 1) {
        $msql_error .= "\n(** error recursion **)";
    }
    if ($sql_errormail != '') {
        // sendout email
        $email_content = $msql_error;
        $email_content .= "\n--------------------\n";
        $email_content .= print_r(debug_backtrace(), true);
        if (admin_errormail($sql_errormail, 'sql_error', $email_content, $emailheaders)) {
            mb_send_mail($sql_errormail, 'sql_error: ' . $absolute_server_URI, $email_content, $emailheaders);
        }
    }
    if ($interface_output == 'html') {
        // display errorpage
        $errmsg = $dberrormsg . ($debug_page ? "<br />" . $msql_error : "");
        if ($db_error <= 1) {
            tpl_errorMsg('sql_error', $errmsg);
        } else {
            // datbase error recursion, because another error occured while trying to
            // build the error template (e.g. because connection was lost, or an error mail
            // could not load translations from database)
            $errtitle = "Datenbankfehler";
            require "html/error.php";
        }
        exit;
    } else {
        if ($interface_output == 'plain') {
            echo "\n";
            echo 'sql_error' . "\n";
            if ($debug_page) {
                echo $msql_error . "\n";
            }
            echo '---------' . "\n";
            echo print_r(debug_backtrace(), true) . "\n";
            exit;
        }
    }
    die('sql_error');
}
function sql_error()
{
    if (class_exists('\\okapi\\Okapi')) {
        throw new Exception("SQL Error " . mysql_errno() . ": " . mysql_error());
    }
    global $sql_errormail;
    global $emailheaders;
    global $absolute_server_URI;
    global $interface_output;
    global $dberrormsg;
    // sendout email
    $email_content = mysql_errno() . ": " . mysql_error();
    $email_content .= "\n--------------------\n";
    $email_content .= print_r(debug_backtrace(), true);
    echo $sql_errormail . ' sql_error: ' . $absolute_server_URI . " " . $email_content;
    if ($interface_output == 'html') {
        // display errorpage
        tpl_errorMsg('sql_error', $dberrormsg);
        exit;
    } else {
        if ($interface_output == 'plain') {
            echo "\n";
            echo 'sql_error' . "\n";
            echo '---------' . "\n";
            echo print_r(debug_backtrace(), true) . "\n";
            exit;
        }
    }
    die('sql_error');
}
Beispiel #12
0
     $target = $_REQUEST['target'];
 }
 if ($target == '') {
     // wenn im REQUEST nix war, guck mal im POST
     if (isset($_POST['target'])) {
         $target = $_POST['target'];
     }
 }
 if ($target == '') {
     $target = 'index.php';
 }
 if (isset($_REQUEST['action'])) {
     if ($_REQUEST['action'] == 'cookieverify') {
         // wir sollten eingeloggt sein ... kucken, ob cookie gesetzt ...
         if (!isset($_COOKIE[$opt['cookie']['name'] . 'data'])) {
             tpl_errorMsg('login', $cookies_error);
         } else {
             tpl_redirect($target);
         }
         exit;
     }
 }
 //set up the template replacements
 tpl_set_var('username', '');
 tpl_set_var('target', $target);
 //already logged in?
 if ($usr == false) {
     //set login template
     $tplname = 'login';
     //get the login email address and password
     $usr['email'] = isset($_POST['email']) ? $_POST['email'] : '';
function revertLog($log_id, $language, $lang)
{
    // set $debug = true to display debug messages (or false to hide).
    $debug = false;
    global $tplname, $usr, $lang, $stylepath, $oc_nodeid, $error_wrong_node, $removed_message_title, $removed_message_end, $emailheaders, $rootpath, $cacheid, $log_record, $cache_types, $cache_size, $cache_status, $dblink;
    $logRs = new dataBase($debug);
    $logRsQuery = "SELECT   `cache_logs`.`node` AS `node`, `cache_logs`.`uuid` AS `uuid`, `cache_logs`.`cache_id` AS `cache_id`, `caches`.`user_id` AS `cache_owner_id`,\n                            `caches`.`name` AS `cache_name`, `cache_logs`.`text` AS `log_text`, `cache_logs`.`type` AS `log_type`,\n                            `cache_logs`.`user_id` AS `log_user_id`, `cache_logs`.`date` AS `log_date`,\n                            `log_types`.`icon_small` AS `icon_small`,\n                            `log_types_text`.`text_listing` AS `text_listing`,\n                            `user`.`username` as `log_username`\n                     FROM   `log_types`, `log_types_text`, `cache_logs`, `caches`, `user`\n                    WHERE   `cache_logs`.`id`=:log_id\n                      AND   `cache_logs`.`user_id`=`user`.`user_id`\n                      AND   `caches`.`cache_id`=`cache_logs`.`cache_id`\n                      AND   `log_types_text`.`log_types_id`=`log_types`.`id` AND `log_types_text`.`lang`=:lang\n                      AND   `cache_logs`.`deleted` = 1\n                      AND   `log_types`.`id`=`cache_logs`.`type`";
    $logRs->paramQuery($logRsQuery, array('log_id' => array('value' => $log_id, 'data_type' => 'integer'), 'lang' => array('value' => $lang, 'data_type' => 'string')));
    //log exists?
    if ($logRs->rowCount() == 1) {
        $log_record = $logRs->dbResultFetch();
        unset($logRs);
        //  include($stylepath . '/removelog.inc.php');
        if ($log_record['node'] != $oc_nodeid) {
            tpl_errorMsg('removelog', $error_wrong_node);
            exit;
        }
        //cache-owner or log-owner
        if ($log_record['log_user_id'] == $usr['userid'] || $log_record['cache_owner_id'] == $usr['userid'] || $usr['admin']) {
            // revert the log.
            $revert = new dataBase($debug);
            $query = "UPDATE `cache_logs` SET deleted = 0 , `last_modified`=NOW() WHERE `cache_logs`.`id`=:log_id LIMIT 1";
            $revert->paramQuery($query, array('log_id' => array('value' => $log_id, 'data_type' => 'i')));
            unset($revert);
            //user stats update
            $statUpd = new dataBase();
            $query = "SELECT `founds_count`, `notfounds_count`, `log_notes_count` FROM `user` WHERE `user_id`=:user_id";
            $statUpd->paramQuery($query, array('user_id' => array('value' => $log_record['log_user_id'], 'data_type' => 'i')));
            $user_record = $statUpd->dbResultFetch();
            unset($statUpd);
            if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                $user_record['founds_count']++;
            } elseif ($log_record['log_type'] == 2) {
                $user_record['notfounds_count']++;
            } elseif ($log_record['log_type'] == 3) {
                $user_record['log_notes_count']++;
            }
            $updateUser = new dataBase($debug);
            $query = "UPDATE `user` SET `founds_count`=:var1, `notfounds_count`=:var2, `log_notes_count`=:var3 WHERE `user_id`=:var4";
            $params = array('var1' => array('value' => $user_record['founds_count'], 'data_type' => 'i'), 'var2' => array('value' => $user_record['notfounds_count'], 'data_type' => 'i'), 'var3' => array('value' => $user_record['log_notes_count'], 'data_type' => 'i'), 'var4' => array('value' => $log_record['log_user_id'], 'data_type' => 'i'));
            $updateUser->paramQuery($query, $params);
            unset($updateUser, $params, $user_record);
            //call eventhandler
            require_once $rootpath . 'lib/eventhandler.inc.php';
            event_remove_log($cacheid, $usr['userid'] + 0);
            //update cache-stat if type or log_date changed
            $cachStat = new dataBase($debug);
            $query = "SELECT `founds`, `notfounds`, `notes` FROM `caches` WHERE `cache_id`=:var1";
            $cachStat->paramQuery($query, array('var1' => array('value' => $log_record['cache_id'], 'data_type' => 'i')));
            $cache_record = $cachStat->dbResultFetch();
            unset($cachStat);
            if ($log_record['log_type'] == 1 || $log_record['log_type'] == 7) {
                $cache_record['founds']++;
            } elseif ($log_record['log_type'] == 2 || $log_record['log_type'] == 8) {
                $cache_record['notfounds']++;
            } elseif ($log_record['log_type'] == 3) {
                $cache_record['notes']++;
            }
            //Update last found
            $lastF = new dataBase();
            $query = "SELECT MAX(`cache_logs`.`date`) AS `date` FROM `cache_logs` WHERE ((cache_logs.`type`=1) AND (cache_logs.`cache_id`=:last_tmp))";
            $lastF->paramQuery($query, array('last_tmp' => array('value' => $log_record['cache_id'], 'data_type' => 'i')));
            $lastfound_record = $lastF->dbResultFetch();
            unset($statUpd);
            if ($lastfound_record['date'] === NULL) {
                $lastfound = 'NULL';
            } else {
                $lastfound = $lastfound_record['date'];
            }
            $updateCache = new dataBase();
            $query = "UPDATE `caches` SET `last_found`=:var1, `founds`=:var2, `notfounds`=:var3, `notes`=:var4 WHERE `cache_id`=:var5";
            $params = array('var1' => array('value' => $lastfound, 'data_type' => 'string'), 'var2' => array('value' => $cache_record['founds'], 'data_type' => 'i'), 'var3' => array('value' => $cache_record['notfounds'], 'data_type' => 'i'), 'var4' => array('value' => $cache_record['notes'], 'data_type' => 'i'), 'var5' => array('value' => $log_record['cache_id'], 'data_type' => 'i'));
            $updateCache->paramQuery($query, $params);
            unset($updateCache, $params, $cache_record);
            $_GET['cacheid'] = $log_record['cache_id'];
            $_REQUEST['cacheid'] = $log_record['cache_id'];
            require 'viewcache.php';
        } else {
            //TODO: hm ... no permission to revert the log
            $_GET['cacheid'] = $log_record['cache_id'];
            $_REQUEST['cacheid'] = $log_record['cache_id'];
            require 'viewcache.php';
        }
    } else {
        //TODO: log doesn't exist
        $_GET['cacheid'] = $log_record['cache_id'];
        $_REQUEST['cacheid'] = $log_record['cache_id'];
        require 'viewcache.php';
    }
}
function sql_error()
{
    global $sql_errormail;
    global $emailheaders;
    global $absolute_server_URI;
    global $interface_output;
    global $dberrormsg;
    // sendout email
    $email_content = mysql_errno() . ": " . mysql_error();
    $email_content .= "\n--------------------\n";
    $email_content .= print_r(debug_backtrace(), true);
    mb_send_mail($sql_errormail, 'sql_error: ' . $absolute_server_URI, $email_content, $emailheaders);
    if ($interface_output == 'html') {
        // display errorpage
        tpl_errorMsg('sql_error', $dberrormsg);
        exit;
    } else {
        if ($interface_output == 'plain') {
            echo "\n";
            echo 'sql_error' . "\n";
            echo '---------' . "\n";
            echo print_r(debug_backtrace(), true) . "\n";
            exit;
        }
    }
    die('sql_error');
}