Example #1
0
 function DropDatabase(&$db, $name)
 {
     if (!$db->Connect()) {
         return 0;
     }
     if (!msql_drop_db($name, $db->connection)) {
         return $db->SetError("Drop database", msql_error());
     }
     return 1;
 }
//name of database user
define('DB_PW', 'W3arethebest');
//password
define('DB_HOST', 'localhost');
//where the database is running
//a variable created based on the connection to the sql database
$dbLink = mysql_connect(DB_HOST, DB_USER, DB_PW);
if (!$dbLink) {
    //checks if there is a valid db connection; if not, execute statement
    die('Connection failed: ' . msql_error());
}
//selects the mysql database based on the link and stores it in a variable
$selectedDB = mysql_select_db(DB_NAME, $dbLink);
if (!$selectedDB) {
    //checks if there is a valid db selected; if not, execute statement
    die('Error: ' . DB_NAME . ': ' . msql_error());
}
//Collect these values from the form and store them into a variable
$eID = $_GET['e_ID'];
$eSDate = $_POST['Start_Date'];
$eSDate = date("Y-m-d", strtotime($eSDate));
$eSDate = mysql_real_escape_string($eSDate);
$eEDate = $_POST['End_Date'];
$eEDate = date("Y-m-d", strtotime($eEDate));
$eEDate = mysql_real_escape_string($eEDate);
$eSTime = $_POST['timeH'] . ":" . $_POST['timeM'] . ":00";
$eLocation = $_POST['Location'];
$eLocation = mysql_real_escape_string($eLocation);
$ePUA = $_POST['PUA'];
$ePUA = mysql_real_escape_string($ePUA);
$eName = $_POST['Name'];
Example #3
0
 /**
  * Gets the DBMS' native error message produced by the last query
  *
  * @return string  the DBMS' error message
  */
 function errorNative()
 {
     return @msql_error();
 }
<?php

require_once "mysql.php";
echo msql_error();
function carddata($echo = false)
{
    $result = mysql_query("SELECT * FROM card");
    $cards = "";
    $data = "{";
    while ($line = mysql_fetch_array($result)) {
        if (strlen($cards) > 0) {
            $cards .= ",";
        }
        $id = $line['ID'];
        while (strlen($id) < 4) {
            $id = "0" . $id;
        }
        $cards .= "\"" . $id . "\"";
        if (strlen($data) > 1) {
            $data .= ',';
        }
        $data .= '"' . $id . '":{"name":"' . $line['name'] . '","mana":' . $line['mana'] . ',"range":' . $line['range'];
        if ($line['direction']) {
            $data .= ',"direction":"' . $line['direction'] . '"';
        }
        $effects = mysql_query("SELECT * FROM card INNER JOIN cardeffect ON card.ID = cardID INNER JOIN effect ON effect.ID = effectID WHERE card.ID = " . $line['ID']);
        /*
         * === Feedback Alpers, Jan. 5 ===
         *
         * Schön effizienter Code fürs Einlesen der Datensätze.
         */
Example #5
0
<?php

#if(!mysql_connect("mysql2.gear.host","safetaxi","Safetaxi1!"))
if (!mysql_connect("localhost", "root", "pass")) {
    die('oops connection problem ! --> ' . mysql_error());
}
if (!mysql_select_db("dbtest")) {
    die('oops database selection problem ! --> ' . mysql_error());
}
//selecting which database to use here
mysql_select_db("dbtest") or die("no database by that name" . msql_error());
//now here change the name  of the table you are selecting information from. But copy and past this and create another php file if your are going to use another table.
$result = mysql_query("SELECT * FROM taxi_drivers ") or die('Errant query:');
$rows = mysql_num_rows($result);
$return_arr = array();
while ($row2 = mysql_fetch_assoc($result)) {
    $return_arr[] = $row2;
}
echo json_encode($return_arr);
Example #6
0
 /**
  * Fetch a row and insert the data into an existing array.
  *
  * Formating of the array and the data therein are configurable.
  * See DB_result::fetchInto() for more information.
  *
  * @param resource $result    query result identifier
  * @param array    $arr       (reference) array where data from the row
  *                            should be placed
  * @param int      $fetchmode how the resulting array should be indexed
  * @param int      $rownum    the row number to fetch
  *
  * @return mixed DB_OK on success, null when end of result set is
  *               reached or on failure
  *
  * @see DB_result::fetchInto()
  * @access private
  */
 function fetchInto($result, &$arr, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@msql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $arr = @msql_fetch_array($result, MSQL_ASSOC);
         if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
             $arr = array_change_key_case($arr, CASE_LOWER);
         }
     } else {
         $arr = @msql_fetch_row($result);
     }
     if (!$arr) {
         if ($error = @msql_error()) {
             return $this->raiseError($error);
         } else {
             return null;
         }
     }
     if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
         $this->_rtrimArrayValues($arr);
     }
     if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
         $this->_convertNullArrayValuesToEmpty($arr);
     }
     return DB_OK;
 }
Example #7
0
<?php 
#if(!mysql_connect("mysql2.gear.host","safetaxi","Safetaxi1!"))
if (!mysql_connect("mysql2.gear.host", "bobosampledb", "safetaxi!")) {
    die('oops connection problem ! --> ' . mysql_error());
}
if (!mysql_select_db("bobosampledb")) {
    die('oops database selection problem ! --> ' . mysql_error());
}
//selecting which database to use here
mysql_select_db("bobosampledb") or die("no database by that name" . msql_error());
//now here change the name  of the table you are selecting information from. But copy and past this and create another php file if your are going to use another table.
$result = mysql_query("SELECT * FROM taxi_drivers ") or die('Errant query:');
$rows = mysql_num_rows($result);
$return_arr = array();
while ($row2 = mysql_fetch_assoc($result)) {
    $return_arr[] = $row2;
}
echo json_encode($return_arr);
Example #8
0
 function fetchInto($result, &$ar, $fetchmode, $rownum = null)
 {
     if ($rownum !== null) {
         if (!@msql_data_seek($result, $rownum)) {
             return null;
         }
     }
     if ($fetchmode & DB_FETCHMODE_ASSOC) {
         $ar = @msql_fetch_array($result, MSQL_ASSOC);
     } else {
         $ar = @msql_fetch_row($result);
     }
     if (!$ar) {
         if ($error = msql_error()) {
             return $this->raiseError($error);
         } else {
             return null;
         }
     }
     return DB_OK;
 }
Example #9
0
echo "<ul class='top-list' style='display: inline-block;'><li class='loc'>Bangalore(West)</li>";
$i = 0;
while ($i < 10) {
    echo "<li>" . $top_list[$i]['medName'] . "</li>";
    $i++;
}
echo "</ul></center>";
unset($top_list);
?>
        </div>
    </div>
    <!-- <div class="graphs"></div> -->
    <?php 
if (isset($_GET['med'])) {
    $name = $_GET['med'];
    $conn = mysql_connect(DB_HOST, DB_USER) or die(msql_error());
    mysql_select_db("Codesteins") or die(mysql_error());
    $query = "SELECT sno,medName FROM allmeds WHERE medName LIKE '%" . $name . "'";
    // echo $query;
    $result = mysql_query($query) or die(mysql_error());
    $arr = mysql_fetch_array($result) or die(mysql_error());
    // echo $arr[0];
    // echo type($arr);
    // print_r($arr);
    echo "<div style='text-align: center;'><h1>The graph below shows the sales of " . strtoupper($arr[1]) . "</h1></div>";
    // echo $arr['sno'];
    if (empty($arr)) {
        # code...
        echo "<span class='empty-error'>No matches found. Please check the name you've entered.</span>";
    }
    if (isset($arr['sno'])) {
Example #10
0
 function FetchResultArray($result, &$array, $row)
 {
     if (isset($this->limits[$result])) {
         if ($row > $this->limits[$result][1]) {
             return $this->SetError("Fetch result array", "attempted to retrieve a row beyhond the result limit");
         }
         $actual_row = $row + $this->limits[$result][0];
     } else {
         $actual_row = $row;
     }
     if (!msql_data_seek($result, $row) || !($array = msql_fetch_row($result))) {
         return $this->SetError("Fetch result array", msql_error());
     }
     $this->highest_fetched_row[$result] = max($this->highest_fetched_row[$result], $row);
     return $this->ConvertResultRow($result, $array);
 }
Example #11
0
 function connect_fbql($host, $user, $pass, $db)
 {
     $this->fbsql_link = fbsql_pconnect($host, $user, $pass);
     if ($this->fbsql_link == 0) {
         return false;
     }
     if (!fbsql_select_db($db, $this->fbsql_link)) {
         print "Database Error " . msql_error() . "\n";
         return false;
     }
     return $this->fbsql_link;
 }
Example #12
0
function delete_user_core($user_id, $clear_posts = false, $retain_pms = false)
{
    // Set global variables
    global $index;
    global $phpbb_version;
    global $phpbb_banlist;
    global $phpbb_user_group;
    global $phpbb_users;
    global $phpbb_groups;
    global $phpbb_posts;
    global $phpbb_posts_text;
    global $phpbb_topics;
    global $phpbb_vote_voters;
    global $phpbb_auth_access;
    global $phpbb_sessions;
    global $phpbb_sessions_keys;
    global $phpbb_privmsgs;
    global $phpbb_privmsgs_text;
    global $phpbb_topics_watch;
    // First things first, sanitize the $user_id
    $user_id = safe_sql($user_id);
    //
    // Obtain username and level based on user_id
    //
    $sql = "SELECT * FROM {$phpbb_users} WHERE user_id={$user_id} LIMIT 1";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    $username = safe_sql($myrow['username']);
    $user_level = safe_sql($myrow['user_level']);
    // Obtain first admin account to set as group mod if deleted user is a group mod (step 5)
    $sql = "SELECT * FROM {$phpbb_users} WHERE user_level=1 ORDER BY user_id ASC LIMIT 1";
    $result = mysql_query($sql);
    $myrow = mysql_fetch_array($result);
    $admin_id = safe_sql($myrow['user_id']);
    // Debug info:
    // echo '<pre>';
    // echo gettype( $myrow );
    // die( $admin_id );
    // This actually starts the delete process
    // **************************************************************
    //
    // First sql query is to collect group information about the user
    //
    // **************************************************************
    $sql = "SELECT g.group_id FROM {$phpbb_user_group} ug, {$phpbb_groups} g WHERE ug.user_id = {$user_id} AND g.group_id = ug.group_id AND g.group_single_user = 1";
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    unset($row[0]);
    // Read note directly below about this line:
    // PHPBB's $row = $db->sql_fetchrow($result); line returns an array containg the user id:
    // Array
    // (
    // 	[group_id] => 123
    // )
    // The mqsql fetch array used in this scrip: $myrow = mysql_fetch_array($result);
    // Returns the following:
    // Array
    // (
    //	[0] => 123
    //	[group_id] => 123
    // )
    // Therefore I unset the $row[0] element
    // Debugging info:
    // echo '<pre>';
    // print_r( $row );
    // echo"\n\n$username";
    // die();
    // ***************************************************************************
    //
    // Second sql query sets the poster id to the anonymous account for all posts
    // First query in this section is for the $clear_posts variable
    //
    // ***************************************************************************
    //
    // This check fixes the:
    //	Error deleting user's group from groups table:
    //	Line: 1477
    //	File: /toolkit.php
    //	Query: DELETE FROM `phpbb_groups` WHERE `group_id`=
    //	MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    //
    // Error message that was appearing in v2.1a because the returned value of $row was not correct
    // Debug for numeric check
    /* echo '<pre>';
    	var_dump( $row );
    
    	$i = is_numeric( '2 3' );
    	var_dump( $i );
    	die(); */
    if (!is_numeric($row['group_id'])) {
        echo '<font size="4"><b>An incorrect value has been returned for group_id in the \'phpbb_groups\' table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . '<br /><b>User ID: </b>' . $user_id . '<br /><b>Username: </b>' . $username . '<br /><b>Details:</b> This value should be a purely numeric integer. The value returned by the database is:<br /><pre>';
        var_dump($row);
        echo '</pre><br />Please contact Starfoxtj at <a href="http://starfoxtj.no-ip.com">http://starfoxtj.no-ip.com</a> and report this error.';
        echo '<br /><br /><b>Note: </b> The script has halted before any changes to the database were made for this specific user.<br />All other users that were deleted before <b>' . $username . '</b> were properly removed.';
        echo '<br /><br /><b>Full envoirment details:</b><br /><pre>';
        var_dump(get_defined_vars());
        die;
    }
    // If clear posts is set to true, replace all posts made by user to "DELETED"
    if ($clear_posts == true) {
        $sql = "SELECT `post_id` FROM `{$phpbb_posts}` WHERE `poster_id`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error selecting selecting posts to clear:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
        // Assings the results of the above query into an array
        while ($myrow = mysql_fetch_array($result)) {
            $marked_posts[] = $myrow['post_id'];
        }
        // Makes mark an empty array if the user has no PMs
        if (!isset($marked_posts)) {
            $marked_posts = array();
        }
        // First check to see if user has any posts, if not skip replacing the posts
        if (isset($marked_posts) && count($marked_posts)) {
            $marked_posts = implode(',', $marked_posts);
            $sql = "UPDATE `{$phpbb_posts_text}` SET `post_text`='DELETED' WHERE `post_id` IN ( {$marked_posts} )";
            // echo '<pre>';
            // echo $sql;
            // echo '<br />';
            // print_r( $marked_posts );
            // die();
            if (!($result = mysql_query($sql))) {
                die('<font size="4"><b>Error setting posts to DELETED:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
            }
        }
        // Sets the poster id to the anonymous account for all posts and replaces the username with DELETED
        $sql = "UPDATE `{$phpbb_posts}` SET `poster_id`=-1, `post_username`='DELETED' WHERE `poster_id`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting poster id to anonymous for deleted user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    } else {
        // Sets the poster id to the anonymous account for all posts, but retains the original username
        $sql = "UPDATE `{$phpbb_posts}` SET `poster_id`=-1, `post_username`='" . str_replace("\\'", "''", addslashes($username)) . "' WHERE `poster_id`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting poster id to anonymous for deleted user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    }
    // ***************************************************************************
    //
    // Third sql query sets the topic id to the anonymous account for all topics
    //
    // ***************************************************************************
    // If clear posts is set to true, replace all topics made by user to "DELETED"
    if ($clear_posts == true) {
        $sql = "UPDATE `{$phpbb_topics}` SET `topic_title`='DELETED' WHERE `topic_poster`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting topics to DELETED:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
        // Sets the topic id to the anonymous account for all topics and replaces the username with DELETED
        $sql = "UPDATE `{$phpbb_topics}` SET `topic_poster`=-1 WHERE `topic_poster`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting topic id poster to anonymous for deleted user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    } else {
        // Sets the poster id to the anonymous account for all posts, but retains the original username
        $sql = "UPDATE `{$phpbb_topics}` SET `topic_poster`=-1 WHERE `topic_poster`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting topic id poster to anonymous for deleted user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    }
    // ***************************************************************************
    //
    // Fourth sql query sets the voter id to anonymous
    //
    // ***************************************************************************
    $sql = "UPDATE `{$phpbb_vote_voters}` SET `vote_user_id`=-1 WHERE `vote_user_id`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error setting voter ID to anonymous:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Fifth sql query collects the phpbb_groups info and assigns it to the
    // $group_mods array where the user is a moderator
    //
    // ***************************************************************************
    $sql = "SELECT `group_id` FROM `{$phpbb_groups}` WHERE `group_moderator`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error selecting groups where user is a moderator:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // Assings the results of the above query into an array
    while ($myrow = mysql_fetch_array($result)) {
        $group_mod[] = $myrow['group_id'];
    }
    // Debugging info:
    // echo '<pre>';
    // print_r( $group_mod );
    // die();
    // If the user is a moderator for any groups, this query assigns the
    // new mod status to the oldest admin account
    if (isset($group_mod) && count($group_mod)) {
        //
        // Make SURE to insert a query here to check for the first admin account to associate as the new group moderator
        // after the deleted user is deleted!
        // Done
        // $admin_id = 3; //This is a temp static admin id that will be dymamic in the final release
        $update_mod_id = implode(',', $group_mod);
        $sql = "UPDATE `{$phpbb_groups}` SET `group_moderator`={$admin_id} WHERE `group_moderator` IN ( {$update_mod_id} )";
        // Debugging info:
        // echo '<pre>';
        // echo $sql;
        // die();
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting new group moderator to oldest admin:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    }
    // ***************************************************************************
    //
    // Sixth sql query deletes the user from the phpbb_users table
    //
    // ***************************************************************************
    $sql = "DELETE FROM `{$phpbb_users}` WHERE `user_id`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user from users table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Seventh sql query deletes the user from the phpbb_user_group table
    //
    // ***************************************************************************
    $sql = "DELETE FROM `{$phpbb_user_group}` WHERE `user_id`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user from user_group table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Eighth sql query moved to the top to check and exit if error
    //
    // ***************************************************************************
    $sql = "DELETE FROM `{$phpbb_groups}` WHERE `group_id`=" . $row['group_id'];
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user\'s group from groups table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Ninth sql query deletes the user from the phpbb_auth_access table
    //
    // ***************************************************************************
    $sql = "DELETE FROM  `{$phpbb_auth_access}` WHERE `group_id`=" . $row['group_id'];
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user from auth_access table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Tenth sql query deletes the user from the phpbb topics watch table
    //
    // ***************************************************************************
    $sql = "DELETE FROM `{$phpbb_topics_watch}` WHERE `user_id`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user from topics_watch table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Eleventh sql query deletes the user from the banlist table
    //
    // ***************************************************************************
    $sql = "DELETE FROM `{$phpbb_banlist}` WHERE `ban_userid`={$user_id}";
    if (!($result = mysql_query($sql))) {
        die('<font size="4"><b>Error deleting user from the banlist table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
    }
    // ***************************************************************************
    //
    // Twelfth sql query deletes the user from the sessions table
    //
    // ***************************************************************************
    // This delete section was added in .19, so a check is done before using it incase
    // the admin is running an older version of phpbb
    if ($phpbb_version >= 0.19) {
        $sql = "DELETE FROM `{$phpbb_sessions}` WHERE `session_user_id`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error deleting user from the sessions table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    }
    // ***************************************************************************
    //
    // Twelfth sql query deletes the user from the sessions_keys table
    //
    // ***************************************************************************
    // This delete section was added in .19, so a check is done before using it incase
    // the admin is running an older version of phpbb
    if ($phpbb_version >= '.0.19') {
        // First check if the sesssions keys table exists
        // (Since alot of .19 boards dont have it due to incomplete updates
        $sql_key_check = "SHOW TABLES LIKE '{$phpbb_sessions_keys}'";
        if (!($result_key_check = mysql_query($sql_key_check))) {
            die('<font size="4"><b>Error selecting session keys table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
        // This section actually checks if the table exists, if not it skips
        // deleting the user from this table
        if (mysql_fetch_array($result_key_check)) {
            $sql = "DELETE FROM `{$phpbb_sessions_keys}` WHERE `user_id`={$user_id}";
            if (!($result = mysql_query($sql))) {
                die('<font size="4"><b>Error deleting user from the sessions_keys table:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
            }
        }
    }
    // ***************************************************************************
    //
    // The final sql query collets the to/from PMs with the user's id & deletes them
    //
    // ***************************************************************************
    // If retain_pms is set to true, change PM author to anonymous instead of deleting them
    if ($retain_pms == true) {
        // This query sets the from_user_id to the anonymous account so the PMs dont have to be deleted
        $sql = "UPDATE `{$phpbb_privmsgs}` SET `privmsgs_from_userid`=-1 WHERE `privmsgs_from_userid`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting from PM from_user_id to anonymous:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
        // This query sets the to_user_id to the anonymous account so the PMs dont have to be deleted
        $sql = "UPDATE `{$phpbb_privmsgs}` SET `privmsgs_to_userid`=-1 WHERE `privmsgs_to_userid`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error setting from PM to_user_id to anonymous:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
    } else {
        $sql = "SELECT `privmsgs_id` FROM `{$phpbb_privmsgs}` WHERE `privmsgs_from_userid`={$user_id} OR `privmsgs_to_userid`={$user_id}";
        if (!($result = mysql_query($sql))) {
            die('<font size="4"><b>Error selecting PMs for the user:</b></font><br /><b>Line:</b> ' . __LINE__ . '<br /><b>File:</b> ' . $_SERVER['PHP_SELF'] . "<br /><b>Query:</b> {$sql}<br /><b>MySQL Error:</b> " . mysql_error());
        }
        // Debugging info:
        // echo "<br />$sql<br />";
        // This section marks and assigns the resulting PMs into the $marked array
        while ($myrow = mysql_fetch_array($result)) {
            $marked[] = $myrow['privmsgs_id'];
        }
        // Makes mark an empty array if the user has no PMs
        if (!isset($marked)) {
            $marked = array();
        }
        // This section actually goes through the list and deletes the PMs
        // Debugging info:
        // echo '<pre>';
        // print_r( $marked );
        if (count($marked)) {
            $delete_id = implode(',', $marked);
            // Debugging info:
            // echo "<br />$delete_id";
            $sql = "DELETE FROM `{$phpbb_privmsgs_text}` WHERE `privmsgs_text_id` IN ( {$delete_id} )";
            // Debugging info:
            // echo "<br />$sql";
            if (!($result = mysql_query($sql))) {
                die('Error deleting user PMs:<br />Line: ' . __LINE__ . '<br />File: ' . $_SERVER['PHP_SELF'] . "<br />Query: {$sql}<br />MySQL Error: " . msql_error());
            }
            $sql = "DELETE FROM `{$phpbb_privmsgs}` WHERE `privmsgs_id` IN ( {$delete_id} )";
            // Debugging info:
            // echo "<br />$sql";
            if (!($result = mysql_query($sql))) {
                die('Error deleting user Pms:<br />Line: ' . __LINE__ . '<br />File: ' . $_SERVER['PHP_SELF'] . "<br />Query: {$sql}");
            }
        }
    }
    // And thats it! The user should now be fully and properly deleted!
}
Example #13
0
function SaveCopyToArchive($dbi, $pagename, $pagehash)
{
    global $ArchivePageStore;
    $pagehash = MakeDBHash($pagename, $pagehash);
    // $pagehash["content"] is now an array of strings
    // of MSQL_MAX_LINE_LENGTH
    if (IsInArchive($dbi, $pagename)) {
        $PAIRS = "author='{$pagehash['author']}'," . "created={$pagehash['created']}," . "flags={$pagehash['flags']}," . "lastmodified={$pagehash['lastmodified']}," . "pagename='{$pagehash['pagename']}'," . "refs='{$pagehash['refs']}'," . "version={$pagehash['version']}";
        $query = "UPDATE {$ArchivePageStore['table']} SET {$PAIRS} WHERE pagename='{$pagename}'";
    } else {
        // do an insert
        // build up the column names and values for the query
        $COLUMNS = "author, created, flags, lastmodified, " . "pagename, refs, version";
        $VALUES = "'{$pagehash['author']}', " . "{$pagehash['created']}, {$pagehash['flags']}, " . "{$pagehash['lastmodified']}, '{$pagehash['pagename']}', " . "'{$pagehash['refs']}', {$pagehash['version']}";
        $query = "INSERT INTO archive ({$COLUMNS}) VALUES({$VALUES})";
    }
    // echo "<p>Query: $query<p>\n";
    // first, insert the metadata
    $retval = msql_query($query, $dbi['dbc']);
    if ($retval == false) {
        printf(gettext("Insert/update into table 'archive' failed: %s"), msql_error());
        print "<br>\n";
    }
    // second, insert the page data
    // remove old data from page_table
    $query = "delete from {$ArchivePageStore['page_table']} where pagename='{$pagename}'";
    // echo "Delete query: $query<br>\n";
    $retval = msql_query($query, $dbi['dbc']);
    if ($retval == false) {
        printf(gettext("Delete on %s failed: %s"), $ArchivePageStore[page_table], msql_error());
        print "<br>\n";
    }
    // insert the new lines
    reset($pagehash["content"]);
    for ($x = 0; $x < count($pagehash["content"]); $x++) {
        $line = addslashes($pagehash["content"][$x]);
        $query = "INSERT INTO {$ArchivePageStore['page_table']} " . "(pagename, lineno, line) " . "VALUES('{$pagename}', {$x}, '{$line}')";
        // echo "Page line insert query: $query<br>\n";
        $retval = msql_query($query, $dbi['dbc']);
        if ($retval == false) {
            printf(gettext("Insert into %s failed: %s"), $ArchivePageStore[page_table], msql_error());
            print "<br>\n";
        }
    }
}
<?php

include "main_function.php";
define('NUMBER_OF_TIPS', 3);
define('NUMBER_OF_NEIGHBOUR_FOR_TOTEM', 6);
DEFINE('NUMBER_OF_NEIGHBOUR', 3);
$db_host = "localhost";
$db_username = "******";
$db_pass = "******";
$db_name = "rted";
$dbhandle = mysql_connect($db_host, $db_username, $db_pass) or die("Unable to connect to MySQL: " . msql_error());
$mysql_rted = mysql_select_db($db_name, $dbhandle) or die("Could not select tips");
//There are 5 tables in the database: building, building_neighbour, building_tips, energy_consumption, tips;
date_default_timezone_set('America/Vancouver');
//sample URL = http://localhost:9999/index.php?building_name=Dene, replace 'Dene' if you want to check other buildings
if (empty($_GET["building_name"])) {
    echo "Please give a building name<br>";
    exit;
}
//1.Get the url and building_name
$building_name = $_GET["building_name"];
//OUTPUT VALUE!!!
$building_id = buildingID($building_name);
$clock = date('H:i A');
//OUTPUT VALUE!!!
$today = get_today_lastweek()[0];
//$lastweek = get_today_lastweek()[1];
$lastweek = date('m/d/Y H:i:s', mktime(16, 45, 0, 1, 4, 2016));
$number_tips = constant('NUMBER_OF_TIPS');
if ($building_name == 'Totem') {
    $number_neighboor = constant('NUMBER_OF_NEIGHBOUR_FOR_TOTEM');