/**
  * Execute the configured controller actions
  * Example:
  * http://localhost/index.php/cron/run/config/cleanupdb
  */
 public function actionTouch()
 {
     if (ERunActions::runBackground()) {
         $config = isset($_GET['config']) ? $_GET['config'] : null;
         $this->_runActions($config);
     }
 }
コード例 #2
0
 /**
  * Register the request interval.
  *
  * @param CFilterChain $filterChain
  *
  * @return bool
  */
 protected function postFilter($filterChain)
 {
     $id = $this->getIntervalId($filterChain);
     ERunActions::registerInterval($this->interval, $id);
 }
コード例 #3
0
ファイル: ERunActionsHttpClient.php プロジェクト: huynt57/vs
 /**
  * Socked based http request
  * Based on code from: http://www.php.net/manual/de/function.fsockopen.php#101872
  * Added touchOnly feature, changed headers
  *
  * @param mixed $ip
  * @param integer $port
  * @param string $uri
  * @param string $verb
  * @param array $getdata
  * @param array $postData
  * @param array $cookie
  * @param array $custom_headers
  * @param integer $timeout
  * @param mixed $req_hdr
  * @param mixed $res_hdr
  * @return
  */
 public function request($ip, $port = 80, $uri = '/', $verb = 'GET', $getdata = array(), $postData = null, $contentType = null, $cookie = array(), $custom_headers = array(), $timeout = 2000, $req_hdr = false, $res_hdr = false)
 {
     $isSSL = $port == 443;
     $ret = '';
     $verb = strtoupper($verb);
     $cookie_str = '';
     $getdata_str = count($getdata) ? '?' : '';
     $postdata_str = '';
     if (!empty($getdata)) {
         foreach ($getdata as $k => $v) {
             $getdata_str .= urlencode($k) . '=' . urlencode($v) . '&';
         }
         $getdata_str = substr($getdata_str, 0, -1);
     }
     if (isset($postData)) {
         if (is_array($postData)) {
             foreach ($postData as $k => $v) {
                 $postdata_str .= urlencode($k) . '=' . urlencode($v) . '&';
             }
             $postdata_str = substr($postdata_str, 0, -1);
         } else {
             $postdata_str = is_string($postData) ? $postData : serialize($postData);
         }
     }
     foreach ($cookie as $k => $v) {
         $cookie_str .= urlencode($k) . '=' . urlencode($v) . '; ';
     }
     $crlf = "\r\n";
     $req = $verb . ' ' . $uri . $getdata_str . ' HTTP/1.1' . $crlf;
     $req .= 'Host: ' . $ip . $crlf;
     $req .= 'User-Agent: ' . $this->userAgent . $crlf;
     $req .= "Cache-Control: no-store, no-cache, must-revalidate" . $crlf;
     $req .= "Cache-Control: post-check=0, pre-check=0" . $crlf;
     $req .= "Pragma: no-cache" . $crlf;
     foreach ($custom_headers as $k => $v) {
         $req .= $k . ': ' . $v . $crlf;
     }
     if (!empty($cookie_str)) {
         $req .= 'Cookie: ' . substr($cookie_str, 0, -2) . $crlf;
     }
     if ($verb == 'POST' && !empty($postdata_str)) {
         if (is_array($postData)) {
             $req .= 'Content-Type: application/x-www-form-urlencoded' . $crlf;
         } else {
             if (empty($contentType)) {
                 $contentType = 'text/plain';
             }
             $req .= 'Content-Type: ' . $contentType . $crlf;
         }
         $req .= 'Content-Length: ' . strlen($postdata_str) . $crlf;
         $req .= 'Connection: close' . $crlf . $crlf;
         $req .= $postdata_str;
     } else {
         $req .= 'Connection: close' . $crlf . $crlf;
     }
     if ($req_hdr) {
         $ret .= $req;
     }
     $ip = $isSSL ? 'ssl://' . $ip : $ip;
     if (($fp = @fsockopen($ip, $port, $errno, $errstr)) == false) {
         $message = "Error {$errno}: {$errstr}";
         if ($this->_touchOnly) {
             ERunActions::logError($message);
             return null;
         } else {
             return $message;
         }
     }
     stream_set_timeout($fp, 0, $timeout * 1000);
     fputs($fp, $req);
     if (!$this->_touchOnly) {
         while ($line = fgets($fp)) {
             $ret .= $line;
         }
         fclose($fp);
         if (!$res_hdr) {
             $ret = substr($ret, strpos($ret, "\r\n\r\n") + 4);
         }
         return $ret;
     } else {
         fclose($fp);
         return null;
     }
 }
コード例 #4
0
	public function actionBackgroundmsg($phone_nos,$msg)
	{
		$count = count($phone_nos);

		Yii::import('application.extensions.runactions.components.ERunActions');
			
		//require_once "Mail.php";

		if (ERunActions::runBackground()) {
			$output = implode(",",$phone_nos);
			$smsobj=new SmsApi;
			$r=$smsobj->sendsms($output,$msg);
				if(preg_match('/alert_/',$r))
					echo 'sent';
				
			}
		else
		{
			$this->redirect(array('admin'));
		}
	}
コード例 #5
0
ファイル: BookServiceController.php プロジェクト: huynt57/vs
 public function actionStep2()
 {
     // require_once(Yii::getPathOfAlias('application.components.Paypal') . '/autoload.php');
     $this->layoutPath = Yii::getPathOfAlias('webroot') . "/themes/classic/views/layouts";
     $this->layout = 'nonPrepare';
     $this->checkSession(2);
     $request = Yii::app()->request;
     if ($request->isPostRequest && isset($_POST)) {
         try {
             $this->card_number = $this->getPostFilter('card_number');
             $this->card_holder_name = $this->getPostFilter('card_holder_name');
             $this->expiry_year = $this->getPostFilter('expiry_year');
             $this->expiry_month = $this->getPostFilter('expiry_month');
             $this->cvc = $this->getPostFilter('cvc');
             $this->first_name = $this->getPostFilter('first_name');
             $this->last_name = $this->getPostFilter('last_name');
             $this->bill_city = $this->getPostFilter('bill_city');
             $this->bill_address = $this->getPostFilter('bill_address');
             $this->bill_country = $this->getPostFilter('bill_country');
             $this->bill_postcode = $this->getPostFilter('bill_postcode');
             $apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential("AZxYt_EVUMu9xXO0DHBHn4KGUVx6UMIdQKAb7QeCek609Zo3lFCAIfIKs29-T4PL66cSoN6189SfoACj", "ELebkFS3jmn9CNu4PF1t8OWaIsHASMDalHKp9x1dwEo0KmeKo582SfeVIC3CC99tmin7NoJZp00jI2Oc"));
             $addr = new \PayPal\Api\Address();
             $addr->setLine1($this->bill_address);
             $addr->setCity($this->bill_city);
             $addr->setCountryCode($this->bill_country);
             $addr->setPostalCode($this->bill_postcode);
             $addr->setState('OH');
             $card = new \PayPal\Api\CreditCard();
             $card->setNumber($this->card_number);
             $card->setType('visa');
             $card->setExpireMonth($this->expiry_month);
             $card->setExpireYear($this->expiry_year);
             $card->setCvv2($this->cvc);
             $card->setFirstName($this->first_name);
             $card->setLastName($this->last_name);
             $card->setBillingAddress($addr);
             $fi = new \PayPal\Api\FundingInstrument();
             $fi->setCreditCard($card);
             $payer = new \PayPal\Api\Payer();
             $payer->setPaymentMethod('credit_card');
             $payer->setFundingInstruments(array($fi));
             $amount = new \PayPal\Api\Amount();
             $amount->setCurrency('USD');
             $amount->setTotal('0.12');
             $transaction = new \PayPal\Api\Transaction();
             $transaction->setAmount($amount);
             $transaction->setDescription('This is the payment transaction description.');
             $redirectUrls = new \PayPal\Api\RedirectUrls();
             $redirectUrls->setReturnUrl(Yii::app()->createAbsoluteUrl('bookService/step3' . '?success=true'))->setCancelUrl(Yii::app()->createAbsoluteUrl('bookService/step3' . '?success=false'));
             $payment = new \PayPal\Api\Payment();
             $payment->setIntent('sale');
             $payment->setPayer($payer);
             $payment->setTransactions(array($transaction));
             try {
                 $res = $payment->create($apiContext);
             } catch (PayPal\Exception\PayPalConnectionException $e) {
                 echo $e->getData();
                 // This will print a JSON which has specific details about the error.
                 // exit(1);
             }
             $this->nextStep(3);
             if (ERunActions::runBackground()) {
                 $this->SendMailConfirm();
             }
             // die();
             $this->redirectStep(3);
         } catch (exception $e) {
             var_dump($e->getMessage());
         }
     }
     $this->render('step2');
 }
コード例 #6
0
ファイル: SiteController.php プロジェクト: gopi158/Sample
 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";
             }
         }
     }
 }
コード例 #7
0
 /**
  * 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;
     }
 }
コード例 #8
0
 public function actionTimeConsumingProcess()
 {
     Yii::log('action: TimeConsumingProcess', 'error');
     ERunActions::touchUrl($this->createAbsoluteUrl('test/SendMail'), null, null, array());
     echo json_encode(array('status' => 'ok'));
 }
コード例 #9
0
 public function action_do_sync_Images()
 {
     if (ERunActions::runBackground()) {
         //do all the stuff that should work in background
         $s3 = new A2s3();
         $query = "select id, nombre from aud_imagenes where aws = 0 ";
         $dataQuery = Yii::app()->db->createCommand($query)->queryAll();
         foreach ($dataQuery as $key => $value) {
             $url = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->baseUrl . "/uploads/" . $value["nombre"];
             $response = $s3->putObject(array('Bucket' => '54Mmggroup', 'Key' => $value["nombre"], 'SourceFile' => $url));
             $query = "update aud_imagenes set aws = 1 where id = {$value['id']}";
             Yii::app()->db->createCommand($query)->execute();
         }
     }
 }