Example #1
0
 public function executeIndex()
 {
     static $pf = array('android' => Package::PF_ANDROID, 'ios' => Package::PF_IOS, 'all' => null);
     $platform = mfwRequest::param('pf');
     if (!in_array($platform, array('android', 'ios', 'all'))) {
         $ua = mfwRequest::userAgent();
         if ($ua->isAndroid()) {
             $platform = 'android';
         } elseif ($ua->isIOS()) {
             $platform = 'ios';
         } else {
             $platform = 'all';
         }
     }
     $tags = mfwRequest::param('tags') ? explode(' ', mfwRequest::param('tags')) : array();
     $current_page = mfwRequest::param('page', 1);
     $offset = ($current_page - 1) * self::LINE_IN_PAGE;
     $pkgs = PackageDb::selectByAppIdPfTagsWithLimit($this->app->getId(), $pf[$platform], $tags, $offset, self::LINE_IN_PAGE + 1);
     $has_next_page = false;
     if ($pkgs->count() > self::LINE_IN_PAGE) {
         $pkgs = $pkgs->slice(0, self::LINE_IN_PAGE);
         $has_next_page = true;
     }
     $comment_count = CommentDb::selectCountByAppId($this->app->getId());
     $top_comments = CommentDb::selectByAppId($this->app->getId(), 2);
     $commented_package = PackageDb::retrieveByPKs($top_comments->getColumnArray('package_id'));
     $params = array('pf' => $platform, 'is_owner' => $this->app->isOwner($this->login_user), 'packages' => $pkgs, 'active_tags' => $tags, 'current_page' => $current_page, 'has_next_page' => $has_next_page, 'filter_open' => mfwRequest::param('filter_open'), 'top_comments' => $top_comments, 'comment_count' => $comment_count, 'commented_package' => $commented_package);
     return $this->build($params);
 }
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);
 }