public function changeProfile($id) { if (!empty($_POST)) { $instance = new ProfileModel(); $instance->update($id, ['first_name' => $_POST['first_name'], 'last_name' => $_POST['last_name'], 'cpostal' => $_POST['cpostal'], 'adress' => $_POST['adress'], 'departement' => $_POST['departement'], 'region' => $_POST['region'], 'city' => $_POST['city'], 'country' => $_POST['country'], 'birthday' => $_POST['birthday']]); } }
public static function start() { // Include model incFile('modules/profile/system/Model.php'); incFile('../mail/class.phpmailer.php'); // Connect to DB $model = new ProfileModel(); if (getSession('user')) { $id = getSession('user'); } else { $id = getCookie('user'); setSession('user', $id, false); } // $id = (getSession('user')) ? getSession('user') : getCookie('user') ; if ($id) { $uData = array(); // Update user $uData['controller'] = CONTROLLER; $uData['action'] = ACTION; $uData['dateLast'] = time(); $model->updateUserByID($uData, $id); // Get data user Request::setParam('user', $model->getUserByID($id)); // Count new message Request::setParam('countMsg', $model->countMsg($id)); // Count new message Request::setParam('countRequests', $model->countRequests($id)); // Count challenges Request::setParam('countChallenges', $model->countChallengesList($id)); } else { $gip = ip2long($_SERVER['REMOTE_ADDR']); // Null Request::setParam('user', null); // Guest Request::setParam('guest', $model->getGuestByIP($gip)); // Role Request::setRole('guest'); /* // Language if (CONTROLLER == 'page' && ACTION == 'lang') { if (Request::getUri(0) == 'ru' OR Request::getUri(0) == 'en') setMyCookie('lang', Request::getUri(0), time() + 365 * 86400); } $lang = getCookie('lang'); if ($lang == 'ru' OR $lang == 'en') Lang::setLanguage($lang); else Lang::setLanguage(); */ if (Request::getParam('guest')->id) { $gData['count'] = Request::getParam('guest')->count + 1; $gData['time'] = time(); $model->update('guests', $gData, "`id` = '" . Request::getParam('guest')->id . "' LIMIT 1"); } else { $gData['ip'] = $gip; $gData['browser'] = $_SERVER['HTTP_USER_AGENT']; $gData['referer'] = $_SERVER['HTTP_REFERER']; $gData['count'] = 1; $gData['time'] = time(); $model->insert('guests', $gData); } } // Count users online Request::setParam('countUsersOnline', $model->countUsersOnline()); // Count guests online Request::setParam('countGuestsOnline', $model->countGuestsOnline()); }
public function removeAssetAction() { $response['error'] = 0; $response['id'] = false; $response['blocked'] = false; if (isPost()) { $model = new ProfileModel(); $post = allPost(); $match = $model->getMatchByID(post('mid', 'int')); if (!$match->blocked) { $response['id'] = $post['aid']; if (!$post['id']) { $response['error'] = Lang::translate("MATCH_WRONG_DATA"); } else { $asset = $model->getMatchAsset(Request::getParam('user')->id, $post['id']); if (!$model->removeAsset(Request::getParam('user')->id, $post['id'])) { $response['error'] = Lang::translate("MATCH_DB_ERROR"); } else { if ($match) { if (Request::getParam('user')->id == $match->uid) { $field = 'uready'; } else { $field = 'pready'; } if ($match->{$field} == '1') { $data[$field] = '0'; $response['target_h']['#readyBtn'] = Lang::translate("MATCH_NOT_READY"); } if ($match->{$field} == '1') { $data[$field] = '0'; $response['target_h']['#readyBtn'] = "MATCH_NOT_READY"; } /* $marketPrice = get_contents("http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=".urlencode($asset->market_name)); $marketJson = json_decode($marketPrice); $arr1 = array("$", "€"); $arr2 = array("", ""); $price = str_replace($arr1, $arr2, $marketJson->median_price); */ $price = $asset->price; if (Request::getParam('user')->id == $match->uid) { $data['usum'] = floatval($match->usum - $price); } else { $data['psum'] = floatval($match->psum - $price); } echo $model->update('matches', $data, " `id` = '{$match->id}' ", true); if (!$model->setMatchReady($match->id, $data)) { $response['error'] = Lang::translate("MATCH_DB_ERROR"); } } else { $response['error'] = Lang::translate("MATCH_WRONG"); } } } } else { $response['error'] = Lang::translate("MATCH_BLOCKED"); $response['blocked'] = true; } } else { $response['error'] = Lang::translate("MATCH_EMPTY_DATA"); } echo json_encode($response); exit; }
try { //call addNew method of ProfileModel and pass the credits of the profile to create $pm->addNew($credits); } catch (Exception $e) { //if exception of type 2, 5 or six is catched, print the error message in //contentView div in index.php else re-throw exception if ($e->getCode() == 2 || $e->getCode() == 5 || $e->getCode() == 6) { $errorMsg = "<br/>" . $e->getMessage() . "<br/>"; } else { throw $e; } } } else { try { //same as for addNew but only for Exeptions of type 5 $pm->update($credits); } catch (Exception $e) { if ($e->getCode() == 5 || $e->getCode() == 6) { $errorMsg = "<br/>" . $e->getMessage() . "<br/>"; } else { throw $e; } } } //if profile is wished to be default set Session and cookie variables appropriate if ($setDefault) { @session_start(); $_SESSION['defaultProfile'] = $credits['up_email']; setcookie("defaultProfile", $credits['up_email'], time() + 60 * 60 * 24 * 7 * 2, dirname($_SERVER['PHP_SELF']), $_SERVER['SERVER_NAME']); } }