示例#1
0
function sqlQuerySelect($sqlQuery)
{
    $connect = sqlConnect();
    $result = mysqli_query($connect, $sqlQuery);
    $data = mysqli_fetch_all($result, MYSQLI_ASSOC);
    mysqli_close($connect);
    return $data;
}
示例#2
0
文件: common.php 项目: knytrune/ABXD
    $_COOKIE = array_map('AutoDeslash', $_COOKIE);
}
function usectime()
{
    $t = gettimeofday();
    return $t['sec'] + $t['usec'] / 1000000;
}
$timeStart = usectime();
include "version.php";
include "config/salt.php";
include "dirs.php";
include "settingsfile.php";
include "debug.php";
include "mysql.php";
include "config/database.php";
if (!sqlConnect()) {
    die("Can't connect to the board database. Check the installation settings");
}
if (!fetch(query("SHOW TABLES LIKE '{misc}'"))) {
    die(header("Location: install.php"));
}
include "mysqlfunctions.php";
include "settingssystem.php";
Settings::load();
Settings::checkPlugin("main");
include "feedback.php";
include "language.php";
include "write.php";
include "snippets.php";
include "links.php";
class KillException extends Exception
示例#3
0
function install()
{
    global $dblink, $dbserv, $dbuser, $dbpass, $dbname, $dbpref, $dberror, $abxd_version;
    doSanityChecks();
    if (file_exists("config/database.php")) {
        //TODO: Check for errors when parsing this file (It may be corrupted or wrong or whatever.
        //If it fails, fail gracefully and instruct the user to fix or delete database.php
        include "config/database.php";
    } else {
        $dbserv = $_POST['dbserv'];
        $dbuser = $_POST['dbuser'];
        $dbpass = $_POST['dbpass'];
        $dbname = $_POST['dbname'];
        $dbpref = $_POST['dbpref'];
    }
    $convert = $_POST["convert"] == "true";
    $convertFrom = $_POST["convertFrom"];
    $convertDbName = $_POST["convertDbName"];
    $convertDbPrefix = $_POST["convertDbPrefix"];
    if (!sqlConnect()) {
        installationError("Could not connect to the database. Error was: " . $dberror);
    }
    $currVersion = getInstalledVersion();
    if ($currVersion == $abxd_version) {
        installationError("The board is already installed and updated (Database version {$currVersion}). You don't need to run the installer!\n");
    }
    if ($currVersion != -1 && $convert) {
        die("ERROR: You asked to convert a forum database, but an ABXD installation was already found in the installation DB. Converting is only possible when doing a new installation.");
    }
    echo "Setting utf8_unicode_ci collation to the database...\n";
    query("ALTER DATABASE {$dbname} COLLATE utf8_unicode_ci");
    if ($currVersion == -1) {
        echo "Installing database version {$abxd_version}...\n";
    } else {
        echo "Upgrading database from version {$currVersion} to {$abxd_version}...\n";
    }
    upgrade();
    $misc = Query("select * from {misc}");
    if (NumRows($misc) == 0) {
        Query("INSERT INTO `{misc}` (`views`, `hotcount`, `milestone`, `maxuserstext`) VALUES (0, 30, 'Nothing yet.', 'Nobody yet.');");
    }
    Query("UPDATE `{misc}` SET `version` = {0}", $abxd_version);
    if (!is_dir("config")) {
        mkdir("config");
    }
    if ($currVersion == -1) {
        //Stuff to do on new installation (Not upgrade)
        Import("install/smilies.sql");
        if ($convert) {
            runConverter($convertFrom, $convertDbName, $convertPrefix);
        } else {
            Import("install/installDefaults.sql");
        }
        if (file_exists("config/salt.php")) {
            echo "Not generating new salt.php as it's already present...\n";
        } else {
            echo "Generating new salt.php...\n";
            writeConfigSalt();
        }
    }
    if (!file_exists("config/database.php")) {
        writeConfigDatabase();
    }
}
示例#4
0
<?php

// Zlayers' Blog, released under GPL v.3.0. Please see COPYRIGHT for further information.
require_once "backoffice/bases.php";
sqlConnect();
session_start();
function truncate($value, $length, $url)
{
    if (strlen($value) > $length) {
        $value = substr($value, 0, $length);
        $n = 0;
        while (substr($value, -1) != chr(32)) {
            $n++;
            $value = substr($value, 0, $length - $n);
        }
        $value = $value . " ...<a href='{$url}'><em>more</em></a>";
    }
    return $value;
}
$navbar = "<ul>\n                        <li><a href=" . '"' . "index.php?action=home&p=1" . '"' . ">Home</a></li>\n                        <li><a href=" . '"' . "index.php?action=list" . '"' . ">List posts</a></li>\n\t\t\t<li><a href=" . '"' . "index.php?action=about" . '"' . ">About me</a></li>\n                </ul>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta content="text/html" charset="UTF-8"  http-equiv="content-type">
<link href='file.css' type="text/css" rel="stylesheet" />
<title>Homepage</title>
</head>
<body>
示例#5
0
#$sourceName = "source1";
if (!file_exists("../textdb/" . $sourceName . ".sources.json")) {
    bad_request(5);
}
$datasource = file_get_contents("../textdb/" . $sourceName . ".sources.json");
$datasource = json_decode($datasource, true);
$CCConnectionSettings[$sourceName] = $datasource;
## CHECK IF CONNECTED ###################################
if (CCGetParam("connect") == "true") {
    if (isset($_SESSION["CONNECTED"]) and isset($_SESSION["CONNECTED"][$sourceName])) {
        unset($_SESSION["CONNECTED"][$sourceName]);
    }
    $user = CCGetParam("user");
    $password = cryptoJsAesDecrypt($pass_phrase, $_POST["password"]);
    #echo $password;
    sqlConnect($user, $password);
    die;
} else {
    if ($sourceName == "default") {
        #var_dump($_SESSION);
        if (!isset($_SESSION["CONNECTED"]) or !isset($_SESSION["CONNECTED"][$sourceName])) {
            die('{"ERROR" : {"CODE":"2","MESSAGE":"NOT CONNECTED TO \\"DEFAULT\\" DATABASE", "TYPE" : "' . $CCConnectionSettings[$sourceName]["Type"] . '"}}');
        } else {
            # Si se usa la base de datos default, simepre usa el usuario definido en el datasource
            $_SESSION["CONNECTED"][$sourceName]->{"user"} = $CCConnectionSettings[$sourceName]["User"];
            $_SESSION["CONNECTED"][$sourceName]->{"password"} = $CCConnectionSettings[$sourceName]["User"];
        }
    } else {
        if (!isset($_SESSION["CONNECTED"]) or !isset($_SESSION["CONNECTED"][$sourceName])) {
            die('{"ERROR" : {"CODE":"12","MESSAGE":"NOT CONNECTED TO DATABASE ' . $sourceName . '.", "TYPE" : "' . $CCConnectionSettings[$sourceName]["Type"] . '"}}');
        }
<HTML>
<TITLE>Create/Report Resource</TITLE>
<HEAD>

   <?php
      include ('variables.php');
      include ('commonAPIs.php');
      include ('sqlAPI.php');
      include ('phpDebugAPI.php');
      include ('sqlAddData.php');
      include ('sqlGetData.php');
      sqlConnect("root", "root", "PartsDB");

      if (IsSet($_GET['AddMachine']) && $_GET['AddMachine'] == "true") {
        sqlAddMachine();
      } else if (IsSet($_GET['AddSupplier']) && $_GET['AddSupplier'] == "true") {
        sqlAddSupplierFromPost();
      } else if (IsSet($_GET['AddPart']) && $_GET['AddPart'] == "true") {
        sqlAddPart();
      } else if (IsSet($_GET['AddTool']) && $_GET['AddTool'] == "true") {
        sqlAddToolFromPost();
      } else if (IsSet($_GET['UpdateToolUsage']) && $_GET['UpdateToolUsage'] == "true") {
        sqlUpdateToolUsage();
      }

      
      $machineNames = sqlGetMachines();
      $toolPartNumbers = sqlGetTools();
      $insertPartNumbers = sqlGetInserts();
      $toolTypes = sqlGetToolTypes();
      $holderNames = sqlGetHolders();
示例#7
0
function createXML()
{
    $connection = sqlConnect();
    $imp = new DOMImplementation();
    $dtd = $imp->createDocumentType('author', '', 'author.dtd');
    $dom->encoding = 'UTF-8';
    $dom->standalone = false;
    /* Es wird eine XML-Datei aus einer Domstruktur generiert. */
    $dom = $imp->createDocument("", "", $dtd);
    /*if($dom != FALSE){
        return "";
      }*/
    $root = $dom->createElement('authors');
    $dom->appendChild($root);
    $list = FALSE;
    $dataXML = "";
    if ($ergebnis = mysqli_query($connection, "SELECT name, email, telefon, fax FROM autor")) {
        $length = mysqli_num_rows($ergebnis);
        /* Zum identifizieren leerer Anfragen. */
        if ($length == 0) {
            $list = FALSE;
        }
        /* Erstellen der einzlenen Autoren. */
        for ($i = 0; $i < $length; $i += 1) {
            $list = mysqli_fetch_row($ergebnis);
            /* Hinzugüfen der Daten. */
            $node = $dom->createElement("author");
            $root->appendChild($node);
            $elementName = "";
            for ($z = 0; $z < 4; $z += 1) {
                switch ($z) {
                    case 0:
                        $elementName = "name";
                        break;
                    case 1:
                        $elementName = "email";
                        break;
                    case 2:
                        $elementName = "telefon";
                        break;
                    case 3:
                        $elementName = "fax";
                        break;
                }
                $child = $dom->createElement($elementName);
                $node->appendChild($child);
                $child->nodeValue = $list[$z];
            }
        }
        $dataXML = $dom->saveXML();
        mysqli_free_result($ergebnis);
    }
    mysqli_close($connection);
    return $dataXML;
}
示例#8
0
function deleteNews($id)
{
    $connection = sqlConnect();
    $id = mysqli_real_escape_string($id);
    $sql = "DELETE FROM news WHERE id = {$id}";
    mysqli_query($connection, $sql);
}
示例#9
0
<?php

// $Id$ vim:sts=2:et:sw=2
define(CODE_VERSION, "2.03.00-devel");
//echo "Temporarily disabled - we'll be right back!";
//exit (0);
require_once ".config/config.php";
require_once "lib/helpers.php";
require_once "lib/common.php";
require_once "lib/sql.php";
sqlConnect(SQL_CONFIG);
require_once "lib/session.php";
// GLOBALS ...
$Authenticated = false;
$UserName = '******';
$UserID = null;
$UserLevel = 'guest';
session_start();
define("SID_FORM", "<input type=\"hidden\" name=\"" . session_name() . "\" value=\"" . session_id() . "\" />");
if (isset($_POST['logout_x']) || isset($_GET['logout_x'])) {
    session_destroy();
    unset($_SESSION);
    sessionStaticInfo();
}
/////////  added here for php5 ? ... menotume 2006/4/15
sessionStaticInfo();
/////////////////
if (isset($_POST['settheme'])) {
    $theme = $_POST['settheme'];
    setcookie('themename', $theme, time() + 60 * 60 * 24 * 60, '/');
} else {