示例#1
0
 function __construct($userID, DBConnection $DBConnection)
 {
     $query = "Select * FROM users WHERE id={$userID}";
     $results = $DBConnection->queryDB($query);
     if ($this->getDBConnection()->getDBConnection()->errno) {
         trigger_error('Mysql Error (' . $this->getDBConnection()->getDBConnection()->errno . '): ' . $this->getDBConnection()->getDBConnection()->error);
     } else {
         if (is_resource($results)) {
             $row = $results->fetch_assoc();
             $this->userID = $row["id"];
             $this->userName = $row["user_id"];
             $this->password = $row["user_password"];
         } else {
             trigger_error('No Valid Resource For UserID: ' . $userID);
         }
     }
     //$this->accounts = json_decode ( '{"youtube":{"user":"******","password":"******"},"metacafe":{"user":"******","password":"******"},"viddler":{"user":"******","password":"******"},"yahoo":{"user":"******","password":"******"}}', true );
     //var_dump ( $this->accounts );
 }
<?php

require_once 'ConfigParser.php';
require_once 'DBConnection.php';
new ConfigParser();
// Get the configuation details and store them as environment variables
if (isset($_REQUEST['userName']) && isset($_REQUEST['password'])) {
    $DBConnection = new DBConnection(mysqlServerIP2, dbname, dbuser, dbpassword);
    // Check to see if userName Already exist
    $results = $DBConnection->queryDB("Select id from users Where username='******'userName'] . "'");
    if ($results->num_rows > 0) {
        // Username already exists
        echo "Username already exists";
    } else {
        $DBConnection->queryDB("Insert into users (username,password) VALUES ('" . $_REQUEST['userName'] . "','" . $_REQUEST['password'] . "')");
        if ($DBConnection->getDBConnection()->errno) {
            echo "Error creating account for user";
        } else {
            echo "success";
        }
    }
} else {
    echo "usernam and password required";
}
<?php

require_once 'ConfigParser.php';
require_once 'DBConnection.php';
require_once 'UserAccount.php';
new ConfigParser();
// Get the configuation details and store them as environment variables
if (isset($_REQUEST['userName']) && isset($_REQUEST['password'])) {
    $DBConnection = new DBConnection(mysqlServerIP2, dbname, dbuser, dbpassword);
    $results = $DBConnection->queryDB("Select id from users Where username='******'userName'] . "' AND password='******'password'] . "'");
    $row = $results->fetch_assoc();
    $userID = $row["id"];
    $userAccount = new UserAccount($userID, $DBConnection);
    $results = $DBConnection->queryDB("Select location from uploadsites order by location");
    while ($row = $results->fetch_assoc()) {
        $accountName = $row['location'];
        if (isset($_REQUEST[$accountName . '-userName'])) {
            $accountUserName = $_REQUEST[$accountName . '-userName'];
            $accountPassword = $_REQUEST[$accountName . '-password'];
        } else {
            $alteredAccountName = str_replace(".", "_", $accountName);
            //echo("Altered Account: $alteredAccountName\n");
            $accountUserName = $_REQUEST[$alteredAccountName . '-userName'];
            $accountPassword = $_REQUEST[$alteredAccountName . '-password'];
        }
        //echo ("Updating $accountName with Username: "******" Password: "******"\n");
        $userAccount->updateAccount($accountName, $accountUserName, $accountPassword);
    }
    $success = $userAccount->saveAccounts();
    if ($success) {
        echo "Info Has Been Saved";