Exemple #1
0
 function get_table_content($db, $table, $handler)
 {
     $result = mysql_db_query($db, "SELECT * FROM {$table}") or mysql_die();
     $i = 0;
     while ($row = mysql_fetch_row($result)) {
         $table_list = "(";
         for ($j = 0; $j < mysql_num_fields($result); $j++) {
             $table_list .= mysql_field_name($result, $j) . ",";
         }
         $table_list = substr($table_list, 0, -2);
         $table_list .= ")";
         if (isset($GLOBALS["showcolumns"])) {
             $schema_insert = "INSERT INTO {$table} {$table_list} VALUES (";
         } else {
             $schema_insert = "INSERT INTO {$table} VALUES (";
         }
         for ($j = 0; $j < mysql_num_fields($result); $j++) {
             if (!isset($row[$j])) {
                 $schema_insert .= " NULL,";
             } elseif ($row[$j] != "") {
                 $schema_insert .= " '" . addslashes($row[$j]) . "',";
             } else {
                 $schema_insert .= " '',";
             }
         }
         $schema_insert = ereg_replace(",\$", "", $schema_insert);
         $schema_insert .= ")";
         $handler(trim($schema_insert));
         $i++;
     }
     return true;
 }
 function SyncDBContent($db_host = "", $db_name = "", $db_user = "", $db_user = "")
 {
     $this->db_name = $db_name;
     $this->db_link = @mysql_connect($db_host, $db_user, $db_pass) or mysql_die();
     mysql_select_db($this->db_name) or mysql_die();
     $this->db_tables = $this->get_tablenames();
 }
Exemple #3
0
/**
 * Insert datas from one table to another one
 *
 * @param   string  the original insert statement
 *
 * @global  string  the database name
 * @global  string  the original table name
 * @global  string  the target database and table names
 * @global  string  the sql query used to copy the data
 */
function my_handler($sql_insert = '')
{
    global $db, $table, $target;
    global $sql_insert_data;
    $sql_insert = eregi_replace('INSERT INTO (`?)' . $table . '(`?)', 'INSERT INTO ' . $target, $sql_insert);
    $result = mysql_query($sql_insert) or mysql_die('', $sql_insert);
    $sql_insert_data .= $sql_insert . ';' . "\n";
}
 if (!empty($lastname_per)) {
     // Look if contact is in table
     $columns = "*";
     $tables = "contact";
     $where = "conid='{$id}'";
     if (!$db->query("SELECT {$columns} FROM {$tables} WHERE {$where}")) {
         mysql_die($db);
     } else {
         // If contact in table
         if ($db->next_record()) {
             if ($db->f("user") == $auth->auth["uname"] || $perm->have_perm("admin")) {
                 // Insert new contact person
                 $tables = "persons";
                 $set = "conid_per='{$id}',salutation_per='{$salutation_per}',firstname_per='{$firstname_per}',lastname_per='{$lastname_per}',grad_per='{$grad_per}',position_per='{$position_per}',phone_per='{$phone_per}',fax_per='{$fax_per}',email_per='{$email_per}',homepage_per='{$homepage_per}',comment_per='{$comment_per}',status_per='A',modification_per=NOW(),creation_per=NOW()";
                 if (!$db->query("INSERT {$tables} SET {$set}")) {
                     mysql_die($db);
                 }
                 // Select and show new/updated contact with contact persons
                 conbyconid($db, $id);
                 perbyconid($db, $id);
                 if ($ml_notify) {
                     $msg = "insert contact person \"{$firstname_per} {$lastname_per}\" of contact (ID: {$id}) by " . $auth->auth["uname"] . ".";
                     mailuser("admin", "insert contact person", $msg);
                 }
             } else {
                 $be->box_full($t->translate("Error"), $t->translate("Access denied"));
             }
             // If contact is not in table
         } else {
             $be->box_full($t->translate("Error"), $t->translate("Contact") . " (ID: {$id}) " . $t->translate("does not exist") . ".");
         }
Exemple #5
0
<?php

/* $Id: tbl_select.php,v 1.17 2001/08/29 12:00:07 loic1 Exp $ */
/**
 * Gets some core libraries
 */
require './grab_globals.inc.php';
require './lib.inc.php';
/**
 * Not selection yet required -> displays the selection form
 */
if (!isset($param) || $param[0] == '') {
    include './header.inc.php';
    $result = @mysql_list_fields($db, $table);
    if (!$result) {
        mysql_die('', 'mysql_list_fields(' . $db . ', ' . $table . ')');
    } else {
        // Gets the list and number of fields
        $fields_count = mysql_num_fields($result);
        for ($i = 0; $i < $fields_count; $i++) {
            $fields_list[] = mysql_field_name($result, $i);
            $fields_type[] = mysql_field_type($result, $i);
            $fields_len[] = mysql_field_len($result, $i);
        }
        ?>
<form method="post" action="tbl_select.php">
    <input type="hidden" name="server" value="<?php 
        echo $server;
        ?>
" />
    <input type="hidden" name="lang" value="<?php 
Exemple #6
0
            $sql_query .= "\n" . 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD INDEX (' . $index . ')';
            $result = mysql_query('ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD INDEX (' . $index . ')') or mysql_die();
        }
    }
    // end if
    // Builds the uniques statements and updates the table
    $unique = '';
    if (isset($field_unique)) {
        for ($i = 0; $i < count($field_unique); $i++) {
            $j = $field_unique[$i];
            $unique .= backquote($field_name[$j]) . ', ';
        }
        // end for
        $unique = ereg_replace(', $', '', $unique);
        if (!empty($unique)) {
            $sql_query .= "\n" . 'ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD UNIQUE (' . $unique . ')';
            $result = mysql_query('ALTER TABLE ' . backquote($db) . '.' . backquote($table) . ' ADD UNIQUE (' . $unique . ')') or mysql_die();
        }
    }
    // end if
    // Go back to table properties
    $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenAltered;
    include './tbl_properties.php';
    exit;
} else {
    $action = 'tbl_addfield.php';
    include './tbl_properties.inc.php';
    // Diplays the footer
    echo "\n";
    include './footer.inc.php';
}
Exemple #7
0
function dbn($string)
{
    global $database_link;
    mysql_query($string, $database_link) or mysql_die($string);
}
Exemple #8
0
/** Runs '$query' and returns the first (arbitrarily) found row.
 */
function GetRowByQuery($query)
{
    $QueryResult = mysql_query($query) or mysql_die($query);
    $Result = mysql_fetch_array($QueryResult);
    return $Result;
}
Exemple #9
0
    // Adds table type (2 May 2001 - Robbat2)
    if (!empty($tbl_type) && $tbl_type != 'Default') {
        $sql_query .= ' TYPE = ' . $tbl_type;
    }
    if (MYSQL_INT_VERSION >= 32300 && !empty($comment)) {
        $sql_query .= ' comment = \'' . sql_addslashes($comment) . '\'';
    }
    // Executes the query
    $result = mysql_query($sql_query) or mysql_die();
    $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
    include './tbl_properties.php';
    exit;
} else {
    if (isset($num_fields)) {
        $num_fields = intval($num_fields);
    }
    // No table name
    if (!isset($table) || trim($table) == '') {
        mysql_die($strTableEmpty);
    } else {
        if (empty($num_fields) || !is_int($num_fields)) {
            mysql_die($strFieldsEmpty);
        } else {
            $action = 'tbl_create.php';
            include './tbl_properties.inc.php';
            // Diplays the footer
            echo "\n";
            include './footer.inc.php';
        }
    }
}
Exemple #10
0
 function get_table_def($db, $table, $crlf)
 {
     $schema_create = "";
     //$schema_create .= "DROP TABLE IF EXISTS $table;$crlf";
     $schema_create .= "CREATE TABLE {$table} ({$crlf}";
     $result = mysql_db_query($db, "SHOW FIELDS FROM {$table}") or mysql_die();
     while ($row = mysqli_fetch_array($result)) {
         $schema_create .= "   {$row['Field']} {$row['Type']}";
         if (isset($row["Default"]) && (!empty($row["Default"]) || $row["Default"] == "0")) {
             $schema_create .= " DEFAULT '{$row['Default']}'";
         }
         if ($row["Null"] != "YES") {
             $schema_create .= " NOT NULL";
         }
         if ($row["Extra"] != "") {
             $schema_create .= " {$row['Extra']}";
         }
         $schema_create .= ",{$crlf}";
     }
     $schema_create = ereg_replace("," . $crlf . "\$", "", $schema_create);
     $result = mysql_db_query($db, "SHOW KEYS FROM {$table}") or mysql_die();
     while ($row = mysqli_fetch_array($result)) {
         $kname = $row['Key_name'];
         if ($kname != "PRIMARY" && $row['Non_unique'] == 0) {
             $kname = "UNIQUE|{$kname}";
         }
         if (!isset($index[$kname])) {
             $index[$kname] = array();
         }
         $index[$kname][] = $row['Column_name'];
     }
     while (list($x, $columns) = @each($index)) {
         $schema_create .= ",{$crlf}";
         if ($x == "PRIMARY") {
             $schema_create .= "   PRIMARY KEY (" . implode($columns, ", ") . ")";
         } elseif (substr($x, 0, 6) == "UNIQUE") {
             $schema_create .= "   UNIQUE " . substr($x, 7) . " (" . implode($columns, ", ") . ")";
         } else {
             $schema_create .= "   KEY {$x} (" . implode($columns, ", ") . ")";
         }
     }
     $schema_create .= "{$crlf})";
     return stripslashes($schema_create);
 }
Exemple #11
0
 function showRelated($foreign_table = false, $opts = false)
 {
     if (is_array($opts)) {
         extract($opts);
     }
     if ($foreign_table) {
         $sql = " SELECT * FROM {$foreign_table} WHERE {$this->_indexField} = {$this->id} ";
         $result = mysql_db_query($this->_db, $sql) or mysql_die($sql);
         if ($debug) {
             echo "<hr><pre> {$sql} </pre><hr>";
         }
         if ($get_result) {
             return $result;
         }
         // It would be nice to use the object here, and be able to customize with the $this->summary_link function.
         if (class_exists($foreign_table)) {
             while ($row = mysql_fetch_array($result)) {
                 $object = new $table($row[0]);
                 $object->summary_link();
             }
         } else {
             // get the title field
             $sql = "";
         }
     }
 }
 public function exists($id = '')
 {
     $idf = $this->_idField;
     if ($id === '') {
         $id = $this->getId();
     }
     // bail if a lookup would obviously fail
     if (!$this->hasId()) {
         return false;
     }
     $sql = "SELECT `{$this->_idField}` FROM `{$this->_table}` WHERE `{$this->_idField}` = '{$id}'";
     $foundit = false;
     if ($res = mysql_db_query($this->_db, $sql) or mysql_die($sql)) {
         if (mysql_num_rows($res) == 1) {
             $found_id = mysql_result($res, 0, 0);
             if ($found_id == $id) {
                 $foundit = true;
             }
         }
         mysql_free_result($res);
     }
     return $foundit;
 }
Exemple #13
0
 if ($num_dbs) {
     $true_dblist = array();
     for ($i = 0; $i < $num_dbs; $i++) {
         $dblink = @mysql_select_db($dblist[$i]);
         if ($dblink) {
             $true_dblist[] = $dblist[$i];
         }
         // end if
     }
     // end for
     unset($dblist);
     $dblist = $true_dblist;
     unset($true_dblist);
     $num_dbs = count($dblist);
 } else {
     $dbs = mysql_list_dbs() or mysql_die('', 'mysql_list_dbs()', FALSE, FALSE);
     $num_dbs = @mysql_num_rows($dbs);
     $real_num_dbs = 0;
     for ($i = 0; $i < $num_dbs; $i++) {
         $db_name_tmp = mysql_dbname($dbs, $i);
         //echo $db_name_tmp."<br>";
         if ($db_name_tmp != "test") {
             $dblink = @mysql_select_db($db_name_tmp);
             if ($dblink) {
                 $dblist[] = $db_name_tmp;
                 $real_num_dbs++;
             }
         }
     }
     // end for
     $num_dbs = $real_num_dbs;
Exemple #14
0
function get_table_content($src_table, $dest_table, $crlf, $escape, &$stream = null)
{
    $out = '';
    $table_list = '';
    $result = mysql_query("SELECT * FROM {$src_table}") or mysql_die();
    $i = 0;
    $block_size = 100;
    while ($row = mysql_fetch_row($result)) {
        if (empty($table_list)) {
            $table_list = "(";
            for ($j = 0; $j < mysql_num_fields($result); $j++) {
                $table_list .= $escape . mysql_field_name($result, $j) . $escape . ", ";
            }
            $table_list = substr($table_list, 0, -2);
            $table_list .= ")";
        }
        if ($i % $block_size == 0) {
            $schema_insert = ';' . $crlf . 'INSERT INTO ' . $escape . $dest_table . $escape . ' ' . $table_list . ' VALUES' . $crlf . '(';
        } else {
            $schema_insert = ",{$crlf}(";
        }
        for ($j = 0; $j < mysql_num_fields($result); $j++) {
            if (!isset($row[$j])) {
                $schema_insert .= " NULL,";
            } elseif ($row[$j] != "") {
                $schema_insert .= " '" . mysql_real_escape_string($row[$j]) . "',";
            } else {
                $schema_insert .= " '',";
            }
        }
        $schema_insert = ereg_replace(",\$", "", $schema_insert);
        $schema_insert .= ")";
        if (!empty($stream)) {
            fputs($stream, $schema_insert);
        } else {
            $out .= $schema_insert;
        }
        $i++;
    }
    if (!empty($stream)) {
        return true;
    }
    return $out . ';' . $crlf;
}
Exemple #15
0
 /**
  * Outputs the content of a table in CSV format
  *
  * Last revision 14 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the database name
  * @param   string   the table name
  * @param   integer  the offset on this table
  * @param   integer  the last row to get
  * @param   string   the field separator character
  * @param   string   the optionnal "enclosed by" character
  * @param   string   the handler (function) to call. It must accept one
  *                   parameter ($sql_insert)
  *
  * @global  string   whether to obtain an excel compatible csv format or a
  *                   simple csv one
  *
  * @return  boolean always true
  */
 function get_table_csv($db, $table, $limit_from = 0, $limit_to = 0, $sep, $enc_by, $esc_by, $handler)
 {
     global $what;
     // Handles the "separator" and the optionnal "enclosed by" characters
     if (empty($sep) || $what == 'excel') {
         $sep = ';';
     } else {
         if (get_magic_quotes_gpc()) {
             $sep = stripslashes($sep);
         }
         $sep = str_replace('\\t', "\t", $sep);
     }
     if (empty($enc_by) || $what == 'excel') {
         $enc_by = '"';
     } else {
         if (get_magic_quotes_gpc()) {
             $enc_by = stripslashes($enc_by);
         }
         $enc_by = str_replace('&quot;', '"', $enc_by);
     }
     if (empty($esc_by) || $what == 'excel') {
         // double the "enclosed by" character
         $esc_by = $enc_by;
     } else {
         if (get_magic_quotes_gpc()) {
             $esc_by = stripslashes($esc_by);
         }
     }
     // Defines the offsets to use
     if ($limit_from > 0) {
         $limit_from--;
     } else {
         $limit_from = 0;
     }
     if ($limit_to > 0 && $limit_from >= 0) {
         $add_query = " LIMIT {$limit_from}, {$limit_to}";
     } else {
         $add_query = '';
     }
     // Gets the data from the database
     $local_query = 'SELECT * FROM ' . backquote($db) . '.' . backquote($table) . $add_query;
     $result = mysql_query($local_query) or mysql_die('', $local_query);
     // Format the data
     $i = 0;
     while ($row = mysql_fetch_row($result)) {
         @set_time_limit(60);
         $schema_insert = '';
         $fields_cnt = mysql_num_fields($result);
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (!isset($row[$j])) {
                 $schema_insert .= 'NULL';
             } else {
                 if ($row[$j] != '') {
                     // loic1 : always enclose fields
                     if ($what == 'excel') {
                         $row[$j] = ereg_replace("\r(\n)?", "\n", $row[$j]);
                     }
                     $schema_insert .= $enc_by . str_replace($enc_by, $esc_by . $enc_by, $row[$j]) . $enc_by;
                 } else {
                     $schema_insert .= '';
                 }
             }
             if ($j < $fields_cnt - 1) {
                 $schema_insert .= $sep;
             }
         }
         // end for
         $handler(trim($schema_insert));
         ++$i;
     }
     // end while
     return TRUE;
 }
Exemple #16
0
 // this case)
 if ($is_delete && eregi('^DELETE( .+)?( FROM (.+))$', $sql_query, $parts) && !eregi(' WHERE ', $parts[3])) {
     $OPresult = @mysql_query('SELECT COUNT(*) as count' . $parts[2]);
     if ($OPresult) {
         $num_rows = mysql_result($OPresult, 0, 'count');
     } else {
         $num_rows = 0;
     }
 }
 // Executes the query
 $result = @mysql_query($full_sql_query);
 // Displays an error message if required and stop parsing the script
 if (mysql_error()) {
     $error = mysql_error();
     include './header.inc.php';
     mysql_die($error, $full_sql_query);
 }
 // Gets the number of rows affected/returned
 if (!$is_affected) {
     $num_rows = @mysql_num_rows($result);
 } else {
     if (!isset($num_rows)) {
         $num_rows = @mysql_affected_rows();
     }
 }
 // Counts the total number of rows for the same 'SELECT' query without the
 // 'LIMIT' clause that may have been programatically added
 if (empty($sql_limit_to_append)) {
     $SelectNumRows = $num_rows;
 } else {
     if ($is_select) {
Exemple #17
0
<?php

/* $Id: tbl_rename.php,v 1.7 2001/08/22 20:42:51 loic1 Exp $ */
/**
 * Gets some core libraries
 */
require './grab_globals.inc.php';
require './lib.inc.php';
/**
 * A new name has been submitted -> do the work
 */
if (isset($new_name) && trim($new_name) != '') {
    $old_name = $table;
    $table = $new_name;
    include './header.inc.php';
    mysql_select_db($db);
    $local_query = 'ALTER TABLE ' . backquote($old_name) . ' RENAME ' . backquote($new_name);
    $result = mysql_query($local_query) or mysql_die('', $local_query);
    $message = sprintf($strRenameTableOK, $old_name, $table);
    $reload = 'true';
} else {
    include './header.inc.php';
    mysql_die($strTableEmpty);
}
/**
 * Back to the calling script
 */
require './tbl_properties.php';
Exemple #18
0
     #delta bomb
     #clear all shields on all ships before we start.
     db("select s.ship_id from {$db_name}_ships s, {$db_name}_users u where s.location = '{$user['location']}' && u.login_id\t!= 1 && s.ship_id > 1 && s.login_id = u.login_id && u.turns_run > '{$turns_safe}'");
     while ($target_ship = dbr(1)) {
         dbn("update {$db_name}_ships set shields = 0 where ship_id = '{$target_ship['ship_id']}'");
     }
     $target_ship = "";
     $bomb_damage = 5000;
 }
 if ($star['event_random'] == 2) {
     $bomb_damage *= 3;
 }
 $ship_counter = 0;
 $dam_victim = array();
 $destroyed_ships = 0;
 $lastresort = mysql_query("select s.fighters,s.shields,s.ship_id,s.metal,s.fuel,s.location,s.login_id,s.class_name,s.ship_name,s.point_value,u.login_name from {$db_name}_ships s,{$db_name}_users u where s.location = '{$user['location']}' && s.ship_id > '1' && s.login_id >'1' && s.login_id = u.login_id && u.turns_run >= '{$turns_safe}'") or mysql_die("Bombs are messed up.");
 $elim = 0;
 #loop through players to damage.
 while ($target_ship = mysql_fetch_array($lastresort)) {
     #db("select login_name,login_id,ship_id from ${db_name}_users where login_id = '$target_ship[login_id]'");
     #$target = dbr();
     $ship_counter++;
     $temp121 = 0;
     $temp121 = damage_ship($bomb_damage, 0, 0, $user, $target_ship, $target_ship);
     #Used to limit messages sent, so each player only gets 1 message.
     $dam_victim[$target_ship['login_id']] .= "\n<br /><b class='b1'>{$target_ship['ship_name']}</b> ({$target_ship['class_name']})";
     if ($temp121 > 0) {
         $dam_victim[$target_ship['login_id']] .= $st[1085];
         $elim++;
     }
 }
Exemple #19
0
if (!empty($db)) {
    $db_start = $db;
}
// loic1: lib.inc.php will be loaded by header.inc.php
//require('./lib.inc.php');
require './header.inc.php';
/**
 * Get the list and number of available databases.
 * Skipped if no server selected: in this case no database should be displayed
 * before the user choose among available ones at the welcome screen.
 */
if ($server > 0) {
    //<
    // Get the valid databases list
    $num_dbs = count($dblist);
    $dbs = @mysql_list_dbs() or mysql_die('', 'mysql_list_dbs()');
    while ($a_db = mysql_fetch_object($dbs)) {
        if (!$num_dbs) {
            $dblist[] = $a_db->Database;
            //<
        } else {
            $true_dblist[$a_db->Database] = '';
            //<
        }
    }
    if ($num_dbs && empty($true_dblist)) {
        $dblist = array();
    } else {
        if ($num_dbs) {
            for ($i = 0; $i < $num_dbs; $i++) {
                if (isset($true_dblist[$dblist[$i]])) {
Exemple #20
0
 $rs_usr = mysql_query($local_query, $stdlink) or mysql_die('', $local_query, FALSE);
 $result_usr = mysql_fetch_array($rs_usr);
 $create = $result_usr['Create_priv'] == 'Y';
 $db_to_create = '';
 // Does user have Create priv on a inexistant db?
 // if yes, show him in the dialog the first inexistant db name that we
 // find, in most cases it's probably the one he just dropped :)
 // (Note: we only get here after a browser reload, I don't know why)
 if (!$create) {
     $userlink = @mysql_connect($cfgServer['host'] . $server_port . $server_socket, $cfgServer['user'], $cfgServer['password']);
     if ($userlink == FALSE) {
         $local_query = 'mysql_connect(' . $cfgServer['host'] . $server_port . $server_socket . ', ' . $cfgServer['user'] . ', ' . $cfgServer['password'] . ')';
         mysql_die('', $local_query, FALSE, FALSE);
     }
     $local_query = 'SELECT Db FROM mysql.db WHERE User = \'' . sql_addslashes($cfgServer['user']) . '\'';
     $rs_usr = mysql_query($local_query, $stdlink) or mysql_die('', $local_query, FALSE);
     while ($row = mysql_fetch_array($rs_usr)) {
         if (!mysql_select_db($row['Db'], $userlink)) {
             $db_to_create = $row['Db'];
             $create = TRUE;
             break;
         }
     }
 }
 // The user is allowed to create a db '
 if ($create) {
     echo "\n";
     ?>
 <!-- db creation form -->
 <tr>
     <td valign="baseline"><img src="images/item.gif" width="7" height="7" alt="item" /></td>
Exemple #21
0
function db_m($string)
{
    global $db_maint_func_query, $database_link;
    $db_maint_func_query = mysql_query($string, $database_link) or mysql_die($string);
}
Exemple #22
0
                        $set = "category='{$new_category}'";
                        $where = "type='{$type}' AND category='{$category}'";
                        if (!$dbcat->query("UPDATE {$tables} SET {$set} WHERE {$where}")) {
                            mysql_die($dbcat);
                        } else {
                            $bx->box_full($t->translate("Administration"), $t->translate("Category") . " {$category} " . $t->translate("has been renamed to") . " {$new_category}");
                        }
                    }
                    break;
                case "del":
                    if ($dbcat->num_rows() < 1) {
                        $be->box_full($t->translate("Error"), $t->translate("Category") . " {$category} " . $t->translate("does not exist"));
                    } else {
                        $where = "type='{$type}' AND category='{$category}'";
                        if (!$dbcat->query("DELETE FROM {$tables} WHERE {$where}")) {
                            mysql_die($dbcat);
                        } else {
                            $bx->box_full($t->translate("Administration"), $t->translate("Category") . " {$category} " . $t->translate("has been deleted"));
                        }
                    }
                    break;
                default:
            }
        }
    } else {
        $be->box_full($t->translate("Error"), $t->translate("Parameter missing"));
    }
} else {
    $be->box_full($t->translate("Error"), $t->translate("Access denied"));
}
?>
Exemple #23
0
/**
 * Checks whether the current user is a super-user or not
 *
 * @return  boolean  true as soon as the current user is super-user, no return
 *                   else
 *
 * @access	private
 */
function check_rights()
{
    $result = @mysql_query('USE mysql');
    if (mysql_error()) {
        mysql_die($GLOBALS['strNoRights']);
    }
    return true;
}
Exemple #24
0
        $show_comment = '';
    }
}
// 2. Get table keys and retains them
$local_query = 'SHOW KEYS FROM ' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
$primary = '';
while ($row = mysql_fetch_array($result)) {
    $ret_keys[] = $row;
    if ($row['Key_name'] == 'PRIMARY') {
        $primary .= $row['Column_name'] . ', ';
    }
}
// 3. Get fields
$local_query = 'SHOW FIELDS FROM ' . backquote($table);
$result = mysql_query($local_query) or mysql_die('', $local_query);
/**
 * Displays the table structure ('show table' works correct since 3.23.03)
 */
?>



<!-- TABLE INFORMATIONS -->
<table border="<?php 
echo $cfgBorder;
?>
">
<tr>
    <th><?php 
echo ucfirst($strField);
Exemple #25
0
                     // Move uploaded logo to logo directory
                     if (!empty($logo_name)) {
                         $to = $sys_logo_dir . $db->f("entid") . "ent_" . basename($logo_name);
                         if (!copy($logo, $to)) {
                             $be->box_full($t->translate("Error"), $t->translate("Unable to copy logofile to logo directory"));
                         }
                         if (!chmod($to, 0666)) {
                             $be->box_full($t->translate("Error"), $t->translate("Unable to change logofile mode"));
                         }
                     }
                     // Insert new counters
                     $dbcnt = new DB_SourceBiz();
                     $tables = "counter";
                     $set = "entid=" . $db->f("entid");
                     if (!$dbcnt->query("INSERT {$tables} SET {$set}")) {
                         mysql_die($dbcnt);
                     } else {
                         // Select and show new enterprise with counters
                         entbyentid($db, $db->f("entid"));
                         if ($ml_notify) {
                             $msg = "insert enterprise {$name} by " . $auth->auth["uname"] . ".";
                             mailuser("admin", "insert enterprise", $msg);
                         }
                     }
                 }
             }
         }
     }
 } else {
     $be->box_full($t->translate("Error"), $t->translate("No Short Profile specified"));
 }
Exemple #26
0
<?php

/* $Id: db_create.php,v 1.8 2001/08/22 20:42:51 loic1 Exp $ */
/**
 * Gets some core libraries
 */
require './grab_globals.inc.php';
require './header.inc.php';
/**
 * Executes the db creation sql query
 */
$local_query = 'CREATE DATABASE ' . backquote($db);
$result = mysql_query('CREATE DATABASE ' . backquote($db)) or mysql_die('', $local_query, FALSE);
/**
 * Displays the result and moves back to the calling page
 */
$message = $strDatabase . ' ' . htmlspecialchars($db) . ' ' . $strHasBeenCreated;
require './db_details.php';
Exemple #27
0
<?php

header("Content-type: text/xml");
print "<?xml version='1.0' encoding=\"ISO-8859-1\" ?>\r\n<main>\n";
$login_id = $_GET['login_id'];
$game = $_GET['game'];
if ($login_id && $login_id != 'undefined' && $game) {
    include "games/config.dat.php";
    include "includes/{$game}" . "_vars.inc.php";
    $midx = $GAME_VARS['uv_size_x_width'] / 2;
    $midy = $GAME_VARS['uv_size_y_height'] / 2;
    $database_link = @mysql_connect(DATABASE_HOST, DATABASE_USER, DATABASE_PASSWORD) or write_to_error_log("No connection to the Database could be created.<p />The following error was reported:<br /><b>" . mysql_error() . "</b>");
    mysql_select_db(DATABASE, $database_link) or mysql_die("");
    $resultat = mysql_query("select explored_sys, location from {$game}" . "_users where login_id={$login_id}");
    $user = mysql_fetch_array($resultat);
    $etoiles = explode(',', $user['explored_sys']);
    foreach ($etoiles as $etoile) {
        $resultat2 = mysql_query("select * from {$game}" . "_stars where star_id={$etoile}");
        $origine = mysql_fetch_array($resultat2);
        for ($i = 1; $i <= 7; $i++) {
            $type_lien = '';
            if ($origine['link_' . $i]) {
                // lien normal
                $resultat3 = mysql_query("select * from {$game}" . "_stars where star_id=" . $origine['link_' . $i]);
                $destination = mysql_fetch_array($resultat3);
                $type_lien = "normal";
            } elseif ($i == 7 && $origine['wormhole']) {
                // lien wormhole
                $resultat3 = mysql_query("select * from {$game}" . "_stars where star_id=" . $origine['wormhole']);
                $destination = mysql_fetch_array($resultat3);
                if ($origine['star_id'] == $destination['wormhole']) {
Exemple #28
0
    $valuelist = ereg_replace(', $', '', $valuelist);
    $query = 'INSERT INTO ' . backquote($table) . ' (' . $fieldlist . ') VALUES (' . $valuelist . ')';
    $message = $strInsertedRows . '&nbsp;';
}
// end row insertion
/**
 * Executes the sql query and get the result, then move back to the calling
 * page
 */
mysql_select_db($db);
$sql_query = $query;
$result = mysql_query($query);
if (!$result) {
    $error = mysql_error();
    include './header.inc.php';
    mysql_die($error);
} else {
    if (file_exists('./' . $goto)) {
        if ($goto == 'db_details.php' && !empty($table)) {
            unset($table);
        }
        include './header.inc.php';
        if (@mysql_affected_rows()) {
            $message .= @mysql_affected_rows();
        } else {
            $message = $strModifications;
        }
        include './' . ereg_replace('\\.\\.*', '.', $goto);
    } else {
        //header('Location: ' . $cfgPmaAbsoluteUri . $goto);
    }
Exemple #29
0
                    }
                }
                if (!isset($reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)', $a_sql_query)) {
                    $reload = 'true';
                }
            }
            // end for
        }
    }
    // end else if
}
// end if
/**
 * Go back to the calling script
 */
require './header.inc.php';
if (isset($my_die)) {
    mysql_die('', $my_die);
}
// Be nice with bandwidth...
if ($sql_file != 'none' && $pieces_count > 10) {
    $sql_query = '';
    unset($sql_query_cpy);
    $message = "{$strSuccess}&nbsp:<br />{$strTheContent} ({$pieces_count} {$strInstructions})&nbsp;";
} else {
    $message = $strSuccess;
}
if (!isset($goto) || $goto != 'db_details.php' && $goto != 'tbl_properties.php') {
    $goto = 'db_details.php';
}
require './' . $goto;