コード例 #1
0
ファイル: QRCodePage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     if (!isset($params['qr-data'])) {
         $params['qr-data'] = Application::getBaseURL()->build();
     }
     $hParams = new HttpParams($params);
     $this->currentParams = $hParams;
     $this->doGenerateCode = $hParams->hasValues(array('qr-data', 'qr-size', 'qr-fgcolor', 'qr-bgcolor'));
 }
コード例 #2
0
ファイル: AddWildcardPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     self::requirePermission('link.add_wildcard');
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
 }
コード例 #3
0
 public function init($params)
 {
     self::requireLogin();
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
     $dbc = Application::dbConnection();
     $this->dbSettings = $dbc->options()->getOptions(array('home_action', 'home_target'));
 }
コード例 #4
0
ファイル: LinksSettingsPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
     $dbc = Application::dbConnection();
     $this->dbSettings = $dbc->options()->getOptions(array('linkgen_chars', 'linkgen_length', 'custom_links_regex'));
 }
コード例 #5
0
ファイル: LoginPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     if (Authorization::loggedIn()) {
         self::redirectTo('home');
         exit;
     }
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->tryProcessPostData($postData);
     }
 }
コード例 #6
0
ファイル: UsersSettingsPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
     $dbc = Application::dbConnection();
     $this->dbSettings = $dbc->options()->getOptions(array('allow_registration', 'registration_user_group', 'allow_name_changes'));
     $this->availableGroups = $dbc->groups()->getGroups(0, 100);
 }
コード例 #7
0
ファイル: ConfigPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     if (Installer::getStatus() !== Installer::CREATE_CONFIG) {
         InstallationPage::redirectToCorrectStep();
         exit;
     }
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
 }
コード例 #8
0
 public function init($params)
 {
     self::requireLogin();
     $dbc = Application::dbConnection();
     $this->settings = $dbc->options()->getOptions(array('allow_name_changes'));
     $this->userInfo = Authorization::user();
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
         $this->userInfo = Authorization::user('reload');
     }
 }
コード例 #9
0
ファイル: RegistrationPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     if (Authorization::loggedIn()) {
         self::redirectTo('home');
         exit;
     }
     $dbc = Application::dbConnection();
     if (!$dbc->options()->getOption('allow_registration')) {
         self::redirectTo('login');
         exit;
     }
     $postData = \tniessen\tinyIt\HttpParams::_POST();
     if ($postData && !$postData->isEmpty()) {
         $this->currentParams = $postData;
         $this->tryProcessPostData($postData);
     }
 }
コード例 #10
0
ファイル: LinkDetailsPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     $dbc = Application::dbConnection();
     if ($lid = $this->linkId) {
         $this->linkInfo = $dbc->links()->getLink($lid);
         if ($this->linkInfo) {
             if ($this->editMode) {
                 $allowed = self::hasPermission('link.edit_links');
                 $allowed |= $this->linkInfo->owner_id === Authorization::user()->id && self::hasPermission('link.edit_own_links');
                 if ($allowed) {
                     $postData = \tniessen\tinyIt\HttpParams::_POST();
                     if ($postData && !$postData->isEmpty()) {
                         $this->currentParams = $postData;
                         $this->tryProcessEditPostData($postData);
                     }
                 } else {
                     $this->editMode = false;
                     $this->errorMessage = 'You are not permitted to edit this link.';
                 }
             } elseif ($this->deleteMode) {
                 self::requireNonce();
                 $allowed = self::hasPermission('link.delete_links');
                 $allowed |= $this->linkInfo->owner_id === Authorization::user()->id && self::hasPermission('link.delete_own_links');
                 if ($allowed) {
                     if ($dbc->links()->removeLink($lid)) {
                         self::redirectTo('links/list');
                         exit;
                     } else {
                         $this->errorMessage = 'Internal error while deleting link';
                     }
                 } else {
                     $this->errorMessage = 'You are not permitted to delete this link.';
                 }
             }
             if ($oid = $this->linkInfo->owner_id) {
                 $this->linkInfo->userInfo = $dbc->users()->getUser($oid);
             }
             if ($this->linkInfo->type === 'static') {
                 $this->linkInfo->fullURL = Application::getBaseURL()->build() . $this->linkInfo->path;
             }
         }
     }
 }
コード例 #11
0
ファイル: GroupDetailsPage.php プロジェクト: tniessen/tinyIt
 public function init($params)
 {
     self::requireLogin();
     $dbc = Application::dbConnection();
     if ($gid = $this->groupId) {
         $this->groupInfo = $dbc->groups()->getGroup($gid);
         if ($this->groupInfo) {
             if ($this->editMode) {
                 if (self::hasPermission('group.edit_groups')) {
                     $postData = \tniessen\tinyIt\HttpParams::_POST();
                     if ($postData && !$postData->isEmpty()) {
                         $this->tryProcessEditPostData($postData);
                     }
                 } else {
                     $this->errorMessage = 'You are not permitted to edit this group.';
                 }
             } elseif ($this->deleteMode) {
                 self::requireNonce();
                 if (self::hasPermission('group.delete_groups')) {
                     $moveToGroup = 0;
                     if (isset($params['setGroup'])) {
                         $moveToGroup = intval($params['setGroup']);
                     }
                     if (!$moveToGroup || $dbc->groups()->getGroup($moveToGroup) && $moveToGroup != $gid) {
                         $dbc->users()->moveUsersToGroup($gid, $moveToGroup);
                         if ($dbc->groups()->removeGroup($gid)) {
                             self::redirectTo('groups/list');
                             exit;
                         } else {
                             $this->errorMessage = 'Internal error while deleting group';
                         }
                     } else {
                         $this->errorMessage = 'Invalid target group for affected users.';
                     }
                 } else {
                     $this->errorMessage = 'You are not permitted to delete this group.';
                 }
             }
             $this->groupInfo->nMembers = $dbc->users()->countGroupMembers($gid);
             $this->availableGroups = $dbc->groups()->getGroups(0, 100);
         }
     }
 }
コード例 #12
0
ファイル: Page.php プロジェクト: tniessen/tinyIt
 /**
  * Requires an authorized session and a valid `nonce` GET parameter.
  *
  * If the client did not send a valid nonce along with the request, this
  * function will redirect the client to another page.
  *
  * This function will call Page::requireLogin prior to any other actions.
  *
  * @param string $redirectTo
  */
 public static final function requireNonce($redirectTo = 'home')
 {
     self::requireLogin();
     $data = \tniessen\tinyIt\HttpParams::_GET();
     $okay = $data->has('nonce') && Authorization::isNonce($data->get('nonce'));
     if (!$okay) {
         self::redirectTo($redirectTo);
         exit;
     }
 }