コード例 #1
1
ファイル: edit.php プロジェクト: kojoobadu/kojo_side_projects
<?php

include_once "dbconnect.php";
include_once "query_builder.php";
//Get type (table to access)
$type = $_GET["type"];
//if there is no type, return error
if ($type == null) {
    echo "noTypeError";
} else {
    //Get connection to database
    $conn = db_connect();
    //if there is no connection returned, die
    if ($conn == null) {
        die("Connection error");
    }
    //Get SQL Query/Queries for $type
    $sql = buildEdit($type);
    //Query the database
    $result = mysqli_multi_query($conn, $sql);
    //If a result is returned, signal a success
    if ($result) {
        echo "success";
    } else {
        echo "fail";
    }
    //Disconnect from database
    db_disconnect($conn);
}
コード例 #2
1
ファイル: page-layout.php プロジェクト: Norky/PBS-tools
function system_chooser()
{
    echo "System:  <SELECT name=\"system\" size=\"1\">\n";
    echo "<OPTION value=\"%\">Any\n";
    $db = db_connect();
    $sql = "SELECT DISTINCT(system) FROM Jobs;";
    $result = db_query($db, $sql);
    while ($result->fetchInto($row)) {
        $rkeys = array_keys($row);
        foreach ($rkeys as $rkey) {
            echo "<OPTION>" . $row[$rkey] . "\n";
        }
    }
    db_disconnect($db);
    echo "</SELECT><BR>\n";
}
コード例 #3
0
 function run()
 {
     db_connect();
     $rsCache = sql("SELECT `cache_id`, `latitude`, `longitude` FROM `caches` WHERE `need_npa_recalc`=1");
     while ($rCache = mysql_fetch_assoc($rsCache)) {
         $sql = sql("DELETE FROM `cache_npa_areas` WHERE `cache_id`='&1' AND `calculated`=1", $rCache['cache_id']);
         mysql_query($sql);
         // Natura 2000
         $rsLayers = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `npa_areas` WHERE WITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = mysql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sql = sql("INSERT INTO `cache_npa_areas` (`cache_id`, `npa_id`, `calculated`) VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 mysql_query($sql);
             }
         }
         mysql_free_result($rsLayers);
         // Parki PL
         $rsLayers = sql("SELECT `id`, AsText(`shape`) AS `geometry` FROM `parkipl` WHERE WITHIN(GeomFromText('&1'), `shape`)", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = mysql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sql = sql("INSERT INTO `cache_npa_areas` (`cache_id`, `parki_id`, `calculated`) VALUES ('&1', '&2', 1) ON DUPLICATE KEY UPDATE `calculated`=1", $rCache['cache_id'], $rLayers['id']);
                 mysql_query($sql);
             }
         }
         mysql_free_result($rsLayers);
         // End of Parki PL
         $sql = sql("UPDATE `caches` SET `need_npa_recalc`=0 WHERE `cache_id`='&1'", $rCache['cache_id']);
         mysql_query($sql);
     }
     mysql_free_result($rsCache);
     db_disconnect();
 }
コード例 #4
0
function checkandadd(&$uPOST)
{
    $a = 0;
    while (isset($uPOST["varn" . $a])) {
        if (isset($uPOST["varv" . $a])) {
            if (extExists($uPOST["varn" . $a], 1)) {
                db_connect();
                $query = "SELECT `value` from `ext` WHERE `data`='" . $uPOST["varn" . $a] . "' AND `maxmin`='1' LIMIT 1";
                sanitize($uPOST["varn" . $a]);
                $result = mysql_query($query) or die("query failed");
                db_disconnect();
                $c_row = mysql_fetch_assoc($result);
                if ($uPOST["varv" . $a] > $c_row['value']) {
                    //echo "highest";
                    extInsert($uPOST["varn" . $a], 1, $uPOST["varv" . $a], $uPOST['uts']);
                }
            }
        }
        if (isset($uPOST["varv" . $a])) {
            if (extExists($uPOST["varn" . $a], 0)) {
                db_connect();
                $query = "SELECT `value` from `ext` WHERE `data`='" . $uPOST["varn" . $a] . "' AND `maxmin`='0' LIMIT 1";
                sanitize($uPOST["varn" . $a]);
                $result = mysql_query($query) or die("query failed");
                db_disconnect();
                $c_row = mysql_fetch_assoc($result);
                if ($uPOST["varv" . $a] < $c_row['value']) {
                    //echo "lowest";
                    extInsert($uPOST["varn" . $a], 0, $uPOST["varv" . $a], $uPOST['uts']);
                }
            }
        }
        $a++;
    }
}
コード例 #5
0
ファイル: subs.php プロジェクト: progervlad/utils
function write_data_to_db($query)
{
    $link = db_connect();
    mysql_query("SET NAMES cp1251");
    $result = mysql_query($query, $link) or die('MySQL error: ' . mysql_error());
    db_disconnect($link);
    if ($result) {
        return $msg = true;
    } else {
        return $msg = false;
    }
}
コード例 #6
0
ファイル: subs.php プロジェクト: progervlad/utils
function write_data_to_db($query, $type)
{
    $link = db_connect();
    mysql_query("SET NAMES utf8");
    $result = mysql_query($query, $link) or die('MySQL error: ' . mysql_error());
    if ($result and $type == 'insert') {
        return $id = mysql_insert_id();
    } elseif ($result and ($type == 'update' or $type == 'delete')) {
        return true;
    } else {
        return $id = false;
    }
    db_disconnect($link);
}
コード例 #7
0
ファイル: records.php プロジェクト: jonsowman/sgsweather-web
function getExt($data, $maxmin)
{
    db_connect();
    $query = "SELECT * FROM `ext` WHERE data='" . $data . "' AND maxmin='" . $maxmin . "' LIMIT 1";
    $result = mysql_query($query) or die("query failed: " . mysql_error());
    db_disconnect();
    if (mysql_num_rows($result) > 0) {
        $value = mysql_result($result, null, "value");
        $uts = mysql_result($result, null, "uts");
    } else {
        die("Searched data did not exist!");
    }
    return array($value, $uts);
}
コード例 #8
0
 function run()
 {
     /* begin db connect */
     db_connect();
     if ($dblink === false) {
         echo 'Unable to connect to database';
         exit;
     }
     /* end db connect */
     $xmlfile = $this->loadXML();
     if ($xmlfile == false) {
         return;
     }
     $this->importXML($xmlfile);
     $this->removeXML($xmlfile);
     db_disconnect();
 }
コード例 #9
0
function db_connect()
{
    global $dblink, $dbpconnect, $dbusername, $dbname, $dbserver, $dbpasswd, $dbpconnect;
    //connect to the database by the given method - no php error reporting!
    if ($dbpconnect == true) {
        $dblink = @mysql_pconnect($dbserver, $dbusername, $dbpasswd);
    } else {
        $dblink = @mysql_connect($dbserver, $dbusername, $dbpasswd);
    }
    if ($dblink != false) {
        //database connection established ... set the used database
        if (@mysql_select_db($dbname, $dblink) == false) {
            //error while setting the database ... disconnect
            db_disconnect();
            $dblink = false;
        }
    }
}
コード例 #10
0
ファイル: dao.php プロジェクト: suvika17/m10s
function db_query($query)
{
    // Подключаемся к БД
    $link = db_connect();
    // Выполняем SQL-запрос
    $result = mysqli_query($link, $query) or die('Запрос не удался: ' . mysqli_error($link));
    // Получаем данные как ассоциативный массив
    $rows = array();
    while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
        $rows[] = $row;
    }
    // Освобождаем память от результата
    mysqli_free_result($result);
    // Закрываем соединение
    db_disconnect($link);
    // Возвращаем результат запроса
    return $rows;
}
コード例 #11
0
ファイル: import.php プロジェクト: pawelzielak/opencaching-pl
 function run($node_id)
 {
     /* begin db connect */
     db_connect();
     //        if ($dblink === false)
     //        {
     //            echo 'Unable to connect to database';
     //            exit;
     //        }
     /* end db connect */
     $xmlfile = $this->loadXML($node_id);
     if ($xmlfile == false) {
         db_disconnect();
         return false;
     }
     $retValue = $this->importXML($xmlfile, $node_id);
     $this->removeXML($xmlfile);
     db_disconnect();
     return $retValue;
 }
コード例 #12
0
function get_available($sDate, $eDate)
{
    global $units;
    db_connect();
    $query = mysql_query("SELECT * FROM reservations WHERE date BETWEEN '" . $sDate . "' AND '" . $eDate . "'");
    while ($row = mysql_fetch_array($query)) {
        echo "Date with reservation(s): " . $row[1] . "<br />";
        // For testing only, remove for production!
        for ($i = 1; $i <= $units; $i++) {
            if ($row[$i + 1]) {
                $avail[$i] = True;
            }
            //echo $i." - ".$row[$i+1]."<br />";  // Will output list of units and reservation #s - For testing only, remove for production!
        }
    }
    echo "<br />";
    // For testing only, remove for production!
    db_disconnect();
    return $avail;
}
コード例 #13
0
 function run()
 {
     /* begin db connect */
     db_connect();
     if ($dblink === false) {
         echo 'Unable to connect to database';
         exit;
     }
     /* end db connect */
     $sql = "SELECT * FROM scores";
     $scores_query = mysql_query($sql);
     while ($scores = mysql_fetch_array($scores_query)) {
         $sql2 = "SELECT * FROM cache_logs WHERE `deleted`=0 AND user_id = " . sql_escape($scores['user_id']) . " AND cache_id = " . sql_escape($scores['cache_id']) . " AND (`type`=1 OR `type`=7)";
         $logs_query = mysql_query($sql2);
         if (mysql_num_rows($logs_query) == 0) {
             $sql3 = "SELECT username FROM user WHERE user_id = " . $scores['user_id'];
             $fakeUser = mysql_result(mysql_query($sql3), 0);
             //echo "uzytkownik: ".$scores['user_id']."=".$fakeUser." ocenil skrzynke: ".$scores['cache_id']." na ".$scores['score'];
             //echo "<br />";
             $sql_del = "DELETE FROM scores WHERE user_id = " . sql_escape($scores['user_id']) . " AND cache_id = " . sql_escape($scores['cache_id']);
             mysql_query($sql_del);
             $sql4 = "SELECT count(*) FROM scores WHERE cache_id='" . sql_escape($scores['cache_id']) . "'";
             $liczba = mysql_result(mysql_query($sql4), 0);
             $sql4 = "SELECT score FROM scores WHERE cache_id='" . sql_escape($scores['cache_id']) . "'";
             $score = mysql_query($sql4);
             $suma = 0;
             // obliczenie nowej sredniej
             while ($res = mysql_fetch_array($score)) {
                 $suma += $res['score'];
             }
             if ($liczba != 0) {
                 $srednia = $suma / $liczba;
             } else {
                 $srednia = 0;
             }
             $sql4 = "UPDATE caches SET votes='" . sql_escape($liczba) . "', score='" . sql_escape($srednia) . "' WHERE cache_id='" . sql_escape($scores['cache_id']) . "'";
             mysql_query($sql4);
         }
     }
     db_disconnect();
 }
コード例 #14
0
ファイル: blocks.php プロジェクト: acohn/grinnellplans-php
    if ($user->webview == 1) {
        $warning = new AlertText("Warning! Your plan is set to be viewable by guests. This will allow blocked users to read your plan\n            simply by logging out. If you would like to change this setting, please visit\n            <a href=\"/webview.php\">the guest settings page</a>.");
        $header->append($warning);
    }
    $about = new InfoText('Users that you have blocked will not be able to read your plan, and you will not see each other listed in quicklove or search results.
        <a href="/blocking-about.php">See the FAQ for more information</a>.
        <br /><br />
        <b>Please be aware that your activity on Notes is still visible to everyone.</b> If you feel this presents a serious problem to you, please <a href="mailto:grinnellplans@gmail.com">contact the administrators</a>.');
    $header->append($about);
    $heading = new HeadingText('Blocked Users', 2);
    $thispage->append($heading);
    $blocklist = new WidgetList('blocked_user_list', true);
    $thispage->append($blocklist);
    $q = Doctrine_Query::create()->select("*")->from("Accounts a")->innerJoin("a.BlockedBy b")->where("b.blocking_user_id = ?", $idcookie);
    $blocked_users = $q->execute();
    foreach ($blocked_users as $blocked_user) {
        $entry = new WidgetGroup('newplan', false);
        $plan = new PlanLink($blocked_user->username);
        $form = new Form('block', 'User blocking options');
        $item = new HiddenInput('unblock_user', $blocked_user->userid);
        $form->append($item);
        $item = new SubmitInput("Unblock {$blocked_user->username}");
        $form->append($item);
        $entry->append($plan);
        $entry->append($form);
        $blocklist->append($entry);
    }
}
interface_disp_page($thispage);
db_disconnect($dbh);
コード例 #15
0
ファイル: common.inc.php プロジェクト: kirstenko/oc-server3
function tpl_BuildTemplate($dbdisconnect = true)
{
    //template handling vars
    global $style, $stylepath, $tplname, $vars, $langpath, $locale, $opt, $oc_nodeid, $translate, $usr;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    // country dropdown
    global $tpl_usercountries;
    tpl_set_var('screen_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen.css"));
    tpl_set_var('screen_msie_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen_msie.css"));
    tpl_set_var('print_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_print.css"));
    if (isset($bScriptExecution)) {
        $bScriptExecution->Stop();
        tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    } else {
        tpl_set_var('scripttime', sprintf('%1.3f', 0));
    }
    tpl_set_var('sponsorbottom', $opt['page']['sponsor']['bottom']);
    if (isset($opt['locale'][$locale]['page']['subtitle1'])) {
        $opt['page']['subtitle1'] = $opt['locale'][$locale]['page']['subtitle1'];
    }
    if (isset($opt['locale'][$locale]['page']['subtitle2'])) {
        $opt['page']['subtitle2'] = $opt['locale'][$locale]['page']['subtitle2'];
    }
    tpl_set_var('opt_page_subtitle1', $opt['page']['subtitle1']);
    tpl_set_var('opt_page_subtitle2', $opt['page']['subtitle2']);
    tpl_set_var('opt_page_title', $opt['page']['title']);
    if ($opt['logic']['license']['disclaimer']) {
        if (isset($opt['locale'][$locale]['page']['license_url'])) {
            $lurl = $opt['locale'][$locale]['page']['license_url'];
        } else {
            $lurl = $opt['locale']['EN']['page']['license_url'];
        }
        if (isset($opt['locale'][$locale]['page']['license'])) {
            $ltext = $opt['locale'][$locale]['page']['license'];
        } else {
            $ltext = $opt['locale']['EN']['page']['license'];
        }
        $ltext = mb_ereg_replace('%1', $lurl, $ltext);
        $ltext = mb_ereg_replace('{site}', $opt['page']['sitename'], $ltext);
        $ld = '<p class="sidebar-maintitle">' . $translate->t('Datalicense', '', '', 0) . '</p>' . '<div style="margin:20px 0 16px 0; width:100%; text-align:center;">' . $ltext . '</div>';
        tpl_set_var('license_disclaimer', $ld);
    } else {
        tpl_set_var('license_disclaimer', '');
    }
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    /* prepare user country selection
     */
    $tpl_usercountries = array();
    $rsUserCountries = sql("SELECT `countries_options`.`country`,\n\t\t                  IF(`countries_options`.`nodeId`='&1', 1, IF(`countries_options`.`nodeId`!=0, 2, 3)) AS `group`,\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name`\n\t\t             FROM `countries_options`\n\t\t       INNER JOIN `countries` ON `countries_options`.`country`=`countries`.`short`\n\t\t        LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`\n\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\n\t\t            WHERE `countries_options`.`display`=1\n\t\t         ORDER BY `group` ASC,\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) ASC", $oc_nodeid, $locale);
    while ($rUserCountries = sql_fetch_assoc($rsUserCountries)) {
        $tpl_usercountries[] = $rUserCountries;
    }
    sql_free_result($rsUserCountries);
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    tpl_set_var('backgroundimage', '<div id="bg1">&nbsp;</div><div id="bg2">&nbsp;</div>');
    tpl_set_var('bodystyle', '');
    if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
        $sCode = read_file($stylepath . '/main_print.tpl.php');
    } else {
        if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
            $sCode = read_file($stylepath . '/popup.tpl.php');
        } else {
            $sCode = read_file($stylepath . '/main.tpl.php');
        }
    }
    $sCode = '?>' . $sCode;
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process translations
    $sCode = tpl_do_translation($sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}
コード例 #16
0
ファイル: usage-summary.php プロジェクト: Norky/PBS-tools
            echo "</TR>\n";
            ob_flush();
            flush();
        }
        echo "</TABLE>\n";
        if (isset($_POST['xls'])) {
            $xlsresult = db_query($db, $sql);
            $columns = array("package", "jobcount", "cpuhours", "users", "groups");
            result_as_xls($xlsresult, $columns, $_POST['system'] . "-software_usage-" . $_POST['start_date'] . "-" . $_POST['end_date']);
        }
        if (isset($_POST['ods'])) {
            $odsresult = db_query($db, $sql);
            $columns = array("package", "jobcount", "cpuhours", "users", "groups");
            result_as_ods($odsresult, $columns, $_POST['system'] . "-software_usage-" . $_POST['start_date'] . "-" . $_POST['end_date']);
        }
    }
    db_disconnect($db);
    bookmarkable_url();
} else {
    begin_form("usage-summary.php");
    system_chooser();
    date_fields();
    $orders = array("jobcount", "cpuhours", "users", "groups");
    checkboxes_from_array("Supplemental reports", array("institution", "software"));
    $defaultorder = "cpuhours";
    pulldown("order", "Order results by", $orders, $defaultorder);
    checkbox("Generate Excel files for supplemental reports", "xls");
    checkbox("Generate ODF files for supplemental reports", "ods");
    end_form();
}
page_footer();
コード例 #17
0
 $whereClause = 'gameUUID=\'' . mysql_real_escape_string($gameUUID) . '\'';
 $stats_in_db = mysql_query('SELECT * FROM glestgamestats WHERE ' . $whereClause . ';');
 $all_stats = array();
 while ($stats = mysql_fetch_array($stats_in_db)) {
     array_push($all_stats, $stats);
 }
 unset($stats_in_db);
 unset($stats);
 $player_stats_in_db = mysql_query('SELECT * FROM glestgameplayerstats WHERE ' . $whereClause . ' ORDER BY factionIndex;');
 $all_player_stats = array();
 while ($player_stats = mysql_fetch_array($player_stats_in_db)) {
     array_push($all_player_stats, $player_stats);
 }
 unset($player_stats_in_db);
 unset($player_stats);
 db_disconnect(DB_LINK);
 unset($linkid);
 foreach ($all_stats as $stats) {
     echo "\t\t\t" . '<tr>' . PHP_EOL;
     // Game Stats
     $gameDuration = $stats['framesToCalculatePlaytime'];
     $gameDuration = getTimeString($gameDuration);
     printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($gameDuration, ENT_QUOTES), PHP_EOL);
     printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($stats['maxConcurrentUnitCount'], ENT_QUOTES), PHP_EOL);
     printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($stats['totalEndGameConcurrentUnitCount'], ENT_QUOTES), PHP_EOL);
     printf("\t\t\t\t<td>%s</td>%s", htmlspecialchars($stats['isHeadlessServer'], ENT_QUOTES), PHP_EOL);
     echo "\t\t\t" . '</tr>' . PHP_EOL;
     echo '		</table>' . PHP_EOL;
     // Player stats for Game
     echo '		<table>' . PHP_EOL;
     echo '			<tr>' . PHP_EOL;
コード例 #18
0
<?php

/**
 * ajaxAddCacheToPt.php
 * this script add or remove cache to specified power Trail.
 * do neccesary checks and calculations like gometrical power trail lat/lon.
 *
 * works via Ajax call.
 */
$rootpath = __DIR__ . '/../';
require_once __DIR__ . '/../lib/common.inc.php';
db_disconnect();
if (!isset($_SESSION['user_id'])) {
    print 'no hacking please!';
    exit;
}
$ptAPI = new powerTrailBase();
if (isset($_REQUEST['rcalcAll'])) {
    recalculateOnce();
    print '<br><br><b>cachePoints were updated</b>';
    exit;
}
isset($_REQUEST['projectId']) ? $projectId = $_REQUEST['projectId'] : exit;
isset($_REQUEST['cacheId']) ? $cacheId = $_REQUEST['cacheId'] : exit;
isset($_REQUEST['rmOtherUserCacheFromPt']) ? $rmOtherUserCacheFromPt = true : ($rmOtherUserCacheFromPt = false);
$db = \lib\Database\DataBaseSingleton::Instance();
// check if cache is already cannected with any power trail
$query = 'SELECT `PowerTrailId` FROM `powerTrail_caches` WHERE `cacheId` = :1';
$db->multiVariableQuery($query, $cacheId);
$resultPowerTrailId = $db->dbResultFetch();
if (isset($_REQUEST['removeByCOG']) && $_SESSION['ptRmByCog'] === 1) {
コード例 #19
0
$mysqli = db_connect();
// Прочитаем параметры текущего пользователя
$user = check_user_login($mysqli);
// Обработаем запрос на выход если он есть
check_user_logout($mysqli, $user);
//Если пользователь не авторизирован - выкинем его
if ($user == false) {
    header('Location: login.php');
    exit;
}
// Проверим права
if ($user['rights'] < $req_rights) {
    exit('У вас недостаточно прав для просмотра данной страницы');
}
/*--------- Тело программы ---------*/
$mysqli = new mysqli(DB_HOST, DB_LOGIN, DB_PASSWORD, DB_NAME);
$mysqli->set_charset("utf8");
$page_title = "Мастер отчетов";
// Зададим заголовок окна браузера
$page_class = "class=\"report\"";
// Класс окна
$page_scripts = "<script src=\"lib/rome.standalone.min.js\"></script>\r\n<script src=\"lib/base64binary.js\"></script>\r\n<script src=\"lib/dygraph-combined.js\"></script>\r\n<script>var config = " . json_encode(conf_get_main($mysqli)) . ";\r\nvar report_config = " . json_encode(report_get_by_id($mysqli, $_GET['r'])) . ";</script>\r\n<script src=\"js/report-builder.js\"></script>";
$page_styles = "<link rel=\"stylesheet\" type=\"text/css\" href=\"lib/jquery.datetimepicker.css\"/>";
require "include/header.php";
// Вставим заголовочный файл темы
echo "<h1>{$page_title}</h1>";
// Вставим подвал
require "include/footer.php";
// Отключимся от базы
db_disconnect($mysqli);
コード例 #20
0
function tpl_BuildTemplate($dbdisconnect = true, $minitpl = false, $noCommonTemplate = false)
{
    //template handling vars
    global $stylepath, $tplname, $vars, $langpath, $lang_array, $lang, $language;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    $bScriptExecution->Stop();
    tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    tpl_set_var('language_flags', writeLanguageFlags($lang_array));
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    if ($minitpl) {
        $sCode = read_file($stylepath . '/mini.tpl.php');
    } else {
        if ($noCommonTemplate) {
            $sCode = '{template}';
        } else {
            if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
                $sCode = read_file($stylepath . '/main_print.tpl.php');
            } else {
                if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
                    $sCode = read_file($stylepath . '/popup.tpl.php');
                } else {
                    $sCode = read_file($stylepath . '/main.tpl.php');
                }
            }
        }
    }
    $sCode = '?>' . $sCode . '<?';
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    $sCode = tpl_do_translate($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}
コード例 #21
0
ファイル: process.php プロジェクト: RobK/GenerateDataJson
    exit;
}
// get our basic data
$link = db_connect();
$g_male_names = get_firstnames("male");
$g_female_names = get_firstnames("female");
$g_names = get_firstnames();
$g_words = get_lipsum();
$g_surnames = get_surnames();
$g_cities = get_cities();
$g_states = get_states();
$g_provinces = get_provinces();
$g_provinces_nl = get_provinces_nl();
$g_countries = get_countries();
$g_counties = get_counties();
db_disconnect($link);
$g_resultType = $_POST['resultType'];
$g_numCols = $_POST['numCols'];
$g_numResults = $_POST['numResults'];
$template = get_random_data_template($_POST, $g_numCols);
switch ($g_resultType) {
    case "HTML":
        require "html.php";
        break;
    case "Excel":
        require "excel.php";
        break;
    case "XML":
        require "xml.php";
        break;
    case "CSV":
コード例 #22
0
ファイル: common.inc.php プロジェクト: RH-Code/opencaching
function tpl_BuildTemplate($dbdisconnect = true)
{
    //template handling vars
    global $stylepath, $tplname, $vars, $langpath, $locale, $opt;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    // country dropdown
    global $tpl_usercountries;
    if (isset($bScriptExecution)) {
        $bScriptExecution->Stop();
        tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    } else {
        tpl_set_var('scripttime', sprintf('%1.3f', 0));
    }
    tpl_set_var('sponsortopright', $opt['page']['sponsor']['topright']);
    tpl_set_var('sponsorbottom', $opt['page']['sponsor']['bottom']);
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    /* prepare user country selection
     */
    $tpl_usercountries = array();
    $rsUserCountries = sql("SELECT `countries_options`.`country`, `countries_options`.`group`, \r\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name` \r\n\t\t             FROM `countries_options` \r\n\t\t       INNER JOIN `countries` ON `countries_options`.`country`=`countries`.`short`\r\n\t\t        LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` \r\n\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' \r\n\t\t            WHERE `countries_options`.`display`=1 \r\n\t\t         ORDER BY `countries_options`.`group` ASC,\r\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) ASC", $locale);
    while ($rUserCountries = sql_fetch_assoc($rsUserCountries)) {
        $tpl_usercountries[] = $rUserCountries;
    }
    sql_free_result($rsUserCountries);
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
        $sCode = read_file($stylepath . '/main_print.tpl.php');
    } else {
        if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
            $sCode = read_file($stylepath . '/popup.tpl.php');
        } else {
            $sCode = read_file($stylepath . '/main.tpl.php');
        }
    }
    $sCode = '?>' . $sCode;
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process translations
    $sCode = tpl_do_translation($sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}
コード例 #23
0
ファイル: accounts.php プロジェクト: rgarcia/generatedata
function update_total_row_count($account_id, $num_rows)
{
    global $g_table_prefix;
    $link = db_connect();
    // Ben, surely there's a way to do this in a single query...
    $select_query = mysql_query("\n    SELECT num_records_generated\n    FROM   {$g_table_prefix}user_accounts\n    WHERE  account_id = {$account_id}\n      ");
    $result = mysql_fetch_assoc($select_query);
    $num_generated = $result["num_records_generated"];
    $new_total = $num_generated + $num_rows;
    mysql_query("\n    UPDATE {$g_table_prefix}user_accounts\n    SET    num_records_generated = {$new_total}\n    WHERE  account_id = {$account_id}\n      ");
    db_disconnect($link);
}
コード例 #24
0
function db_connect()
{
    global $dblink, $dbpconnect, $dbusername, $dbname, $dbserver, $dbpasswd, $dbpconnect;
    global $opt;
    //connect to the database by the given method - no php error reporting!
    if ($dbpconnect == true) {
        $dblink = @mysql_pconnect($dbserver, $dbusername, $dbpasswd);
    } else {
        $dblink = @mysql_connect($dbserver, $dbusername, $dbpasswd);
    }
    if ($dblink != false) {
        mysql_query("SET NAMES '" . mysql_real_escape_string($opt['charset']['mysql'], $dblink) . "'", $dblink);
        //database connection established ... set the used database
        if (@mysql_select_db($dbname, $dblink) == false) {
            //error while setting the database ... disconnect
            db_disconnect();
            $dblink = false;
        }
    }
}
コード例 #25
0
ファイル: settings.php プロジェクト: sagamusix/s3m.it
function redirect($target)
{
    header("Location: {$target}");
    db_disconnect();
    die;
}
コード例 #26
0
 function run()
 {
     global $dblink, $lang;
     /* begin db connect */
     db_connect();
     if ($dblink === false) {
         echo 'Unable to connect to database';
         exit;
     }
     /* end db connect */
     //      global $opt;
     $rsCache = sql("SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE ISNULL(`cache_location`.`cache_id`) UNION SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` INNER JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE `caches`.`country`!='PL' AND `caches`.`last_modified`>`cache_location`.`last_modified`");
     while ($rCache = mysql_fetch_assoc($rsCache)) {
         $sCode = '';
         $rsLayers = sql("SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE WITHIN(GeomFromText('&1'), `shape`) ORDER BY `level` DESC", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
         while ($rLayers = mysql_fetch_assoc($rsLayers)) {
             if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
                 $sCode = $rLayers['code'];
                 break;
             }
         }
         mysql_free_result($rsLayers);
         if ($sCode != '') {
             $adm1 = null;
             $code1 = null;
             $adm2 = null;
             $code2 = null;
             $adm3 = null;
             $code3 = null;
             $adm4 = null;
             $code4 = null;
             if (mb_strlen($sCode) > 5) {
                 $sCode = mb_substr($sCode, 0, 5);
             }
             if (mb_strlen($sCode) == 5) {
                 $code4 = $sCode;
                 $adm4 = sqlValue("SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'", 0);
                 $sCode = mb_substr($sCode, 0, 4);
             }
             if (mb_strlen($sCode) == 4) {
                 $code3 = $sCode;
                 $adm3 = sqlvalue("SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'", 0);
                 $sCode = mb_substr($sCode, 0, 3);
             }
             if (mb_strlen($sCode) == 3) {
                 $code2 = $sCode;
                 $adm2 = sqlvalue("SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'", 0);
                 $sCode = mb_substr($sCode, 0, 2);
             }
             if (mb_strlen($sCode) == 2) {
                 $code1 = $sCode;
                 if (checkField('countries', 'list_default_' . $lang)) {
                     $lang_db = $lang;
                 } else {
                     $lang_db = "en";
                 }
                 // try to get localised name first
                 $adm1 = sqlvalue("SELECT `countries`.`{$lang}`\n                     FROM `countries`\n                    WHERE `countries`.`short`='{$sCode}'", 0);
                 if ($adm1 == null) {
                     $adm1 = sqlvalue("SELECT `name` FROM `nuts_codes` WHERE `code`='{$sCode}'", 0);
                 }
             }
             $sql = sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `adm2`, `adm3`, `adm4`, `code1`, `code2`, `code3`, `code4`) VALUES ('&1', '&2', '&3', '&4', '&5', '&6', '&7', '&8', '&9') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`='&3', `adm3`='&4', `adm4`='&5', `code1`='&6', `code2`='&7', `code3`='&8', `code4`='&9'", $rCache['cache_id'], $adm1, $adm2, $adm3, $adm4, $code1, $code2, $code3, $code4);
             mysql_query($sql);
         } else {
             if (checkField('countries', 'list_default_' . $lang)) {
                 $lang_db = $lang;
             } else {
                 $lang_db = "en";
             }
             $sCountry = sqlvalue("SELECT `countries`.`pl`\n                                         FROM `caches`\n                                   INNER JOIN `countries` ON `caches`.`country`=`countries`.`short`\n                                        WHERE `caches`.`cache_id`='{$rCache['cache_id']}'", 0);
             $sCode1 = sqlvalue("SELECT `caches`.`country` FROM `caches` WHERE `caches`.`cache_id`='&1'", null, $rCache['cache_id']);
             $sql = sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `code1`) VALUES ('&1', '&2', '&3') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`=NULL, `adm3`=NULL, `adm4`=NULL, `code1`='&3', `code2`=NULL, `code3`=NULL, `code4`=NULL", $rCache['cache_id'], $sCountry, $sCode1);
             mysql_query($sql);
         }
     }
     mysql_free_result($rsCache);
     db_disconnect();
 }