Ejemplo n.º 1
0
 function __construct()
 {
     global $prefix;
     $db_connection = new dbConnection();
     $this->link = $db_connection->connect();
     ini_set("soap.wsdl_cache_enabled", "0");
     self::$sms_client = new SoapClient('http://87.107.121.54/post/Send.asmx?wsdl', array('encoding' => 'UTF-8'));
     $this->parameters['username'] = "";
     $this->parameters['password'] = "";
     $this->parameters['from'] = "";
     return $this->link;
 }
 public static function getInstance($logStream, $checkVersion = true)
 {
     if (!self::$conn) {
         global $config;
         // If we have a socket set - use it..
         if (isset($config['DB']['socket'])) {
             self::$conn = new dbConnection($config['DB']['host'], $config['DB']['user'], $config['DB']['password'], $config['DB']['schema'], $config['DB']['port'], $config['DB']['socket']);
             // If no socket setup - just use TCP settings
         } else {
             self::$conn = new dbConnection($config['DB']['host'], $config['DB']['user'], $config['DB']['password'], $config['DB']['schema'], $config['DB']['port']);
         }
         // Check for error connecting...
         // We use mysqli_connect_error and errno instead of $conn->connect_error / errno because it was broken before PHP 5.2.9 and 5.3.0
         if (mysqli_connect_error()) {
             throw new Exception('dbConnection->getInstance: ' . "Error: Can't connect to MySQL (" . mysqli_connect_errno() . ") - please check that settings in config.php are correct." . self::$conn->connect_error);
         }
     } else {
         // Test the connection -- throw it away and reconnect if it is bad.
         if (!self::$conn->ping()) {
             self::$conn = false;
             return self::getInstance($logStream, $checkVersion);
         }
     }
     self::$conn->setLogStream($logStream);
     // If this db connection getter is configged to check the version (default is to do so), then check it.
     if ($checkVersion) {
         self::$conn->checkSchemaVersion();
     }
     return self::$conn;
 }
Ejemplo n.º 3
0
 private static function Connect()
 {
     if (!isset(self::$connection)) {
         self::$connection = new mysqli('localhost', 'root', '123456', 'fedifa_wish');
         if (self::$connection->connect_error) {
             die('Connect Error (' . self::$connection->connect_errno . ') ' . self::$connection->connect_error);
         }
     }
 }
 public function SignUpUser()
 {
     $user = addslashes(trim($_POST['username']));
     $psw = addslashes(trim($_POST['password']));
     $fname = addslashes(trim($_POST['fname']));
     $lname = addslashes(trim($_POST['lname']));
     $email = addslashes(trim($_POST['email']));
     $sex = addslashes(trim($_POST['sex']));
     $birthday = addslashes(trim($_POST['birthday']));
     $phone = addslashes(trim($_POST['phone']));
     $name = addslashes(trim($_POST['nameshow']));
     $address = addslashes(trim($_POST['address']));
     $district = addslashes(trim($_POST['district']));
     $province = addslashes(trim($_POST['province']));
     $postcode = addslashes(trim($_POST['postcode']));
     $sql = "INSERT INTO member ";
     $sql .= " VALUES(0, '{$user}' , '{$psw}' , '{$fname}' , '{$lname}' , '{$email}' , '{$sex}' , '{$birthday}' , '{$phone}')";
     $db = new dbConnection();
     $this->callback = $db->insert($sql);
 }
Ejemplo n.º 5
0
 function processCallback()
 {
     $this->consumer = new Zend_OAuth_Consumer($this->configuration);
     if (!empty($_GET) && isset($_SESSION['EPICOLLECT_TOKEN'])) {
         $token = $this->consumer->getAccessToken($_GET, unserialize($_SESSION['EPICOLLECT_TOKEN']));
         $_SESSION['EPICOLLECT_ACCESS_TOKEN'] = serialize($token);
         $_SESSION['EPICOLLECT_TOKEN'] = null;
         $db = new dbConnection();
         $res = $db->do_query("CALL setOAuthLoginDetails('{$this->provider}', '{$token->user_id}', '{$token->screen_name}', '{$_SESSION['EPICOLLECT_TOKEN']}', '{$_SESSION['EPICOLLECT_ACCESS_TOKEN']}', '" . session_id() . "')");
         if ($res === true) {
             if ($arr = $db->get_row_array()) {
                 $_SESSION["EcUserId"] = $arr["EcUserId"];
                 $_SESSION["newUser"] = $arr["newUser"];
             }
         } else {
             throw new OAuthException(500, $res);
         }
     } else {
         exit('Invalid callback request. Oops. Sorry.');
     }
 }
 function getInfo()
 {
     global $config;
     if (!is_numeric($this->id)) {
         throw new Exception('backupStrategy->getInfo: ' . "Error: The ID for this object is not an integer.");
     }
     $conn = dbConnection::getInstance($this->log);
     $sql = "SELECT * FROM backup_strategies WHERE backup_strategy_id=" . $this->id;
     if (!($res = $conn->query($sql))) {
         throw new Exception('backupStrategy->getInfo: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     $info = $res->fetch_array();
     return $info;
 }
Ejemplo n.º 7
0
 function setKilled($bool = true)
 {
     if (!is_numeric($this->id)) {
         throw new Exception('backupJob->setKilled: ' . "Error: The ID for this object is not an integer.");
     }
     $conn = dbConnection::getInstance($this->log);
     if ($bool) {
         $killed = 1;
     } else {
         $killed = 0;
     }
     $sql = "UPDATE backup_jobs SET killed = " . $killed . " WHERE backup_job_id=" . $this->id;
     if (!$conn->query($sql)) {
         throw new DBException('backupJob->setKilled: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     return;
 }
 public function SignUpUser()
 {
     $user = addslashes(trim($_POST['username']));
     $psw = addslashes(trim($_POST['password']));
     $fname = addslashes(trim($_POST['fname']));
     $lname = addslashes(trim($_POST['lname']));
     $email = addslashes(trim($_POST['email']));
     $birthday = addslashes(trim($_POST['birthday']));
     $phone = addslashes(trim($_POST['phone']));
     $name = addslashes(trim($_POST['nameshow']));
     $address = addslashes(trim($_POST['address']));
     $district = addslashes(trim($_POST['district']));
     $province = addslashes(trim($_POST['province']));
     $postcode = addslashes(trim($_POST['postcode']));
     $sqlProvince = "select PROVINCE_NAME from province where PROVINCE_ID = '" . $province . "'";
     $result = mysqli_query(parent::getLink(), $sqlProvince);
     $pro = "";
     while ($data = mysqli_fetch_array($result)) {
         $pro = $data['PROVINCE_NAME'];
     }
     $address .= " อ." . $district . " จ." . $pro;
     //$pattern = "/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{8,16}$/";
     $pattern = "/^(?=.*\\d)(?=.*[a-zA-Z])(?=.*[0-9])\\w{8,16}\$/";
     if (!preg_match($pattern, $psw)) {
         echo "not match";
         exit;
     }
     $sql = "INSERT INTO user ";
     $sql .= " VALUES(0, '{$user}' , '{$psw}' , 'member' , '{$fname}' , '{$lname}' , '{$email}' , '{$birthday}' ,'{$address}','{$phone}');";
     //$select = "select username,password from user where username = '******' AND password = '******'";
     //$r_s = mysqli_query(parent::getLink(), $select);
     $rs = mysqli_query(parent::getLink(), $sql);
     if ($rs) {
         echo "success";
         exit;
     } else {
         echo "error";
         exit;
     }
 }
Ejemplo n.º 9
0
<?php

session_start();
$action = '';
if (isset($_GET['act'])) {
    $action = $_GET['act'];
}
if ($action == "all") {
    require_once 'dbConnection.php';
    require_once 'wishClass.php';
    $connection = new dbConnection();
    $status = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['status']));
    $owner = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['owner']));
    $performer = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['performer']));
    $moneyFrom = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['moneyFrom']));
    $moneyTo = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['moneyTo']));
    $pointsFrom = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['pointsFrom']));
    $pointsTo = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['pointsTo']));
    $rankFrom = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['rankFrom']));
    $rankTo = preg_replace("/[^0-9,.]/", "", $connection->escape($_POST['rankTo']));
    $wishes = wishClass::selectAll($status, $owner, $performer, $moneyFrom, $moneyTo, $pointsFrom, $pointsTo, $rankFrom, $rankTo);
    if (!isset($_SESSION['count'])) {
        $_SESSION['count'] = 0;
    }
    foreach ($wishes as $wish) {
        if (!file_exists("images/profiles/{$wish->ownerId}.jpg")) {
            $profileImage = 'not-found.png';
        } else {
            $profileImage = $wish->ownerId . '.jpg' . '?' . time();
        }
        if ($wish->status == 0) {
Ejemplo n.º 10
0
<?php

session_start();
require_once 'dbConnection.php';
$connection = new dbConnection();
if (isset($_SESSION['UserID']) && $_SESSION['UserID'] != 0) {
    if ($_POST['act'] == 'plus') {
        $wishID = mysqli_real_escape_string($mysqli, $_POST['wishID']);
        $connection->insert("REPLACE INTO `WishRating` SET `WishID` = " . $_POST['wishID'] . ", `UserID`=" . $_SESSION['UserID'] . ", `PlusMinus`=1");
    } elseif ($_POST['act'] == 'minus') {
        $connection->insert("REPLACE INTO `WishRating` SET `WishID` = " . $_POST['wishID'] . ", `UserID`=" . $_SESSION['UserID'] . ", `PlusMinus`=0");
    } elseif ($_POST['act'] == 'setNull') {
        $connection->insert("DELETE FROM `WishRating` WHERE `WishID` = " . $_POST['wishID'] . " AND `UserID`=" . $_SESSION['UserID']);
    }
    echo true;
} else {
    echo false;
}
Ejemplo n.º 11
0
 /**
  * QueryBuilder::getCount()
  * 
  * @return
  */
 function getCount()
 {
     $where = sizeof($this->wheres) > 0 ? ' WHERE ' . implode(" \n AND \n\t", $this->wheres) : '';
     $order = sizeof($this->orders) > 0 ? ' ORDER BY ' . implode(", ", $this->orders) : '';
     $group = sizeof($this->groups) > 0 ? ' GROUP BY ' . implode(", ", $this->groups) : '';
     $query = "SELECT count(*) FROM \n\t" . $this->class->databaseInfo->table . "\n " . implode("\n ", $this->joins) . $where . ' ' . $group . ' ' . $order . ' ';
     return dbConnection::getInstance($this->class->databaseInfo->connection)->fetchOne($query);
 }
 function destroy()
 {
     // Validate this...
     if (!is_numeric($this->id)) {
         throw new Exception('scheduledBackup->destroy: ' . "Error: The ID for this object is not an integer.");
     }
     $queueManager = new queueManager();
     $queueManager->setLogStream($this->log);
     // We need to take over all queues for this backup and make sure nothing is running.
     $queues = array('scheduledBackup:' . $this->id, 'retentionApply:' . $this->id, 'postProcess:' . $this->id);
     foreach ($queues as $queue) {
         $ticket = $queueManager->getTicketNumber($queue);
         if (!$queueManager->checkFrontOfQueue($queue, $ticket)) {
             throw new ProcessingException("Error: Cannot remove the Scheduled Backup Task as it is currently running.");
         }
     }
     // Check to see if anything is running for this scheduledBackup
     $runningBackupGetter = new runningBackupGetter();
     $runningBackupGetter->setLogStream($this->log);
     $runningBackups = $runningBackupGetter->getByScheduledBackup($this);
     if (sizeOf($runningBackups) > 0) {
         throw new ProcessingException("Error: Cannot remove the Scheduled Backup Task as it is currently running.");
     }
     // Get all snapshots and destroy them..
     $groups = $this->getSnapshotGroupsNewestToOldest();
     foreach ($groups as $group) {
         $snapshots = $group->getAllSnapshotsNewestToOldest();
         foreach ($snapshots as $snapshot) {
             $snapshot->destroy();
         }
     }
     // If we have a materialized snapshot - destroy that too
     if ($latestMaterialized = $this->getMostRecentCompletedMaterializedSnapshot()) {
         $latestMaterialized->destroy();
     }
     $conn = dbConnection::getInstance($this->log);
     // Remove DB the entries for this scheduledBackup
     $sql = "DELETE sb.*, sbp.* FROM scheduled_backups sb JOIN scheduled_backup_params sbp USING (scheduled_backup_id) WHERE scheduled_backup_id = " . $this->id;
     if (!$conn->query($sql)) {
         throw new DBException('scheduledBackup->setParam: ' . "Error: Query {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     return;
 }
Ejemplo n.º 13
0
 function __construct()
 {
     $db_Connection = new dbConnection();
     $this->link = $db_Connection->connect();
     return $this->link;
 }
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 15
0
 function setParam($param, $value)
 {
     // Validate this...
     if (!is_numeric($this->id)) {
         throw new Exception('host->getScheduledBackupDisplay: ' . "Error: The ID for this object is not an integer.");
     }
     $conn = dbConnection::getInstance($this->log);
     switch (strtolower($param)) {
         case 'hostname':
             self::validateHostname($value);
             $backups = $this->getScheduledBackups();
             if (sizeOf($backups) > 0) {
                 // We have backups linked to this volume
                 // Collect and print the information ...
                 $info = $this->getInfo();
                 $errMsg = 'Error: Unable to edit the hostname for host with hostname: ' . $info['hostname'] . "\n\n" . $this->getScheduledBackupDisplay();
                 throw new ProcessingException($errMsg);
             }
             $sql = "UPDATE hosts SET hostname='" . $conn->real_escape_string($value) . "' WHERE host_id=" . $this->id;
             break;
         case 'description':
             self::validateHostDescription($value);
             $sql = "UPDATE hosts SET description='" . $conn->real_escape_string($value) . "' WHERE host_id=" . $this->id;
             break;
         case 'ssh_port':
             self::validateSSHPort($value);
             $sql = "UPDATE hosts SET ssh_port=" . $value . " WHERE host_id=" . $this->id;
             break;
         case 'active':
             self::validateActive($value);
             $sql = "UPDATE hosts SET active='" . $conn->real_escape_string(strtoupper($value)) . "' WHERE host_id=" . $this->id;
             break;
         case 'staging_path':
             self::validateStagingPath($value);
             $sql = "UPDATE hosts SET staging_path='" . $conn->real_escape_string($value) . "' WHERE host_id=" . $this->id;
             break;
         default:
             throw new InputException("Error: Unknown Host parameter: " . $param);
             break;
     }
     if (!$conn->query($sql)) {
         throw new DBException('host->setParam: ' . "Error: Query {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     return;
 }
 function upgrade()
 {
     // Look for running backups without checking schema version
     $runningBackupGetter = new runningBackupGetter();
     $runningBackupGetter->setSchemaVersionChecks(false);
     // Get the runningbackups - this getter automatically removes stale entries, so it should only return truly running pids...
     $runningBackups = $runningBackupGetter->getAll();
     $backupCount = sizeOf($runningBackups);
     // If we find running backups, abort with error
     if ($backupCount > 0) {
         throw new ProcessingException('schemaUpgrader->upgrade: ' . "Error: Detected " . $backupCount . " backup(s) currently running. Please retry upgrading the schema later.");
     }
     // Create a new DB connection getter that does not check the schema version...
     $conn = dbConnection::getInstance($this->log, false);
     $schemaVersion = $conn->getSchemaVersion();
     switch (true) {
         // If the schema versions match - all is good  - nothing to do
         case $schemaVersion == XBM_SCHEMA_VERSION:
             $this->resultMsg = "The schema version of the XtraBackup Manager database is already at the expected version number (" . XBM_SCHEMA_VERSION . ").";
             return true;
             break;
             // If the schema version of the DB is higher than what we need - throw an error!
         // If the schema version of the DB is higher than what we need - throw an error!
         case $schemaVersion > XBM_SCHEMA_VERSION:
             $this->resultMsg = "The schema version of the XtraBackup Manager database (" . $schemaVersion . ") is higher than the expected version number (" . XBM_SCHEMA_VERSION . ").";
             return false;
             break;
             // Schema version is < expected version - we need to upgrade!
         // Schema version is < expected version - we need to upgrade!
         case $schemaVersion < XBM_SCHEMA_VERSION:
             // Find all the files in the $XBM_AUTO_INSTALLDIR/sql/changes/ directory
             global $XBM_AUTO_INSTALLDIR;
             $files = glob($XBM_AUTO_INSTALLDIR . '/sql/changes/*');
             // Sort them just in case the OS gives them back in a strange order
             asort($files);
             // Walk the array and build a list of scripts to run of files that are numeric and > $schemaVersion
             $toRun = array();
             foreach ($files as $filename) {
                 $basename = basename($filename);
                 if (is_numeric($basename) && $basename > $schemaVersion && $basename <= XBM_SCHEMA_VERSION) {
                     $toRun[] = $filename;
                 }
             }
             // Walk over the array applying each schema update
             foreach ($toRun as $scriptName) {
                 $version = basename($scriptName);
                 // Run the script
                 $sql = file_get_contents($scriptName);
                 if (!($res = $conn->query($sql))) {
                     throw new Exception('schemaUpgrader->upgrade: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
                 }
                 // Update the schemaVersion in the DB
                 $sql = "UPDATE schema_version SET version=" . $version;
                 if (!($res = $conn->query($sql))) {
                     throw new Exception('schemaUpgrader->upgrade: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
                 }
             }
             $this->resultMsg = "The XtraBackup Manager database schema was successfully upgraded to schema version " . XBM_SCHEMA_VERSION . ".";
             return true;
             break;
             // Catch all - should never get here
         // Catch all - should never get here
         default:
             $this->resultMsg = "An issue occurred when comparing schema versions. This probably indicated a bug in XtraBackup Manager.";
             return false;
             break;
     }
     // Catch all - should never get here
     $this->resultMsg = "An issue occurred when comparing schema versions. This probably indicated a bug in XtraBackup Manager.";
     return false;
     // Get the schema version
 }
Ejemplo n.º 17
0
<?php

session_start();
require_once 'dbConnection.php';
$connection = new dbConnection();
session_regenerate_id();
$email = $connection->escape($_POST['email']);
$pass = $connection->escape($_POST['pass']);
$result = $connection->select("SELECT UserID, Email, Password FROM `Users` WHERE `Email`='{$email}' AND `Password`='{$pass}'");
if (mysqli_num_rows($result) == 0) {
    echo 0;
} else {
    echo 1;
    $row = $result->fetch_assoc();
    $_SESSION['Login'] = $email;
    $_SESSION['UserID'] = $row['UserID'];
}
Ejemplo n.º 18
0
<?php

session_start();
require_once 'dbConnection.php';
$connection = new dbConnection();
$email = $connection->escape($_POST['email']);
$pass = $connection->escape($_POST['pass']);
$fname = $connection->escape($_POST['fname']);
$lname = $connection->escape($_POST['lname']);
$phone = $connection->escape($_POST['phone']);
$err = 0;
# проверяем, не сущестует ли пользователя с таким именем
$result = $connection->select("SELECT COUNT(UserID) FROM Users WHERE Email='" . $email . "'");
$row = $result->fetch_row();
if ($row[0] !== 0) {
    $err = 1;
}
//"Пользователь с таким логином уже существует в базе данных"
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $err = 2;
}
//" invalid emailaddress
# Если нет ошибок, то добавляем в БД нового пользователя
if ($err == 0) {
    $result = $connection->insert("INSERT INTO `Users`(`Email`, `Password`, `FirstName`, `LastName`, `Phone`) VALUES ('" . $email . "','" . $pass . "','" . $fname . "','" . $lname . "','" . $phone . "')");
    if ($result != 0) {
        echo 0;
        session_regenerate_id();
        $_SESSION['UserID'] = $connection->getLastInsertedID();
        $_SESSION['Login'] = $email;
    }
        <div class="container">
            <div class="navbar-header">
                <button class="navbar-toggle collapsed menu-nav" data-toggle="collapse" data-target="#topNav" >
                    MENU
                </button> 
                <a href="admin.php" class="navbar-brand">         
                    <font size="5">Management User</font>   
                </a>
            </div>          
        </div>
    </nav>
    <?php 
include_once './config/config.php';
$id = $_GET['id'];
$sql = "select * from user where user_id = '" . $id . "'";
$db = new dbConnection();
$rs = mysqli_query($db->getLink(), $sql);
$username = "";
$firstname = "";
$lastname = "";
$password = "";
$type = "";
$email = "";
$birthday = "";
$address = "";
$phone = "";
while ($row = mysqli_fetch_array($rs)) {
    $username = $row['username'];
    $firstname = $row['firstname'];
    $lastname = $row['lastname'];
    $password = $row['password'];
Ejemplo n.º 20
0
 public function fetch()
 {
     $db = new dbConnection();
     //global $db;
     $this->titleFields = array();
     $qry = "SELECT * from form WHERE";
     if (is_numeric($this->id)) {
         $qry = "{$qry} idForm = {$this->id}";
     } else {
         $qry = "{$qry} projectName = '{$this->survey->name}' AND name = '{$this->name}'";
     }
     $res = $db->do_query($qry);
     if ($res === true) {
         while ($arr = $db->get_row_array()) {
             $this->id = $arr["idForm"];
             $this->key = $arr["keyField"];
             $this->name = $arr["name"];
             $this->number = $arr["table_num"];
             $this->version = $arr["version"];
             $this->group = $arr["group"];
             $this->isMain = $arr["isMain"] == "1";
         }
     }
     $qry = "SELECT f.idField as idField, f.key, f.name, f.label, ft.name as type, f.required, f.jump, f.isinteger as isInt, f.isDouble, f.title, f.regex, f.doubleEntry, f.search, f.group_form, f.branch_form, f.display, f.genkey, f.date, f.time, f.setDate, f.setTime, f.min, f.max, f.crumb, f.`match`, f.active, f.defaultValue, f.otherFieldProperties, f.upperCase, f.position FROM field f LEFT JOIN fieldtype ft on ft.idFieldType = f.type WHERE ";
     if (is_numeric($this->id)) {
         $qry = "{$qry} f.form = {$this->id} ORDER BY f.position";
     } else {
         $qry = "{$qry} f.projectName = '{$this->survey->name}' AND f.formname = '{$this->name}' ORDER BY f.position";
     }
     $res = $db->do_query($qry);
     if ($res === true) {
         while ($arr = $db->get_row_array()) {
             if (!array_key_exists($arr["name"], $this->fields)) {
                 $fld = new EcField();
             } else {
                 $fld = $this->fields[$arr["name"]];
             }
             $fld->form = $this;
             $fld->fromArray($arr);
             $fld->name = preg_replace('/[^0-9a-z]/i', '_', $fld->name);
             $fld->otherAttributes = json_decode($arr['otherFieldProperties']);
             $this->fields[$fld->name] = $fld;
             if ($fld->key) {
                 $this->key = $fld->name;
             }
             if ($fld->title && $fld->active) {
                 array_push($this->titleFields, $fld->name);
             }
         }
         foreach ($this->fields as $fld) {
             //$db = new dbConnection();
             if (!$fld->idField) {
                 continue;
             }
             $res = $db->do_query("SELECT `index`, `label`, `value` FROM `option` WHERE `field` = {$fld->idField}");
             //$db2->exec_sp("getOptions", array($fld->idField));
             if ($res !== true) {
                 die($res);
             }
             while ($arr = $db->get_row_array()) {
                 $opt = new EcOption();
                 $opt->fromArray($arr);
                 $opt->idx = $arr["index"];
                 array_push($fld->options, $opt);
             }
             if ($fld->type == "branch") {
                 array_push($this->branches, $fld->branch_form);
                 array_push($this->branchfields, $fld->name);
             }
         }
         return true;
     } else {
         return $res;
     }
 }
Ejemplo n.º 21
0
<?php

include 'config.php';
include 'dbConnection.php';
include 'xmlDocument.php';
include 'sanitizer.class.php';
$dbConnect = new dbConnection();
$xmlDoc = new xmlDocument();
$san = new HTML_Sanitizer();
$userId = $dbConnect->checkLogin($_GET['lname'], $_GET['pwstr']);
if (!isset($_GET['pwstr']) || !isset($_GET['lname']) || $userId == false) {
    die("away");
}
function mkdir_recursive($pathname, $mode)
{
    is_dir(dirname($pathname)) || mkdir_recursive(dirname($pathname), $mode);
    return is_dir($pathname) || @mkdir($pathname, $mode);
}
function fixDirName($dir)
{
    if ($dir[strlen($dir) - 1] != '/') {
        $dir = $dir . "/";
    }
    return $dir;
}
//e.g. from = "/files", to = "/files/myFiles/Images", deletes the folders images and myfiles if empty, path is always relative to work dir!
function rmdir_fromTo($from, $to)
{
    $to = trim($to, '/');
    $from = trim($from, '/');
    if (!is_dir($to) || !is_dir($from) || strlen($to) <= strlen($from)) {
Ejemplo n.º 22
0
$res = $db->do_query("CALL updateUser(2, 'name', '*****@*****.**');");
if ($res === true) {
} else {
    $spPass = false;
    echo "<tr><td>Update User</td><td>";
    echo "<span class=\"failure\">{$res}</span>";
}
$db = new dbConnection();
$res = $db->do_query("CALL getUserOAuthDetails(2, 'twitter');");
if ($res === true) {
} else {
    $spPass = false;
    echo "<tr><td>Get User OAuth</td><td>";
    echo "<span class=\"failure\">{$res}</span>";
}
$db = new dbConnection();
$res = $db->do_query("CALL endOAuthSession(2, 'twitter');");
if ($res === true) {
} else {
    $spPass = false;
    echo "<tr><td>End OAuth Session</td><td>";
    echo "<span class=\"failure\">{$res}</span>";
}
if ($spPass) {
    echo "<tr><td>Stored Procedures</td><td>";
    echo "<span class=\"success\">OK</span></tr>";
}
echo "<tr><th colspan=\"2\">Authorisation Interface</th></tr>";
//Authorisation battery
//Oauth Test
//OpenId Test
 function destroy()
 {
     global $config;
     // Validate
     $this->__validate();
     $this->setStatus('DELETING');
     $this->deleteFiles();
     // Remove the row from the DB.
     $conn = dbConnection::getInstance($this->log);
     $sql = "DELETE FROM materialized_snapshots WHERE materialized_snapshot_id=" . $this->id;
     if (!$conn->query($sql)) {
         throw new Exception('materializedSnapshot->destroy: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     if ($conn->affected_rows != 1) {
         throw new Exception('materializedSnapshot->destroy: ' . "Error: Failed to delete the Materialized Snapshot with ID " . $this->id . ".");
     }
     return true;
 }
Ejemplo n.º 24
0
 public function edit($table, $key, $value, $qKey, $qValue)
 {
     $dataBase = new dbConnection();
     $dataBase->connection()->prepare("UPDATE " . $table . " SET " . $key . "='" . $value . "' WHERE " . $qKey . "='" . $qValue . "' ")->execute();
 }
Ejemplo n.º 25
0
 public function addToDb()
 {
     global $db;
     if (!$db) {
         $db = new dbConnection();
     }
     $qry = "SELECT idFieldType FROM FieldType where name = '{$this->type}'";
     $db->do_query($qry);
     while ($arr = $db->get_row_array()) {
         $fieldType = $arr["idFieldType"];
     }
     $lbl = mysql_escape_string($this->label);
     $qry = "INSERT INTO Field (form, projectName, formName, type, name, label, language, regex, title, `key`, isinteger, isdouble, active, doubleentry, jump, required, search, group_form, branch_form, display, genkey, date, time, setdate, settime, position) VALUES\n\t\t\t\t\t\t\t\t ({$this->form->id}, '{$this->form->survey->name}', '{$this->form->name}', {$fieldType}, '{$this->name}','{$lbl}', '{$this->language}',";
     $qry .= $this->regex != "" ? "'{$this->regex}'," : "NULL,";
     $qry .= $this->title ? "1," : "0,";
     $qry .= $this->key ? "1," : "0,";
     $qry .= $this->isInt ? "1," : "0,";
     $qry .= $this->isDouble ? "1," : "0,";
     $qry .= "1,";
     $qry .= $this->doubleEntry ? "1," : "0,";
     $qry .= $this->jump ? "'{$this->jump}'," : "NULL,";
     $qry .= $this->required ? "1," : "0,";
     $qry .= $this->search ? "1," : "0,";
     $qry .= $this->group_form ? "'{$this->group_form}'," : "NULL,";
     $qry .= $this->branch_form ? "'{$this->branch_form}'," : "NULL,";
     $qry .= $this->display ? "1," : "0,";
     $qry .= $this->genkey ? "1," : "0,";
     $qry .= $this->date ? "'{$this->date}'," : "NULL,";
     $qry .= $this->time ? "'{$this->time}'," : "NULL,";
     $qry .= $this->setDate ? "'{$this->setDate}'," : "NULL,";
     $qry .= $this->setTime ? "'{$this->setTime}'," : "NULL,";
     $qry .= "{$this->position})";
     $res = $db->do_query($qry);
     if ($res === true) {
         foreach ($this->options as $opt) {
             $res = $db->exec_sp("addOption", array($this->form->survey->name, $this->form->name, $this->name, $opt->idx, $opt->label, $opt->value));
             if ($res !== true) {
                 return $res;
             }
         }
     }
     return $res;
 }
Ejemplo n.º 26
0
    die("\nResult: ERROR\nMessage: No mode given!");
}
if (isset($_GET['s'])) {
    $skill = floatval($_GET['s']);
}
if (isset($_GET['c'])) {
    $confidence = floatval($_GET['c']);
}
if (!isset($sourceUsername) or !isset($password)) {
    die("\nResult: ERROR\nMessage: Missing argument");
}
////////////////////////////////////////////////////////////
if (!validateSpringAccount($sourceUsername, $password)) {
    die("\nResult: ERROR\nMessage: Invalid login");
}
$dbConnect = new dbConnection();
switch ($mode) {
    case 0:
        if (!isset($targetUsername) or !isset($confidence)) {
            die("\nResult: ERROR\nMessage: Missing argument");
        }
        $dbresult = $dbConnect->addConfidence($sourceUsername, $targetUsername, $confidence);
        if (!$dbresult) {
            die("\nResult: ERROR\nMessage: Addin confidence failed!");
        } else {
            echo "\nResult: OK\nMessage: Confidence added: " . $sourceUsername . " - " . $targetUsername . " : " . $confidence;
        }
        break;
    case 1:
        if (!isset($targetUsername) or !isset($skill)) {
            die("\nResult: ERROR\nMessage: missing argument");
Ejemplo n.º 27
0
<?php

include 'config.php';
include 'dbConnection.php';
include 'xmlDocument.php';
ini_set('display_errors', 1);
set_time_limit(3600);
//Timeout limit 1 hour (could be a big file or slow con)
if ($_GET['m'] == NULL) {
    die("No mode given!");
}
$dbConnect = new dbConnection();
$xmlDoc = new xmlDocument();
class vsp
{
    public $login;
    public $password;
}
function validateSpringAccount($username, $pw)
{
    return true;
    //remove when new SD (>1.4.1) is out (to activate account verification)
    $param1 = new vsp();
    $param1->login = $username;
    $param1->password = $pw;
    $soap = new SoapClient("http://planet-wars.eu/SpringAuthService.asmx?wsdl");
    $res = $soap->VerifySpringAccount($param1);
    return $res->VerifySpringAccountResult;
}
function checkUsername($username, $pw)
{
Ejemplo n.º 28
0
<?php

require "w2db.php";
require "w2lib.php";
$db = new dbConnection("mysql");
$db->connect("127.0.0.1", "root", "", "test", "3306");
switch ($_REQUEST['name'] . "::" . $_REQUEST['cmd']) {
    case 'users::get-records':
        $sql = "SELECT * FROM users\n\t\t\t\t WHERE ~search~ ORDER BY ~sort~";
        $res = $w2grid->getRecords($sql, null, $_REQUEST);
        $w2grid->outputJSON($res);
        break;
    case 'users::delete-records':
        $res = $w2grid->deleteRecords("users", "userid", $_REQUEST);
        $w2grid->outputJSON($res);
        break;
    case 'user_edit::get-record':
        $sql = "SELECT userid, fname, lname, email, login, password\n\t\t\t\tFROM users \n\t\t\t\tWHERE userid = " . $_REQUEST['recid'];
        $res = $w2grid->getRecord($sql);
        $w2grid->outputJSON($res);
        break;
    case 'user_edit::save-record':
        $res = $w2grid->saveRecord('users', 'userid', $_REQUEST);
        $w2grid->outputJSON($res);
        break;
    default:
        $res = array();
        $res['status'] = 'error';
        $res['message'] = 'Command "' . $_REQUEST['cmd'] . '" is not recognized.';
        $res['postData'] = $_REQUEST;
        $w2grid->outputJSON($res);
 function getChild()
 {
     global $config;
     if (!is_numeric($this->id)) {
         throw new Exception('backupSnapshot->getChild: ' . "Error: The ID for this object is not an integer.");
     }
     $conn = dbConnection::getInstance($this->log);
     $sql = "SELECT backup_snapshot_id FROM backup_snapshots WHERE status='COMPLETED' AND parent_snapshot_id=" . $this->id;
     if (!($res = $conn->query($sql))) {
         throw new Exception('backupSnapshot->getChild: ' . "Error: Query: {$sql} \nFailed with MySQL Error: {$conn->error}");
     }
     if ($res->num_rows != 1) {
         throw new Exception('backupSnapshot->getChild: ' . "Error: Could not identify a single child of this backupSnapshot.");
     }
     $row = $res->fetch_array();
     $backupGetter = new backupSnapshotGetter();
     return $backupGetter->getById($row['backup_snapshot_id']);
 }
Ejemplo n.º 30
0
<?php

include 'header.php';
require_once 'dbConnection.php';
$connection = new dbConnection();
$result = $connection->Select("SELECT A.WishID, A.WisherID, A.PerformerID, A.WisherComplain, A.PerformerComplain, C.FirstName WisherFName, C.LastName WisherLName, C.Rank WisherRank, D.FirstName PerformerFName, D.LastName PerformerLName, D.Rank PerformerRank\nFROM `courts` AS A\nJOIN `Wishes` AS B \n\tON A.WishID=B.WishID \nJOIN Users AS C \n\tON A.WisherID=C.UserID\nJOIN Users AS D \n\tON A.PerformerID=D.UserID\n");
echo <<<HTML
<div class="center-block">
<div id="centerCourtz">
\t<div class="overflowOuter">
\t<div class="centerCourtzRaws">
HTML;
$count = 1;
while ($row = $result->fetch_assoc()) {
    if (!file_exists("images/profiles/{$row['WisherID']}.jpg")) {
        $wisherProfileImage = 'not-found.png';
    } else {
        $wisherProfileImage = $row['WisherID'] . '.jpg' . '?' . time();
    }
    if (!file_exists("images/profiles/{$row['PerformerID']}.jpg")) {
        $performerProfileImage = 'not-found.png';
    } else {
        $performerProfileImage = $row['PerformerID'] . '.jpg' . '?' . time();
    }
    echo <<<HTML
    \t<div class="courtz-row">
    \t\t<div class="buttons">
\t\t\t\t<div class="button" onclick="buttonsBackground(id,{$row['WishID']})" id="plus{$count}"><img src="buttons/ButtonPLUS1.png"/></div>
\t\t\t\t<div class="button" onclick="buttonsBackground(id,{$row['WishID']})" id="favo{$count}"><img src="buttons/ButtonFAVO1.png"/></div>
\t\t\t\t<div class="button" onclick="buttonsBackground(id,{$row['WishID']})" id="minus{$count}"><img src="buttons/ButtonMINUS1.png"/></div>
\t\t\t</div>