Beispiel #1
0
function viewqueries()
{
    global $tplname, $usr;
    global $viewquery_line, $noqueries, $bgcolor1, $bgcolor2;
    $tplname = 'viewqueries';
    $dbc = new dataBase();
    $i = 0;
    $content = '';
    //$rs = sql("SELECT `id`, `name` FROM `queries` WHERE `user_id`='&1' ORDER BY `name` ASC", $usr['userid']);
    $query = "SELECT id, name FROM `queries` WHERE `user_id`=:1 ORDER BY `name` ASC";
    $dbc->multiVariableQuery($query, $usr['userid']);
    if ($dbc->rowCount() != 0) {
        //while ($r = sql_fetch_array($rs))
        while ($r = $dbc->dbResultFetch()) {
            $thisline = $viewquery_line;
            $thisline = mb_ereg_replace('{queryname}', htmlspecialchars($r['name'], ENT_COMPAT, 'UTF-8'), $thisline);
            $thisline = mb_ereg_replace('{queryid}', htmlspecialchars($r['id'], ENT_COMPAT, 'UTF-8'), $thisline);
            if ($i % 2 == 1) {
                $thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
            } else {
                $thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
            }
            $content .= $thisline;
            $i++;
        }
        //mysql_free_result($rs);
    } else {
        $content = $noqueries;
    }
    unset($dbc);
    tpl_set_var('queries', $content);
    tpl_BuildTemplate();
    exit;
}
 function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "delete from CACHE_ACCESS_LOGS where date_sub(now(), INTERVAL 5 DAY) > event_date";
     set_time_limit(360);
     $db->simpleQuery($sql);
     $total_deleted = $db->rowCount();
     set_time_limit(60);
     unset($db);
     echo "total_deleted={$total_deleted}\n";
 }
Beispiel #3
0
function find_news($start, $end)
{
    global $tpl;
    global $lang;
    global $znalezione;
    $wp = mysql_real_escape_string($_GET['wp']);
    $query = "select id,type,user_id,date,text,deleted from cache_logs where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "') order by date desc limit " . $start . "," . $end;
    $wynik = db_query($query);
    $query = "select name,cache_id from caches where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "');";
    $wynik2 = db_query($query);
    $caches = mysql_fetch_assoc($wynik2);
    $tpl->assign("name", $caches['name']);
    // detailed cache access logging
    global $enable_cache_access_logs;
    if (@$enable_cache_access_logs) {
        if (!isset($dbc)) {
            $dbc = new dataBase();
        }
        $cache_id = $caches['cache_id'];
        $user_id = @$_SESSION['user_id'] > 0 ? $_SESSION['user_id'] : null;
        $access_log = @$_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
        if ($access_log === null) {
            $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = array();
            $access_log = $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
        }
        if (@$access_log[$cache_id] !== true) {
            $dbc->multiVariableQuery('INSERT INTO CACHE_ACCESS_LOGS
                        (event_date, cache_id, user_id, source, event, ip_addr, user_agent, forwarded_for)
                     VALUES
                        (NOW(), :1, :2, \'M\', \'view_logs\', :3, :4, :5)', $cache_id, $user_id, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_FORWARDED_FOR']);
            $access_log[$cache_id] = true;
            $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = $access_log;
        }
    }
    $znalezione = array();
    while ($logs = mysql_fetch_assoc($wynik)) {
        if ($logs['deleted'] == 0) {
            $query = "select username from user where user_id = '" . $logs['user_id'] . "';";
            $wynik3 = db_query($query);
            $user = mysql_fetch_row($wynik3);
            $logs2['id'] = $logs['id'];
            $logs2['user_id'] = $logs['user_id'];
            $logs2['newtype'] = $logs['type'];
            $logs2['newdate'] = date('j.m.Y', strtotime($logs['date']));
            $logs2['username'] = $user[0];
            $logs2['newtext'] = html2log($logs['text']);
            $znalezione[] = $logs2;
        }
    }
    $tpl->assign("wp_oc", $wp);
    $tpl->assign("logs", $znalezione);
}
 function load()
 {
     include_once $this->dir . 'classes/dataBase.class.php';
     $db = new dataBase($this->dir);
     global $arrLang;
     $sql = "SELECT `idvar`, `descrp` FROM `languajevar` WHERE `module` IN ('GENERIC','MENU','" . $_SESSION['menu'] . "') AND `languaje` = '" . $_SESSION['lang'] . "'";
     // echo $sql;
     $result = $db->QueryFetchArrayASSOC($sql);
     $arrLang = array();
     foreach ($result as $value) {
         $arrLang[$value['idvar']] = utf8_encode($value['descrp']);
     }
     // 		echo "<pre>".print_r($arrLang,true)."</pre>";
 }
Beispiel #5
0
 function checkAgainstDb()
 {
     $linkInfo = array();
     $returnInfo = array();
     $hashOfUrl = md5($this->urlItself);
     $dbc = new dataBase();
     $linkInfo = $dbc->getInfo($hashOfUrl);
     if (!empty($linkInfo)) {
         foreach ($linkInfo as $key => $value) {
             $returnInfo = array(array("Answer:" => "The " . $key . " website is " . ($value === "true" ? "safe" : "not safe"), array("If you wish to visit anyway" => "{$key}")));
         }
         return $returnInfo;
     } else {
         return array("Data" => "No records found");
     }
 }
Beispiel #6
0
 /**  =====================================================================================
      * Funkcja sprawdzająca czy użytkownik uczestniczył w wydarzeniu
      *
      * dane wejściowe:
      * id skrzynki
      * id zalogowanego użytkownika
      *
      * zwraca true lub false
      *
       ===================================================================================== */
 private static function is_event_attended($cache_id, $user_id)
 {
     $q = 'SELECT user_id FROM cache_logs WHERE cache_id =:v1 AND user_id =:v2 AND type = 7 AND Deleted=0';
     $db = new dataBase();
     $params['v1']['value'] = (int) $cache_id;
     $params['v1']['data_type'] = 'integer';
     $params['v2']['value'] = (int) $user_id;
     $params['v2']['data_type'] = 'integer';
     $db->paramQuery($q, $params);
     $rec = $db->dbResultFetch();
     unset($db);
     if (isset($rec['user_id'])) {
         return true;
     } else {
         return false;
     }
 }
Beispiel #7
0
 function getInstance()
 {
     try {
         if (!self::$instance) {
             self::$instance = new PDO("mysql:host=127.0.0.1;dbname=lmb_2.0", "root", "admin", array(PDO::ATTR_PERSISTENT => true));
         }
         return self::$instance;
     } catch (PDOException $e) {
         return $e->getMessage();
     }
 }
function getUserRow($userId)
{
    require_once __DIR__ . '/Database/Db.php';
    $db = new dataBase();
    $db->multiVariableQuery('SELECT username, hidden_count, log_notes_count, founds_count, notfounds_count, email, country, latitude, longitude FROM `user` WHERE `user_id`=:1', $userId);
    return $db->dbResultFetchOneRowOnly();
}
Beispiel #9
0
if ($powerTrailModuleSwitchOn) {
    tpl_set_var('ptDisplay', 'block');
} else {
    tpl_set_var('ptDisplay', 'none');
}
if ($BlogSwitchOn) {
    tpl_set_var('blogDisplay', 'block');
} else {
    tpl_set_var('blogDisplay', 'none');
}
/////////////////////////////////////////////////////
//Titled Caches
///////////////////////////////////////////////////
$usrid = -1;
$TitledCaches = "";
$dbc = new dataBase();
if ($usr != false) {
    $usrid = $usr['userid'];
}
$query = "SELECT caches.cache_id, caches.name cacheName, adm1 cacheCountry, adm3 cacheRegion, caches.type cache_type, \n        caches.user_id, user.username userName, cache_titled.date_alg, cache_logs.text, cache_desc.short_desc,\n        logUser.user_id logUserId, logUser.username logUserName\nFROM cache_titled\nJOIN caches ON cache_titled.cache_id = caches.cache_id\nJOIN cache_desc ON caches.cache_id = cache_desc.cache_id and language=:1\nJOIN cache_location ON caches.cache_id = cache_location.cache_id\nJOIN user ON caches.user_id = user.user_id\n        \nJOIN cache_logs ON cache_logs.id = cache_titled.log_id \nJOIN user logUser ON logUser.user_id = cache_logs.user_id\n               \nORDER BY date_alg DESC \nLIMIT 1";
$dbc->multiVariableQuery($query, $lang);
$pattern = "<span style='font-size:13px'><img src='{cacheIcon}' class='icon16' alt='Cache' title='Cache' />\n        <a href='viewcache.php?cacheid={cacheId}'><b>{cacheName}</b></a></span> \n        \n        <span style='font-size:11px'> " . tr('hidden_by') . "</span>\n        <span style='font-size:13px'><a href='viewprofile.php?userid={userId}'><b>{userName}</b></a></span><br>\n                \n        <span style='font-size:11px;font-style:italic'>{cacheShortDesc}</span><br>\n                \n        <span class='content-title-noshade' style='font-size:11px'>{country} > {region}</span>\n        <br><br>        \n        <table class='CacheTitledLog' >\n                <tr><td>{logText}\n                <br><br><img src='images/rating-star.png'/> Autor: <a href='viewprofile.php?userid={logUserId}'><b>{logUserName}<b></a></td></tr>\n        </table>";
for ($i = 0; $i < $dbc->rowCount(); $i++) {
    $rec = $dbc->dbResultFetch();
    $line = $pattern;
    $line = mb_ereg_replace('{cacheIcon}', myninc::checkCacheStatusByUser($rec, $usrid), $line);
    $line = mb_ereg_replace('{dateAlg}', $rec["date_alg"], $line);
    $line = mb_ereg_replace('{cacheName}', $rec["cacheName"], $line);
    $line = mb_ereg_replace('{userId}', $rec["user_id"], $line);
    $line = mb_ereg_replace('{userName}', $rec["userName"], $line);
    $line = mb_ereg_replace('{cacheId}', $rec["cache_id"], $line);
 if (isset($_REQUEST['userid'])) {
     $user_id = $_REQUEST['userid'];
 } else {
     $user_id = $usr['userid'];
 }
 tpl_set_var('userid', $user_id);
 require $stylepath . '/viewprofile.inc.php';
 require $stylepath . '/lib/icons.inc.php';
 $tplname = 'viewprofile';
 if ($user_id != $usr['userid']) {
     // do not highlight My stats menu item if browsing other users stats
     $mnu_siteid = 'start';
 }
 $stat_menu = array('title' => tr('Statictics'), 'menustring' => tr('Statictics'), 'siteid' => 'statlisting', 'navicolor' => '#E8DDE4', 'visible' => false, 'filename' => 'viewprofile.php?userid=' . $user_id, 'submenu' => array(array('title' => tr('graph_find'), 'menustring' => tr('graph_find'), 'visible' => true, 'filename' => 'ustatsg2.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'findstat', 'icon' => 'images/actions/stat'), array('title' => tr('graph_created'), 'menustring' => tr('graph_created'), 'visible' => true, 'filename' => 'ustatsg1.php?userid=' . $user_id, 'newwindow' => false, 'siteid' => 'createstat', 'icon' => 'images/actions/stat')));
 $content = "";
 $database = new dataBase();
 $rddQuery = "select TO_DAYS(NOW()) - TO_DAYS(`date_created`) `diff` from `user` WHERE user_id=:1 ";
 $database->multiVariableQuery($rddQuery, $user_id);
 $ddays = $database->dbResultFetch();
 $query = "SELECT admin, guru, hidden_count, founds_count, is_active_flag, email, password, log_notes_count, notfounds_count, username, last_login, country, date_created, description, hide_flag FROM user WHERE user_id=:1 LIMIT 1";
 $database->multiVariableQuery($query, $user_id);
 $user_record = $database->dbResultFetch();
 tpl_set_var('username', $user_record['username']);
 if (date('m') == 4 and date('d') == 1) {
     tpl_set_var('username', tr('primaAprilis1'));
 }
 tpl_set_var('country', tr($user_record['country']));
 tpl_set_var('registered', fixPlMonth(strftime($dateformat, strtotime($user_record['date_created']))));
 $description = $user_record['description'];
 tpl_set_var('description', nl2br($description));
 if ($description != "") {
<?php

function __autoload($filename)
{
    include "classes/" . $filename . ".php";
}
$dataBase = new dataBase();
var_dump($dataBase->getRow("*", "artikels"));
if (isset($_POST["artikelToevoegen"])) {
    $titel = $_POST["titel"];
    $kernWoorden = $_POST["kernwoorden"];
    $artikel = $_POST["artikel"];
    $datum = $_POST["datum"];
    var_dump($dataBase->insert("artikels", "titel, kernwoorden, artikel, auteur, datum", "'" . $titel . "','" . $kernWoorden . "','" . $artikel . "','" . "*****@*****.**" . "','" . $datum . "'"));
}
?>

<!doctype html>

<html>

	<head>

		<title>Classe database test</title>

		<link rel="stylesheet" type="text/css" href="css/style.css">
	</head>

	<body>

			<h1>FrameWork test</h1>
function removeDbEntery($code)
{
    $db = new dataBase();
    $query = 'DELETE FROM `PowerTrail_cacheCandidate` WHERE `link` = :1';
    $db->multiVariableQuery($query, $code);
}
Beispiel #13
0
    $nPeriod = $record['period'];
    $aNrColumn[$nPeriod] = $i;
    $sPN = $nPeriod . $sPeriodName;
    echo "gcb.addColumn('number', '{$sPN}');";
    $i = $i + 1;
}
////////////////////
//echo " var chartOpt = gcb.getChartOption();";
//echo " chartOpt.vAxis.title= '".tr2('NrCaches',$lang)."';";
echo "</script>";
unset($dbc);
////////////////////////////
foreach ($asUserID as $sID) {
    $sCondition = " and cl.user_id = '" . $sID . "'";
    $sCondition .= $sDateCondition;
    $dbc = new dataBase();
    $query = "SELECT u.username username, u.user_id user_id,\n            " . $sGranulate . ",\n            COUNT(*) count\n\n            FROM\n            cache_logs cl\n            join caches c on c.cache_id = cl.cache_id\n            join user u on cl.user_id = u.user_id\n\n            WHERE cl.deleted=0 " . $sTypeCondition . $sCondition . "GROUP BY period";
    $dbc->multiVariableQuery($query);
    echo "<script type='text/javascript'>";
    $nStart = 1;
    while ($record = $dbc->dbResultFetch()) {
        $nPeriod = $record['period'];
        $nVal = $record['count'];
        if ($nStart == 1) {
            $sUserName = $record['username'];
            $sUserName = str_replace("'", "`", $sUserName);
            $nUserId = $record['user_id'];
            echo "\n            gcb.addEmptyRow();\n            gcb.addToLastRow( 0, '{$sUserName}' );\n            ";
            $nStart = 0;
        }
        $nrCol = $aNrColumn[$nPeriod];
Beispiel #14
0
<?php

require_once "database.php";
/*$create="create table test(
		id int(11) primary key auto_increment,
		name varchar(32)
	)";
$alter="alter table test add image_url varchar(128)";
if(mysql_query($create)&&mysql_query($alter)){
	echo "1";
}else{
	echo mysql_error();
	echo "-1";
}*/
$db = new dataBase();
$table = array();
$table["id"] = "int(11)";
$table["name"] = "varchar(32)";
$table["image_Url"] = "varchar(128)";
$db->print_table($table);
Beispiel #15
0
 03455225983
 haq.irfan89@gmail.com
*/
include "DataBase.class.php";
if (isset($_POST['table'])) {
    $table = $_POST['table'];
    $id = $_POST['id'];
    $dbname = 'mapdatabase';
    //Name of the database
    $dbuser = '******';
    //Username for the db
    $dbpass = '';
    //Password for the db
    $dbserver = 'localhost';
    //Name of the mysql server
    $db = new dataBase("{$dbuser}", "{$dbpass}", "{$dbserver}");
    $dbcnx = $db->connectDb();
    $db->selectDb($dbname);
    if ($db->delete($table, $id)) {
        echo "Data Deleted \n";
        echo "Redirecting in 5 seconds...";
        header('Refresh: 5; URL=map.php');
    } else {
        echo "Not Deleted \n";
        echo "Redirecting in 5 seconds...";
        header('Refresh: 5; URL=delete.php');
    }
} else {
    ?>
<div align="center" class="center">
<div align="center"><font size="6" >Enter Table name and ID you want to delete</font> </div><br>
	<?php 
session_start();
function __autoload($filename)
{
    include "classes/" . $filename . ".php";
}
$dataBase = new dataBase();
if (isset($_POST["changeInfo"])) {
    $newEmail = $_POST["email"];
    $id = $_POST["id"];
    if ($_POST["email"] != "" && $_FILES["profilePicture"]["name"] != "") {
        if ($_FILES["profilePicture"]["type"] == "image/png" || $_FILES["profilePicture"]["type"] == "image/jpeg" || $_FILES["profilePicture"]["type"] == "image/gif") {
            if ($_FILES["profilePicture"]["size"] <= 2000000) {
                $newPictureName = newName($_FILES["profilePicture"]["name"]);
                while (file_exists("img\\" . $newPictureName)) {
                    $newPictureName = newName($_FILES["profilePicture"]["name"]);
                }
                move_uploaded_file($_FILES['profilePicture']['tmp_name'], "img\\" . $newPictureName);
                $test = $dataBase->update("users", "email", "'" . $newEmail . "'", "profile_picture", "'" . $newPictureName . "'", "id", "'" . $id . "'");
                $salt = $dataBase->getRow("salt", "users", true, "'" . $id . "'", "id");
                $actualSalt = $salt[0]["salt"];
                $hash = openssl_digest($newEmail . $actualSalt, 'sha512');
                var_dump($test);
                setcookie("login", $newEmail . "," . $hash, time() + 2592000);
                header("location: gegevens-wijzigen-form.php");
            } else {
                $_SESSION["notifications"]["type"] = "error";
                $_SESSION["notifications"]["message"] = "File is too big";
                header("location: gegevens-wijzigen-form.php");
            }
        } else {
Beispiel #17
0
function outputSearchForm($options)
{
    global $stylepath, $usr, $error_plz, $error_locidnocoords, $error_ort, $error_noort, $error_nofulltext;
    global $default_lang, $search_all_countries, $cache_attrib_jsarray_line, $cache_attrib_img_line;
    global $lang, $language, $config;
    //simple mode (only one easy filter)
    $filters = read_file($stylepath . '/search.simple.tpl.php');
    tpl_set_var('filters', $filters, false);
    tpl_set_var('formmethod', 'get');
    // checkboxes
    if (isset($options['sort'])) {
        $bBynameChecked = $options['sort'] == 'byname';
    } else {
        $bBynameChecked = $usr['userid'] == 0;
    }
    tpl_set_var('byname_checked', $bBynameChecked == true ? ' checked="checked"' : '');
    if (isset($options['sort'])) {
        $bBydistanceChecked = $options['sort'] == 'bydistance';
    } else {
        $bBydistanceChecked = $usr['userid'] != 0;
    }
    tpl_set_var('bydistance_checked', $bBydistanceChecked == true ? ' checked="checked"' : '');
    if (isset($options['sort'])) {
        $bBycreatedChecked = $options['sort'] == 'bycreated';
    } else {
        $bBycreatedChecked = $usr['userid'] == 0;
    }
    tpl_set_var('bycreated_checked', $bBycreatedChecked == true ? ' checked="checked"' : '');
    tpl_set_var('hidopt_sort', $options['sort']);
    tpl_set_var('f_inactive_checked', $options['f_inactive'] == 1 ? ' checked="checked"' : '');
    tpl_set_var('hidopt_inactive', $options['f_inactive'] == 1 ? '1' : '0');
    tpl_set_var('f_ignored_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_ignored_disabled', $options['f_ignored'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_ignored', $options['f_ignored'] == 1 ? '1' : '0');
    tpl_set_var('f_userfound_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_userfound_disabled', $options['f_userfound'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_userfound', $options['f_userfound'] == 1 ? '1' : '0');
    tpl_set_var('f_userowner_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_userowner_disabled', $options['f_userowner'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_userowner', $options['f_userowner'] == 1 ? '1' : '0');
    tpl_set_var('f_watched_disabled', $usr['userid'] == 0 ? ' disabled="disabled"' : '');
    if ($usr['userid'] != 0) {
        tpl_set_var('f_watched_disabled', $options['f_watched'] == 1 ? ' checked="checked"' : '');
    }
    tpl_set_var('hidopt_watched', $options['f_watched'] == 1 ? '1' : '0');
    tpl_set_var('f_geokret_checked', $options['f_geokret'] == 1 ? ' checked="checked"' : '');
    tpl_set_var('hidopt_geokret', $options['f_geokret'] == 1 ? '1' : '0');
    if (isset($options['cacherating'])) {
        tpl_set_var('all_caches_checked', $options['cacherating'] == 0 ? ' checked="checked"' : '');
        tpl_set_var('recommended_caches_checked', $options['cacherating'] > 0 ? ' checked="checked"' : '');
        tpl_set_var('cache_min_rec', $options['cacherating'] > 0 ? $options['cacherating'] : 0);
        tpl_set_var('min_rec_caches_disabled', $options['cacherating'] == 0 ? ' disabled="disabled"' : '');
    }
    if (isset($options['cacherating'])) {
        tpl_set_var('cacherating', htmlspecialchars($options['cacherating'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cacherating', '');
    }
    if (isset($options['region'])) {
        tpl_set_var('region', htmlspecialchars($options['region'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('region', '');
    }
    if (isset($options['country'])) {
        tpl_set_var('country', htmlspecialchars($options['country'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('country', '');
    }
    if (isset($options['cachetype'])) {
        tpl_set_var('cachetype', htmlspecialchars($options['cachetype'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachetype', '');
    }
    if (isset($options['cachesize_1'])) {
        tpl_set_var('cachesize_1', htmlspecialchars($options['cachesize_1'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_1', '');
    }
    if (isset($options['cachesize_2'])) {
        tpl_set_var('cachesize_2', htmlspecialchars($options['cachesize_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_2', '');
    }
    if (isset($options['cachesize_3'])) {
        tpl_set_var('cachesize_3', htmlspecialchars($options['cachesize_3'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_3', '');
    }
    if (isset($options['cachesize_4'])) {
        tpl_set_var('cachesize_4', htmlspecialchars($options['cachesize_4'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_4', '');
    }
    if (isset($options['cachesize_5'])) {
        tpl_set_var('cachesize_5', htmlspecialchars($options['cachesize_5'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_5', '');
    }
    if (isset($options['cachesize_6'])) {
        tpl_set_var('cachesize_6', htmlspecialchars($options['cachesize_6'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_6', '');
    }
    if (isset($options['cachesize_7'])) {
        tpl_set_var('cachesize_7', htmlspecialchars($options['cachesize_7'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachesize_7', '');
    }
    if (isset($options['cachevote_1']) && isset($options['cachevote_2'])) {
        tpl_set_var('cachevote_1', htmlspecialchars($options['cachevote_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cachevote_2', htmlspecialchars($options['cachevote_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachevote_1', '');
        tpl_set_var('cachevote_2', '');
    }
    if (isset($options['cachenovote'])) {
        tpl_set_var('cachenovote', htmlspecialchars($options['cachenovote'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachenovote', '');
    }
    if (isset($options['cachedifficulty_1']) && isset($options['cachedifficulty_2'])) {
        tpl_set_var('cachedifficulty_1', htmlspecialchars($options['cachedifficulty_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cachedifficulty_2', htmlspecialchars($options['cachedifficulty_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cachedifficulty_1', '');
        tpl_set_var('cachedifficulty_2', '');
    }
    if (isset($options['cacheterrain_1']) && isset($options['cacheterrain_2'])) {
        tpl_set_var('cacheterrain_1', htmlspecialchars($options['cacheterrain_1'], ENT_COMPAT, 'UTF-8'));
        tpl_set_var('cacheterrain_2', htmlspecialchars($options['cacheterrain_2'], ENT_COMPAT, 'UTF-8'));
    } else {
        tpl_set_var('cacheterrain_1', '');
        tpl_set_var('cacheterrain_2', '');
    }
    // cachename
    tpl_set_var('cachename', isset($options['cachename']) ? htmlspecialchars($options['cachename'], ENT_COMPAT, 'UTF-8') : '');
    // koordinaten
    if (!isset($options['lat_h'])) {
        if ($usr !== false) {
            $rs = sql('SELECT `latitude`, `longitude` FROM `user` WHERE `user_id`=\'' . sql_escape($usr['userid']) . '\'');
            $record = sql_fetch_array($rs);
            $lon = $record['longitude'];
            $lat = $record['latitude'];
            mysql_free_result($rs);
            if ($lon < 0) {
                tpl_set_var('lonE_sel', '');
                tpl_set_var('lonW_sel', ' selected="selected"');
                $lon = -$lon;
            } else {
                tpl_set_var('lonE_sel', ' selected="selected"');
                tpl_set_var('lonW_sel', '');
            }
            if ($lat < 0) {
                tpl_set_var('latN_sel', '');
                tpl_set_var('latS_sel', ' selected="selected"');
                $lat = -$lat;
            } else {
                tpl_set_var('latN_sel', ' selected="selected"');
                tpl_set_var('latS_sel', '');
            }
            $lon_h = floor($lon);
            $lat_h = floor($lat);
            $lon_min = ($lon - $lon_h) * 60;
            $lat_min = ($lat - $lat_h) * 60;
            tpl_set_var('lat_h', $lat_h);
            tpl_set_var('lon_h', $lon_h);
            tpl_set_var('lat_min', sprintf("%02.3f", $lat_min));
            tpl_set_var('lon_min', sprintf("%02.3f", $lon_min));
        } else {
            tpl_set_var('lat_h', '00');
            tpl_set_var('lon_h', '000');
            tpl_set_var('lat_min', '00.000');
            tpl_set_var('lon_min', '00.000');
            tpl_set_var('latN_sel', ' selected="selected"');
            tpl_set_var('latS_sel', '');
            tpl_set_var('lonE_sel', ' selected="selected"');
            tpl_set_var('lonW_sel', '');
        }
    } else {
        tpl_set_var('lat_h', isset($options['lat_h']) ? $options['lat_h'] : '00');
        tpl_set_var('lon_h', isset($options['lon_h']) ? $options['lon_h'] : '000');
        tpl_set_var('lat_min', isset($options['lat_min']) ? $options['lat_min'] : '00.000');
        tpl_set_var('lon_min', isset($options['lon_min']) ? $options['lon_min'] : '00.000');
        if ($options['lonEW'] == 'W') {
            tpl_set_var('lonE_sel', '');
            tpl_set_var('lonW_sel', 'selected="selected"');
        } else {
            tpl_set_var('lonE_sel', 'selected="selected"');
            tpl_set_var('lonW_sel', '');
        }
        if ($options['latNS'] == 'S') {
            tpl_set_var('latS_sel', 'selected="selected"');
            tpl_set_var('latN_sel', '');
        } else {
            tpl_set_var('latS_sel', '');
            tpl_set_var('latN_sel', 'selected="selected"');
        }
    }
    tpl_set_var('distance', isset($options['distance']) ? $options['distance'] : 20);
    if (!isset($options['unit'])) {
        $options['unit'] = 'km';
    }
    if ($options['unit'] == 'km') {
        tpl_set_var('sel_km', 'selected="selected"');
        tpl_set_var('sel_sm', '');
        tpl_set_var('sel_nm', '');
    } else {
        if ($options['unit'] == 'sm') {
            tpl_set_var('sel_km', '');
            tpl_set_var('sel_sm', 'selected="selected"');
            tpl_set_var('sel_nm', '');
        } else {
            if ($options['unit'] == 'nm') {
                tpl_set_var('sel_km', '');
                tpl_set_var('sel_sm', '');
                tpl_set_var('sel_nm', 'selected="selected"');
            }
        }
    }
    // plz
    tpl_set_var('plz', isset($options['plz']) ? htmlspecialchars($options['plz'], ENT_COMPAT, 'UTF-8') : '');
    tpl_set_var('ort', isset($options['ort']) ? htmlspecialchars($options['ort'], ENT_COMPAT, 'UTF-8') : '');
    // owner
    tpl_set_var('owner', isset($options['owner']) ? htmlspecialchars($options['owner'], ENT_COMPAT, 'UTF-8') : '');
    // finder
    tpl_set_var('finder', isset($options['finder']) ? htmlspecialchars($options['finder'], ENT_COMPAT, 'UTF-8') : '');
    //countryoptions
    $countriesoptions = $search_all_countries;
    $rs = sql('SELECT `short` FROM `countries` WHERE `short` IN (SELECT DISTINCT `country` FROM `caches`) ');
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        if ($record['short'] == $options['country']) {
            $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars(tr($record['short']), ENT_COMPAT, 'UTF-8') . '</option>';
        } else {
            $countriesoptions .= '<option value="' . htmlspecialchars($record['short'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars(tr($record['short']), ENT_COMPAT, 'UTF-8') . '</option>';
        }
        $countriesoptions .= "\n";
    }
    tpl_set_var('countryoptions', $countriesoptions);
    //regionoptions
    $regionsoptions = '<option value="" selected="selected">' . tr('all_regions') . '</option>';
    tpl_set_var('regionoptions', $regionsoptions);
    // Typ skrzynki
    $cachetype_options = '';
    if (checkField('cache_type', $lang)) {
        $lang_db = $lang;
    } else {
        $lang_db = "en";
    }
    $rs = sql('SELECT `id`, `&1`, `icon_large` FROM `cache_type` ORDER BY `sort`', $lang_db);
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        /*
        if ($record['id'] == $options['cachetype'])
            $cachetype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" selected="selected">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</option>';
        else
            $cachetype_options .= '<option value="' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</option>';
        */
        $c_rec_id = $record['id'] - 1;
        $cachetype_icon = $record['icon_large'];
        //      if ($options['cachetype'][$c_rec_id] == '1') {
        //          $cachetype_options .= '<input type="checkbox" name="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" checked="checked" /><label for="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</label>';
        //      } else {
        //          $cachetype_options .= '<input type="checkbox" name="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" /><label for="l_cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$default_lang], ENT_COMPAT, 'UTF-8') . '</label>';
        //      }
        $cachetype_icon = str_replace("mystery", "quiz", $cachetype_icon);
        // mystery is an outdated name, we use 'quiz' now :-)
        $cachetype_icon_bw = $cachetype_icon;
        $cachetype_icon = str_replace(".png", "-i.png", $cachetype_icon);
        $cachetype_icon_bw = str_replace(".png", "-i-bw.png", $cachetype_icon_bw);
        $cachetype_icon = str_replace(".gif", "-i.png", $cachetype_icon);
        $cachetype_icon_bw = str_replace(".gif", "-i-bw.png", $cachetype_icon_bw);
        $hidden_css = "position: absolute; visibility: hidden;";
        // css required to hide an image
        // this marks saved user preference for searching, if 1, the cache is by default searched
        // and thus making the colour image visibile
        if (isset($options['cachetype'][$c_rec_id]) && $options['cachetype'][$c_rec_id] == '1') {
            $icon_hidden = "";
            $icon_bw_hidden = $hidden_css;
        } else {
            $icon_hidden = $hidden_css;
            $icon_bw_hidden = "";
        }
        $hidden_css = "position: absolute; visibility: hidden;";
        $cachetype_options .= '<img id="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '"    src="' . htmlspecialchars($stylepath . "/images/" . $cachetype_icon, ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" alt="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" onmousedown="javascript:switchCacheType(\'cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '\')" style="cursor: pointer;' . $icon_hidden . '" />';
        $cachetype_options .= '<img id="cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '_bw" src="' . htmlspecialchars($stylepath . "/images/" . $cachetype_icon_bw, ENT_COMPAT, 'UTF-8') . '" title="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" alt="' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '" onmousedown="javascript:switchCacheType(\'cachetype_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '\')" style="cursor: pointer;' . $icon_bw_hidden . '" />';
        if ($i == 2) {
            $cachetype_options .= '&nbsp;&nbsp;&nbsp;';
        }
        $cachetype_options .= "\n";
    }
    tpl_set_var('cachetype_options', $cachetype_options);
    //Rozmiar skrzynki
    $cachesize_options = '';
    if (checkField('cache_size', $lang)) {
        $lang_db = $lang;
    } else {
        $lang_db = "en";
    }
    $rs = sql('SELECT `id`, `&1` FROM `cache_size` ORDER BY `id`', $lang_db);
    for ($i = 0; $i < mysql_num_rows($rs); $i++) {
        $record = sql_fetch_array($rs);
        $cachesize_options .= '<input type="checkbox" name="cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" value="1" id="l_cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '" class="checkbox" onclick="javascript:sync_options(this)" checked="checked" /><label for="l_cachesize_' . htmlspecialchars($record['id'], ENT_COMPAT, 'UTF-8') . '">' . htmlspecialchars($record[$lang_db], ENT_COMPAT, 'UTF-8') . '</label>';
        $cachesize_options .= "\n";
    }
    tpl_set_var('cachesize_options', $cachesize_options);
    // gpxlogLimit
    if ($options['gpxLogLimit'] == false) {
        tpl_set_var('gpxLogLimitUserChoice', 5);
    } else {
        tpl_set_var('gpxLogLimitUserChoice', $options['gpxLogLimit']);
    }
    function attr_jsline($tpl, $options, $id, $textlong, $iconlarge, $iconno, $iconundef, $category)
    {
        $line = $tpl;
        $line = mb_ereg_replace('{id}', $id, $line);
        if (array_search($id, $options['cache_attribs']) === false) {
            if (array_search($id, $options['cache_attribs_not']) === false) {
                $line = mb_ereg_replace('{state}', 0, $line);
            } else {
                $line = mb_ereg_replace('{state}', 2, $line);
            }
        } else {
            $line = mb_ereg_replace('{state}', 1, $line);
        }
        $line = mb_ereg_replace('{text_long}', addslashes($textlong), $line);
        $line = mb_ereg_replace('{icon}', $iconlarge, $line);
        $line = mb_ereg_replace('{icon_no}', $iconno, $line);
        $line = mb_ereg_replace('{icon_undef}', $iconundef, $line);
        $line = mb_ereg_replace('{category}', $category, $line);
        return $line;
    }
    function attr_image($tpl, $options, $id, $textlong, $iconlarge, $iconno, $iconundef, $category)
    {
        $line = $tpl;
        $line = mb_ereg_replace('{id}', $id, $line);
        $line = mb_ereg_replace('{text_long}', $textlong, $line);
        if (array_search($id, $options['cache_attribs']) === false) {
            if (array_search($id, $options['cache_attribs_not']) === false) {
                $line = mb_ereg_replace('{icon}', $iconundef, $line);
            } else {
                $line = mb_ereg_replace('{icon}', $iconno, $line);
            }
        } else {
            $line = mb_ereg_replace('{icon}', $iconlarge, $line);
        }
        return $line;
    }
    // cache-attributes
    $attributes_jsarray = '';
    $attributes_img = '';
    $attributesCat2_img = '';
    // select attributes depend on specified language.
    $database = new dataBase(false);
    $query = "SELECT `id`, `text_long`, `icon_large`, `icon_no`, `icon_undef`, `category` FROM `cache_attrib` WHERE `language` LIKE :1 ORDER BY `id`";
    $database->multiVariableQuery($query, strtoupper($lang));
    // if specified language is in database
    if ($database->rowCount() <= 0) {
        // if we have not specified language in db, just use english.
        $database->multiVariableQuery($query, 'EN');
    }
    $rs = $database->dbResultFetchAll();
    unset($database);
    foreach ($rs as $record) {
        // icon specified
        $line = attr_jsline($cache_attrib_jsarray_line, $options, $record['id'], $record['text_long'], $record['icon_large'], $record['icon_no'], $record['icon_undef'], $record['category']);
        if ($attributes_jsarray != '') {
            $attributes_jsarray .= ",\n";
        }
        $attributes_jsarray .= $line;
        $line = attr_image($cache_attrib_img_line, $options, $record['id'], $record['text_long'], $record['icon_large'], $record['icon_no'], $record['icon_undef'], $record['category']);
        if ($record['category'] != 1) {
            $attributesCat2_img .= $line;
        } else {
            $attributes_img .= $line;
        }
    }
    $line = attr_jsline($cache_attrib_jsarray_line, $options, "99", tr("with_password"), $config['search-attr-icons']['password'][0], $config['search-attr-icons']['password'][1], $config['search-attr-icons']['password'][2], 0);
    $attributes_jsarray .= ",\n" . $line;
    $line = attr_image($cache_attrib_img_line, $options, "99", tr("with_password"), $config['search-attr-icons']['password'][0], $config['search-attr-icons']['password'][1], $config['search-attr-icons']['password'][2], 0);
    $attributes_img .= $line;
    tpl_set_var('cache_attrib_list', $attributes_img);
    tpl_set_var('cache_attribCat2_list', $attributesCat2_img);
    tpl_set_var('attributes_jsarray', $attributes_jsarray);
    tpl_set_var('hidopt_attribs', implode(';', $options['cache_attribs']));
    tpl_set_var('hidopt_attribs_not', implode(';', $options['cache_attribs_not']));
    tpl_set_var('fulltext', '');
    tpl_set_var('ft_name_checked', 'checked="checked"');
    tpl_set_var('ft_desc_checked', '');
    tpl_set_var('ft_logs_checked', '');
    tpl_set_var('ft_pictures_checked', '');
    // fulltext options
    if ($options['searchtype'] == 'byfulltext') {
        if (!isset($options['fulltext'])) {
            $options['fulltext'] = '';
        }
        tpl_set_var('fulltext', htmlspecialchars($options['fulltext'], ENT_COMPAT, 'UTF-8'));
        if (isset($options['ft_name']) && $options['ft_name'] == 1) {
            tpl_set_var('ft_name_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_name_checked', '');
        }
        if (isset($options['ft_desc']) && $options['ft_desc'] == 1) {
            tpl_set_var('ft_desc_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_desc_checked', '');
        }
        if (isset($options['ft_logs']) && $options['ft_logs'] == 1) {
            tpl_set_var('ft_logs_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_logs_checked', '');
        }
        if (isset($options['ft_pictures']) && $options['ft_pictures'] == 1) {
            tpl_set_var('ft_pictures_checked', 'checked="checked"');
        } else {
            tpl_set_var('ft_pictures_checked', '');
        }
    }
    // errormeldungen
    tpl_set_var('ortserror', '');
    if (isset($options['error_plz'])) {
        tpl_set_var('ortserror', $error_plz);
    } else {
        if (isset($options['error_ort'])) {
            tpl_set_var('ortserror', $error_ort);
        } else {
            if (isset($options['error_locidnocoords'])) {
                tpl_set_var('ortserror', $error_locidnocoords);
            } else {
                if (isset($options['error_noort'])) {
                    tpl_set_var('ortserror', $error_noort);
                }
            }
        }
    }
    tpl_set_var('fulltexterror', isset($options['error_nofulltext']) ? $error_nofulltext : '');
    tpl_BuildTemplate();
    exit;
}
        $db->simpleQuery("select * from transaction_test");
        echo '<table><tr><th>id</th><th>name</th></tr>';
        while (($row = $db->dbResultFetch()) !== false) {
            echo "<tr><td>{$row['id']}</td><td>{$row['name']}</td></tr>";
        }
        echo '</table>';
        die;
    }
}
require_once './lib/common.inc.php';
// ob_start();
echo '<b>start</b><br>';
$db = new dataBase();
$db->simpleQuery("drop table if exists transaction_test;");
$db->simpleQuery("\n        create table transaction_test (\n            id int(10) not null auto_increment,\n            name varchar(50) not null,\n            PRIMARY KEY (id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
$db2 = new dataBase();
// test transaction isolation
$db2->beginTransaction();
$db2->simpleQuery("insert into transaction_test (name) values('Asia')");
$db2->simpleQuery("insert into transaction_test (name) values('Kasia')");
$db2->simpleQuery("insert into transaction_test (name) values('Natalia')");
check_database_count($db, 0, __LINE__);
// test commit
$db2->commit();
check_database_count($db, 3, __LINE__);
// test no-transaction
$db2->simpleQuery("insert into transaction_test (name) values('Basia')");
check_database_count($db, 4, __LINE__);
// test rollback
$db2->beginTransaction();
$db2->simpleQuery("delete from transaction_test where name = 'Kasia'");
 if (isset($_REQUEST['logid'])) {
     $log_id = intval($_REQUEST['logid']);
 }
 //user logged in?
 if ($usr == false) {
     tpl_redirect('login.php');
 } else {
     if (!isset($_REQUEST["logid"]) or !isset($_REQUEST["target"]) or !isset($_REQUEST["cacheid"]) or !isset($_REQUEST["posY"])) {
         tpl_redirect("index.php");
     } else {
         $nLogId = $_REQUEST["logid"];
         $sTarget = $_REQUEST["target"];
         $sCacheId = $_REQUEST["cacheid"];
         $nPosY = $_REQUEST["posY"];
         $query = "SELECT 1 FROM log_rating WHERE log_id =:1 and user_id=:2";
         $dbc = new dataBase();
         $dbc->multiVariableQuery($query, $nLogId, $usr["userid"]);
         if ($dbc->rowCount() == 0) {
             //add
             $cDT = new DateTime();
             $currDate = $cDT->format('Y-m-d H:m:s');
             $query = "INSERT INTO log_rating (log_id, user_id, date) VALUES( :1, :2, :3 )";
             $dbc->multiVariableQuery($query, $nLogId, $usr["userid"], $currDate);
         } else {
             $query = "DELETE FROM log_rating WHERE log_id =:1 and user_id=:2";
             $dbc->multiVariableQuery($query, $nLogId, $usr["userid"]);
         }
     }
 }
 $sTarget .= "?cacheid=" . $sCacheId . "&posY=" . $nPosY;
 tpl_redirect($sTarget);
Beispiel #20
0
     tpl_set_var('userid', 0);
     tpl_set_var('username', 'Nicht gefunden');
     $userid = 0;
     $username = "******";
     $notop5 = $user_notfound;
 }
 $i = 0;
 $content = '';
 /* $rs = sql("   SELECT `cache_rating`.`cache_id` AS `cache_id`, `caches`.`name` AS `cachename`,
    `user`.`username` AS `ownername`, `user`.`user_id` AS `owner_id`
    FROM `cache_rating`, `caches`, `user`
    WHERE `cache_rating`.`cache_id` = `caches`.`cache_id`
    AND `caches`.`user_id`=`user`.`user_id`
    AND `cache_rating`.`user_id`='&1' ORDER BY `caches`.`name` ASC", $userid); */
 $query = "SELECT `cache_rating`.`cache_id` AS `cache_id`, `caches`.`name` AS `cachename`,\n                `user`.`username` AS `ownername`, `user`.`user_id` AS `owner_id`\n                FROM `cache_rating`, `caches`, `user`\n                WHERE `cache_rating`.`cache_id` = `caches`.`cache_id`\n                  AND `caches`.`user_id`=`user`.`user_id`\n                  AND `cache_rating`.`user_id`= :1 ORDER BY `caches`.`name` ASC";
 $dbc = new dataBase();
 $dbc->multiVariableQuery($query, $userid);
 //if (mysql_num_rows($rs) != 0)
 if ($dbc->rowCount() != 0) {
     //          while ($r = sql_fetch_array($rs))
     while ($r = $dbc->dbResultFetch()) {
         $thisline = $viewtop5_line;
         $thisline = mb_ereg_replace('{cachename}', htmlspecialchars($r['cachename'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{cacheid}', htmlspecialchars($r['cache_id'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{ownername}', htmlspecialchars($r['ownername'], ENT_COMPAT, 'UTF-8'), $thisline);
         $thisline = mb_ereg_replace('{owner_id}', htmlspecialchars($r['owner_id'], ENT_COMPAT, 'UTF-8'), $thisline);
         if ($i % 2 == 1) {
             $thisline = mb_ereg_replace('{bgcolor}', $bgcolor2, $thisline);
         } else {
             $thisline = mb_ereg_replace('{bgcolor}', $bgcolor1, $thisline);
         }
<?php

error_reporting(E_ALL);
//include_once 'classes/dataBase.class.php';
$db = new dataBase('');
$sql = "SELECT id, descrp FROM slider_categ";
$slider_categ = $db->QueryFetchArrayASSOC($sql);
//echo "<pre>"; print_r($slider_categ);echo "</pre>";die;
$slider = '';
foreach ($slider_categ as $value) {
    $sql = "SELECT s.id, l.image, l.sinopsis, l.nombre\n\t\t\tFROM slider_mae AS s\n\t\t\tINNER JOIN libro l ON s.id_libro = l.id \n\t\t\tWHERE categoria = '" . $value['id'] . "' \n\t\t\tORDER BY posicion ASC";
    $slider_mae = $db->QueryFetchArrayASSOC($sql);
    //echo "<pre>"; print_r($slider_mae);echo "</pre>";
    $slider .= '
	<li>
		<table cellpadding="50">
			<tr><td colspan = 3><center><h1>' . $value['descrp'] . '</h1></center></td></tr>
			<tr>';
    foreach ($slider_mae as $value2) {
        $slider .= '
				<td>
					<center>
						<a href="#" onclick = "abrirfancy(\'' . $value2['id'] . '\', \'vistalibro\')" name="1"><img  src="' . $value2['image'] . '"></a><br/><p style="width: 90%"><b style="font-weight: bold;">' . $value2['nombre'] . ': </b>' . $value2['sinopsis'] . '</p>
					</center>
				</td>';
    }
    $slider .= '
			</tr>
		</table>
	</li>';
}
Beispiel #22
0
include "DataBase.class.php";
$key = $_GET['key'];
$name = $_GET['name'];
$cnic = $_GET['cnic'];
$location = $_GET['location'];
$disease = $_GET['disease'];
$contact = $_GET['contact'];
$dbname = 'mapdatabase';
//Name of the database
$dbuser = '******';
//Username for the db
$dbpass = '';
//Password for the db
$dbserver = 'localhost';
//Name of the mysql server
$db = new dataBase("{$dbuser}", "{$dbpass}", "{$dbserver}");
$dbcnx = $db->connectDb();
$db->selectDb($dbname);
$query = $db->selectFrom("*", "login", "key = " . $key);
if ($query > 0) {
    $google_maps_key = 'ABQIAAAAe8rhZlbrTrtYn3S4B8DbrBSiiq6SSn-FolLKfZOodfiXZD81ZRTNuab0TvJ-86gOsCgtlSG1BHnwtQ';
    $adr = urlencode($location);
    $url = "http://maps.google.com/maps/geo?q=" . $adr . "&output=xml&key={$google_maps_key}";
    $xml = simplexml_load_file($url);
    $status = $xml->Response->Status->code;
    if ($status = '200') {
        //address geocoded correct, show results
        //echo ("The address can be geocoded, we found the following results:<br/>");
        foreach ($xml->Response->Placemark as $node) {
            // loop through the responses
            $address = $node->address;
<?php

//prepare the templates and include all neccessary
require_once './lib/common.inc.php';
//Preprocessing
if ($error == false) {
    //user logged in?
    if ($usr == false) {
        $target = urlencode(tpl_get_current_page());
        tpl_redirect('login.php?target=' . $target);
    } else {
        include $stylepath . '/myignores.inc.php';
        $tplname = 'myignores';
        tpl_set_var('title_text', $title_text);
        $dbc = new dataBase();
        //get all caches ignored
        //$rs = mysql_query('SELECT `cache_ignore`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_ignore` INNER JOIN `caches` ON (`cache_ignore`.`cache_id` = `caches`.`cache_id`) WHERE `cache_ignore`.`user_id`=\'' . addslashes($usr['userid']) . '\' ORDER BY `caches`.`name`', $dblink);
        $query = "SELECT `cache_ignore`.`cache_id` AS `cache_id`, `caches`.`name` AS `name`, `caches`.`last_found` AS `last_found` FROM `cache_ignore` INNER JOIN `caches` ON (`cache_ignore`.`cache_id` = `caches`.`cache_id`) WHERE `cache_ignore`.`user_id`= :1 ORDER BY `caches`.`name`";
        $dbc->multiVariableQuery($query, $usr['userid']);
        $rowCount = $dbc->rowCount();
        if ($rowCount == 0) {
            tpl_set_var('no_ignores', $no_ignores);
            tpl_set_var('ignores_caches', '');
            tpl_set_var('title_text_tab', '');
        } else {
            //tpl_set_var('title_text_tab', $title_text_lbl);
            tpl_set_var('no_ignores', '');
            $ignores = '';
            for ($i = 0; $i < $rowCount; $i++) {
                $record = $dbc->dbResultFetch();
                //$tmp_ignore = $i % 2 == 0 ? $ignoree : $ignoreo;
Beispiel #24
0
function getRegionPMobile($root_id = 0, $selected = 0, $txt = "Регион")
{
    $db = new dataBase();
    echo "<div class='form-group-custom' " . ($root_id == 0 ? "id='choose-region'" : "id='city'") . ">\n\t\t\t\t<h4>{$txt} *</h4>";
    echo "<select " . ($root_id != 0 ? "name='city'" : "") . " class=\"region\" data-validate=\"v_required\">\n        <option value='' disabled " . ($selected == 0 ? "selected" : "") . ">Выбрать...</option>";
    $db->query("SELECT * FROM region WHERE root_id = '{$root_id}'");
    while ($c = mysql_fetch_array($db->data)) {
        echo "<option value='" . $c['href'] . "' data-id='" . $c['id'] . "' " . (($selected === $c['id'] or $selected === $c['href']) ? "selected" : "") . ">" . $c['name'] . "</option>";
    }
    echo "</select>";
    echo "</div>";
}
$rootpath = __DIR__ . '/../../';
require_once $rootpath . 'lib/common.inc.php';
require_once $rootpath . 'util.sec/notification/settings.inc.php';
require_once $rootpath . 'lib/consts.inc.php';
/* take datetime format from settings.inc.php */
$sDateformat = $datetimeFormat;
// Check if another instance of the script is running
$lock_file = fopen("/tmp/notification-run_notify.lock", "w");
if (!flock($lock_file, LOCK_EX | LOCK_NB)) {
    // Another instance of the script is running - exit
    echo "Another instance of run_notify.php is currently running.\nExiting.\n";
    fclose($lock_file);
    exit;
}
// No other instance - do normal processing
$db = new dataBase();
$rsNotifyQuery = " SELECT  `notify_waiting`.`id`, `notify_waiting`.`cache_id`, `notify_waiting`.`type`,\n                `user`.`username`, user.user_id as cache_owner_id,\n                user.hidden_count as hidden, user.notfounds_count as dnf, user.founds_count as found,\n                `user2`.`email`, `user2`.`username` as `recpname`, `user2`.`latitude` as `lat1`, `user2`.`longitude` as `lon1`, `user2`.`user_id` as `recid`,\n                `caches`.`name` as `cachename`, `caches`.`date_hidden`, `caches`.`latitude` as `lat2`, `caches`.`longitude` as `lon2`, `caches`.`wp_oc`,\n                `caches`.`type` as `cachetype`,\n                `caches`.`size` as `cachesize`\n            FROM `notify_waiting`, `caches`, `user`, `user` `user2`\n            WHERE `notify_waiting`.`cache_id`=`caches`.`cache_id`\n              AND `notify_waiting`.`user_id`=`user2`.`user_id`\n              AND `caches`.`user_id`=`user`.`user_id`\n              AND `notify_waiting`.`id` > :1\n            ORDER BY `notify_waiting`.`id`\n            LIMIT 0,100\n";
/* init caches container */
$cacheCntainer = cache::instance();
$cacheTypes = $cacheCntainer->getCacheTypes();
$cacheSizes = $cacheCntainer->getCacheSizes();
$cacheTypeIcons = $cacheCntainer->getCacheTypeIcons();
$id = 0;
do {
    $db->multiVariableQuery($rsNotifyQuery, $id);
    $rsNotify = $db->dbResultFetchAll();
    foreach ($rsNotify as $rNotify) {
        $id = $rNotify['id'];
        /* send out everything that has to be sent */
        if (process_new_cache($rNotify) == 0) {
            $db->multiVariableQuery("DELETE FROM `notify_waiting` WHERE `id` =:1", $rNotify['id']);
 function run()
 {
     $db = new dataBase();
     $db->switchDebug(false);
     $sql = "SELECT user_id FROM user where user_id >= 0 ";
     $params = array();
     if (isset($_GET['user_id'])) {
         $sql .= ' and user_id=:user_id';
         $params['user_id']['value'] = intval($_GET['user_id']);
         $params['user_id']['data_type'] = 'integer';
     }
     $db->paramQuery($sql, $params);
     $users = $db->dbResultFetchAll();
     set_time_limit(3600);
     $total_touched = 0;
     foreach ($users as $user) {
         $user_id = $user['user_id'];
         // repair founds
         $founds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=1", 0, $user_id);
         $notfounds_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=2", 0, $user_id);
         $log_notes_count = $db->multiVariableQueryValue("SELECT count(id) FROM cache_logs WHERE deleted=0 AND user_id = :1 AND type=3", 0, $user_id);
         $cache_watches = $db->multiVariableQueryValue("SELECT count(id) FROM cache_watches WHERE user_id = :1", 0, $user_id);
         $cache_ignores = $db->multiVariableQueryValue("SELECT count(id) FROM cache_ignore WHERE user_id = :1", 0, $user_id);
         $hidden_count = $db->multiVariableQueryValue("select count(cache_id) from caches where status in (1,2,3) and user_id = :1", 0, $user_id);
         $sql = "\n                UPDATE user\n                SET\n                    hidden_count=:new_hidden_count,\n                    cache_ignores=:new_cache_ignores,\n                    log_notes_count=:new_log_notes_count,\n                    founds_count=:new_founds_count,\n                    notfounds_count=:new_notfounds_count,\n                    cache_watches=:new_cache_watches\n                WHERE\n                    user_id=:user_id\n                    AND (\n                        hidden_count is null\n                        OR cache_ignores is null\n                        OR log_notes_count is null\n                        OR founds_count is null\n                        OR notfounds_count is null\n                        OR cache_watches is null\n                        OR hidden_count!=:new_hidden_count\n                        OR cache_ignores!=:new_cache_ignores\n                        OR log_notes_count!=:new_log_notes_count\n                        OR founds_count!=:new_founds_count\n                        OR notfounds_count!=:new_notfounds_count\n                        OR cache_watches!=:new_cache_watches\n                    )\n            ";
         $params = array();
         $params['new_hidden_count']['value'] = intval($hidden_count);
         $params['new_hidden_count']['data_type'] = 'integer';
         $params['new_cache_ignores']['value'] = intval($cache_ignores);
         $params['new_cache_ignores']['data_type'] = 'integer';
         $params['new_log_notes_count']['value'] = intval($log_notes_count);
         $params['new_log_notes_count']['data_type'] = 'integer';
         $params['new_founds_count']['value'] = intval($founds_count);
         $params['new_founds_count']['data_type'] = 'integer';
         $params['new_notfounds_count']['value'] = intval($notfounds_count);
         $params['new_notfounds_count']['data_type'] = 'integer';
         $params['new_cache_watches']['value'] = intval($cache_watches);
         $params['new_cache_watches']['data_type'] = 'integer';
         $params['user_id']['value'] = intval($user_id);
         $params['user_id']['data_type'] = 'integer';
         $db->paramQuery($sql, $params);
         if ($db->rowCount() > 0) {
             echo "<b>user_id={$user_id}</b><br>";
             echo "hidden_count={$hidden_count}<br>cache_ignores={$cache_ignores}<br>";
             echo "log_notes_count={$log_notes_count}<br>founds_count={$founds_count}<br>";
             echo "notfounds_count={$notfounds_count}<br>cache_watches={$cache_watches}<br>";
             $total_touched++;
         }
         $db->closeCursor();
     }
     set_time_limit(60);
     unset($db);
     echo "-----------------------------------<br>total_touched={$total_touched}<br>";
 }
Beispiel #27
0
/**
 * after add a log it is a good idea to full recalculate stats of cache, that can avoid
 * possible errors which used to appear when was calculated old method.
 *
 * TODO: (regarding issue #138)
 * 1. recalculate last_found from DB
 * 2. make this method a library method or so
 * 3. use this method in other places, where such recalculation is needed
 *
 * by Andrzej Łza Woźniak, 12-2013
 */
function recalculateCacheStats($cacheId, $cacheType, $lastFoundQueryString)
{
    if ($cacheType == 6) {
        // event (no idea who developed so irracional rules, not me!)
        $query = "\n            UPDATE `caches`\n            SET `founds`   = (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =7 AND `deleted` =0 ),\n                `notfounds`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =8 AND `deleted` =0 ),\n                `notes`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =3 AND `deleted` =0 )\n            {$lastFoundQueryString}\n            WHERE `cache_id` =:1\n        ";
    } else {
        $query = "\n            UPDATE `caches`\n            SET `founds`   = (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =1 AND `deleted` =0 ),\n                `notfounds`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =2 AND `deleted` =0 ),\n                `notes`= (SELECT count(*) FROM `cache_logs` WHERE `cache_id` =:1 AND TYPE =3 AND `deleted` =0 )\n            {$lastFoundQueryString}\n            WHERE `cache_id` =:1\n        ";
    }
    $db = new dataBase();
    $db->multiVariableQuery($query, $cacheId);
}
/**
 * after delete a log it is a good idea to full recalculate stats of user, that can avoid
 * possible errors which used to appear when was calculated old method.
 *
 * by Andrzej Łza Woźniak, 10-2013
 *
 */
function recalculateUserStats($userId)
{
    $query = "\n        UPDATE `user`\n        SET `founds_count`   = (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =1 AND `deleted` =0 ),\n            `notfounds_count`= (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =2 AND `deleted` =0 ),\n            `log_notes_count`= (SELECT count(*) FROM `cache_logs` WHERE `user_id` =:1 AND TYPE =3 AND `deleted` =0 )\n        WHERE `user_id` =:1\n    ";
    $db = new dataBase();
    $db->multiVariableQuery($query, $userId);
}
<?php

include "artikels-logic.php";
function __autoload($filename)
{
    include "classes/" . $filename . ".php";
}
$dataBase = new dataBase();
$picture = $dataBase->getRow("profile_picture", "users", true, "'" . $email . "'", "email");
$id = $dataBase->getRow("id", "users", true, "'" . $email . "'", "email");
$actualId = $id[0]["id"];
if (empty($picture[0]["profile_picture"])) {
    $imgstring = "img/default.png";
} else {
    $actualPicture = $picture[0]["profile_picture"];
    $imgstring = "img/" . $actualPicture;
}
if (isset($_SESSION["notifications"])) {
    echo "Type :" . $_SESSION["notifications"]["type"];
    echo " message : " . $_SESSION["notifications"]["message"];
    unset($_SESSION["notifications"]);
}
?>




<!doctype html>

<html>
Beispiel #30
0
     }
 }
 if ($total_pages > $PAGES_LISTED) {
     $pages .= '<a href="mycaches.php?status=' . $stat_cache . '&amp;start=' . ($i - 1) * $LOGS_PER_PAGE . '&col=' . $sort_col . '&sort=' . $sort_sort . '">{last_img}</a> ';
 } else {
     $pages .= '{last_img_inactive}';
 }
 $caches_query = "\n            SELECT\n                `caches`.`cache_id`,\n                `caches`.`name`,\n                `date_hidden`,\n                `status`,cache_type.icon_small AS cache_icon_small,\n                `cache_status`.`id` AS `cache_status_id`,\n                `caches`.`founds` AS `founds`,\n                `caches`.`topratings` AS `topratings`,\n                datediff(now(),`caches`.`last_found` ) as `ilosc_dni`,\n                datediff(now(),`caches`.`last_modified` ) as `dni_od_zmiany`,\n                COUNT(`gk_item`.`id`) AS `gkcount`,\n                COALESCE(`cv`.`count`,0) AS `visits`\n            FROM `caches`\n                LEFT JOIN `gk_item_waypoint` ON `gk_item_waypoint`.`wp` = `caches`.`wp_oc`\n                LEFT JOIN `gk_item`\n                    ON `gk_item`.`id` = `gk_item_waypoint`.`id`\n                        AND `gk_item`.`stateid`<>1\n                        AND `gk_item`.`stateid`<>4\n                        AND `gk_item`.`typeid`<>2\n                        AND `gk_item`.`stateid` <>5\n                LEFT JOIN (\n                    SELECT\n                        `count`,\n                        `user_id_ip`,\n                        `cache_id`\n                    FROM `cache_visits`\n                    WHERE `user_id_ip`=0\n                    ) `cv`\n                    ON `caches`.`cache_id` = `cv`.`cache_id`\n                INNER JOIN `cache_type` ON (`caches`.`type` = `cache_type`.`id`),\n                `cache_status`\n            WHERE\n                `user_id`=:user_id\n                AND `cache_status`.`id`=`caches`.`status`\n                AND `caches`.`status` = :stat_cache\n            GROUP BY `caches`.`cache_id`\n            ORDER BY `{$sort_warunek}` {$sort_txt}\n            LIMIT " . intval($start) . ", " . intval($LOGS_PER_PAGE);
 //$params['v1']['value'] = (string) $lang_db;;
 //$params['v1']['data_type'] = 'string';
 $params['user_id']['value'] = (int) $user_id;
 $params['user_id']['data_type'] = 'integer';
 $params['stat_cache']['value'] = (int) $stat_cache;
 $params['stat_cache']['data_type'] = 'integer';
 if (!isset($dbc)) {
     $dbc = new dataBase();
 }
 $dbc->paramQuery($caches_query, $params);
 unset($params);
 $log_record_all = $dbc->dbResultFetchAll();
 $log_record_count = count($log_record_all);
 $file_content = '';
 //while ($log_record=sql_fetch_assoc($rs))
 //prepare second queryt
 $logs_query = "\n            SELECT\n                cache_logs.id,\n                cache_logs.type AS log_type,\n                cache_logs.text AS log_text,\n                DATE_FORMAT(cache_logs.date,'%Y-%m-%d') AS log_date,\n                caches.user_id AS cache_owner,\n                cache_logs.encrypt encrypt,\n                cache_logs.user_id AS luser_id,\n                user.username AS user_name,\n                user.user_id AS user_id,\n                log_types.icon_small AS icon_small,\n                datediff(now(),`cache_logs`.`date_created`) as `ilosc_dni`\n            FROM\n                cache_logs\n                JOIN caches USING (cache_id)\n                JOIN user ON (cache_logs.user_id=user.user_id)\n                JOIN log_types ON (cache_logs.type = log_types.id)\n            WHERE\n                cache_logs.deleted=0 AND\n                `cache_logs`.`cache_id`=:v1\n            ORDER BY `cache_logs`.`date_created` DESC\n            LIMIT 5";
 $edit_geocache_tr = tr('mc_edit_geocache');
 for ($zz = 0; $zz < $log_record_count; $zz++) {
     $log_record = $log_record_all[$zz];
     $tabelka = '';
     $tabelka .= '<td style="width: 90px;">' . htmlspecialchars(date($dateFormat, strtotime($log_record['date_hidden'])), ENT_COMPAT, 'UTF-8') . '</td>';
     $tabelka .= '<td ><a href="editcache.php?cacheid=' . htmlspecialchars($log_record['cache_id'], ENT_COMPAT, 'UTF-8') . '"><img src="tpl/stdstyle/images/free_icons/pencil.png" alt="' . $edit_geocache_tr . '" title="' . $edit_geocache_tr . '"/></a></td>';