Esempio n. 1
0
 public static function getLastID($tabelID, $whereArr = NULL, $obj = NULL)
 {
     if (is_null($obj)) {
         $obj = array();
     }
     $obj['addToEnd'] = 'ORDER BY id DESC LIMIT 1';
     $api = new GetTable($tabelID, $whereArr, $obj);
     $chk = $api->getResult();
     $chk['result'] = $chk['result'][0]['id'];
     return $chk;
 }
Esempio n. 2
0
 public static function getNextInsertID($table, $hash = true, $append = "")
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "getHash");
     //----------------------------------------------------------
     $date = date("Y-m-d H:i:s");
     //----------------------------------------------------------
     $chk = GetTable::getLastID($table);
     //----------------------------------------------------------
     if (!$chk['bool']) {
         $chk['bool'] = false;
         $chk['message'] = "getHash() returned NULL";
         return $chk;
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $total = $chk['result'];
     }
     //----------------------------------------------------------
     $insert_id = $total + 1;
     //----------------------------------------------------------
     return $hash ? alphaID($insert_id . $date . $append) : alphaID($insert_id);
 }
Esempio n. 3
0
 public function getFiles($getHtml = true)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $html;
     $chk = array("bool" => true, 'result' => array(), "func" => "getFiles");
     //----------------------------------------------------------
     $chk = GetTable::go("files", NULL, array("addToEnd" => " ORDER BY id DESC ", "limitFrom" => 0, "limitTo" => 60));
     if (sizeof($chk['result']) > 0) {
         foreach ($chk['result'] as $index) {
             $html .= "<a href = '" . $this->getDownloadUrl() . "?hash=" . $index['hash'] . "'>" . $index['name'] . "</a><br>";
         }
     } else {
         $html = "<p>No files have been uploaded.</p>";
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk['html'] = $html;
     }
     //----------------------------------------------------------
     return !$chk['bool'] || !$getHtml ? $chk : $html;
 }
Esempio n. 4
0
 public function update()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "update");
     //----------------------------------------------------------
     $this->tableID = GlobalMas::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $this->queryString = "UPDATE " . $this->tableID . " ";
     //----------------------------------------------------------
     $this->queryString = MySQL::condition($this->tableID, $this->setArr, "set", $this->queryString);
     $this->queryString = MySQL::condition($this->tableID, $this->whereArr, "where", $this->queryString);
     //----------------------------------------------------------
     $chk = $this->getResult();
     //----------------------------------------------------------
     if ($this->returnTable) {
         $chk = GetTable::go($this->tableID, $this->whereArr);
     }
     //----------------------------------------------------------
     return $chk;
     //----------------------------------------------------------
 }
Esempio n. 5
0
 public function forgotPassword($email)
 {
     Trace::output($this->traceID, "forgotPassword");
     //----------------------------------------------------------
     $this->email = $email;
     $this->addRowFunction = "addForgotRow";
     $this->tblName = ForgotPwRequest_const::TBL;
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'traceID' => "forgotPassword");
     //----------------------------------------------------------
     $chk = GenFun::error_CHK(array($email, $this->tblName));
     //----------------------------------------------------------
     if (!$chk["bool"]) {
         return $chk;
     }
     //----------------------------------------------------------
     if (!$this->character_CHK($email)) {
         $chk['bool'] = false;
         $chk['message'] = "email must only contain numbers, upper, and lowercase characters!!!";
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = GetTable::go(Accounts_const::TBL, array("email" => $email));
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $this->emailRow = $chk['result'][0];
     }
     //----------------------------------------------------------
     if (sizeof($chk['result']) != 0) {
         if ($chk['result']['0']['email'] != $email) {
             $chk['bool'] = false;
             $chk['message'] = "Email does not match email!!!";
         } else {
             if ($chk['bool']) {
                 $chk = GetTable::go(ForgotPwRequest_const::TBL, array("accounts_id" => $this->emailRow['id'], "disabled" => '0', "confirmed" => '0'));
             }
         }
     } else {
         $chk['bool'] = false;
         $chk['message'] = "No Account exist with that email!!!";
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $this->start($chk['result'][0], 1, "emailForgotLink");
     }
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 6
0
 public function getStates()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'traceID' => "initLoad");
     //----------------------------------------------------------
     $chk = GetTable::go("states");
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 7
0
 public function deleteFile($id, $hardDelete = false)
 {
     Trace::output(self::$traceID, "insertFile", func_get_args());
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "deleteFile");
     $date = date("Y-m-d H:i:s");
     //----------------------------------------------------------
     if ($hardDelete) {
         $file = GetTable::go("files", array("id" => $id));
         $path = $file['result'][0]['hash'];
         $path = GlobalMas::$filesPath_absolute . $path;
         if (!FileFolder::delete($path)) {
             $chk['bool'] = false;
             $chk['message'] = "file was not deleted";
         }
     }
     if (!$chk['bool']) {
         return $chk;
     } else {
         $chk = Update::go("files", array("deleted" => $date), array('id' => $id));
     }
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 8
0
 public function insertINTO()
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'function' => "insertINTO");
     $this->updateArr = array();
     //----------------------------------------------------------
     $chk = GenFun::errorKey_chk($this->setArr, NULL, true);
     //----------------------------------------------------------
     $this->setArr = $chk['valueArr'];
     //----------------------------------------------------------
     if (!$chk['bool']) {
         return $chk;
     }
     //----------------------------------------------------------
     $this->tableID = Constants::$mysqli->real_escape_string($this->tableID);
     //----------------------------------------------------------
     $this->queryString = $this->insertType . " " . $this->tableID . " (";
     foreach ($this->setArr as $i => $value) {
         if (strrpos($value, "{hash}") === 0) {
             $this->updateArr[$i] = $value;
         } else {
             $this->queryString .= $i . ",";
         }
     }
     //----------------------------------------------------------
     foreach ($this->updateArr as $i => $value) {
         unset($this->setArr[$i]);
     }
     //----------------------------------------------------------
     $this->queryString = substr($this->queryString, 0, -1);
     $this->queryString .= ") ";
     //----------------------------------------------------------
     $keys = array_keys($this->setArr);
     $this->queryString .= "VALUES ";
     //----------------------------------------------------------
     $high = sizeof($this->setArr[$keys[0]]);
     for ($i = 1; $i < sizeof($this->setArr); $i++) {
         if (is_array($this->setArr[$keys[$i]])) {
             $cur = sizeof($this->setArr[$keys[$i]]);
             if ($high < $cur) {
                 $high = $cur;
             }
         }
     }
     //----------------------------------------------------------
     for ($i = 0; $i < 1; $i++) {
         $value = $this->setArr[$keys[$i]];
         $num = is_array($value) ? sizeof($value) : 1;
         for ($j = 0; $j < $high; $j++) {
             if (is_array($this->setArr[$keys[$i]])) {
                 $value = $this->setArr[$keys[$i]][$j];
             }
             if ($i == 0) {
                 $this->queryString .= "(";
             }
             if (strrpos($value, "(") !== false && strrpos($value, "(") == 0 && !$this->ignore) {
                 $this->queryString .= $value;
                 //$this->queryString .= ",";
             } else {
                 if ($value == "DEFAULT") {
                     $this->queryString .= $value;
                 } else {
                     $this->queryString .= "'" . Constants::$mysqli->escape_string($value) . "'";
                 }
             }
             //-------------------------------------------------
             for ($k = 0; $k < sizeof($this->setArr); $k++) {
                 if ($keys[$k] != $keys[$i]) {
                     $this->queryString .= ",";
                     if (is_array($this->setArr[$keys[$k]])) {
                         $v = $this->setArr[$keys[$k]][$j];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     } else {
                         $v = $this->setArr[$keys[$k]];
                         $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'";
                     }
                 }
             }
             //-------------------------------------------------
             //if ($i == sizeof($this->setArr)-1) {
             //$this->queryString = substr($this->queryString, 0, -1);
             $this->queryString .= ")";
             //}
             //-------------------------------------------------
             if ($j < $high - 1) {
                 $this->queryString .= ",";
             }
         }
     }
     //----------------------------------------------------------
     if (!is_null($this->onDuplicate)) {
         $this->queryString .= " ON DUPLICATE KEY UPDATE ";
         $this->queryString = MySQL::condition($this->tableID, $this->onDuplicate, NULL, $this->queryString);
     }
     //----------------------------------------------------------
     if (!$this->returnQuery) {
         $chk = $this->getResult();
         $insert_id = $chk['insert_id'];
         if ($chk['duplicate']) {
             $chk['duplicate'] = GetTable::go($this->tableID, $this->setArr);
         } else {
             if (sizeof($this->updateArr) > 0) {
                 foreach ($this->updateArr as $i => $value) {
                     if (strrpos($value, "{hash}") === 0) {
                         $value = strtr($value, array('{hash}' => ""));
                         /*if (!is_numeric($value)) {
                         			$chk['bool'] = false;
                         			$chk['messgae'] = "In order to use the alphaID() utility ".$value.' must be numeric!!!';
                         			return $chk;
                         		}*/
                         $this->updateArr[$i] = alphaID($insert_id . $value);
                     }
                 }
                 $this->setArr['id'] = $insert_id;
                 $chk = Update::go($this->tableID, $this->updateArr, $this->setArr);
             }
         }
         if (!$chk['bool']) {
             return $chk;
         }
         if ($this->returnRow) {
             $chk['row'] = GetTable::go($this->tableID, array("id" => $insert_id));
             if ($chk['row']['bool']) {
                 $chk['row'] = $chk['row']['result'][0];
             }
         }
         $chk['insert_id'] = $insert_id;
         return $chk;
     } else {
         return $this->queryString;
     }
 }
Esempio n. 9
0
 public function _getProjects($limit = null)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "getProjects");
     //----------------------------------------------------------
     $chk = GetTable::go("projects", NULL, array("addToEnd" => " Order By id DESC" . (is_null($limit) ? "" : " LIMIT " . $limit)));
     //---------------------------------------------------------
     return $chk;
 }
Esempio n. 10
0
 public function session_CHK($email = NULL, $accounts_id = NULL)
 {
     Trace::output($this->traceID, "session_CHK", func_get_args());
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'traceID' => "session_CFG");
     $userKey;
     $last_userKey;
     //----------------------------------------------------------
     if (is_null($email) && !isset($_COOKIE[$this->cookiePrefix . "user"])) {
         $chk['bool'] = false;
     }
     //----------------------------------------------------------
     if (!$chk['bool']) {
         $chk['message'] = "No session or email exist!!!";
         return $chk;
     }
     //----------------------------------------------------------
     if (session_id() == '') {
         session_start();
     }
     //----------------------------------------------------------
     if ($chk['bool'] && isset($_COOKIE[$this->cookiePrefix . "user"]) && is_null($email)) {
         $chk = $this->getSession($_COOKIE[$this->cookiePrefix . 'user']);
         if ($chk['bool']) {
             //Constants::$loggedIN = $chk['result'][0];
             $email = $chk['result'][0]['email'];
             $accounts_id = $chk['result'][0]['id'];
         }
     } else {
         $chk['bool'] = false;
     }
     //----------------------------------------------------------
     if (!$chk['bool'] && is_null($email)) {
         $chk['bool'] = false;
         $chk['message'] = "No session or email exist!!!";
         return $chk;
     }
     //----------------------------------------------------------
     $session_id = GenFun::encrypt(session_id() . $this->salt . $email);
     //----------------------------------------------------------
     $last_userKey = $_COOKIE[$this->cookiePrefix . "user"];
     //----------------------------------------------------------
     $userKey = $email . "-" . alphaID(time() . rand(0, 13000000));
     //----------------------------------------------------------
     setcookie($this->cookiePrefix . "user", $userKey, GenFun::getCookieTime());
     //----------------------------------------------------------
     $this->setAndChk($email);
     //----------------------------------------------------------
     if (!$chk['bool']) {
         $chk = GetTable::go(Accounts_const::TBL, array("email" => $email));
         //------------------------------------------------------
         if ($chk['bool'] && sizeof($chk['result']) > 0) {
             Update::go(SessionLog_const::TBL, array("disabled" => "{function}NOW()"), array("accounts_id" => $chk['result'][0]['id']));
         }
         //------------------------------------------------------
         session_regenerate_id();
         $session_id = GenFun::encrypt(session_id() . $this->salt . $email);
         if ($chk['bool']) {
             $chk = InsertINTO::go(SessionLog_const::TBL, array("userKey" => $userKey, "accounts_id" => $chk['result'][0]['id'], "session_id" => $session_id));
         }
         //------------------------------------------------------
         $session = $this->getSession($userKey);
         //------------------------------------------------------
         if ($session['bool']) {
             Constants::$loggedIN = $session['result'][0];
         }
     } else {
         setcookie("shit", $userKey, GenFun::getCookieTime());
         $chk = Update::go(SessionLog_const::TBL, array("userKey" => $userKey), array("userKey" => $last_userKey));
         Constants::$loggedIN['userKey'] = $userKey;
         if ($chk['bool']) {
             $chk['message'] = "session for this user has already been established!!!";
         }
     }
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 11
0
<?php

require_once "Import.php";
require_once Import::$uber_src_path . "server/werm/utils/GenFun.php";
if (file_exists("ProjectGlobal.php")) {
    Import::current("ProjectGlobal.php");
}
Import::sUtils("GetTable.php");
$hash = $_GET['hash'];
$chk = GetTable::go("files", array("hash" => $hash));
$_GET['url'] = ProjectGlobal::$filesPath . "/{$hash}/" . $chk['result'][0]['name'];
include Import::services("Download.php");
Esempio n. 12
0
 public function confirm($linkHash = NULL, $confirmTbl = NULL)
 {
     Trace::output($this->traceID, "confirm");
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $row = NULL;
     $confirmLink;
     $tbl = NULL;
     $this->confirmTbl = $confirmTbl;
     //----------------------------------------------------------
     if ($linkHash == NULL && isset($_GET['hash'])) {
         $linkHash = $_GET['hash'];
     }
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "confirm");
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = GenFun::error_CHK(array($linkHash, $this->confirmTbl));
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $this->getConfirmLink(NULL, $linkHash);
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     $confirmLink = $chk['result'][0];
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $this->exp_CHK($confirmLink);
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     if ($confirmLink['type'] == 1) {
         if (!$chk['bool']) {
             $chk = GetTable::go($this->confirmTbl, array("id" => $confirmLink['confirming_id']));
         } else {
             return $chk;
         }
         //------------------------------------------------------
         $tbl = $chk['result'][0];
         //------------------------------------------------------
         if ($chk['bool']) {
             $chk = $this->tblConfirm_CHK($tbl);
         } else {
             return $chk;
         }
         //------------------------------------------------------
         if (!$chk['bool']) {
             $chk = $this->confirmSubscription($tbl['id'], $confirmLink['type']);
         } else {
             return $chk;
         }
         //------------------------------------------------------
     } else {
         if ($confirmLink['type'] == 0) {
             if (!$chk['bool']) {
                 $chk = $this->disableSubscription($confirmLink['confirming_id']);
             } else {
                 return $chk;
             }
         }
     }
     //----------------------------------------------------------
     if ($chk['bool']) {
         $chk = $this->disableConfirmLink($linkHash);
     } else {
         return $chk;
     }
     //----------------------------------------------------------
     if ($chk['bool'] && $confirmLink['type'] == 0) {
         $chk['message'] = $email . " has successfully unsubscried to " . $tbl['categories_id'];
     }
     //----------------------------------------------------------
     if ($chk['bool'] && $confirmLink['type'] == 1) {
         $chk['message'] = $email . " has successfully subscried to " . $tbl['categories_id'];
         $chk['type'] = 0;
     }
     //----------------------------------------------------------
     $chk['confirmLink'] = $confirmLink;
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 13
0
 public function email_CHK($email)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, "traceID" => "email_CHK");
     //----------------------------------------------------------
     $email_result = GetTable::go("accounts", array('email' => $email));
     //----------------------------------------------------------
     if (!$email_result['bool']) {
         return $email_result;
     }
     //----------------------------------------------------------
     if (sizeof($email_result['result']) == 0) {
         $chk['bool'] = true;
     } else {
         $chk['bool'] = false;
         $chk['message'] = "'" . $email . "' ALREADY BELONGS TO A PMBL MEMBER";
     }
     //----------------------------------------------------------
     $chk['email'] = $email;
     //----------------------------------------------------------
     return $chk;
 }
Esempio n. 14
0
 public function _getPlaylist($hash = NULL, $lookThroughAll = false, $excludeVideo_id = NULL, $exclude_id = NULL, $limitFrom = NULL, $limitTo = NULL, $getTotal = false, $returnQuery = false)
 {
     Trace::output($this->traceID, "getPlaylist: " . print_r(func_get_args(), true));
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $excludeVideo_id = GenFun::varChk($excludeVideo_id);
     //----------------------------------------------------------
     $whereArr = array();
     //----------------------------------------------------------
     if (!$lookThroughAll) {
         $whereArr["title"] = "{ignore} IS NOT NULL";
         $whereArr["disabled"] = "{ignore} IS NULL";
     }
     //----------------------------------------------------------
     if (!is_null($hash)) {
         $whereArr["hash"] = $hash;
     }
     //----------------------------------------------------------
     if (!is_null($exclude_id)) {
         $whereArr["id"] = "{isnot}{$exclude_id}";
     }
     //----------------------------------------------------------
     if (!is_null($excludeVideo_id)) {
         $whereArr['id'] = "{notin}" . $this->getPlaylistWithVideo($excludeVideo_id, false, true);
     }
     //----------------------------------------------------------
     $chk = GetTable::go("playlist", $whereArr, array('getTotalRows' => $getTotal, "chkForQuery" => true, "returnQuery" => $returnQuery ? true : false));
     //----------------------------------------------------------
     if (!is_null($hash)) {
         $chk['result'] = $chk['result'][0];
     }
     //----------------------------------------------------------
     return $chk;
 }