Example #1
0
File: Feedback.php Project: rjha/sc
 static function delete($id)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = "delete from sc_feedback where id = ?";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("i", $id);
         $stmt->execute();
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #2
0
File: Mail.php Project: rjha/sc
 static function add($name, $email, $token, $source)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //sanitize input
     $name = $mysqli->real_escape_string($name);
     $email = $mysqli->real_escape_string($email);
     $token = $mysqli->real_escape_string($token);
     $sql = " insert into sc_mail_queue(name,email,token, source,created_on,expired_on) ";
     $sql .= " values(?,?,?,?,now(), now() + INTERVAL 1 DAY) ";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("sssi", $name, $email, $token, $source);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #3
0
File: Media.php Project: rjha/sc
 static function add($mediaVO)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $mediaId = NULL;
     $sql = " insert into sc_media(bucket,original_name, stored_name, ";
     $sql .= " size,mime, original_height, original_width,created_on,store,thumbnail,thumbnail_name) ";
     $sql .= " values(?,?,?,?,?,?,?,now(),?,?,?) ";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("sssisiisss", $mediaVO->bucket, $mediaVO->originalName, $mediaVO->storeName, $mediaVO->size, $mediaVO->mime, $mediaVO->height, $mediaVO->width, $mediaVO->store, $mediaVO->thumbnail, $mediaVO->thumbnailName);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
     $mediaId = MySQL\Connection::getInstance()->getLastInsertId();
     return $mediaId;
 }
Example #4
0
File: Site.php Project: rjha/sc
 static function updateTracker($postId, $version)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $stmt = $mysqli->prepare("CALL UPDATE_SITE_TRACKER(?,?)");
     $stmt->bind_param("ii", $postId, $version);
     $flag = $stmt->execute();
     if (!$flag) {
         MySQL\Error::handle($stmt);
     }
     $stmt->close();
 }
Example #5
0
File: User.php Project: rjha/sc
 static function set_tu_bit($userId, $value)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = "update sc_denorm_user set updated_on = now(), tu_bit = ? where id = ?";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("ii", $value, $userId);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #6
0
File: Bookmark.php Project: rjha/sc
 static function remove($subjectId, $objectId, $verb)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = "delete from sc_bookmark where subject_id = ? and object_id = ? and verb = ? ";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("iii", $subjectId, $objectId, $verb);
         $stmt->execute();
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #7
0
File: Lists.php Project: rjha/sc
 static function delete($loginId, $listId)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = " delete from sc_list where id = ? and login_id = ?";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("ii", $listId, $loginId);
         $stmt->execute();
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #8
0
 static function glset($key, $value)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     //create the key if it does not exist
     // otherwise update
     $sql = " insert into sc_glob_table(t_hash,t_key,t_value,created_on) values (?,?,?,now()) ";
     $sql .= " on duplicate key update t_value = values(t_value), updated_on = values(created_on) ";
     $stmt = $mysqli->prepare($sql);
     $khash = md5(trim($key), TRUE);
     if ($stmt) {
         $stmt->bind_param("sss", $khash, $key, $value);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #9
0
File: Login.php Project: rjha/sc
 static function updateIp($sessionId, $loginId, $remoteIp)
 {
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     $sql = " update sc_login set ip_address = ?, session_id = ? , updated_on = now() ";
     $sql .= " where id = ? ";
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("ssi", $remoteIp, $sessionId, $loginId);
         $stmt->execute();
         if ($mysqli->affected_rows != 1) {
             MySQL\Error::handle($stmt);
         }
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }
Example #10
0
 static function changePassword($tableName, $loginId, $email, $password)
 {
     if (empty($tableName)) {
         trigger_error("User Table name is not supplied", E_USER_ERROR);
         exit(1);
     }
     Util::isEmpty('Email', $email);
     Util::isEmpty('Password', $password);
     $mysqli = MySQL\Connection::getInstance()->getHandle();
     // get random salt
     $salt = substr(md5(uniqid(rand(), true)), 0, 8);
     $password = trim($password);
     $message = $password . $salt;
     //create SHA-1 digest from email and password
     // we store this digest in table
     $digest = sha1($message);
     $sql = " update {table} set updated_on=now(), salt=?, password=? where email = ? and login_id = ?";
     $sql = str_replace("{table}", $tableName, $sql);
     $stmt = $mysqli->prepare($sql);
     if ($stmt) {
         $stmt->bind_param("sssi", $salt, $digest, $email, $loginId);
         $stmt->execute();
         $stmt->close();
     } else {
         MySQL\Error::handle($mysqli);
     }
 }