Пример #1
0
 public static function add($param)
 {
     $pdo = new DBUtils();
     $key_str = "";
     $val_str = "";
     $sql = "";
     if (isset($param['type'])) {
         $key_str .= "type,";
         $val_str .= "'{$param['type']}',";
     }
     if (isset($param['studentName'])) {
         $key_str .= "studentName,";
         $val_str .= "'{$param['studentName']}',";
     }
     if (isset($param['num'])) {
         $key_str .= "num" . ",";
         $val_str .= "'{$param['num']}',";
     }
     $now = time();
     $key_str .= "time" . ",";
     $val_str .= "'{$now}',";
     $key_str .= "course" . ",";
     $val_str .= "'{$GLOBALS['STUDENT_COURSE_TYPE'][0]}',";
     $key_str = substr($key_str, 0, strlen($key_str) - 1);
     $val_str = substr($val_str, 0, strlen($val_str) - 1);
     $sql = "insert into student_news (" . $key_str . ")";
     $sql .= " VALUES (" . $val_str . ")";
     $articleId = $pdo->insert($sql);
     return $articleId;
 }
Пример #2
0
 public static function getIndex()
 {
     $pdo = new DBUtils();
     $sql = "select * from homepage";
     $rs = $pdo->query($sql);
     return $rs;
 }
Пример #3
0
 public static function updatePhoto($param)
 {
     $pdo = new DBUtils();
     $sql = "update homepage set photoUrl = '" . $param['photoUrl'] . "' where id  = '{$param['id']}'";
     $rs = $pdo->update($sql);
     return $rs;
 }
Пример #4
0
 public static function delNav($snavId)
 {
     $pdo = new DBUtils();
     $sql = "delete from second_nav where snavId = '{$snavId}'";
     //        print_r($sql);
     //        exit;
     $rs = $pdo->delete($sql);
     return $rs;
 }
Пример #5
0
 public static function getOne($courseId)
 {
     $pdo = new DBUtils();
     $sql = "select * from course where courseId = {$courseId}";
     $course = $pdo->getOne($sql);
     $sql = "select * from courseType where courseId = {$courseId}";
     $courseType = $pdo->query($sql);
     return array("course" => $course, "courseType" => $courseType);
 }
Пример #6
0
 public function verifyUser()
 {
     $dbUtil = new DBUtils();
     $value = $dbUtil->verifyUser($this->username, $this->password);
     if ($value) {
         $_SESSION["id"] = $this->username;
         return "Logged in sucessfully";
     } else {
         return "Log in failed. Please try with proper user.";
     }
     return $value;
 }
Пример #7
0
 public function log()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId);
     if (!empty($this->userId)) {
         $userXPLog = new GameUserXpLog();
         $userXPLog->setUserId($this->userId);
         $userXPLog->setXp($this->xp);
         $userXPLog->setTime($this->time);
         $userXPLog->setType($this->type);
         $userXPLog->setGameId($this->gameId);
         $userXPLog->setResult($this->result);
         $userXPLog->setOpponentId($this->opponentId);
         try {
             $user = GameUsers::getGameUserById($this->userId);
             if (!empty($user)) {
                 $userXPLog->setUserLevel($user->userLevelNumber);
                 $userXPLog->setUserCoin($user->coins);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
             }
         } catch (Exception $exc) {
             $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString());
         }
         try {
             $userXPLog->insertIntoDatabase(DBUtils::getConnection());
             $log->logInfo("userxplog > log > Success");
         } catch (Exception $exc) {
             $log->logError("userxplog > log > Error : " . $exc->getTraceAsString());
         }
     } else {
         $log->logError("userxplog > log > user Id is empty ");
     }
 }
 public static function getGameCategoryItemWithLanguage()
 {
     $SQL = "SELECT categories.*,lang.language AS langCode,lang.text AS langText FROM " . TBL_GAME_ITEM_CATEGORY . " AS categories," . TBL_GAME_ITEM_CATEGORY_LANGUAGE . " AS lang WHERE categories.active=1 AND categories.categoryCode=lang.categoryCode ORDER BY id ASC";
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     if (!empty($query)) {
         $list = array();
         $ids = array();
         $i = 0;
         while ($db_field = mysql_fetch_assoc($query)) {
             $cat = GameItemCategory::createFromSQLWithLanguage($db_field);
             if (!empty($cat)) {
                 $catId = $cat->getId();
                 if (!empty($catId)) {
                     if (isset($ids[$catId]) && isset($list[$ids[$catId]])) {
                         $oldItem = $list[$ids[$catId]];
                         $oldItem->languages = array_merge($oldItem->languages, $cat->languages);
                     } else {
                         array_push($list, $cat);
                         $ids[$catId] = $i;
                         $i++;
                     }
                 }
             }
         }
         unset($ids);
         return $list;
     }
     return array();
 }
Пример #9
0
 public static function gameResult(GameUsers $user, GameUsers $opponent, $roomGroupId, $action, $gameId = null, $double = 0, $normal = true, $type = null, $time = null)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($user) && !empty($action)) {
         if (empty($action) || !empty($action) && $action != GameUtils::$GAME_RESULT_ACTION_WIN && $action != GameUtils::$GAME_RESULT_ACTION_LOST) {
             $result->result = "Unknown Action";
             return $result;
         }
         GameUtils::updateXP($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCoin($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCounts($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         if ($action == GameUtils::$GAME_RESULT_ACTION_WIN && ($type == GameUtils::$GAME_RESULT_ACTION_TYPE_LEFT || $type == GameUtils::$GAME_RESULT_ACTION_TYPE_TIMESUP) && !empty($opponent)) {
             if (empty($time)) {
                 $time = time();
             }
             Queue::userLostConnLost($opponent->userId, $user->userId, $roomGroupId, GameUtils::$GAME_RESULT_ACTION_LOST, $gameId, $double, $normal, $type, $time);
         }
         try {
             $user->updateToDatabase(DBUtils::getConnection());
             $result->success = true;
             $result->result = new stdClass();
             $result->result->user = $user;
         } catch (Exception $exc) {
             $result->success = true;
             $result->result = $exc->getTraceAsString();
         }
         return $result;
     } else {
         $result->result = "User not found";
         return $result;
     }
 }
 public static function setConstant($key, $value = null)
 {
     if (!empty($key)) {
         GameConstantUtil::setCacheConstant($key, $value);
         $setting = GameConstants::findByExample(DBUtils::getConnection(), GameConstants::create()->setKey_($key));
         if (!empty($setting)) {
             if (sizeof($setting) > 0) {
                 $setting = $setting[0];
                 $k = $setting->getKey_();
                 if (empty($k)) {
                     $setting = null;
                 }
             } else {
                 $setting = null;
             }
         }
         if (!empty($setting)) {
             $setting->setValue_($value);
         } else {
             $setting = GameConstants::create();
             $setting->setKey_($key);
             $setting->setValue_($value);
         }
         $setting->updateInsertToDatabase(DBUtils::getConnection());
     }
     return false;
 }
Пример #11
0
function getNav()
{
    $pdo = new DBUtils();
    $sql = "select * from nav";
    $nav = $pdo->query($sql);
    $header = array();
    foreach ($nav as $key => $val) {
        $header[$val['navId']] = array("navName" => $val['navName'], "navId" => $val['navId'], "second" => array());
    }
    $sql = "select * from second_nav";
    $second = $pdo->query($sql);
    foreach ($second as $key => $val) {
        $header[$val['navId']]['second'][$val['snavId']] = array("snavName" => $val['snavName'], "snavId" => $val['snavId'], "link" => $val['snavName']);
    }
    return $header;
}
Пример #12
0
 public static function autoLogin($rememberme = true)
 {
     if (isset($_SESSION["userId"])) {
         $userId = $_SESSION["userId"];
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             UtilFunctions::storeSessionUser($user, $rememberme);
             return $user;
         }
     }
     if (isset($_COOKIE["auth"]) && false) {
         $cookie = $_COOKIE["auth"];
         $arr = explode('&', $cookie);
         $userName = substr($arr[0], 4);
         $hash = substr($arr[1], 5);
         $user = GameUsers::getGameUserByUserName($userName);
         if (!empty($user)) {
             if ($hash == md5($user->getPassword())) {
                 $user->setLastLoginDate(time());
                 $user->setLoginCount($user->getLoginCount() + 1);
                 $user->updateToDatabase(DBUtils::getConnection());
                 Queue::checkUserFriends($user->userId);
                 UtilFunctions::storeSessionUser($user, $rememberme);
                 return $user;
             } else {
                 UtilFunctions::forgetMe();
             }
         }
     }
     return false;
 }
    /**
     * save data in plenty_countries_of_delivery
     * 
     * @param PlentySoapObject_GetCountriesOfDelivery $countryOfDelivery
     */
    private function saveInDatabase($countryOfDelivery)
    {
        $query = 'REPLACE INTO `plenty_countries_of_delivery` 
						' . DBUtils::buildInsert(array('country_id' => $countryOfDelivery->CountryID, 'active' => $countryOfDelivery->CountryActive, 'country_name' => $countryOfDelivery->CountryName, 'iso_code_2' => $countryOfDelivery->CountryISO2));
        $this->getLogger()->debug(__FUNCTION__ . ' save country ' . $countryOfDelivery->CountryISO2 . ' ' . $countryOfDelivery->CountryName);
        DBQuery::getInstance()->replace($query);
    }
Пример #14
0
 function find_by_account($account, $limit = null)
 {
     $db =& DBUtils::connect();
     $sql = 'SELECT f.id, f.url AS url FROM foaf f
         JOIN member m ON f.member_id = m.id
         WHERE m.account = ?';
     $result = $db->getAll($sql, array($account));
     if (DB::isError($result)) {
         trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . $result->toString(), E_USER_ERROR);
         return null;
     }
     $parser =& new FOAFParser(true, CACHE_LITE_DIR, 60 * 60 * 24 * 1);
     $foafs = array();
     foreach ($result as $foaf) {
         if (@$parser->parse($foaf['url']) === false) {
             continue;
         }
         $people = $parser->getKnowsPerson();
         foreach ($people as $index => $person) {
             $people[$index]['foaf_id'] = $foaf['foaf_id'];
             $people[$index]['foaf_url'] = $foaf['url'];
             $p =& new FOAFParser(true, CACHE_LITE_DIR, 60 * 60 * 24 * 1);
             if ($p->parse($person['seeAlso'])) {
                 $person['img'] = $p->getImg();
             }
             $foafs[$person['seeAlso']] = $person;
         }
     }
     $res = array();
     foreach ($foafs as $foaf) {
         $res[] = $foaf;
     }
     return $res;
 }
Пример #15
0
 function find_with_content_category_by_account($account)
 {
     $db =& DBUtils::connect();
     $sql = 'SELECT cc.id AS category_id, cc.name AS category_name, mcf.feed_id
         FROM member_to_content_category_to_feed mcf
         JOIN member m ON mcf.member_id = m.id
         JOIN content_category cc ON mcf.content_category_id = cc.id
         WHERE m.account = ?';
     $result = $db->getAll($sql, array($account));
     if (DB::isError($result)) {
         trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . $result->toString(), E_USER_ERROR);
         return false;
     }
     $mcfs = $result;
     $other = ContentCategoryUtils::get(PLNET_OTHER_CATEGORY_ID);
     $feeds = FeedUtils::get_feeds_by_account($account);
     $feeds_with_category = array();
     foreach ($feeds as $key => $feed) {
         foreach ($mcfs as $i => $mcf) {
             if ($feed['id'] == $mcf['feed_id']) {
                 $feed['category_id'] = $mcf['category_id'];
                 $feed['category_name'] = $mcf['category_name'];
             }
         }
         if (!isset($feed['category_id'])) {
             $feed['category_id'] = $other['id'];
             $feed['category_name'] = $other['name'];
         }
         $feeds_with_category[] = $feed;
     }
     return $feeds_with_category;
 }
Пример #16
0
 function Pager($sql_count, $sql, $current_page)
 {
     global $g_rb_database_type, $g_rb_pagerLimit, $DB_LINK;
     $this->page_limit = $g_rb_pagerLimit;
     $this->page = $current_page;
     $this->sql = $sql;
     if ($g_rb_database_type == "postgres") {
         $sql .= " LIMIT " . $this->page_limit;
         if ($this->page > 0) {
             $sql .= " OFFSET " . ($this->page - 1) * $this->page_limit;
         }
     } else {
         if ($g_rb_database_type == "mysql") {
             $sql .= " LIMIT ";
             if ($this->page > 0) {
                 $sql .= ($this->page - 1) * $this->page_limit . ", ";
             }
             $sql .= $this->page_limit;
         }
     }
     // Get the count
     $rc = $DB_LINK->Execute($sql_count);
     DBUtils::checkResult($rc, NULL, NULL, $sql_count);
     $this->total_results = $rc->fields[0];
     // Make the query and set the results
     $this->dbResults = $DB_LINK->Execute($sql);
     DBUtils::checkResult($this->dbResults, NULL, NULL, $sql);
     // Compute the max number of pages
     $this->max_pages = ceil($this->total_results / $this->page_limit);
 }
Пример #17
0
 function lookup_consumer($consumer_key)
 {
     /*{{{*/
     $secret = DBUtils::retrieveCustomer($consumer_key);
     if ($secret) {
         return new OAuthConsumer($consumer_key, $secret, NULL);
     }
     return NULL;
 }
Пример #18
0
 function Start($aDBServer, $aProjName)
 {
     $dbutils = new DBUtils($aDBServer);
     $dbutils->SetProject($aProjName);
     $this->iDirectory = $dbutils->GetProjDir($aProjName);
     $this->iProjName = $aProjName;
     $proj = $dbutils->GetProject();
     $this->iShowPrivate = $dbutils->GetShowPrivate($aProjName);
     $this->iDocType = $proj['fld_doctype'];
     $ds = new DocStat($dbutils);
     list($avg, $nc, $nm) = $ds->ProjStat($aProjName);
     $t = '<table width=100% border=1 style="background-color:lightblue;"><tr><td align=center><span style="font-size:20pt;font-family:arial;font-weight:bold;">' . $aProjName . "</span></td></tr></table>\n";
     $t .= '<div align=center><h3 style="color:darkred;font-family:arial;">Documentation status: ' . round($avg * 100) . '%</h3>';
     $t .= '<span style="font-family:arial;">Total number of Classes: ' . $nc . ', Methods: ' . $nm . "</span><p>\n";
     if ($this->iShowPrivate) {
         $t .= '<i>This version <b>includes</b> private methods & classes</i><p>';
     } else {
         $t .= '<i>This version does <b>not</b> include private methods & classes</i><p>';
     }
     $t .= '<p><i>Generated at ' . strftime('%d %b %Y  at  %H:%M') . "</i><br>\n";
     $t .= "</div><hr>";
     $t .= "<p>" . $proj['fld_desc'];
     if ($this->iDocType == 0) {
         $dt = 'HTML: Multiple files.';
         $this->iWriter->Open($this->iDirectory . 'projinfo.html');
         $this->iWriter->W($t);
         $this->iWriter->Close();
         $this->iWriter->Open($this->iDirectory . 'index.html');
         $this->iWriter->W($this->iIndexFramePage);
         $this->iWriter->Close();
     } else {
         $dt = 'HTML: Single file.';
         $this->iWriter->Open($this->iDirectory . 'index.html');
         $this->iWriter->W($this->iIndexPage);
         $this->iWriter->W($this->iCSS);
         $this->iWriter->W($t);
     }
     HTMLGenerator::CloseWinButton('left');
     echo "<hr>";
     echo "<font face=arial><b>Generating reference for project : <font color=blue>{$aProjName}</font></b></font><br>";
     echo "Output directory: <b><font color=blue>" . $this->iDirectory . '</font></b><br>';
     echo "Output format: <b><font color=blue>{$dt}</font></b> <p>\n";
     echo "<hr>";
 }
Пример #19
0
 function get_tagid_by_tagname($tagid)
 {
     $db =& DBUtils::connect();
     $sql = "SELECT id FROM tag WHERE name = ?";
     $result =& $db->getOne($sql, array($tagid));
     if (DB::isError($result)) {
         trigger_error('PlnetUtils::get_tagid_from_tagname(): fetch error.' . $result->toString(), E_USER_ERROR);
         return false;
     }
     return $result;
 }
Пример #20
0
 function get($content_category_id)
 {
     $db =& DBUtils::connect();
     $sql = 'SELECT * FROM content_category WHERE id = ?';
     $result = $db->getRow($sql, array($content_category_id));
     if (DB::isError($result)) {
         trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . $result->toString(), E_USER_ERROR);
         return false;
     }
     return $result;
 }
Пример #21
0
 function get_sources_by_account($account)
 {
     $db =& DBUtils::connect();
     $sql = "SELECT s.id, s.name, s.uri, s.link, s.icon \n            FROM member m \n            JOIN source s ON m.id = s.member_id \n            WHERE m.account = ? \n            ORDER BY s.id";
     $result = $db->getAll($sql, array($account));
     if (DB::isError($result)) {
         trigger_error('PlnetUtils::get_sources_by_account(): ' . $result->toString(), E_USER_ERROR);
         return false;
     }
     return $result;
 }
Пример #22
0
 /**
 	Gets a Column out of the database and returns them as a ADOdb type result
 	@param $table the table to query from
 	@param $valFld the first field to select
 	@param $keyFld The seconf field to select
 	@param $order how to order the result (should be either $valFld or $keyFld)
 	@return A ADOdb result
 */
 public static function fetchColumn($table, $valFld, $keyFld = '', $order = '')
 {
     global $DB_LINK;
     $table = $DB_LINK->addq($table, get_magic_quotes_gpc());
     $valFld = $DB_LINK->addq($valFld, get_magic_quotes_gpc());
     $keyFld = $DB_LINK->addq($keyFld, get_magic_quotes_gpc());
     $order = $DB_LINK->addq($order, get_magic_quotes_gpc());
     $sql = "SELECT {$valFld}" . ($keyFld ? ",{$keyFld}" : "") . " FROM {$table}" . ($order ? " ORDER BY {$order}" : "");
     $rc = $DB_LINK->Execute($sql);
     DBUtils::checkResult($rc, NULL, NULL, $sql);
     return $rc;
 }
Пример #23
0
 function get_hot_tags($limit = null)
 {
     $db =& DBUtils::connect();
     $sql = "SELECT t.name, COUNT(t.id) AS cnt\n            FROM entry e\n            JOIN entry_to_tag e2t ON e.id = e2t.entry_id\n            JOIN tag t ON e2t.tag_id = t.id\n            WHERE ? < e.date\n            GROUP BY t.id\n            ORDER BY cnt desc";
     $sql .= $limit != null ? " LIMIT " . $limit : "";
     $tags = $db->getAll($sql, array(date("Y-m-d", time() - 172800)));
     if (DB::isError($tags)) {
         trigger_error('fetch error.' . $tags->toString(), E_USER_ERROR);
         return false;
     }
     return $tags;
 }
Пример #24
0
 public static function setNextId($field)
 {
     if (!empty($field)) {
         $field = DBUtils::mysql_escape($field);
         $id = rand(1000, 10000000);
         $SQL = "INSERT INTO " . TBL_KEYGENERATOR . " (PK_COLUMN,VALUE_COLUMN)  VALUES ('" . $field . "'," . $id . ")";
         mysql_query($SQL) or die(mysql_error());
         return $id;
     } else {
         return -1;
     }
 }
Пример #25
0
 public function checkFriends()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("user > checkFriends > start userId : " . $this->userId);
     $user = GameUsers::getGameUserById($this->userId);
     if (!empty($user)) {
         $userId = $user->userId;
         if (!empty($userId)) {
             $fbFriends = FriendUtils::getUserFacebookFriends($user);
             if (!empty($fbFriends) && sizeof($fbFriends) > 0) {
                 $fbFriendIds = null;
                 foreach ($fbFriends as $fbFriend) {
                     if (!empty($fbFriend) && isset($fbFriend["id"])) {
                         if (empty($fbFriendIds)) {
                             $fbFriendIds = $fbFriend["id"];
                         } else {
                             $fbFriendIds = $fbFriendIds . "," . $fbFriend["id"];
                         }
                     }
                 }
                 $fbFriendUserIds = FriendUtils::getUserIdsFromFacebookIds($fbFriendIds);
                 if (!empty($fbFriendUserIds)) {
                     $friendIds = FriendUtils::getUserFriendIds($userId);
                     foreach ($fbFriendUserIds as $fbFriendId) {
                         if (!empty($fbFriendId)) {
                             $add = false;
                             if (!empty($friendIds) && sizeof($friendIds) > 0) {
                                 if (!in_array($fbFriendId, $friendIds)) {
                                     $add = true;
                                 }
                             } else {
                                 $add = true;
                             }
                             if ($add) {
                                 $friend = new GameUserFriends();
                                 $friend->setUserId($this->userId);
                                 $friend->setType("facebook");
                                 $friend->setFriendId($fbFriendId);
                                 try {
                                     $friend->insertIntoDatabase(DBUtils::getConnection());
                                 } catch (Exception $exc) {
                                     error_log("userclass>checkFriends userId : " . $this->userId . " friend Id : " . $fbFriendId . " Error : " . $exc->getMessage() . " Trace :" . $exc->getTraceAsString());
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $log->logInfo("user > checkFriends > end userId : " . $this->userId);
 }
Пример #26
0
 public static function getDAU($sDate, $eDate)
 {
     $SQL = "SELECT count(distinct " . TBL_GAME_USER_LOGIN_LOG . ".userId) as count_ FROM " . TBL_GAME_USER_LOGIN_LOG . "," . TBL_GAME_USERS . " WHERE " . TBL_GAME_USER_LOGIN_LOG . ".userId NOT IN(" . ADMIN_EXCEPT_USERS . ") AND " . TBL_GAME_USER_LOGIN_LOG . ".time BETWEEN " . $sDate . " AND " . $eDate . " AND " . TBL_GAME_USER_LOGIN_LOG . ".userId=" . TBL_GAME_USERS . ".userId AND " . TBL_GAME_USERS . ".registerDate<" . $sDate;
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     $count = 0;
     if (!empty($query)) {
         $db_field = mysql_fetch_assoc($query);
         if (isset($db_field["count_"])) {
             $count = $db_field["count_"];
         }
     }
     return $count;
 }
 public static function getTotalCount()
 {
     $SQL = "SELECT COUNT(*) as total FROM " . TBL_GAME_USER_FEEDBACK;
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     if (!empty($query)) {
         while ($db_field = mysql_fetch_assoc($query)) {
             if (!empty($db_field["total"])) {
                 return $db_field["total"];
             }
         }
     }
     return 0;
 }
 public static function updateUserImage($userId)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($userId)) {
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             $tmpImgPath = UserProfileImageUtils::downloadFBProfileImage($user->facebookId);
             $profileImageUrl = null;
             if (!empty($tmpImgPath)) {
                 try {
                     $s3 = new S3(AWS_API_KEY, AWS_SECRET_KEY);
                     $s3->setEndpoint(AWS_S3_ENDPOINT);
                     $imageName = "pi_" . $userId . ".png";
                     $s3Name = "profile.images/" . $userId . "/" . $imageName;
                     $res = $s3->putObjectFile($tmpImgPath, AWS_S3_BUCKET, $s3Name, S3::ACL_PUBLIC_READ);
                     if ($res) {
                         $profileImageUrl = 'http://' . AWS_S3_BUCKET . '.s3.amazonaws.com/' . $s3Name;
                         try {
                             unlink($tmpImgPath);
                         } catch (Exception $exc) {
                             error_log($exc->getTraceAsString());
                         }
                     } else {
                         $result->result = json_encode($res);
                     }
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             } else {
                 $profileImageUrl = USER_DEFAULT_IMAGE_URL;
             }
             if (!empty($profileImageUrl)) {
                 $user->setProfilePicture($profileImageUrl);
                 try {
                     $user->updateToDatabase(DBUtils::getConnection());
                     $result->success = true;
                     $result->result = null;
                 } catch (Exception $exc) {
                     $result->result = $exc->getTraceAsString();
                 }
             }
         } else {
             $result->result = "user not found";
         }
     } else {
         $result->result = "user id empty";
     }
     return $result;
 }
 public static function useRequest($id, $used = 1)
 {
     if (!empty($id)) {
         try {
             $req = GameFbRequest::findById(DBUtils::getConnection(), $id);
             if (!empty($req)) {
                 $req->setUsed($used);
                 $req->setUsedTime(time());
                 $req->updateToDatabase(DBUtils::getConnection());
             }
         } catch (Exception $exc) {
             error_log($exc->getTraceAsString());
         }
     }
 }
Пример #30
-1
 public static function edit($aboutusId, $content)
 {
     $pdo = new DBUtils();
     $sql = "update aboutus set content='{$content}' where aboutusId = '{$aboutusId}'";
     $rs = $pdo->update($sql);
     return $rs;
 }