Esempio n. 1
0
function databaseCreate($serverName, $databaseName, $databaseUser, $databasePassword)
{
    try {
        $conn = databaseConnect($serverName, "information_schema", $databaseUser, $databasePassword);
        $sql = "CREATE DATABASE IF NOT EXISTS {$databaseName};\n\t\tUSE {$databaseName};\n\t\tCREATE TABLE IF NOT EXISTS `events` (\n\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t`dates` date NOT NULL,\n\t\t`description` varchar(200) NOT NULL,\n\t\tPRIMARY KEY (`id`))\n\t\tENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;";
        $conn->exec($sql);
    } catch (PDOException $e) {
        echo "Table creation failed: " . $e->getMessage() . " <br>";
        die;
    }
}
Esempio n. 2
0
    if (@mysql_connect($GLOBALS['mysql_server'], $GLOBALS['db_user'], $GLOBALS['db_password'])) {
        if (@mysql_select_db($GLOBALS['db_name'])) {
            return 1;
        }
        return 0;
    }
    return 0;
}
function databaseIsInstalled()
{
    return mysql_query("SELECT * FROM `grammafone_users` LIMIT 0,1");
}
function databaseReset()
{
    $query = array();
    $query[] = "TRUNCATE TABLE grammafone_status";
    $query[] = "TRUNCATE TABLE grammafone_songs";
    $query[] = "TRUNCATE TABLE grammafone_artists";
    $query[] = "TRUNCATE TABLE grammafone_albums";
    $query[] = "TRUNCATE TABLE grammafone_playlist";
    $query[] = "TRUNCATE TABLE grammafone_stats";
    $query[] = "TRUNCATE TABLE grammafone_currentsong";
    foreach ($query as $q) {
        mysql_query($q);
    }
    return true;
}
// Connecting to database
if (databaseConnect() == 0) {
    die('Cannot connect to database ' . $GLOBALS['db_name'] . '. Check the configuration!');
}
Esempio n. 3
0
<?php

/**
 * Database Tables: posts
 * Table <posts>: id (int, auto_increment),
 *   topic_id (int), author_id (int),
 *   message (text), rating (int), created (str),
 *   flags (str), edited (str)
 */
require_once 'config.php';
require_once 'core.php';
require_once 'users.php';
require_once 'topics.php';
databaseConnect();
function postGetById($id)
{
    global $database_cfg;
    $res = databaseQuery("select * from " . $database_cfg["prefix"] . "posts where id='" . stringEncode($id) . "'", "Post not found");
    return $res[0];
}
function postGetByAuthorId($author_id)
{
    global $database_cfg;
    return databaseQuery("select * from " . $database_cfg["prefix"] . "posts where author_id='" . stringEncode($author_id) . "'");
}
function postGetByTopicId($topic_id)
{
    global $database_cfg;
    return databaseQuery("select * from " . $database_cfg["prefix"] . "posts where topic_id='" . stringEncode($topic_id) . "'");
}
function postGetByRating($rating)
Esempio n. 4
0
    $from = $configValues['EMAIL_FROM'];
    // set appropriate (html, utf8 and to/from addresses) headers
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
    $headers .= 'To: System Administrator <' . $to . '>' . "\r\n";
    $headers .= 'From: daloRADIUS Node Monitor<' . $from . '>' . "\r\n";
    // mail it
    mail($to, $subject, $message, $headers);
}
/**
 * getHTMLMessage()
 *
 */
function getHTMLMessage($table)
{
    $result = "";
    $result .= "<html><head><title>daloRADIUS Node Monitor";
    $result .= "</title></head>";
    $result .= "<body><table>";
    foreach ($table as $field => $value) {
        $result .= "<tr><td>{$field}</td><td>{$value}</td></tr>";
    }
    $result .= "</table></body></html>";
    return $result;
}
$dbh = databaseConnect();
getHardDelayNodes($dbh);
databaseDisconnect($dbh);
?>

Esempio n. 5
0
/**
 * Adds call information to the CallInfo table.
 * @param string $address Where the fire takes place
 * @param string $fire_type Type of fire (structure, etc)
 * @param string $time_of_call When the call was recieved
 * @param string $responding_unit Unit that responds to the call
 * @param string $truck_leaves Time the truck leaves the firehouse
 *               Format: YYYY-MM-DD HH:MM:SS
 * @param string $truck_arrives Time the truck arrives at the fire
 *               Format: YYYY-MM-DD HH:MM:SS
 *
 */
function addToCallTable($address, $fire_type, $time_of_call, $responding_unit, $truck_leaves, $truck_arrives)
{
    $mysqli = databaseConnect();
    $insert_query = "INSERT INTO CallInfo VALUES (" . $address . ", " . $fire_type . ", " . $time_of_call . ", " . $responding_unit . ", " . $truck_leaves . ", " . $truck_arrives . ")";
    if (!$mysqli->query($insert_query)) {
        echo 'Table insert failed: (' . $mysqli->errno . ') ' . $mysqli->error;
    }
}
Esempio n. 6
0
//execute cron script for all services
//for uxpanel slave instances, there is currently no good way to check
// if the slave instance is the correct instance
//as a result, we simply run on all slave instances
//this means that the cron script being called shouldn't do anything bad
$result = $db->query("SELECT id, type FROM services");
while ($row = $result->fetch_array()) {
    $service_id = $row[0];
    $service_type = $row[1];
    $params = array();
    $result2 = $db->query("SELECT k, v FROM service_params WHERE service_id = '{$service_id}'");
    while ($row2 = $result2->fetch_array()) {
        $params[$row2[0]] = $row2[1];
    }
    //if slave parameter is set but we are not a slave, don't run (and vice versa)
    //similarly, if slave_id parameter is set but it doesn't match our ID, don't run
    $isslave = isset($params['slave']) && $params['slave'];
    if ((!$isslave || $config['slave_enabled']) && ($isslave || !$config['slave_enabled']) && (!isset($params['slave_id']) || $config['slave_enabled'] && $params['slave_id'] == $config['slave_id'])) {
        if ($service_type == 'database') {
            $link = databaseConnect($service_id);
            executeCron($service_id, $link, $params);
        } else {
            if (function_exists('executeCronOther')) {
                executeCronOther($service_id, $service_type, $params);
            }
        }
    }
}
if (function_exists('executeCronShutdown')) {
    executeCronShutdown();
}
Esempio n. 7
0
function databaseClearBans($service_id)
{
    $link = databaseConnect($service_id);
    if (!$link) {
        return array();
    }
    $link->query("DELETE FROM bans");
}
Esempio n. 8
0
 * 
 * index.php decides what function to apply, i.e. what
 * action to take, based upon the action argument it receives
 * via the URL. It it important to understand that ALL user-actions
 * , hence GET- and POST requests this application receive are 
 * relayed trough this file.
 * 
 * Modified by DIRN on 09/06/2015, changelog 12341	
 */
session_start();
// set serverside cookie
require_once "conf/config.conf.php";
// System configuration also contains other require-statements
// set to the user defined error handler, see : lib/general.lib.php
$new_error_handler = set_error_handler("fcErrorHandler");
$db_conn = databaseConnect();
// Connect to DB
// Since every request or POST is routed via this PHP file
// we may need to process a submitted form. Depending on the action argument
// processCurrentAction does that.
//
// Avoid HTML output before this action. See for mapping of commands processing.lib.php
processCurrentAction();
// Functions that generate content to browser, see general.lib.php
displayHeader();
// Generate HTML header as well as the `top' of the page
displayNavigation();
// Generate navigation bar-menu
displaySearch();
//Generate search input
renderCurrentAction();
Esempio n. 9
0
function db_delete_post($mod_delete_post_xid, $db_query)
{
    $mod_delete_post_xid_quoted = "'" . mysql_real_escape_string($mod_delete_post_xid, $db_query) . "'";
    $db = databaseConnect('fotos_root_usr', 'fotos_root_pass', 'fotos');
    // averiguamos el true id
    $delete_post_stmt = "SELECT id FROM posts WHERE xid={$mod_delete_post_xid_quoted} AND is_deleted='0'";
    //    print $delete_post_stmt . "<br>\n";
    $delete_rs = executeQuery(Bnumber(), $db, $delete_post_stmt, "canBeZero");
    if ($delete_rs === FALSE) {
        gotoHomeIf(NULL, NULL, 'redirect');
    }
    $delete_row = mysql_fetch_row($delete_rs);
    $mod_delete_post_id = $delete_row[0];
    // seleccionamos las fotos, y las borramos una a una
    $delete_pic_stmt = "SELECT pic_id FROM posts_pics pp WHERE pp.post_id = '{$mod_delete_post_id}' AND pp.is_deleted='0'";
    //print $delete_pic_stmt . "<br>\n";
    $pics_rs = executeQuery(Bnumber(), $db, $delete_pic_stmt, "canBeZero");
    if ($pics_rs) {
        while ($pic_row = mysql_fetch_row($pics_rs)) {
            //print $pic_row[0] . "<br>\n";
            db_delete_pic($mod_delete_post_xid, "000000000", $db, $mod_delete_post_id, $pic_row[0]);
        }
        mysql_free_result($pics_rs);
    }
    // quitamos las asociaciones a tags
    $delete_tags_stmt = "SELECT tp.tag_id FROM tags_posts tp WHERE tp.post_id = '{$mod_delete_post_id}' AND tp.is_deleted='0'";
    //print $delete_tags_stmt . "<br>\n";
    $tags_rs = executeQuery(Bnumber(), $db, $delete_tags_stmt, "canBeZero");
    if ($tags_rs) {
        while ($tag_row = mysql_fetch_row($tags_rs)) {
            //print "tag: " . $tag_row[0] . "<br>\n";
            db_delete_tag($tag_row[0], $mod_delete_post_id, $db);
        }
    }
    // marcamos los tags como borrados si no apuntan a nadie mas
    // lo ultimo es marcar el post como borrado, para poder repetir en caso de error
    $delete_post_stmt = "UPDATE posts SET is_deleted='1',delete_date=now() WHERE id='{$mod_delete_post_id}' AND is_deleted='0'";
    //print $delete_post_stmt . "<br>\n";
    executeNonQuery(Bnumber(), $db, $delete_post_stmt);
    //$link = substr($_SERVER['HTTP_REFERER'], strlen("http://" . $_SERVER['HTTP_HOST']), strlen($_SERVER['HTTP_REFERER']) - strlen("http://" . $_SERVER['HTTP_HOST']));
    deleteCache(DIR_HOME . "/cache/{$mod_delete_post_xid}");
    //    header("Refresh: 0; URL=" URL_HOME . "/a/display/$mod_delete_post_xid");
    gotoHomeIf(NULL, NULL, 'redirect');
    //    exit;
}
Esempio n. 10
0
	AUTOMATIC DATABASE CONNECTION
		THIS STRICTLY CONNECTS TO THE DATABASE, DATABASE 
		CALLS ARE TO BE DONE SEPARATELY, VIA STANDARD MYSQL.
	CREATED BY RYAN ILG
	HTTP://RYANILG.COM
	CREATED: Sun Sep 30 21:56:25 PDT 2007
	LAST UPDATE: Wed Apr 13 19:39:30 PDT 2011
*/
// CONNECT TO THE DATABASE SERVER
function databaseConnect($host, $username, $password)
{
    global $message;
    // CONNECT, IF UNABLE TO, DISPLAY A MESSAGE
    if (!@mysql_connect($host, $username, $password)) {
        exit('<h3>Database Connection Issue</h3><p>It seems like we were unable to connect to the database server. Check your host, username and password.</p>');
    }
}
// SELECT THE DATABASE
function selectDatabase($database)
{
    global $message;
    // SELECT THE DATABASE, IF UNABLE TO, DISPLAY A MESSAGE
    if (!@mysql_select_db($database)) {
        exit('<h3>Database Retrieval Problem</h3><p>It seems like we were unable to pull up the database table.</p>');
    }
}
// BECAUSE THIS FILE IS LOADED ONLY WHEN REQUESTED,
// WE CAN CONNECT ON EVERY PAGE LOAD, GIVING ACCESS
// AUTOMATICALLY TO THE CONTENT PAGE FILES
databaseConnect(DB_SERVER, DB_USER, DB_PASS);
selectDatabase(DB_DATABASE);