public function __construct()
 {
     $dbinfo = MyDatabase::getConnectionDetails();
     $host = $dbinfo["host"];
     $database = $dbinfo["database"];
     $username = $dbinfo["username"];
     $password = $dbinfo["password"];
     $db = new MyDatabase($host, $database, $username, $password);
     $this->conn = $db->get_connection();
 }
示例#2
0
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new static();
     }
     return self::$instance;
 }
示例#3
0
 /**
  * Opens a connection to the database.
  */
 public static function connect()
 {
     if (!self::isConfigured()) {
         return;
     }
     include self::CONFIG;
     self::$connection = @mysql_connect($server, $username, $password);
     if (!self::$connection) {
         return;
     }
     if (!mysql_select_db($database)) {
         /* fail */
         $err_num = mysql_errno();
         switch ($err_num) {
             case 1049:
                 // database not found
                 mysql_query('create database ' . $database . ';');
                 mysql_select_db($database);
                 break;
                 /* else */
                 echo 'Failed to create database.';
                 exit;
         }
     }
 }
示例#4
0
 public function __construct()
 {
     if (MyDatabase::isConfigured()) {
         MyDatabase::connect();
         $this->querySize();
     }
     $this->template = HtmlTemplate::fromFile('index.html');
     $this->user = new User();
     $this->template->assign('user');
 }
function setstatus($data, $id = "")
{
    $dbase = new MyDatabase(DBNAME, DBHOST, DBUSER, DBPASS);
    $ids = explode(',', $_POST['id']);
    for ($i = 0; $i < count($ids); $i++) {
        $result = $dbase->_query("SELECT * FROM " . TBLPREFIX . "subscribers where id=\"{$ids[$i]}\"");
        $recrow = mysql_fetch_row($result);
        $stat = $recrow[15];
        unset($recrow);
        if ($stat == 1) {
            $stat = 0;
        } else {
            $stat = 1;
        }
        $in = "update " . TBLPREFIX . "subscribers set status = {$stat}\n        where id=\"{$ids[$i]}\"";
        $result = $dbase->_query($in);
    }
    if ($result) {
    } else {
    }
    unset($dbase);
}
示例#6
0
  </div>
  
  <?php 
if (isset($_POST["submit"])) {
    $username = trim($_POST["username"]);
    $password = trim($_POST["password"]);
    if (strlen($username) == 0 || strlen($password) == 0) {
        echo '<script type="text/javascript">' . '$(".error-message").removeClass("hidden");' . '$(".error-message p strong").html("You\'ve got an empty field");' . 'setTimeout(function() {$(".error-message").hide();}, 3000);' . '</script>';
        return;
    }
    $dbinfo = MyDatabase::getConnectionDetails();
    $host = $dbinfo["host"];
    $database = $dbinfo["database"];
    $db_username = $dbinfo["username"];
    $db_password = $dbinfo["password"];
    $db = new MyDatabase($host, $database, $db_username, $db_password);
    $conn = $db->get_connection();
    $query = "SELECT * FROM authentication WHERE username = ?";
    $stmt = $conn->prepare($query);
    $stmt->bindParam("1", $username);
    $stmt->execute();
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    /*echo(var_dump($result));*/
    if ($result == false) {
        echo '<script type="text/javascript">' . '$(".error-message").removeClass("hidden");' . '$(".error-message p strong").html("Your username or password is wrong");' . 'setTimeout(function() {$(".error-message").hide();}, 3000);' . '</script>';
    } else {
        if (password_verify($password, $result["password"])) {
            if ($result["locked"] == 0) {
                $_SESSION["auth"] = true;
                $_SESSION["role"] = $result["role"];
                $_SESSION["locked"] = $result["locked"];
            $fp = fopen('mysql.php', 'w');
            $filedata = '<?php $server = \'' . $_POST['server'] . '\'; $username = \'' . $_POST['username'] . '\'; $password = \'' . $_POST['password'] . '\'; $database = \'' . $_POST['database'] . '\'; ?>';
            fwrite($fp, $filedata, strlen($filedata));
            fclose($fp);
            chmod('mysql.php', 0400);
            mkdir(Image::PATH, 0755);
            mkdir(Statistics::STATS_DIR, 0755);
            $error = '';
        } else {
            $error = 'no file';
        }
    }
}
if ($error == '') {
    require_once 'tools/MyDatabase.php';
    MyDatabase::connect();
    $table_books = mysql_query('describe books;');
    if ($table_books == null) {
        // no table, so create
        $new_table = 'CREATE TABLE `books` (';
        $new_table .= '`id` bigint(20) NOT NULL auto_increment,';
        $new_table .= '`auth_key` varchar(32) NOT NULL,';
        $new_table .= '`mail` varchar(128) NOT NULL,';
        $new_table .= '`created` datetime NOT NULL,';
        $new_table .= '`expires` datetime NOT NULL,';
        $new_table .= '`expired` datetime,';
        $new_table .= '`author` varchar(128) NOT NULL,';
        $new_table .= '`title` varchar(128) NOT NULL,';
        $new_table .= '`year` decimal(4,0) NOT NULL,';
        $new_table .= '`price` decimal(5,2) NOT NULL,';
        $new_table .= '`isbn` varchar(17) NOT NULL,';
示例#8
0
function getProfileDetails()
{
    $detailsJSON = array();
    $JSONData = json_decode(file_get_contents('php://input'));
    $breakerID = $JSONData->breaker_id;
    $dbase = new MyDatabase(DBNAME, DBHOST, DBUSER, DBPASS);
    $query = "SELECT B.id,B.socialid,B.mobile,B.country,B.name,B.username,B.email,B.profileimage,B.latitude,\n             B.longitude,B.dateregistered,B.dateofbirth,B.about,B.gender,B.city,B.lang,\n             (SELECT name_en FROM breakcategory WHERE id=(SELECT breakid FROM breaks WHERE pid={$breakerID} LIMIT 1)) as break_category_en,\n             (SELECT name_ar FROM breakcategory WHERE id=(SELECT breakid FROM breaks WHERE pid={$breakerID} LIMIT 1)) as break_category_ar    \n             FROM breakers as B WHERE B.id={$breakerID}";
    $result = $dbase->_query($query);
    while ($row = mysql_fetch_array($result)) {
        $details = array("id" => $row['id'], "socialid" => $row['socialid'], "mobile" => $row['mobile'], "country" => $row['country'], "name" => $row['name'], "username" => $row['username'], "email" => $row['email'], "breaker_image" => UPLOAD_SERVER . "/resources/images/profile/" . $row['profileimage'], "latitude" => $row['latitude'], "longitude" => $row['longitude'], "latitude" => $row['latitude'], "dateregistered" => $row['dateregistered'], "dateofbirth" => $row['dateofbirth'], "about" => $row['about'], "gender" => $row['gender'], "city" => $row['city'], "lang" => $row['lang'], "break_category_en" => $row['break_category_en'], "break_category_ar" => $row['break_category_ar']);
        $detailsJSON[] = $details;
    }
    giveResponseToApp($detailsJSON);
}
示例#9
0
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/*
 * This script connects to the database or exits by sending an error message.
 * If a connection is etablished, old database entries will be deleted.
 */
require_once 'tools/MyDatabase.php';
require_once 'tools/Output.php';
require_once 'text/Template.php';
$templateText = <<<EOT
    <h2>Störung</h2>
    <div class="text">
    Leider besteht zur Zeit keine Verbindung zur Datenbank. :-(
    </div>
EOT;
MyDatabase::connect();
if (!MyDatabase::getConnection()) {
    $tmpl = new Template($templateText);
    $output = new Output();
    $output->send($tmpl->result());
    exit;
}
示例#10
0
<?php

include_once "php_class/auth.php";
include "/configs/db.php";
$page_title = "Application Setting";
include_once "layout/header.php";
$role = $_SESSION["role"];
if ($role === "normal") {
    header("LOCATION:index.php");
}
$dbinfo = MyDatabase::getConnectionDetails();
$host = $dbinfo["host"];
$database = $dbinfo["database"];
$db_username = $dbinfo["username"];
$db_password = $dbinfo["password"];
$db = new MyDatabase($host, $database, $db_username, $db_password);
?>

<div>
    <div class="row">
        <!--shows result of any operation carried on this page-->
        <div class="hidden alert" id="alert-message"><p class="text-center"><strong>Successful</strong></p></div>
    </div>
    <div class="row">
        <div class="col-xs-12 col-md-6">
            <form role="form" class="form-horizontal" id="addUser" method="post" action="<?php 
$_SERVER['PHP_SELF'];
?>
">
                <fieldset>
                    <legend>Add New User</legend>