public static function Delete() { $results = []; $test = QueryFactory::Build("delete"); $test->From("users")->Where(["email", "=", "asd"])->Limit(); self::testing("Delete"); $qinfo = DatabaseManager::Query($test); self::testQuery($test, true, 1, $qinfo->RowCount()); $results[count($results)] = $qinfo; $qinfo = DatabaseManager::Query($test); self::testQuery($test, false, 0, $qinfo->RowCount()); $results[count($results)] = $qinfo; return $results; }
public function setValues($id, $pw, $dnr, $snr, $msg, $customer_id, $campaign_id, $delivery_receipt, $unique_msg_id) { $ActionResult = false; if (160 < strlen($msg)) { $NearestSpace = strpos($msg, ' ', 160); $Message = substr($msg, 0, $NearestSpace); $SecondMessage = substr($msg, $NearestSpace, strlen($msg)); } else { $Message = $msg; $SecondMessage = ""; } $url = "http://smsgw1.a2p.mme.syniverse.com/sms.php?" . "id={$id}" . "&pw=" . UrlEncode($pw) . "&drep=" . $delivery_receipt . "&dnr=" . UrlEncode($dnr) . "&snr=" . UrlEncode($snr) . "&dtag=" . $unique_msg_id . "&msg=" . UrlEncode($Message); if ($f = @fopen($url, "r")) { $answer = fgets($f, 255); if (substr($answer, 0, 1) == "+") { $res = "success: {$answer}"; $ActionResult = true; } else { $res = "failure: {$answer}"; $ActionResult = $res; } } else { $res = "failure: error opening URL"; } if ($SecondMessage != "") { $url = "http://smsgw1.a2p.mme.syniverse.com/sms.php?" . "id={$id}" . "&pw=" . UrlEncode($pw) . "&drep=" . $delivery_receipt . "&dnr=" . UrlEncode($dnr) . "&snr=" . UrlEncode($snr) . "&dtag=" . $unique_msg_id . "&msg=" . UrlEncode($SecondMessage); if ($f = @fopen($url, "r")) { $answer = fgets($f, 255); if (substr($answer, 0, 1) == "+") { $res = "success: {$answer}"; $ActionResult = true; } else { $res = "failure: {$answer}"; $ActionResult = $res; } } else { $res = "failure: error opening URL"; } } $db = new DatabaseManager(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE); $SQL = 'INSERT INTO MessagingOutGoingLog(AdminCustomerID,CampaignCampaignID,MessagingMessageTypeID,DeliveryReceipt,Destination,Message,MessageKey,Result) VALUES(' . $customer_id . ', ' . $campaign_id . ', 4, "' . $delivery_receipt . '", "' . $dnr . '", "' . mysql_real_escape_string($msg) . '", "' . $unique_msg_id . '", "' . mysql_real_escape_string($res) . '")'; $db->setQuery($SQL); $db->Query(); return $ActionResult; }
function process($curr) { echo $curr["name"] . ": "; echo $curr["frequency"] . "<br>"; //if need to run task if (strtotime($curr["frequency"], $curr["lastRun"]) < time()) { //run job include __DIR__ . '/' . $curr["name"]; //update last run time $ran = QueryFactory::Build('update'); $ran->Table("schedule")->Set(["lastRun", time()])->Where(["name", '=', $curr["name"]]); $success = DatabaseManager::Query($ran); //for testing if ($success->RowCount() > 0) { echo $curr['name'] . " updated"; } else { echo $curr['name'] . " failed"; } } }
function deactivate($id) { $update = QueryFactory::Build('update'); $update->Table('users')->Set(['activated', -1])->Where(['id', '=', $id]); $temp = DatabaseManager::Query($update); if ($temp->RowCount() == 1) { echo "deactivated " . $id; } else { echo "failed to deactivate " . $id; } }
) # End host alternatives. ([\\w-]{11}) # $1: VIDEO_ID is exactly 11 chars. (?=[^\\w-]|$) # Assert next char is non-ID or EOS. (?! # Assert URL is not pre-linked. [?=&+%\\w.-]* # Allow URL (query) remainder. (?: # Group pre-linked alternatives. [\'"][^<>]*> # Either inside a start tag, | </a> # or inside <a> element text contents. ) # End recognized pre-linked alts. ) # End negative lookahead assertion. [?=&+%\\w.-]* # Consume any URL (query) remainder. ~ix', $text, $result); return $result[1]; } $select = QueryFactory::Build("select")->Select("id", "title", "content", "created", "viewby")->From("articles"); $info = DatabaseManager::Query($select); $articles = $info->Result(); // Result returns the result directly if there is only one result // This compensates for that by wrapping the single result in an array, like multiple articles would be // This allows for a simpler code base if ($info->RowCount() < 2) { $articles = [$articles]; } ?> <script> var youtubeLinkRegex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/; $(document).ready(function(){ var editors = 0; var articles = $("#articlesList"); articles.on('click', '#edit', function (e) { p = $(e.target).parent().parent();
$secret = "6LejtgYTAAAAAMlSC70hXViKkntfBVU2PBdICylx"; // this is a secret code for reCaptcha connection $ip = gethostbyname($_SERVER['SERVER_NAME']); // this is how you grab end user's ip $captcha = $_POST['g-recaptcha-response']; $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$captcha}&remoteip={$ip}"); $captchaResult = json_decode($response, true); //****************************************************************************************************************************************************************************** if ($captchaResult['success']) { $id = UserModel::Register($email, $password); // Call to Register function in UserModel, returns true if register is a success if ($id) { //***************** SEND ACTIVATION EMAIL ******************************** $userQuery = QueryFactory::Build("select"); $userQuery->Select("email", "created")->From("users")->Where(["id", "=", $id])->Limit(); $res = DatabaseManager::Query($userQuery); $res = $res->Result(); // get result from table $link = sha1($id . $res["email"] . $res["created"]); // get the hash value for the link to send out Mailer::Send("{$email}", "Activation Email", "Please click on the link below to activate your account, http://{$server}/activation.php?id={$id}&link={$link}"); $msg = ["Registration successful, please check your email for account activation", 1]; unset($_POST); } } else { $msg = ["You are not a human, registration denied! <br>", 0]; } } } } }
private function populateTable($inserts) { // nothing to populate the table with if (count($inserts) < 1) { return; } foreach ($inserts as $insert) { DatabaseManager::Query($insert); } }
public static function updateElement($id, $column, $value) { $update = QueryFactory::Build("update"); //new update query $update->Table("users")->Where(["id", "=", $id])->Set([$column, $value]); //update the query $res = DatabaseManager::Query($update); // execute the query if ($res->RowCount() == 1) { return true; } return false; }
public function getDataTableRowCount() { $query = QueryFactory::Build('select'); $query->Select('id')->From('enrollment_form'); $enrolCount = DatabaseManager::Query($query); $query = QueryFactory::Build('select'); $query->Select('id')->From('questionnaire_form'); $questCount = DatabaseManager::Query($query); $query = QueryFactory::Build('select'); $query->Select('id')->From('parq_form'); $parqCount = DatabaseManager::Query($query); /* uncomment when assessments are working and done $query = QueryFactory::Build('select'); $query->Select('id')->From('assessment'); $enrolCount = DatabaseManager::Query($query); */ // add the value for assessments when they are done $value_array = array($enrolCount->RowCount(), $questCount->RowCount(), $parqCount->RowCount()); return $value_array; }
$saltTime = $res["salt_time"]; //if current time is greater then last salt ( When the link was created ) // *************** BIG NOTE!!! change this update to 1 day before deploy!!! ( IN SETTINGS TABLE!!!! ) if ($saltTime < time()) { // READ FROM SETTINGS TABLE TO GRAB THE SALT_TIME AND PLUG IT IN BELOW $select = QueryFactory::Build("select"); $select->Select("value")->From("settings")->Where(["name", "=", "forgotpassword"])->Limit(); $lifeTime = DatabaseManager::Query($select)->Result()['value']; //print_r($select->Query(true)); //update salt and salt_time $salt = bin2hex(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)); // this will generate a new salt every time if exceed 24 hrs $update = QueryFactory::Build("update"); $update->Table("users")->Where(["id", "=", $id])->Set(["salt", $salt], ["salt_time", strtotime("{$lifeTime}")]); //update the salt and add a certain time to last salt CHANGE TO VARIABLE $resUpdate = DatabaseManager::Query($update); // execute the query $link = sha1($id . $salt); } else { $link = sha1($id . $salt); } Mailer::Send("{$email}", "Reset Password", "Please click on the link below to change your password, http://{$server}/resetPassword.php?id={$id}&link={$link}"); $msg = ["Please check your email for reset password link", 1]; } } // ******************************** FORM ENFORCEMENT REGKEY !!! *************************************************8 } ?> <div class="background">
<?php require_once "header.php"; $msg = ""; $id = Validator::instance()->sanitize("int", $_GET['id']); //get the ID from the link to prevent people from inserting their own ID // ****************************** Activate the user by ID *********************************************************************** $select = QueryFactory::Build("select"); $select->Select("id", "email", "created", "activated")->From("users")->Where(["id", "=", $id])->Limit(); $res = DatabaseManager::Query($select); $res = $res->Result(); if ($res["activated"] === 1) { $msg = ["Your account is already activated!", 1]; } $userActivationHash = sha1($res["id"] . $res["email"] . $res["created"]); // get user hash from database to compare against the link if ($userActivationHash === $_GET['link']) { if (UserModel::updateElement($res["id"], "activated", "1")) { // if acctivation is a success $msg = ["Account activation successful!", 1]; } else { $msg = ["Your account is already activated!", 0]; } } else { $msg = ["Invalid link, please try again!", 0]; } ?> <div class="background"> <h2><center> Activation </center></h2>
<div class="background"> <!-- Accordion --> <?php $find = QueryFactory::Build('select'); $find->Select("Chairstand", "ArmCurl", "StepTest", "FootUpAndGo", "leftunilateralbalancetest", "rightunilateralbalancetest", "FunctionalReach")->From('assessments')->Where(['userID', '=', $user->id, "AND"], ['DateCompleted', '=', 0]); $find->Limit(); $res = DatabaseManager::Query($find); $result = $res->Result(); $left = $result["leftunilateralbalancetest"]; $right = $result["rightunilateralbalancetest"]; $result["unilateralbalancetest"] = [$left, $right]; unset($result["leftunilateralbalancetest"], $result["rightunilateralbalancetest"]); $time = QueryFactory::Build('select'); $time->Select("NextAssessment")->From("users")->Where(["id", "=", $user->id])->limit(); $time = DatabaseManager::Query($time); $time = $time->Result()["NextAssessment"]; //echo $time; ?> <h1 class="demoHeaders">Assessments</h1> <?php //show next assessment date if ($time > 0 && $time > time()) { echo "<h2>next assessment on " . date("F d, Y", $time) . "</h2>"; } ?> <form method="post"> <?php
public static function isQuestionnaireComplete($id) { $select = QueryFactory::Build("select"); $select->Select('completed')->Table('questionnaire_form')->Where(['userID', '=', $id])->Limit(); $res = DatabaseManager::Query($select); $resultArray = $res->Result(); if ($res->RowCount() == 1) { return $res; } return false; }
<pre> <?php $name = "userTable_" . date('Y-m-d') . '.csv'; $myFile = fopen($name, "w"); $select = QueryFactory::Build("select"); // get all rows to users table $select->Select("id", "email", "created", "password", "pLevel")->From("users"); // Get the results from the query execution $res = DatabaseManager::Query($select)->Result(); //iterate and write to file foreach ($res as $value) { fputcsv($myFile, $value); } //Mailer::Send("$email","Activation Email","Please click on the link below to activate your account, http://localhost/activation.php?id=$id&link=$link"); //delete file??? ?> </pre>
private function validate($insert) { $p = $this->data; $insert->Set(["userID", $p['userID']]); if (isset($p['ArmCurl'])) { $insert->Set(['Armcurl', -1]); } if (isset($p['ChairStand'])) { $insert->Set(['Chairstand', -1]); } if (isset($p['Steptest'])) { $insert->Set(['StepTest', -1]); } if (isset($p['FootUpandGo'])) { $insert->Set(['FootUpAndGo', -1]); } if (isset($p['Unilateral'])) { $insert->Set(['leftunilateralbalancetest', -1]); $insert->Set(['rightunilateralbalancetest', -1]); } if (isset($p['Functional'])) { $insert->Set(['FunctionalReach', -1]); } if (isset($p['Functional']) || isset($p['Unilateral']) || isset($p['FootUpandGo']) || isset($p['Steptest']) || isset($p['ChairStand']) || isset($p['ArmCurl'])) { $date = QueryFactory::Build('update'); $date->Table("users"); $date->Set(['NextAssessment', "UNIX_TIMESTAMP()"]); $date->Where(["id", "=", $p["userID"]]); $s = DatabaseManager::Query($date); return $insert; } else { ?> <script>alert("Please select at least one assessment.");</script><?php } }
public function DeleteWod($Id) { $db = new DatabaseManager(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_CUSTOM_DATABASE); $SQL = 'DELETE FROM CustomWorkouts WHERE recid = "' . $Id . '"'; $db->setQuery($SQL); $db->Query(); $SQL = 'DELETE FROM CustomDetails WHERE CustomWorkoutId = "' . $Id . '"'; $db->setQuery($SQL); $db->Query(); return 'WOD has been deleted'; }
private function set($name, $enabled) { //format string $str = $this->formatString(); //update $update = QueryFactory::Build('update'); $update->Table('settings')->Set(['enabled', $enabled])->Where(['name', '=', $name]); if (strlen($str) > 2) { $update->Table('settings')->Set(['value', $str]); } $cinfo = DatabaseManager::Query($update); if ($cinfo->RowCount() != 1) { return "our servers are having issues please try again later"; } return false; }
<?php //--------------------------------- //path to cronJobs file $path = "cronJobs/"; //path to config and sessions chdir('..'); //needed to use models require_once "config.php"; require_once "sessions.php"; //---------------------------------------- $select = QueryFactory::Build("select"); // get all rows to users table $select->Select("id", "email", "created", "password", "pLevel", "activated")->From("users"); // Get the results from the query execution $res = DatabaseManager::Query($select); if ($res->RowCount() > 1) { $res = $res->Result(); foreach ($res as $row) { //if not admin get from settings? if (!$row["activated"] && time() > strtotime("+1 days", $row["created"])) { //delete user $del = QueryFactory::Build("delete"); $del->Table("users")->Where(["id", "=", $row["id"]]); $deleted = DatabaseManager::Query($del); } } }