Example #1
0
 public function initialize()
 {
     if ($err = parent::initialize()) {
         return $err;
     }
     // いくつかのapiはAPI Key認証なのでログイン不要
     if ($this->module === 'api') {
         if (in_array($this->action, array('upload', 'package_list', 'delete', 'create_token'))) {
             return null;
         }
     }
     // package/install_plist はセッションが使えないため別途認証する.
     if ($this->module === 'package' && $this->action === 'install_plist') {
         return null;
     }
     $this->login_user = User::getLoginUser();
     if (!$this->login_user && $this->getModule() != 'login') {
         $scheme = Config::get('enable_https') ? 'https' : null;
         $this->saveUrlBeforeLogin($scheme);
         return $this->redirect(mfwRequest::makeUrl('/login', $scheme));
     }
     if ($this->login_user) {
         apache_log('user', $this->login_user->getMail());
     }
     return null;
 }
Example #2
0
 public function executeInstall()
 {
     $pf = $this->package->getPlatform();
     $ua = mfwRequest::userAgent();
     if ($pf === Package::PF_IOS && $ua->isIOS()) {
         // itms-service での接続はセッションを引き継げない
         // 一時トークンをURLパラメータに付けることで認証する
         $scheme = Config::get('enable_https') ? 'https' : null;
         // HTTPSが使えるならHTTPS優先
         $plist_url = mfwHttp::composeUrl(mfwRequest::makeUrl('/package/install_plist', $scheme), array('id' => $this->package->getId(), 't' => $this->makeToken()));
         $url = 'itms-services://?action=download-manifest&url=' . urlencode($plist_url);
     } else {
         // iPhone以外でのアクセスはパッケージを直接DL
         $url = $this->package->getFileUrl('+60 min');
     }
     $con = mfwDBConnection::getPDO();
     $con->beginTransaction();
     try {
         InstallLog::Logging($this->login_user, $this->package, $ua, $con);
         $con->commit();
     } catch (Exception $e) {
         $con->rollback();
         error_log(__METHOD__ . '(' . __LINE__ . '): ' . get_class($e) . ":{$e->getMessage()}");
         throw $e;
     }
     apache_log('app_id', $this->app->getId());
     apache_log('pkg_id', $this->package->getId());
     apache_log('platform', $this->package->getPlatform());
     return $this->redirect($url);
 }
Example #3
0
 protected function makePackageArray(Package $pkg)
 {
     $tags = array();
     foreach ($pkg->getTags() as $t) {
         $tags[] = $t->getName();
     }
     return array('package_url' => mfwRequest::makeUrl("/package?id={$pkg->getId()}"), 'application_url' => mfwRequest::makeUrl("/app?id={$pkg->getAppId()}"), 'id' => $pkg->getId(), 'platform' => $pkg->getPlatform(), 'title' => $pkg->getTitle(), 'description' => $pkg->getDescription(), 'ios_identifier' => $pkg->getIOSIdentifier(), 'original_file_name' => $pkg->getOriginalFileName(), 'file_size' => $pkg->getFileSize(), 'created' => $pkg->getCreated(), 'tags' => $tags, 'install_count' => $pkg->getInstallCount());
 }
Example #4
0
 protected function redirect($query, $params = array())
 {
     $query = mfwHttp::composeUrl($query, $params);
     if (strpos($query, 'http') !== 0) {
         $query = mfwRequest::makeUrl($query);
     }
     $headers = array("Location: {$query}");
     return array($headers, null);
 }
Example #5
0
 protected function getAccessToken($code)
 {
     if (!$code) {
         return null;
     }
     $callback_url = mfwRequest::makeUrl('/login/google_callback');
     $url_base = 'https://accounts.google.com/o/oauth2/token';
     $query = array('code' => $code, 'client_id' => $this->config['google_app_id'], 'client_secret' => $this->config['google_app_secret'], 'redirect_uri' => $callback_url, 'grant_type' => 'authorization_code');
     $response = mfwHttp::post($url_base, $query);
     return json_decode($response, true);
 }
Example #6
0
 /**
  * @param[in] string $sender 送信アドレス
  */
 public function sendResetMail()
 {
     $data = array('mail' => $this->row['mail'], 'microtime' => microtime());
     $key = sha1(json_encode($data));
     mfwMemcache::set($key, $data, self::RESET_MAIL_EXPIRE);
     $url = mfwRequest::makeUrl("/login/password_reset?key={$key}");
     $subject = 'Reset password';
     $to = $data['mail'];
     $from = 'From: ' . Config::get('mail_sender');
     $body = "EMLauncher password reset URL:\n{$url}\n";
     if (!mb_send_mail($to, $subject, $body, $from)) {
         throw new RuntimeException("mb_send_mail faild (key:{$key} to:{$to})");
     }
 }
Example #7
0
 protected function buildErrorPage($message, $link = null, $linkmsg = null)
 {
     $params = array('message' => $message, 'link_url' => mfwRequest::makeUrl($link), 'link_msg' => $linkmsg ?: $link);
     $this->setTemplateName('_errorpage');
     return $this->build($params);
 }
Example #8
0
/**
 * Template用関数: URL生成
 */
function url($query)
{
    return mfwRequest::makeUrl($query);
}
Example #9
0
 public function getInstallUrl()
 {
     return mfwRequest::makeUrl("/package/install?id={$this->getId()}");
 }