Exemplo n.º 1
0
 public function executeList(sfWebRequest $request)
 {
     //mixiサーバから値取得
     if ($request->isMethod('get')) {
         $mixi = new MixiAppMobileApi();
         $persistence = $mixi->get(sfConfig::get('sf_opensocial_persistence_api'));
         $mixi_persistence = $persistence->entry->{'mixi.jp:' . MixiAppMobileApi::$ownerId};
         $request->setParameter('to_address', $mixi_persistence->to_address);
         $request->setParameter('to_lon', $mixi_persistence->to_lon);
         $request->setParameter('to_lat', $mixi_persistence->to_lat);
         $request->setParameter('from_address', $mixi_persistence->from_address);
         $request->setParameter('from_lon', $mixi_persistence->from_lon);
         $request->setParameter('from_lat', $mixi_persistence->from_lat);
         $request->setParameter('category', $mixi_persistence->category);
         $request->setParameter('depart_date', array('year' => $mixi_persistence->depart_year, 'month' => $mixi_persistence->depart_month, 'day' => $mixi_persistence->depart_day));
         $request->setParameter('depart_time', array('hour' => $mixi_persistence->depart_hour, 'minute' => $mixi_persistence->depart_min));
     } else {
         if ($request->isMethod('post')) {
             //mixiサーバに値設定
             $depart_date = $this->getRequestParameter('depart_date');
             $depart_time = $this->getRequestParameter('depart_time');
             $mixi = new MixiAppMobileApi();
             $mixi->post(sfConfig::get('sf_opensocial_persistence_api'), array('to_address' => $this->getRequestParameter('to_address'), 'to_lon' => $this->getRequestParameter('to_lon'), 'to_lat' => $this->getRequestParameter('to_lat'), 'from_address' => $this->getRequestParameter('from_address'), 'from_lon' => $this->getRequestParameter('from_lon'), 'from_lat' => $this->getRequestParameter('from_lat'), 'category' => $this->getRequestParameter('category'), 'depart_year' => $depart_date['year'], 'depart_month' => $depart_date['month'], 'depart_day' => $depart_date['day'], 'depart_hour' => $depart_time['hour'], 'depart_min' => $depart_time['minute']));
         }
     }
     //タクトモAPIにアクセス
     $this->form = new SearchDriverForm();
     $b = new sfWebBrowser();
     $this->from_address = $this->getRequestParameter('from_address');
     $this->to_address = $this->getRequestParameter('to_address');
     $this->form->bind($request->getParameterHolder()->getAll());
     if ($this->form->isValid()) {
         $this->display_category = SearchDriverForm::$categories[$this->getRequestParameter('category')];
         $depart_date = $this->getRequestParameter('depart_date');
         $depart_time = $this->getRequestParameter('depart_time');
         $b->post(sfConfig::get('sf_takutomo_search_driver_url'), array('from_address' => $this->getRequestParameter('from_address'), 'from_lat' => $this->getRequestParameter('from_lat'), 'from_lon' => $this->getRequestParameter('from_lon'), 'to_address' => $this->getRequestParameter('to_address'), 'to_lat' => $this->getRequestParameter('to_lat'), 'to_lon' => $this->getRequestParameter('to_lon'), 'depart_date' => $depart_date['year'] . sprintf('%02d', $depart_date['month']) . sprintf('%02d', $depart_date['day']), 'depart_hour' => $depart_time['hour'], 'depart_min' => sprintf('%02d', $depart_time['minute']), 'category' => $this->display_category));
         $xml = new SimpleXMLElement($b->getResponseText());
         //print $b->getResponseText();
         //print((string)$xml->status->code);
         if ((int) $xml->status->code >= 1000) {
             $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
             $this->setTemplate('index');
         } else {
             //xmlを連想配列に変換
             $options = array('complexType' => 'array');
             // print $b->getResponseText();
             $Unserializer = new XML_Unserializer($options);
             $status = $Unserializer->unserialize($b->getResponseText());
             if ($status === true) {
                 $this->list = $Unserializer->getUnserializedData();
                 //print_r($this->list);
             }
         }
         $this->display_description = (string) $xml->status->description;
     } else {
         $this->setTemplate('index');
         //$this->forward("search_driver", "index");
     }
 }
Exemplo n.º 2
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_reserved_driver_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $options = array('complexType' => 'array', 'parseAttributes' => TRUE);
     $Unserializer = new XML_Unserializer($options);
     //$Unserializer->setOption('parseAttributes', TRUE);
     $status = $Unserializer->unserialize($b->getResponseText());
     $this->list = $Unserializer->getUnserializedData();
 }
Exemplo n.º 3
0
 /**
  * 会員が存在するかチェック 
  */
 private function memberExist()
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_check_registration_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $xml = new SimpleXMLElement($b->getResponseText());
     if ((int) $xml->status->code >= 1000) {
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     //xmlを連想配列に変換
     $options = array('complexType' => 'array');
     $Unserializer = new XML_Unserializer($options);
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->member = $Unserializer->getUnserializedData();
     }
     $b->post(sfConfig::get('sf_takutomo_get_eval_comments_url'), array('id' => $this->getRequestParameter('m_id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->comments = $Unserializer->getUnserializedData();
     }
 }
Exemplo n.º 5
0
 /**
  * 予約中と予約したタクシー取得
  * 正常 array
  * error null
  */
 private function getReservedDriverList()
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_reserved_driver_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $options = array('complexType' => 'array', 'parseAttributes' => TRUE);
     $Unserializer = new XML_Unserializer($options);
     $status = $Unserializer->unserialize($b->getResponseText());
     if ($status === true) {
         return $Unserializer->getUnserializedData();
     } else {
         return null;
     }
 }
Exemplo n.º 6
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $b = new sfWebBrowser();
         $b->post(sfConfig::get('sf_takutomo_delete_user_url'), array('guid' => 'DEBUG,sample_member_001'));
         $xml = new SimpleXMLElement($b->getResponseText());
         if ((int) $xml->status->code >= 1000) {
             $this->display_description = (string) $xml->status->description;
         } else {
             $this->display_description = (string) $xml->status->description;
             $this->setTemplate('submit');
         }
     }
 }
Exemplo n.º 7
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new ForgotPasswordForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameterHolder()->getAll());
         if ($this->form->isValid()) {
             $b = new sfWebBrowser();
             $b->post(sfConfig::get('sf_takutomo_forgot_password_url'), array('email' => $this->getRequestParameter('email')));
             $xml = new SimpleXMLElement($b->getResponseText());
             $this->display_description = (string) $xml->status->description;
             $this->setTemplate('submit');
         }
     }
 }
Exemplo n.º 8
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new AddEventCommentForm();
     if ($request->isMethod('get')) {
         $this->form->setDefault('event_id', $request->getParameter('event_id'));
     } elseif ($request->isMethod('post')) {
         $this->form->bind($request->getParameterHolder()->getAll());
         if ($this->form->isValid()) {
             $b = new sfWebBrowser();
             $b->post(sfConfig::get('sf_takutomo_add_event_comment_url'), array('event_id' => $this->getRequestParameter('event_id'), 'comment' => $this->getRequestParameter('comment')));
             print $b->getResponseText();
         }
     }
 }
Exemplo n.º 9
0
 private function getProFileMySelf()
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_myself_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId));
     $xml = new SimpleXMLElement($b->getResponseText());
     $this->profileForm = new sfForm();
     if ((int) $xml->status->code >= 1000) {
         $this->profileForm->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $options = array('complexType' => 'array');
         $Unserializer = new XML_Unserializer($options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->profile = $Unserializer->getUnserializedData();
     }
 }
 /**
  * タクトモ会員登録
  * return boolean
  */
 private function memberRegister()
 {
     $mixi = new MixiAppMobileApi();
     $person = $mixi->get(sfConfig::get('sf_opensocial_person_api') . '?fields=birthday,gender');
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_register_by_guid_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId, 'name' => $person->entry->nickname, 'age' => $this->convertAge($person->entry->birthday), 'gender' => $this->convertGender($person->entry->gender), 'introduction' => ''));
     $xml = new SimpleXMLElement($b->getResponseText());
     $moduleArr = array('index', 'member_register', 'forgot_password');
     if ((int) $xml->status->code >= 1000) {
         /*if(array_search(sfContext::getInstance()->getModuleName(),$moduleArr) === false){
                header("Location:".sfConfig::get('sf_mixi_index_url'));
                exit;
           }*/
         return false;
     }
     return true;
 }
Exemplo n.º 11
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new LoginForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameterHolder()->getAll());
         if ($this->form->isValid()) {
             $b = new sfWebBrowser();
             $b->post('http://api.takutomo.com/v3/member/get_profile_myself.php?api_key=pontuyo', array('email' => $this->getRequestParameter('email'), 'password' => $this->getRequestParameter('password')));
             print $b->getResponseText();
             $xml = new SimpleXMLElement($b->getResponseText());
             //var_dump(MemberForm::$sexs[$this->getRequestParameter('gender')]);
             //$this->display_form = MemberForm::$sexs[$this->getRequestParameter('gender')];
             //$this->form->freeze();
             //	$this->setTemplate('confirm');
         }
     }
 }
Exemplo n.º 12
0
 private function addEventComment(sfWebRequest $request)
 {
     $b = new sfWebBrowser();
     $this->form = new AddEventCommentForm();
     $this->form->bind($request->getParameterHolder()->getAll());
     if ($this->form->isValid()) {
         $b = new sfWebBrowser();
         $b->post(sfConfig::get('sf_takutomo_add_event_comment_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId, 'event_id' => $this->getRequestParameter('event_id'), 'comments' => $this->getRequestParameter('comment')));
         $xml = new SimpleXMLElement($b->getResponseText());
         if ((int) $xml->status->code >= 1000) {
             $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
         } else {
             $this->display_description = (string) $xml->status->description;
             $this->setTemplate('submit');
         }
     }
 }
Exemplo n.º 13
0
 /**
  * @param sfWebRequest $request
  * @throws sfStopException
  */
 public function executeAuth(sfWebRequest $request)
 {
     $client_id = sfConfig::get('app_google_api_client_id');
     $redirect_uri = $this->generateUrl('sf_guard_auth', array('auth_method' => 'google'), true);
     if ($request->hasParameter('code')) {
         $client_secret = sfConfig::get('app_google_api_client_secret');
         $this->redirect = false;
         $params = array('client_id' => $client_id, 'client_secret' => $client_secret, 'grant_type' => 'authorization_code', 'code' => $request->getParameter('code'), 'redirect_uri' => $redirect_uri);
         $browser = new sfWebBrowser(array(), null, array('ssl_verify_host' => false, 'ssl_verify' => false));
         $result = $browser->post('https://accounts.google.com/o/oauth2/token', $params);
         if ($result->getResponseCode() == 200) {
             $this->redirect = true;
             $this->getUser()->setAttribute('google_token', $result->getResponseText());
         }
     } else {
         $scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
         $this->redirect('https://accounts.google.com/o/oauth2/auth?client_id=' . $client_id . '&redirect_uri=' . urlencode($redirect_uri) . '&scope=' . $scope . '&response_type=code&access_type=offline');
     }
 }
Exemplo n.º 14
0
function getEval($id)
{
    $result = null;
    $b = new sfWebBrowser();
    $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $id));
    $xml = new SimpleXMLElement($b->getResponseText());
    if ((int) $xml->status->code >= 1000) {
        return null;
    } else {
        //xmlを連想配列に変換
        $options = array('complexType' => 'array');
        $Unserializer = new XML_Unserializer($options);
        $status = $Unserializer->unserialize($b->getResponseText());
        if ($status) {
            $member = $Unserializer->getUnserializedData();
            return createStars(calculateEvaluate($member));
        }
        return null;
    }
}
Exemplo n.º 15
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new LoginForm();
     $agent = $this->getContext()->getRequest()->getAttribute('userAgent');
     //print($agent->isDoCoMo());
     // APIのURLなどの詳細は以下を参照。
     // http://developer.mixi.co.jp/appli/appli_mobile/lets_enjoy_making_mixiappmobile/for_partners
     $personApi = 'http://api.mixi-platform.com/os/0.8/people/@me/@self';
     $persistenceApi = 'http://****************************************';
     $mixi = new MixiAppMobileApi();
     // owner(viewer) データ取得
     //print_r($mixi->get($personApi));
     $person = $mixi->get($personApi);
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameterHolder()->getAll());
         if ($this->getRequestParameter('login') != '' && $this->form->isValid()) {
             $b = new sfWebBrowser();
             $b->post(sfConfig::get('sf_takutomo_get_profile_myself_url'), array('guid' => 'DEBUG,sample_member_001', 'email' => $this->getRequestParameter('email'), 'password' => $this->getRequestParameter('password')));
             $xml = new SimpleXMLElement($b->getResponseText());
             if ((int) $xml->status->code >= 1000) {
                 $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
             } else {
                 $this->getUser()->setName((string) $xml->profile->name);
                 $this->getUser()->setEmail((string) $xml->profile->email);
                 $this->getUser()->setPassword((string) $xml->profile->password);
                 $this->getUser()->setAuthenticated(true);
                 //$this->redirect("member", "index");
                 //print('index');
                 $this->forward('member', 'index');
                 $this->redirect('http://pontuyo.net/takutomo/web/member');
                 if ($agent->isDoCoMo()) {
                     $this->redirect('member/index?sid=' + SID);
                 } else {
                     $this->redirect('member/index');
                 }
             }
             $this->display_description = (string) $xml->status->description;
             //$this->display_response = (string)$b->getResponseText();
         }
     }
 }
 public function execute($request)
 {
     if (!$this->context->user->hasCredential('administrator') || !sfConfig::get('app_check_for_updates')) {
         return sfView::NONE;
     }
     $this->currentVersion = qubitConfiguration::VERSION;
     $this->updateCheckUrl = 'http://updatecheck.qubit-toolkit.org/check/';
     $this->cookiePath = sfContext::getInstance()->request->getRelativeUrlRoot();
     if (1 > strlen($this->cookiePath)) {
         $this->cookiePath = '/';
     }
     $this->updateCheckData = array();
     $this->updateCheckData['address'] = $request->getUriPrefix() . $request->getScriptName() . $request->getPathInfo();
     $this->updateCheckData['version'] = qubitConfiguration::VERSION . ' - ' . sfConfig::get('app_version');
     if (null === ($this->updateCheckData['distribution'] = $this->context->user->getAttribute('distribution'))) {
         $packageXmlPath = sfConfig::get('sf_config_dir') . '/package.xml';
         if (file_exists($packageXmlPath)) {
             require_once sfConfig::get('sf_root_dir') . '/vendor/FluentDOM/FluentDOM.php';
             $fd = FluentDOM($packageXmlPath)->namespaces(array('p' => 'http://pear.php.net/dtd/package-2.0'));
             $this->context->user->setAttribute('distribution', $this->updateCheckData['distribution'] = $fd->find('/*/p:name')->item(0)->textContent);
         }
     }
     $this->updateCheckData['site_description'] = sfConfig::get('app_siteDescription');
     $this->updateCheckData['site_title'] = sfConfig::get('app_siteTitle');
     if (!$request->getCookie('has_js')) {
         if (null === ($this->lastVersion = $this->context->user->getAttribute('last_version'))) {
             try {
                 $browser = new sfWebBrowser();
                 $this->lastVersion = $browser->post($this->updateCheckUrl, $this->updateCheckData)->getResponseText();
             } catch (Exception $e) {
                 $this->lastVersion = 0;
             }
             $this->context->user->setAttribute('last_version', $this->lastVersion);
         }
         if (0 == $this->lastVersion || 1 > version_compare($this->lastVersion, qubitConfiguration::VERSION)) {
             return sfView::NONE;
         }
     }
 }
Exemplo n.º 17
0
 public function executeSubmit(sfWebRequest $request)
 {
     $requestIdKey = null;
     $requestIdValue = null;
     if ($this->getRequestParameter('request_id') != "") {
         $requestIdKey = 'request_id';
         $requestIdValue = $this->getRequestParameter('request_id');
     } else {
         if ($this->getRequestParameter('event_id') != "") {
             $requestIdKey = 'event_id';
             $requestIdValue = $this->getRequestParameter('event_id');
         }
     }
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_eval_user_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId, 'id' => $this->getRequestParameter('id'), 'eval' => $this->getRequestParameter('eval'), 'eval_comment' => $this->getRequestParameter('eval_comment'), $requestIdKey => $requestIdValue));
     $this->form = new sfForm();
     $xml = new SimpleXMLElement($b->getResponseText());
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
         $this->setTemplate('index');
     }
     $this->display_description = (string) $xml->status->description;
 }
Exemplo n.º 18
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new ReserveDriverForm();
     $b = new sfWebBrowser();
     $now = strtotime('+15 minute');
     $depart_date = array('year' => date('Y', $now), 'month' => date('n', $now), 'day' => date('j', $now));
     $depart_time = array('hour' => date('G', $now), 'minute' => (int) date('i', $now));
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('driver_id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         //xmlを連想配列に変換
         $options = array('complexType' => 'array');
         $Unserializer = new XML_Unserializer($options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->member = $Unserializer->getUnserializedData();
     }
     if ($request->isMethod('get')) {
         $mixi = new MixiAppMobileApi();
         $persistence = $mixi->get(sfConfig::get('sf_opensocial_persistence_api'));
         $mixi_persistence = $persistence->entry->{'mixi.jp:' . MixiAppMobileApi::$ownerId};
         $this->form->setDefault('to_address', $mixi_persistence->to_address);
         $this->form->setDefault('to_lon', $mixi_persistence->to_lon);
         $this->form->setDefault('to_lat', $mixi_persistence->to_lat);
         $this->form->setDefault('from_address', $mixi_persistence->from_address);
         $this->form->setDefault('from_lon', $mixi_persistence->from_lon);
         $this->form->setDefault('from_lat', $mixi_persistence->from_lat);
         $this->form->setDefault('depart_date', $depart_date['year'] . sprintf('%02d', $depart_date['month']) . $depart_date['day']);
         $this->form->setDefault('depart_time', $depart_time['hour'] . sprintf('%02d', $depart_time['minute']));
         $this->form->setDefault('driver_m_id', $request->getParameter('driver_id'));
         $this->form->setDefault('phone', $request->getParameter('phone'));
         $request->setParameter('from_address', $mixi_persistence->from_address);
         $request->setParameter('to_address', $mixi_persistence->to_address);
         $request->setParameter('depart_date', $depart_date['year'] . sprintf('%02d', $depart_date['month']) . $depart_date['day']);
         $request->setParameter('depart_time', $depart_time['hour'] . sprintf('%02d', $depart_time['minute']));
     } else {
         if ($request->isMethod('post')) {
             $this->form->bind($request->getParameterHolder()->getAll());
             if ($this->form->isValid()) {
                 $b->post(sfConfig::get('sf_takutomo_reserve_driver_url'), array('guid' => 'DEBUG,sample_member_001', 'email' => $this->getUser()->getEmail(), 'password' => $this->getUser()->getPassword(), 'from_address' => $this->getRequestParameter('from_address'), 'from_lat' => $this->getRequestParameter('from_lat'), 'from_lon' => $this->getRequestParameter('from_lon'), 'to_address' => $this->getRequestParameter('to_address'), 'to_lat' => $this->getRequestParameter('to_lat'), 'to_lon' => $this->getRequestParameter('to_lon'), 'depart_date' => $this->getRequestParameter('depart_date'), 'depart_hour' => substr($this->getRequestParameter('depart_time'), 0, 2), 'depart_min' => substr($this->getRequestParameter('depart_time'), 2, 2), 'driver_m_id' => $request->getParameter('driver_m_id'), 'phone' => $request->getParameter('phone')));
                 $xml = new SimpleXMLElement($b->getResponseText());
                 //print $b->getResponseText();
                 //print((string)$xml->status->code);
                 if ((int) $xml->status->code >= 1000) {
                     $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
                 } else {
                     //検索条件をsessionに格納
                     $this->getUser()->setToAddress($this->getRequestParameter('to_address'));
                     $this->getUser()->setToLon($this->getRequestParameter('to_lon'));
                     $this->getUser()->setToLat($this->getRequestParameter('to_lat'));
                     $this->getUser()->setFromAddress($this->getRequestParameter('from_address'));
                     $this->getUser()->setFromLon($this->getRequestParameter('from_lon'));
                     $this->getUser()->setFromLat($this->getRequestParameter('from_lat'));
                     $this->setTemplate('submit');
                 }
                 $this->display_description = (string) $xml->status->description;
                 $this->display_phone = (string) $xml->taxi_data->phone;
             }
         }
     }
 }
Exemplo n.º 19
0
 /**
  * Validate the IPN notification
  *
  * PayPal expects to receive a response to an IPN message within 30 seconds.
  * Your listener should not perform time-consuming operations, such as
  * creating a process, before responding to the IPN message.
  *
  * @param none
  * @return boolean
  */
 protected function handlePaypalData($parameters = array(), $is_ipn = false)
 {
     $this->debug('Parameters posted from Paypal ...');
     foreach ($parameters as $key => $value) {
         $this->debug("{$key}={$value}");
     }
     //--------------------------------------------------------------------------
     // store IPN data in object
     //--------------------------------------------------------------------------
     $this->ipnData = $parameters;
     $this->rewind();
     $this->relatedEntity = null;
     //--------------------------------------------------------------------------
     // post validation request; prepend cmd, leave order intact
     //--------------------------------------------------------------------------
     if ($is_ipn) {
         $this->debug('Sending IPN validation response');
         $browser = new sfWebBrowser(array("Content-type: application/x-www-form-urlencoded\r\n", "Connection: close\r\n\r\n"), null, array('ssl_verify' => false));
         $url = $this->testMode ? self::$ppSandboxUrl : self::$ppProductionUrl;
         $browser->post($url, array('cmd' => '_notify-validate') + $this->ipnData);
     }
     $dispatcher = sfContext::getInstance()->getEventDispatcher();
     //--------------------------------------------------------------------------
     // After PayPal verifies the message, there are additional checks that
     // your listener or back-end or administrative software must take
     //--------------------------------------------------------------------------
     try {
         //------------------------------------------------------------------------
         // make sure response == 'VERIFIED'
         //------------------------------------------------------------------------
         if ($is_ipn) {
             $this->checkVerified($browser->getResponseText());
         }
         //------------------------------------------------------------------------
         // make sure the IPN message is in relation to the business account
         //------------------------------------------------------------------------
         $this->checkReceiver();
         //------------------------------------------------------------------------
         // make sure this response has not been handled before
         //------------------------------------------------------------------------
         $this->checkDuplicateTxn();
         //------------------------------------------------------------------------
         // save the transaction
         //------------------------------------------------------------------------
         $transaction = $this->saveTransaction();
         //------------------------------------------------------------------------
         // make sure IPN data matches an existing entity
         //------------------------------------------------------------------------
         $this->checkEntity();
         //------------------------------------------------------------------------
         // call application specific method to handle payment status
         //------------------------------------------------------------------------
         $this->handlePaymentStatus($this['payment_status'], $this['pending_reason']);
         $dispatcher->notify(new sfEvent($transaction, 'paypal.ipn_success', array('ipn_data' => $this->ipnData)));
         $this->debug('******* SUCCESS ********');
     } catch (sfException $e) {
         $this->lastError = $e->getMessage();
         $dispatcher->notify(new sfEvent($this->lastError, 'paypal.ipn_error', array('ipn_data' => $this->ipnData)));
         $this->debug($this->lastError, 'alert');
         $this->debug('******* FAILED ********');
     }
     return isset($transaction) ? $transaction : false;
 }
Exemplo n.º 20
0
    }
    $item->addChild('original_outing_id', $id);
    $item->addChild('url', "http://www.camptocamp.org/outings/{$id}/{$lang}/" . make_slug(htmlspecialchars($object->get('name'))));
}
if (!$n) {
    exit;
    // it's better to keep the script mute if not necessary, thus avoiding cron to send useless mails
}
// debug info :
//echo "XML created : \n" . $xml->asXML() . " \n";
$b = new sfWebBrowser();
try {
    if (!$b->get($meta_url)->responseIsError()) {
        // Successful response (eg. 200, 201, etc)
        //echo "Pushing $n outing(s) ... \n";
        $b->post($meta_url . 'outings/push', array('metaengine_user_id' => $user_id, 'metaengine_user_key' => $user_key, 'metaengine_xml' => urlencode($xml->asXML())));
        $response = $b->getResponseXml();
        if ($response->status == 1) {
            //echo "Push succeeded. \n";
        } else {
            // now, what append ???
            // try to get more info on what could make it fail
            //var_dump($xml->asXML());
            //var_dump($response);
            foreach ($response->errors->error as $error) {
                if (!isset($complaint)) {
                    echo "Push failed for outings:\n";
                    $complaint = 1;
                }
                echo "- {$error->outing_id} : {$error->error_message}\n";
            }
Exemplo n.º 21
0
 /**
  * 相乗りイベント追加
  */
 private function addEvent(sfWebRequest $request)
 {
     $depart_date = $this->getRequestParameter('depart_date');
     $depart_time = $this->getRequestParameter('depart_time');
     $this->addEvnetForm = new AddEventForm();
     $b = new sfWebBrowser();
     $request->setParameter('add_event_depart_date', $depart_date);
     $request->setParameter('add_event_depart_time', $depart_time);
     $this->addEvnetForm->bind($request->getParameterHolder()->getAll());
     if ($this->addEvnetForm->isValid()) {
         $b->post(sfConfig::get('sf_takutomo_add_event_url'), array('guid' => 'mixi,' . MixiAppMobileApi::$ownerId, 'from_address' => $request->getParameter('from_address'), 'from_lat' => $request->getParameter('from_lat'), 'from_lon' => $request->getParameter('from_lon'), 'to_address' => $request->getParameter('to_address'), 'to_lat' => $request->getParameter('to_lat'), 'to_lon' => $request->getParameter('to_lon'), 'depart_date' => $depart_date['year'] . sprintf('%02d', $depart_date['month']) . sprintf('%02d', $depart_date['day']), 'depart_hour' => $depart_time['hour'], 'depart_min' => sprintf('%02d', $depart_time['minute']), 'detail' => $request->getParameter('detail')));
         $xml = new SimpleXMLElement($b->getResponseText());
         if ((int) $xml->status->code >= 1000) {
             $this->addEvnetForm->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 22
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new AddEventForm();
     $b = new sfWebBrowser();
     $now = strtotime('+15 minute');
     $depart_date = array('year' => date('Y', $now), 'month' => date('n', $now), 'day' => date('j', $now));
     $depart_time = array('hour' => date('G', $now), 'minute' => (int) date('i', $now));
     if ($request->isMethod('get')) {
         $request->setParameter('lat', str_replace('+', '', $this->getRequestParameter('lat')));
         $request->setParameter('lon', str_replace('+', '', $this->getRequestParameter('lon')));
         $b->get(sfConfig::get('sf_google_geo_url'), array('output' => 'xml', 'hl' => 'ja', 'key' => sfConfig::get('sf_google_key'), 'oe' => 'UTF-8', 'll' => $this->getRequestParameter('lat') . ',' . $this->getRequestParameter('lon')));
         $xml = new SimpleXMLElement($b->getResponseText());
         $from_address = (string) $xml->Response->Placemark[0]->AddressDetails->Country->AdministrativeArea->AdministrativeAreaName;
         $from_address .= (string) $xml->Response->Placemark[0]->AddressDetails->Country->AdministrativeArea->Locality->LocalityName;
         $from_address .= (string) $xml->Response->Placemark[0]->AddressDetails->Country->AdministrativeArea->Locality->DependentLocality->DependentLocalityName;
         $from_address .= (string) $xml->Response->Placemark[0]->AddressDetails->Country->AdministrativeArea->Locality->DependentLocality->Thoroughfare->ThoroughfareName;
         //初期値設定
         $this->form->setDefault('from_address', $from_address);
         $this->form->setDefault('from_lat', $this->getRequestParameter('lat'));
         $this->form->setDefault('from_lon', $this->getRequestParameter('lon'));
         $this->form->setDefault('depart_date', $depart_date);
         $this->form->setDefault('depart_time', $depart_time);
     } else {
         if ($request->isMethod('post')) {
             //出発地
             if ($request->getParameter('departure') != '') {
                 $b->get(sfConfig::get('sf_google_geo_url'), array('output' => 'xml', 'sensor' => 'false', 'key' => sfConfig::get('sf_google_key'), 'q' => $request->getParameter('from_address')));
                 //print (string)$b->getResponseText();
                 //print "<br>";
                 $xml = new SimpleXMLElement($b->getResponseText());
                 if (count($xml->Response->Placemark) > 1) {
                     $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), '出発地が複数あります、詳しく入力してください。', array('from_address')));
                 } else {
                 }
                 $split = explode(',', (string) $xml->Response->Placemark[0]->Point->coordinates);
                 $this->form->setDefault('from_address', $request->getParameter('from_address'));
                 $this->form->setDefault('from_lat', $split[1]);
                 $this->form->setDefault('from_lon', $split[0]);
                 $this->form->setDefault('to_address', $request->getParameter('to_address'));
                 $this->form->setDefault('to_lat', $request->getParameter('to_lat'));
                 $this->form->setDefault('to_lon', $request->getParameter('to_lon'));
                 $this->form->setDefault('depart_date', $depart_date);
                 $this->form->setDefault('depart_time', $depart_time);
                 //目的地
             } else {
                 if ($request->getParameter('destination') != '') {
                     $b->get(sfConfig::get('sf_google_geo_url'), array('output' => 'xml', 'sensor' => 'false', 'key' => sfConfig::get('sf_google_key'), 'q' => $request->getParameter('to_address')));
                     $xml = new SimpleXMLElement($b->getResponseText());
                     if (count($xml->Response->Placemark) > 1) {
                         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), '目的地が複数あります、詳しく入力してください。', array('to_address')));
                     }
                     $split = explode(',', (string) $xml->Response->Placemark[0]->Point->coordinates);
                     $this->form->setDefault('to_address', $request->getParameter('to_address'));
                     $this->form->setDefault('to_lat', $split[1]);
                     $this->form->setDefault('to_lon', $split[0]);
                     $this->form->setDefault('from_address', $request->getParameter('from_address'));
                     $this->form->setDefault('from_lat', $request->getParameter('from_lat'));
                     $this->form->setDefault('from_lon', $request->getParameter('from_lon'));
                     $this->form->setDefault('depart_date', $depart_date);
                     $this->form->setDefault('depart_time', $depart_time);
                 } else {
                     $this->form->bind($request->getParameterHolder()->getAll());
                     if ($this->form->isValid()) {
                         $depart_date = $this->getRequestParameter('depart_date');
                         $depart_time = $this->getRequestParameter('depart_time');
                         $b->post(sfConfig::get('sf_takutomo_add_event_url'), array('guid' => 'DEBUG,sample_member_001', 'from_address' => $this->getRequestParameter('from_address'), 'from_lat' => $this->getRequestParameter('from_lat'), 'from_lon' => $this->getRequestParameter('from_lon'), 'to_address' => $this->getRequestParameter('to_address'), 'to_lat' => $this->getRequestParameter('to_lat'), 'to_lon' => $this->getRequestParameter('to_lon'), 'depart_date' => $depart_date['year'] . sprintf('%02d', $depart_date['month']) . sprintf('%02d', $depart_date['day']), 'depart_hour' => $depart_time['hour'], 'depart_min' => $depart_time['minute'], 'detail' => $this->getRequestParameter('detail')));
                         $xml = new SimpleXMLElement($b->getResponseText());
                         //print $b->getResponseText();
                         //print((string)$xml->status->code);
                         if ((int) $xml->status->code >= 1000) {
                             $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
                         } else {
                             //検索条件をsessionに格納
                             $this->getUser()->setToAddress($this->getRequestParameter('to_address'));
                             $this->getUser()->setToLon($this->getRequestParameter('to_lon'));
                             $this->getUser()->setToLat($this->getRequestParameter('to_lat'));
                             $this->getUser()->setFromAddress($this->getRequestParameter('from_address'));
                             $this->getUser()->setFromLon($this->getRequestParameter('from_lon'));
                             $this->getUser()->setFromLat($this->getRequestParameter('from_lat'));
                             $this->setTemplate('submit');
                         }
                         $this->display_description = (string) $xml->status->description;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 23
0
 private function getProfile($id)
 {
     $b = new sfWebBrowser();
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $id));
     $this->profileForm = new sfForm();
     $xml = new SimpleXMLElement($b->getResponseText());
     if ((int) $xml->status->code >= 1000) {
         $this->profileForm->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         $Unserializer = new XML_Unserializer($this->options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->profile = $Unserializer->getUnserializedData();
     }
 }
Exemplo n.º 24
0
    $t->diag('Soap requests');
    $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
    $headers = array('Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getWorldPopulation', 'Content-Type' => 'text/xml');
    $requestBody = <<<EOT
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <getWorldPopulation xmlns="http://www.abundanttech.com/WebServices/Population" />
  </soap:Body>
</soap:Envelope>
EOT;
    $b = new sfWebBrowser(array(), $adapter);
    $b->post($url, $requestBody, $headers);
    $t->like($b->getResponseText(), '/<Country>World<\\/Country>/', 'sfWebBrowser can make a low-level SOAP call without parameter');
    $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx';
    $headers = array('Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getPopulation', 'Content-Type' => 'text/xml');
    $requestBody = <<<EOT
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:pop="http://www.abundanttech.com/WebServices/Population">
  <soapenv:Header/>
  <soapenv:Body>
    <pop:getPopulation>
      <pop:strCountry>Comoros</pop:strCountry>
    </pop:getPopulation>
  </soapenv:Body>
</soapenv:Envelope>
EOT;
    $b = new sfWebBrowser(array(), $adapter);
    $b->post($url, $requestBody, $headers);
    $t->like($b->getResponseText(), '/<Country>Comoros<\\/Country>/', 'sfWebBrowser can make a low-level SOAP call with parameter');
    $t->diag('');
}