public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 function __construct($u, $p, $e = null, $a = null)
 {
     $this->username = $u;
     $this->password = $p;
     $this->email = $e;
     $this->avatar_path = $a;
     $this->DB = DBconnection::getInstance();
 }
Example #3
0
 public function __construct()
 {
     if (session_status() != 2) {
         session_start();
     }
     if (isset($_SESSION['user'])) {
         $this->DBconnection = DBconnection::getInstance();
     } else {
         die;
     }
 }
<?php

session_start();
require_once "dbconnection.class.php";
$DB = DBconnection::getInstance();
$query = "select ID from videos where Name='" . $_SESSION['curr_video'] . "'";
$q = $DB->db_pdo->prepare($query);
$q->execute();
$row = $q->fetch();
$id = $row["ID"];
$qq = "select Login,text,time from timespans join users on timespans.IDUser = users.ID where IDVideo = :id";
$q = $DB->db_pdo->prepare($qq);
$q->execute(array(':id' => $id));
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
    ?>
                        <div class="timespan_link_div">
                            <p id="timespan_user"><?php 
    echo $row['Login'];
    ?>
</p>
                            <p id="timespan_link_time"><?php 
    echo $row['time'];
    ?>
</p>
                            <p id="timespan_link_text"><?php 
    echo $row['text'];
    ?>
</p>
                        </div>
                    <?php 
}
Example #5
0
<?php

include_once 'DBconnection.php';
$classID = $_GET['classID'];
$myDBconnection = new DBconnection();
$myDBconnection->ConnectToDB();
// echo $classID.'<br>';
$myresponse = $myDBconnection->db->prepare('SELECT DISTINCT class_date FROM ' . $classID);
$myresponse->execute();
$result = $myresponse->fetchAll();
$output = array();
// echo json_encode($result);
foreach ($result as $row) {
    array_push($output, $row['class_date']);
}
// echo $myresponse->rowCount();
// echo $result[0]['class_date'];
// return json_encode($myresponse->rowCount());
echo json_encode($output);
// echo '<br>'.$output[0];
Example #6
0
 function deleteCar($id)
 {
     try {
         $connection = new DBconnection("cars");
         $db = $connection->getDb();
         $stmt = $db->prepare("DELETE FROM tbl_car\n\t\t\t\t\t\t\t\t\t\tWHERE auto_id = ?");
         $stmt->bindValue(1, $id, PDO::PARAM_INT);
         $stmt->execute();
         return "SUCCESS";
     } catch (PDOException $ex) {
         return "<p>ERROR: " . $ex->getMessage() . "</p>";
     }
 }
Example #7
0
 public static function getAllFields()
 {
     $db = new DBconnection();
     $result = $db->select(self::getTableName(), self::getTableFields());
     return $result;
 }
Example #8
0
 /**
  * Delete an existing row
  *
  * @author Fernando Ontiveros Lira <*****@*****.**>
  * @access public
  * @return boolean
  */
 public function delete()
 {
     $stQry = "delete from `" . $this->table_name . "` ";
     $stWhere = '';
     $remainKeys = array();
     if (defined('DB_ADAPTER')) {
         $DBEngine = DB_ADAPTER;
     } else {
         $DBEngine = 'mysql';
     }
     foreach ($this->table_keys as $k => $v) {
         $remainKeys[$v] = false;
     }
     if (is_array($this->Fields)) {
         foreach ($this->Fields as $field => $val) {
             $iskey = false;
             $iskey = in_array($field, $this->table_keys);
             if ($iskey == true) {
                 if ($stWhere == "") {
                     $stWhere .= $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine) . "'";
                 } else {
                     $stWhere .= " AND " . $field . "='" . G::sqlEscape($val, isset($this->_dbc->type) ? $this->_dbc->type : $DBEngine) . "'";
                 }
                 $remainKeys[$field] = true;
             }
         }
     }
     foreach ($remainKeys as $field => $bool) {
         if ($bool == false) {
             if ($stWhere != "") {
                 $stWhere .= " AND ";
             }
             $stWhere .= $field . "= ''";
             $remainKeys[$field] = true;
         }
     }
     $stQry = trim($stQry);
     $stWhere = trim($stWhere);
     if ($stWhere == '') {
         $dberror = PEAR::raiseError(null, G_ERROR_WARNING_MESSAGE, null, 'null', "You tried to call delete method without WHERE clause, if you want to delete all records use dbsession", 'G_Error', true);
         DBconnection::logError($dberror, $this->errorLevel);
         return $dberror;
     }
     $stQry .= " WHERE " . $stWhere;
     $result = $this->_dbses->execute($stQry, $this->debug, $this->errorLevel);
     $this->is_new = false;
     return $result;
 }
Example #9
0
<?php

include_once 'DBconnection.php';
include_once 'Instructor.php';
include_once 'instructorClass.php';
$myDBconnection = new DBconnection();
$myDBconnection->ConnectToDB();
$fname = $_POST['FirstName'];
$lname = $_POST['LastName'];
$email = $_POST['Email'];
$myInstructor = new Instructor($fname, $lname, sha1($_POST['Password']), $_POST['Email']);
$checkInstructor = $myInstructor->Selection($myDBconnection->db);
session_start();
// echo $checkInstructor->rowCount();
if ($checkInstructor->rowCount() == 0) {
    if (!isset($_SESSION)) {
        session_destroy();
    }
    $response = $myInstructor->Insertion($myDBconnection->db);
    if ($response == 0) {
        echo "Query Failed";
        $_SESSION['errorMessage'] = "There was an error inserting into the database. Please try again.";
        header('Location: ../registrationPage.php');
    } else {
        echo "query Successful";
        $_SESSION['Email'] = $email;
        $_SESSION['name'] = $fname . " " . $lname;
        $_SESSION['validCredentials'] = true;
        $myDBconnection->closeConnection();
        header('Location: ../LoginPage.php');
    }
 /**
  * Function Execute, to execute a query and send back the recordset.
  *
  * @access public
  * @param eter string strQuery
  * @param eter string debug
  * @param eter string error
  * @return string
  */
 function Execute($strQuery = '', $debug = false, $errorLevel = null)
 {
     //BUG::traceRoute();
     if ($this->dbc == null) {
         $dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', 'You have tried to call a DBSession function without create an instance of DBConnection', 'G_Error', true);
         DBconnection::logError($dberror, $errorLevel);
         return $dberror;
     }
     if ($errorLevel === null) {
         $errorLevel = $this->dbc->errorLevel;
     }
     $this->Free(true);
     if ($debug) {
         print $strQuery . "<br>\n";
     }
     $this->result = $this->dbc->db->query($strQuery);
     if (DB::isError($this->result)) {
         $this->dbc->logError($this->result, $errorLevel);
         return $this->result;
     }
     $dset = new DBRecordSet($this->result);
     return $dset;
 }
Example #11
0
 public static function closeConnection()
 {
     self::$connection = null;
 }
 /**
  * Function Read
  *
  * @author David S. Callizaya S. <*****@*****.**>
  * @access public
  * @return string
  */
 function Read()
 {
     if ($this->result === null) {
         $dberror = PEAR::raiseError(null, DB_ERROR_OBJECT_NOT_DEFINED, null, 'null', "You tried to call to a DBRecordset with an invalid result recordset.", 'G_Error', true);
         DBconnection::logError($dberror);
     }
     $res = $this->result->fetchRow(DB_FETCHMODE_ASSOC);
     //for Pgsql databases,
     //if ( PEAR_DATABASE == "pgsql" && is_array ( $res ) ) { $res = array_change_key_case( $res, CASE_UPPER);  }
     /* Comment Code: This block is not required now because
      *  of the the use of the G::sqlEscape() instead of addslashes
      *  funcion over each  field in DBTable.
      * @author David Callizaya
      */
     /*if (is_array ($res) )
       foreach ($res as $key => $val)
       $res[$key] = stripslashes ($val);  remove the slashes*/
     return $res;
 }
Example #13
0
 public function __construct()
 {
     $this->DBconnection = DBconnection::getInstance();
 }
 /**
  * Gets last autoincrement value inserted
  *
  * @author Fernando Ontiveros Lira <*****@*****.**>
  * @access public
  * @return void
  */
 function GetLastID()
 {
     if (PEAR_DATABASE == "mysql") {
         return mysql_insert_id();
     } else {
         $dberror = PEAR::raiseError(null, DB_ERROR_FEATURE_NOT_AVAILABLE, null, 'null', "getLastID with " . PEAR_DATABASE . ' database.', 'G_Error', true);
         DBconnection::logError($dberror, DB_ERROR_SHOWALL_AND_STOP);
         //this error will stop the execution, until we add this feature!!
         return $dberror;
     }
     return mysql_insert_id();
 }
<?php

session_start();
require_once "dbconnection.class.php";
$dbh = DBconnection::getInstance();
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SlyTube</title>
    <link rel="icon" href="favicon2.png" type="image/png">
    <link rel="stylesheet" href="stylesheets/style.css">
    <link rel="stylesheet" href="stylesheets/video-js.css">
    <link rel="stylesheet" href="stylesheets/upload.css">
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/video.js"></script>
    <script src="js/core.js"></script>
    <script src="js/upload.js"></script>
</head>
<body>
    <div class="wrap">
      <!--  HEADER -->
       <?php 
include "header.php";
?>
        
        <!-- SIDEBAR -->
        <?php