function update() { $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0; $this->stat->saveStat($idu, "profile/update"); $nick = $_POST['nick']; $sex = $_POST['my_sex']; $bday = $_POST['bday']; $bmonth = $_POST['bmonth']; $byear = $_POST['byear']; $idcity = $_POST['idcity']; $desc = $_POST['description']; $birthday = date($byear . '-' . $bmonth . '-' . $bday); $model = new Model_Profile(); $profiles = $model->getProfile($idu); if (count($profiles) > 0) { $profile = $profiles[0]; $profile['nickname'] = $nick; $profile['sex'] = $sex; $profile['birthday'] = $birthday; $profile['idcity'] = $idcity; $profile['description'] = $desc; $model->updateProfile($profile); } header('Location:' . WEB_APP . '/profile/'); }
function upload() { $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0; $this->stat->saveStat($idu, "photo/upload"); if ($idu > 0) { if (isset($_FILES['add-photo'])) { // var_dump($_FILES['add-photo']); $tmpFile = $_FILES['add-photo']['tmp_name']; $info = getimagesize($tmpFile); $width = $info[0]; $height = $info[1]; $mime = $info['mime']; if ($width != null && $height != null) { $md = md5(time()); $path = rtrim(LOCAL_DIR_PHOTO, '/\\') . '/'; $dir = $path . $idu . '/'; if (!is_dir($dir)) { mkdir($dir, 0777, true); } $fileName = $idu . '/' . $md . '.jpg'; $fileFullPath = $path . $fileName; if ($mime == 'image/jpeg') { $image = imagecreatefromjpeg($tmpFile); } if ($mime == 'image/png') { $image = imagecreatefrompng($tmpFile); } if (isset($image)) { $side = min($width, $height); $rect = array('x' => 0, 'y' => 0, 'width' => $side, 'height' => $side); $imageThumb = imagecreatetruecolor(PHOTO_SIZE, PHOTO_SIZE); $image = imagecrop($image, $rect); imagecopyresampled($imageThumb, $image, 0, 0, 0, 0, PHOTO_SIZE, PHOTO_SIZE, $side, $side); imagejpeg($imageThumb, $fileFullPath, 80); $model = new Model_Profile(); $model->uploadPhoto($idu, $fileName); imagedestroy($image); imagedestroy($imageThumb); } else { header('Location:' . WEB_APP . '/photo/'); return; } } else { header('Location:' . WEB_APP . '/photo/'); return; } } header('Location:' . WEB_APP . '/profile/'); } else { unset($_SESSION['idu']); header('Location:' . WEB_APP); } }
function action_profile() { $authentification = new Authentification(); $model = new Model_Profile(); if (isset($_GET['change_avatar'])) { if (isset($_FILES['userfile']['tmp_name'])) { $destination = 'images/' . $_FILES['userfile']['name']; move_uploaded_file($_FILES['userfile']['tmp_name'], $destination); } $model->change_avatar($destination); } if (isset($_GET['subscribe'])) { $model->subscribe($_GET['subscribe']); } if (isset($_GET['unsubscribe'])) { $model->unsubscribe($_GET['unsubscribe']); } if (isset($_GET['user_id'])) { if ($_GET['user_id'] != $_SESSION['user_id']) { if ($model->is_friend($_GET['user_id'])) { $options['type'] = 'friend'; } $data = $model->get_user_data($_GET['user_id']); } else { $data = $model->get_user_data($_SESSION['user_id']); $options['type'] = 'mine'; } } else { $data = $model->get_user_data($_SESSION['user_id']); $options['type'] = 'mine'; } $this->view->generate('view_profile.php', 'view_skeleton.php', $data, $auth_opt, $options); }
/** * Adds new user record * * @param array $user User Array * @return array | bool */ public function addNew($user) { //To modify for Locations. Add Location, then Add User with Reference. $new = new Model_User(); $new->fromArray($user); $newprofile = new Model_Profile(); $newprofile->fromArray($user); $new->Profile = $newprofile; try { $new->save(); } catch (Doctrine_Exception $e) { return $e->getMessage(); } return $new->toArray(); }
protected function update_sort_order() { if (!($ids = \Util_Array::cast_values(explode(',', \Input::post('ids')), 'int', true))) { throw new \HttpInvalidInputException('Invalid input data.'); } return \Site_Model::update_sort_order($ids, \Model_Profile::forge()); }
public function __construct($page_type, Model_Member $member_obj = null) { if (!in_array($page_type, array('regist', 'config', 'regist-config'))) { throw new InvalidArgumentException('First parameter is invalid.'); } $this->profiles = Model_Profile::get4page_type($page_type); $this->page_type = $page_type == 'regist-config' ? 'regist' : $page_type; $this->member_obj = $member_obj; $this->set_member_profiles_profile_id_indexed(); $this->set_public_flags(); }
public static function get4member_id($member_id, $with_relations = false, $profile_display_type_str = null) { $query = self::query()->where('member_id', $member_id); if ($profile_display_type_str && ($profile_display_type = conf('member.profile.display_type.' . $profile_display_type_str))) { $profile_ids = Model_Profile::get_ids4display_type($profile_display_type); if ($profile_ids) { $query = $query->where('profile_id', 'in', $profile_ids); } } if ($with_relations) { $query = $query->related(array('profile', 'profile_option'))->order_by('profile.sort_order'); } return $query->get(); }
function index() { $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0; $msisdn = empty($_POST['msisdn']) ? '' : $_POST['msisdn']; unset($_POST['msisdn']); $telco = isset($_GET['o']) ? htmlspecialchars($_GET['o']) : ""; unset($_GET['o']); $this->stat->saveStat($idu, "unsubscribe/index [{$msisdn}, {$telco}]"); if (!empty($msisdn)) { $telco = isset($_POST['o']) ? htmlspecialchars($_POST['o']) : ""; unset($_POST['o']); if (!empty($telco)) { $model = new Model_Profile(); $utilz = new Utilz(); $result = $utilz->unsubscribe($msisdn, $telco); if ($result === '1') { $model->removeProfile($msisdn); } unset($_SESSION['idu']); header('Location:' . WEB_APP); } else { $this->template->view('error', $idu > 0); } } else { $model = new Model_Profile(); $profiles = $model->getProfile($idu); if (count($profiles) > 0) { $profile = $profiles[0]; if (!empty($profile)) { $msisdn = $profile['msisdn']; } } $this->template->vars('msisdn', $msisdn); $this->template->vars('telco', $telco); $this->template->view('index', $idu > 0); } }
function index() { $idu = isset($_SESSION['idu']) ? $_SESSION['idu'] : 0; $this->stat->saveStat($idu, "index/index [" . $_SERVER["QUERY_STRING"] . "]"); $model = new Model_Index(); if ($idu > 0) { $userList = $model->getUsersList($idu); $this->template->vars('userList', $userList); $this->template->view('index', true); } else { $SubscribeResult = isset($_GET['SubscribeResult']) ? $_GET['SubscribeResult'] : ''; $clickid = intval(isset($_GET['click_id']) ? $_GET['click_id'] : 0); if (!empty($SubscribeResult) && $clickid > 0) { $model_p = new Model_Profile(); $id = $model_p->generateProfile($clickid); $_SESSION['idu'] = $id; header('Location:' . WEB_APP . '/profile/edit'); } else { $userList = $model->getRandomUsers(); $this->template->vars('userList', $userList); $this->template->view('index', false); } } }
public function action_register() { $user_hash = Session::get('ninjauth.user'); $authentication = Session::get('ninjauth.authentication'); $strategy = \NinjAuth\Strategy::forge($authentication['provider']); $email = Input::post('email') ?: Arr::get($user_hash, 'email'); $val = Validation::forge(); $val->add('email', 'email')->add_rule('required')->add_rule('valid_email'); if (Input::method() != 'POST' || $val->run() === false) { return View::forge('register', array('user' => (object) compact('email'), 'error' => $val->error('email'))); } // todo トランザクション $user_id = $strategy->adapter->create_user(array('username' => Arr::get($user_hash, 'nickname'), 'email' => $email)); if ($user_id) { \NinjAuth\Model_Authentication::forge(array('user_id' => $user_id, 'provider' => $authentication['provider'], 'uid' => $authentication['uid'], 'access_token' => $authentication['access_token'], 'secret' => $authentication['secret'], 'refresh_token' => $authentication['refresh_token'], 'expires' => $authentication['expires'], 'created_at' => time()))->save(); Model_Profile::forge(array('full_name' => Arr::get($user_hash, 'name'), 'image' => Arr::get($user_hash, 'image'), 'location' => Arr::get($user_hash, 'location'), 'description' => Arr::get($user_hash, 'description'), 'website' => Arr::get($user_hash, 'urls.Website'), 'twitter' => Arr::get($user_hash, 'urls.Twitter'), 'user_id' => $user_id))->save(); Session::set_flash('ninjauth.user_id', $user_id); Response::redirect(static::$registered_redirect); } }
public function action_profile() { $post = Model_Profile::find('first', array('where' => array('user_id' => $this->current_user->id))); $fieldset = $this->_fieldset()->populate($post); if ($fieldset->validation()->run() == true) { $fields = $fieldset->validated(); $post->full_name = $fields['full_name']; $post->location = $fields['location']; $post->description = $fields['description']; $post->website = $fields['website']; $post->camera = $fields['camera']; $post->user_id = $this->current_user->id; if ($post->save()) { Session::set_flash('success', e('Updated Profile')); Response::redirect('setting/profile'); } } else { $fieldset->repopulate(); //Session::set_flash('error', $fieldset->validation()->errors()); } $this->template->set_global('fieldset', $fieldset, false); $this->template->title = 'Setting » Profile'; $this->template->content = View::forge('setting/profile'); }
public static function check_saved_member_profile_required(Model_Member $member, $disp_type = 'regist') { if (!in_array($disp_type, array('regist'))) { throw new InvalidArgumentException('Second parameter is invalid.'); } if (conf('profile.sex.isRequired') && empty($member->sex)) { return false; } if (conf('profile.birthday.birthyear.isRequired') && empty($member->birthyear)) { return false; } if (conf('profile.birthday.birthday.isRequired') && empty($member->birthday)) { return false; } if (!($profiles = Model_Profile::get_assoc('id', 'is_required', array('is_required' => 1, 'is_disp_' . $disp_type => 1)))) { return true; } $profileds_for_check = $profiles; if (!($member_profiles = Model_MemberProfile::get4member_id($member->id))) { return false; } foreach ($member_profiles as $member_profile) { unset($profileds_for_check[$member_profile->profile_id]); if (empty($profiles[$member_profile->profile_id])) { continue; } if ($member_profile->profile_option_id) { continue; } if ($member_profile->value) { continue; } if (strlen($member_profile->value)) { continue; } return false; } if ($profileds_for_check) { return false; } return true; }
function api_b() { $operators = array("beeline" => 1, "mts" => 2, "megafon" => 3, "tele2" => 4); // http://mobi-flirt.ru/utilz/api_b?action=new&request_id=123&msisdn=123456&operator=mts&click_params={'click_id':111} // action - text наименование действия - new/quit/pay // request_id - int идентификатор уведомления // project_id - int внутренний идентификатор проекта // msisdn - int msisdn в формате 7xxx.. // time - timestamp время события // operator - text наименование оператора - mts/beeline/megafon/tele2 // click_params - json get параметры $action = isset($_GET['action']) ? $_GET['action'] : ''; $request_id = intval(isset($_GET['request_id']) ? $_GET['request_id'] : 0); $project_id = intval(isset($_GET['project_id']) ? $_GET['project_id'] : 0); $msisdn = isset($_GET['msisdn']) ? $_GET['msisdn'] : ''; $time = isset($_GET['time']) ? $_GET['time'] : ''; $operator = isset($_GET['operator']) ? $_GET['operator'] : ''; $click_params = isset($_GET['click_params']) ? $_GET['click_params'] : ''; $click_id = 0; $click_array; if (!empty($click_params)) { $click_array = json_decode($click_params, true); if (isset($click_array)) { $click_id = intval(isset($click_array['click_id']) ? $click_array['click_id'] : 0); } } $op = isset($operators[$operator]) ? $operators[$operator] : 0; $response = 'fail'; if ($action === 'new') { if ($click_id > 0) { $model = new Model_Profile(); $model->activateProfile($click_id, $msisdn, $op); } $response = 'ok'; } else { if ($action === 'quit') { $model = new Model_Profile(); if (!empty($msisdn) && intval($msisdn) > 0) { $model->removeProfile($msisdn); $response = 'ok'; } else { if ($click_id > 0) { $model->removeProfileByClickId($click_id); $response = 'ok'; } } } else { if ($action === 'pay') { $model = new Model_Payment(); $model->payHistory(0, $click_id, 0, $op, $msisdn); $response = 'ok'; } } } $this->stat->saveOperator($msisdn, $_SERVER["REQUEST_URI"], $response); echo $response; }
private function check_id_and_get_profile($profile_id) { if (!$profile_id || !($profile = \Model_Profile::check_authority($profile_id))) { throw new \HttpNotFoundException(); } if (!in_array($profile->form_type, \Site_Profile::get_form_types_having_profile_options())) { throw new \HttpInvalidInputException(); } return $profile; }
private function set_values_profile(\Model_Profile $obj, $values) { $cols = \DB::list_columns('profile'); foreach ($cols as $col => $props) { if (in_array($col, array('id', 'sort_order', 'created_at', 'updated_at'))) { continue; } $obj->{$col} = $values[$col]; } if (!isset($obj->sort_order) || is_null($obj->sort_order)) { $obj->sort_order = \Model_Profile::get_next_sort_order(); } return $obj; }