コード例 #1
0
 private function writeLogToSQL($file, $logname, $description)
 {
     $table = 'Logs';
     $queryType = 'Insert';
     $condition = null;
     $types = array('text', 'text', 'text', 'timestamp');
     $columns = array('Filename', 'LogName', 'Description', 'Datetime');
     $now = getdate(date("U"));
     $datetime = new DateTime();
     $datetime->setDate($now['year'], $now['mon'], $now['mday']);
     $datetime->setTime($now['hours'] + 3, $now['minutes'], $now['seconds']);
     $values = array($file, $logname, $description, $datetime->format('Y/m/d H:i:s'));
     $args = array('column' => $columns, 'value' => $values, 'type' => $types);
     $xml = $this->createXML($table, $args);
     $sql = new SQLMediator();
     $sql->connect();
     $res = $sql->query($xml, $queryType, $condition);
     $sql->disconnect();
 }
コード例 #2
0
<?php

require_once dirname(__FILE__) . '/../base/ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../base/ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../base/XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $sql = new SQLMediator();
    $status = $sql->connect();
    if ($status != null) {
        echo '<error>' . $status . '</error>';
    } else {
        $data = getData($sql);
        echo $data;
        $sql->disconnect();
    }
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function getData($sqlconn)
{
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Logs WHERE LogName = 'Exception' ORDER BY Datetime desc", 'Logs');
    return $res;
}
コード例 #3
0
ファイル: GetSongs.php プロジェクト: benjiboybenjamin/you-mix
<?php

require_once dirname(__FILE__) . '/../ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $mixTitle = $_POST['mixTitle'];
    $sql = new SQLMediator();
    $sql->connect();
    addToMixesLoadedTable($mixTitle, $sql);
    $xmlSongs = getSongs($mixTitle, $sql);
    echo $xmlSongs;
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function addToMixesLoadedTable($loadedMixesTitle, $sqlconn)
{
    $ip = $_SERVER['REMOTE_ADDR'];
    $loadedMixesTitle = str_replace("'", "\\'", $loadedMixesTitle);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$loadedMixesTitle}'", 'Mixes');
    $mixid = getMixId($res);
    $now = getdate(date("U"));
コード例 #4
0
require_once dirname(__FILE__) . '/../ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../MySQL/SQLMediator.php';
require_once dirname(__FILE__) . '/../PHPMailer/class.phpmailer.php';
require_once dirname(__FILE__) . '/../../masterPage/config.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $email = $_POST['email'];
    $sql = new SQLMediator();
    $sql->connect();
    $password = getPassword($email, $sql);
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function getPassword($fEmail, $sqlconn)
{
    $table = 'UserInfo';
    $queryType = 'Select';
    $condition = array('Email', $fEmail, 'text');
    $types = array('text');
    $columns = array('Password');
    $values = array(null);
    $args = array('column' => $columns, 'value' => $values, 'type' => $types);
コード例 #5
0
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
$title = $_POST['title'];
$email = $_POST['email'];
$xml = $_POST['xml'];
$publish = $_POST['publish'];
$now = getdate(date("U"));
$datetime = new DateTime();
$datetime->setDate($now['year'], $now['mon'], $now['mday']);
$datetime->setTime($now['hours'] + 3, $now['minutes'], $now['seconds']);
try {
    $sql = new SQLMediator();
    $sql->connect();
    $mixNameValue = checkMixName($sql, $title);
    if ($mixNameValue == '') {
        addSongs($sql, $xml, $datetime->format('Y/m/d H:i:s'));
        createMix($sql, $title, $email, $publish);
        syncMixAndSongs($sql, $title, $email, $datetime->format('Y/m/d H:i:s'));
    } else {
        echo 'Mix name already exists';
    }
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function checkMixName($sqlconn, $titleMix)
{
コード例 #6
0
ファイル: Activate.php プロジェクト: benjiboybenjamin/you-mix
require_once 'base/ExceptionHandling/GlobalExceptionHandler.php';
require_once 'base/ExceptionHandling/ErrorToException.php';
require_once 'base/XML/XMLFactory.php';
require_once 'base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    echo "<html>\n\t\t\t<head>\n\t\t\t\t<title>Video Factory</title>\n\t\t\t\t<link rel='shortcut icon' href='favicon.png' type='img/x-icon'/>\n\t\t\t\t<link rel='stylesheet' type='text/css' href='masterPage/main.css'/>\n\t\t\t</head>\n\t\t\t<body>\n\t\t\t\t<div id='activatePage' class='container'>\n\t\t\t\t\t<div class='col-xs-12 activateContainer'>\n\t\t\t\t\t<p id='activateTitle' class='col-xs-'12>Video Factory</p>\n\t\t\t\t";
    $key = $_GET['key'];
    $sqlconn = new SQLMediator();
    $sqlconn->connect();
    $values = getValuesFromTempTable($key, $sqlconn);
    if (count($values) == 0) {
        echo 'Key not found<br/>';
        echo "<a class='activateLink' href='/'>Return to site</a>";
    } else {
        $userExists = checkIfUserExists($values['Email'], $sqlconn);
        if ($userExists) {
            echo 'User already has an active account<br/>';
            echo "<a class='activateLink' href='/'>Return to site</a>";
        } else {
            addToUserInfoTable($values, $sqlconn);
            deleteValuesFromTempTable($values['Email'], $sqlconn);
            echo 'Account is now active!<br/>';
            echo "<a class='activateLink' href='/'>Return to site</a>";
コード例 #7
0
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $title = $_POST['title'];
    $email = $_POST['email'];
    $xml = $_POST['xml'];
    $publish = $_POST['publish'];
    $now = getdate(date("U"));
    $datetime = new DateTime();
    $datetime->setDate($now['year'], $now['mon'], $now['mday']);
    $datetime->setTime($now['hours'] + 3, $now['minutes'], $now['seconds']);
    $sql = new SQLMediator();
    $sql->connect();
    clearSongs($title, $email, $sql);
    addSongs($sql, $xml, $datetime->format('Y/m/d H:i:s'));
    syncMixAndSongs($sql, $title, $email, $datetime->format('Y/m/d H:i:s'));
    setPublish($title, $email, $publish, $sql);
    echo 'Mix updated!';
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function clearSongs($titleClear, $emailClear, $sqlconn)
{
    $titleClear = str_replace("'", "\\'", $titleClear);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE Owner = '{$emailClear}' AND MixName = '{$titleClear}'", 'Mixes');
    $mixid = getMixId($res);
コード例 #8
0
<?php

require_once dirname(__FILE__) . '/../base/ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../base/ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../base/XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $mixId = $_POST['mixid'];
    $sql = new SQLMediator();
    $sql->connect();
    $mix = getMix($sql, $mixId);
    echo $mix;
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function getMix($sqlconn, $theMixId)
{
    $table = 'Mixes';
    $queryType = 'Select';
    $condition = array('MixId', $theMixId, 'text');
    $types = array('text');
    $columns = array('MixName');
    $values = array(null);
コード例 #9
0
<?php

require_once dirname(__FILE__) . '/../base/ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../base/ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../base/XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $title = $_POST['title'];
    $sql = new SQLMediator();
    $sql->connect();
    deleteMixAndSongs($title, $sql);
    echo 'Mix deleted';
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function deleteMixAndSongs($titleDelete, $sqlconn)
{
    $titleDelete = str_replace("'", "\\'", $titleDelete);
    $res = $sqlconn->complexQuery("Select", "SELECT * FROM Mixes WHERE MixName = '{$titleDelete}'", 'Mixes');
    $mixid = getMixId($res);
    $res = $sqlconn->complexQuery("Select", "SELECT SongId FROM MixSongs WHERE MixId = '{$mixid}'", 'MixSongs');
    $songids = getSongIds($res);
    $res = $sqlconn->complexQuery("Delete", "DELETE FROM Mixes WHERE MixId = '{$mixid}'", 'Mixes');
コード例 #10
0
ファイル: GetMixId.php プロジェクト: benjiboybenjamin/you-mix
<?php

require_once dirname(__FILE__) . '/../base/ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../base/ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../base/XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $mixName = $_POST['mixname'];
    $sql = new SQLMediator();
    $sql->connect();
    $id = getMix($sql, $mixName);
    echo $id;
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function getMix($sqlconn, $theMixName)
{
    $table = 'Mixes';
    $queryType = 'Select';
    $condition = array('MixName', $theMixName, 'text');
    $types = array('text');
    $columns = array('MixId');
    $values = array(null);
コード例 #11
0
<?php

require_once dirname(__FILE__) . '/../base/ExceptionHandling/GlobalExceptionHandler.php';
require_once dirname(__FILE__) . '/../base/ExceptionHandling/ErrorToException.php';
require_once dirname(__FILE__) . '/../base/XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../base/MySQL/SQLMediator.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
try {
    $mixName = $_POST['mixName'];
    $sql = new SQLMediator();
    $sql->connect();
    $pValue = getPublishedValue($sql, $mixName);
    echo $pValue;
    $sql->disconnect();
} catch (Exception $ex) {
    echo GlobalExceptionHandler::writeException($ex);
}
function getPublishedValue($sqlconn, $theMixName)
{
    $table = 'Mixes';
    $queryType = 'Select';
    $condition = array('MixName', $theMixName, 'text');
    $types = array('text');
    $columns = array('Published');
    $values = array(null);
コード例 #12
0
ファイル: SignUp.php プロジェクト: benjiboybenjamin/you-mix
require_once dirname(__FILE__) . '/../XML/XMLFactory.php';
require_once dirname(__FILE__) . '/../MySQL/SQLMediator.php';
require_once dirname(__FILE__) . '/../PHPMailer/class.phpmailer.php';
require_once dirname(__FILE__) . '/../../masterPage/config.php';
function error_to_exception($code, $message, $file, $line, $context)
{
    if ($code != E_STRICT && $code != E_DEPRECATED) {
        throw new ErrorToException($code, $message, $file, $line, $context);
    }
}
set_error_handler("error_to_exception");
$email = $_POST['email'];
$password = $_POST['password'];
$password2 = $_POST['password2'];
try {
    $sql = new SQLMediator();
    $sql->connect();
    $userExists = checkIfUserExists($email, $sql);
    if ($userExists) {
        echo 'An account with that email already exits.';
    } else {
        $activationKey = uniqid();
        $table = 'TempUser';
        $queryType = 'Insert';
        $condition = null;
        $types = array('text', 'text', 'text');
        $columns = array('Email', 'Password', 'ActivateKey');
        $values = array($email, $password, $activationKey);
        $args = array('column' => $columns, 'value' => $values, 'type' => $types);
        $xml = createXML($table, $args);
        $res = $sql->query($xml, $queryType, $condition);