/** * Allows executing controller actions as background tasks. * A controller action request will always be 'touched' a second time to run in background * * Usage see: controllers/RunActionsController.php * * Use $internalHostInfo when the webserver is running behind a firewall * where only internal routing is configured. * In that case the the detected $request->getHostInfo() can fail. * * * @param boolean $useHttpClient whether to use the EHttpClient extension * @param array $httpClientConfig the config for the EHttpClient extension * @param string $internalHostInfo with scheme: http://127.0.0.1; http://192.168.0.1 * @return */ public static function runBackground($useHttpClient = false, $httpClientConfig = array(), $internalHostInfo = null) { if (!self::isTouchActionRequest()) { $request = Yii::app()->request; $uri = $request->requestUri; $port = $request->getPort(); $host = isset($internalHostInfo) ? $internalHostInfo : $request->getHostInfo(); $url = "{$host}:{$port}{$uri}"; if ($useHttpClient) { ERunActions::touchUrlExt($url, $_POST, null, $httpClientConfig); } else { ERunActions::touchUrl($url, $_POST); } return false; } else { return true; } }
public function actionGetReginfo() { Yii::import('ext.runactions.components.ERunActions'); $firstname = $_POST['fname']; $lastname = $_POST['lname']; $username = isset($_POST['uname']) ? $_POST['uname'] : ""; $email = $_POST['email']; $pwd = $_POST['pwd']; $gender = isset($_POST['gender']) ? $_POST['gender'] : ""; $socialid = $_POST['socialid']; $dob = Yii::app()->dateFormatter->format('yyyy-M-dd', strtotime($_POST['dob'])); $zip = $_POST['zip']; $user = User::model()->findByAttributes(array('email' => $email)); $model = new User(); if ($email == '' || $pwd == '') { echo "Enter fields"; } elseif ($user['email'] != '') { echo "You are already subscribed or your account may not be activated"; } else { if (isset(Yii::app()->session['userinfo'])) { if (isset(Yii::app()->session['login'])) { $id = Yii::app()->session['login']['id']; $model = User::model()->findByPk($id); $model->secondary_email = $email; $model->updatedby = $id; $model->updatedate = date('Y-m-d G:i:s'); } else { $model = new User(); $model->fname = $firstname; $model->lname = $lastname; $model->uname = $username; $model->email = $email; $model->password = md5($pwd); $model->gender = $gender; $model->dob = $dob; $model->zipcode = $zip; $model->usertypeid = 1; } $socialid = Yii::app()->session['userinfo']['SocialNetworkID']; $model->socialnetworkid = $socialid; $social = Yii::app()->session['userinfo']['SocialNetwork']; $model->socialnetwork = $social; /* Modified on 10-1-13 to get image from facebook reg becoz we r nt getng image for other social networks*/ if ($model->socialnetwork == "facebook") { /************* Awber code *******************/ $url = "http://www.aweber.com/scripts/addlead.pl"; $data = http_build_query(array("meta_web_form_id" => "1185568484", "meta_split_id" => "", "listname" => "finao_fbreges", "redirect" => "", "meta_adtracking" => "FBREG", "meta_message" => "1", "meta_required" => "email", "meta_tooltip" => "", "email" => $email)); $this->post_send($url, $data); /************* END of Awber code *******************/ $image = Yii::app()->session['userinfo']['photourl']; $rnd = rand(0, 9999); $img_file = file_get_contents($image); $file_loc = Yii::app()->basePath . '/../images/uploads/profileimages/' . $rnd . '.jpg'; $file_handler = fopen($file_loc, 'w'); if (fwrite($file_handler, $img_file) == false) { echo 'error'; } fclose($file_handler); $img = "images/uploads/profileimages/" . $rnd . '.jpg'; $image = Yii::app()->image->load($img); $image->resize(140, 140); $image->save("images/uploads/backgroundimages/" . $model->profile_bg_image); $model->profile_image = $rnd . '.jpg'; } else { $model->profile_image = 'default-yahoo.jpg'; } $model->status = 1; if ($gender != '') { $model->gender = $gender; } if (isset(Yii::app()->session['login'])) { if ($model->save(false)) { if ($saved) { if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login["id"] = $model->userid; $login["username"] = $model->uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; echo "frnds redirect"; } } } else { if ($model->save(false)) { /* Added on 10-1-13 to save fb details in login details. This is used for normal register want to invite his friends*/ $command = Yii::app()->db->createCommand(); $saved = $command->insert('ha_logins', array('userId' => $model->userid, 'loginProvider' => $model->socialnetwork, 'loginProviderIdentifier' => $model->socialnetworkid)); if ($saved) { $userdet = array(); $userdet['firstname'] = $model->fname; $userdet['lastname'] = $model->lname; $userdet['email'] = $model->email; $userdet['password'] = "******"; $userdet['store_id'] = 1; $userdet['website_id'] = 1; $url1 = Yii::app()->createAbsoluteUrl('site/Processshopreg', array('userdet' => $userdet)); ERunActions::touchUrl($url1); //$login = array(); if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login["id"] = $model->userid; $login["username"] = $uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; //$this->redirect('site/index'); echo "fb registration success"; } } } } else { if (isset(Yii::app()->session['login'])) { echo "Loged user"; exit; } $model->fname = $firstname; $model->lname = $lastname; $model->uname = $username; $model->email = $email; $model->password = md5($pwd); $model->dob = $dob; $model->zipcode = $zip; $model->usertypeid = 63; if ($socialid != 0) { $model->status = 1; } else { $model->status = 0; } $model->superuser = 0; $model->socialnetworkid = $socialid; /*$model->socialnetwork = "facebook";*/ if ($gender != '') { $model->gender = $gender; } $model->activkey = ""; //md5(uniqid(rand(), true)); $model->status = 1; $model->createtime = date('Y-m-d G:i:s'); $model->createdby = 1; $mageid = $this->processshopreg($firstname, $lastname, $email, $pwd); if ($mageid != '') { $model->mageid = $mageid; } if ($model->save(false)) { /* $mageid = $this->processshopreg($firstname,$lastname,$email,$pwd); if(!$mageid == 'exists') { $model->mageid = $mageid; //echo $mageid; exit; $model->save(); } */ if ($model->socialnetworkid != 0) { $image = "http://graph.facebook.com/" . $model->socialnetworkid . "/picture?type=normal"; $img_file = file_get_contents($image); $file_loc = Yii::app()->basePath . '/../images/uploads/profileimages/' . $model->userid . '.jpg'; $file_handler = fopen($file_loc, 'w'); if (fwrite($file_handler, $img_file) == false) { echo 'error'; } fclose($file_handler); $img = "images/uploads/profileimages/" . $model->userid . '.jpg'; $image = Yii::app()->image->load($img); $image->resize(140, 140); $image->save("images/uploads/profileimages/" . $model->userid . '.jpg'); $newuserprofile = new UserProfile(); $newuserprofile->user_id = $model->userid; $newuserprofile->profile_image = $model->userid . '.jpg'; $newuserprofile->createdby = $model->userid; $newuserprofile->createddate = date('Y-m-d G:i:s'); $newuserprofile->updatedby = $model->userid; $newuserprofile->updateddate = date('Y-m-d G:i:s'); $newuserprofile->IsCompleted = ""; $newuserprofile->save(false); $login = array(); if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } if (isset(Yii::app()->session['userinfo'])) { unset(Yii::app()->session['userinfo']); } $login["id"] = $model->userid; $login["username"] = $model->fname . ' ' . $model->lname; $login["email"] = $model->email; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; $userprofile = UserProfile::model()->findByAttributes(array('user_id' => $model->userid)); $login["profImage"] = isset($userprofile->profile_image) ? $userprofile->profile_image : ""; $login["bgImage"] = isset($userprofile->profile_bg_image) ? $userprofile->profile_bg_image : ""; Yii::app()->session['login'] = $login; echo "fb registration success"; } else { if (isset(Yii::app()->session['login'])) { unset(Yii::app()->session['login']); } $login = array(); $login["id"] = $model->userid; $login["username"] = $model->uname; $login["socialnetworkid"] = $model->socialnetworkid; $login["superuser"] = $model->superuser; if ($model->usertypeid == 1) { $login["userType"] = "parent"; } if ($model->usertypeid == 3) { $login["userType"] = "organization"; } Yii::app()->session['login'] = $login; echo "reg success"; } } else { echo "Enter the fields correctly"; } } } }
public function actionTimeConsumingProcess() { Yii::log('action: TimeConsumingProcess', 'error'); ERunActions::touchUrl($this->createAbsoluteUrl('test/SendMail'), null, null, array()); echo json_encode(array('status' => 'ok')); }