public static function chk($username, $accounts_id = NULL) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "session_CFG"); $userKey; //---------------------------------------------------------- $chk = GenFun::error_CHK(array($username)); //---------------------------------------------------------- if ($chk['bool']) { if (is_null(Constants::$mysqli)) { GenFun::hostConnect(); } } else { return $chk; } //---------------------------------------------------------- session_start(); $session_id = GenFun::encrypt(session_id() . self::SALT . $username); //---------------------------------------------------------- if ($chk['bool']) { $chk = MySQL::getTable(SessionLog_const::TBL, array("session_id" => $session_id, "userKey" => $_COOKIE['user'])); } else { return $chk; } //---------------------------------------------------------- $userKey = $username . "-" . rand(0, 13000000); setcookie("user", $userKey); //---------------------------------------------------------- if (sizeof($chk['result']) == 0) { $chk = InsertINTO::go(array("tableID" => SessionLog_const::TBL, "setArr" => array("userKey" => $userKey, "accounts_id" => $accounts_id, "session_id" => $session_id))); } else { $chk = Update::go(SessionLog_const::TBL, array("userKey" => $userKey), array("session_id" => $session_id)); if ($chk['bool']) { $chk['message'] = "session for this user has already been established!!!"; } } //---------------------------------------------------------- return $chk; }
public function changePassword($hash, $password) { Trace::output($this->traceID, "changePassword"); //---------------------------------------------------------- $chk = GenFun::error_chk(array($hash, $password)); //---------------------------------------------------------- $this->tblName = ForgotPwRequest_const::TBL; //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, "traceID" => "changePassword"); //---------------------------------------------------------- $chk = $this->getAccountRow($hash); //---------------------------------------------------------- if (!$chk['bool']) { return $chk; } //---------------------------------------------------------- if ($chk['result'][0]['confirmed'] == 1) { $chk['bool'] = false; } //---------------------------------------------------------- if (sizeof($chk['result']) != 0 && $chk['bool']) { $chk = Update::go(Accounts_const::TBL, array("password" => GenFun::encrypt($password . $this->salt)), array("id" => $chk['result'][0]['accounts_id'])); $chk = $this->confirm($hash, "forgotPwRequest"); } else { $chk['bool'] = false; $chk['message'] = "This link has been disabled!!!"; } //---------------------------------------------------------- if ($chk['bool']) { $chk['message'] = "Password Updated!!!"; } //---------------------------------------------------------- return $chk; }
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; }
private function updateAssets($id, $returnRow = true) { Trace::output($this->traceID, "updateAssets"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "updateAssets"); $insertID = GlobalMas::$mysqli->insert_id; //---------------------------------------------------------- $chk = Update::go(Projects_const::TBL, array(Projects_const::CLM_ASSETS_ID => $insertID), array("id" => $id)); //---------------------------------------------------------- if ($returnRow) { $chk = MySQL::getTable(Assets_const::TBL, array(Assets_const::CLM_ID => $insertID)); } //---------------------------------------------------------- return $chk; }
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; } }
private function process($table, $row, $format) { $chk = array("bool" => true); if (!empty($row[$format])) { $chk = InsertINTO::go('files', array("name" => $row[$format], 'hash' => GenFun::encrypt($row[$format] . $row['id'])), array("ignore" => true)); } if ($chk['bool'] && !empty($row[$format])) { $chk = Update::go("videos", array($format => Constants::$mysqli->insert_id), array("id" => $row['id'])); } print_r($chk); return $chk; }
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; }
public function addAccountRow() { Trace::output($this->traceID, "addRow"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "subscribe"); //---------------------------------------------------------- $chk = InsertINTO::go(Accounts_const::TBL, $this->set); //---------------------------------------------------------- $this->accounts_id = $chk['insert_id']; //---------------------------------------------------------- $geoip = GenFun::getGeoIP(); //---------------------------------------------------------- if ($chk['bool']) { $geoResult = InsertINTO::go("geoip", $geoip); } //---------------------------------------------------------- if (!$geoResult['error']) { Update::go("accounts", array("geoip_id" => $geoResult['insert_id'])); } else { return $geoResult; } //---------------------------------------------------------- return $chk; }
private function confirmSubscription($id) { Trace::output($this->traceID, "confirmSubscription"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, "traceID" => "confirmSubscription"); //---------------------------------------------------------- $chk = Update::go($this->confirmTbl, array('confirmed' => 1), array("id" => $id), array('message_true' => "confirmed!!!")); //---------------------------------------------------------- return $chk; }
public function updateApplication($appID, $event_id, $team_name = "{DEFAULT}", $team_id = NULL) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "updateApplication"); $newTeam_chk = NULL; //---------------------------------------------------------- if ($team_name != "{DEFAULT}" && is_null($team_id)) { $newTeam_chk = $this->newTeam($team_name); } //---------------------------------------------------------- if (!is_null($newTeam_chk)) { if ($newTeam_chk['bool']) { $team_id = GlobalMas::$mysqli->insert_id; } } //---------------------------------------------------------- //print_r($appID); $chk = Update::go("applications", array("teams_id" => $team_id), array("hash" => $appID, "events_id" => $event_id)); //---------------------------------------------------------- //$chk = Result::go($queryString); //---------------------------------------------------------- //$this->getOpenApplications($chk['result']['accounts_id']); //---------------------------------------------------------- return $chk; }
public function resetQueries() { return Update::go("queries", array("last_update" => "{DEFAULT}")); }
private function disableSubscription($id) { Trace::output($this->traceID, "disableSubscription"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, "traceID" => "disableSubscription"); //---------------------------------------------------------- $chk = Update::go($this->confirmTbl, array("disabled" => "{function}NOW()"), array("id" => $id)); /*$queryString = "UPDATE ".$this->confirmTbl; $queryString .= " SET disabled = NOW()"; $queryString .= " WHERE ".$this->confirmTbl.".id='".$id."'"; $result = Constants::$mysqli->query($queryString);*/ //---------------------------------------------------------- if ($chk['bool']) { $chk['bool'] = true; $chk["message"] = "{$id} disabled!!!"; } //---------------------------------------------------------- Trace::output($this->traceID, "disableSubscription: " . $chk['message']); //---------------------------------------------------------- $chk['output'] = Trace::$output; //---------------------------------------------------------- return $chk; }