/**
  * Process date reminder requests
  *
  * @param TrackerManager $trackerManager
  * @param HTTPRequest    $request
  * @param PFUser           $currentUser
  *
  * @return Void
  */
 public function processReminder(TrackerManager $trackerManager, HTTPRequest $request, $currentUser)
 {
     $action = $request->get('action');
     $do_redirect = false;
     $feedback = false;
     try {
         if ($request->get('submit') && $action == 'new_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->addNewReminder($request);
             $feedback = 'tracker_date_reminder_added';
             $do_redirect = true;
         } elseif ($request->get('submit') && $action == 'update_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->editTrackerReminder($request);
             $feedback = 'tracker_date_reminder_updated';
             $do_redirect = true;
         } elseif ($request->get('confirm_delete') && $action == 'confirm_delete_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->deleteTrackerReminder($request->get('reminder_id'));
             $feedback = 'tracker_date_reminder_deleted';
         }
         if ($feedback) {
             $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_date_reminder', $feedback));
         }
     } catch (Tracker_DateReminderException $e) {
         $GLOBALS['Response']->addFeedback('error', $e->getMessage());
     }
     if ($do_redirect || $request->get('cancel_delete_reminder')) {
         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?func=admin-notifications&tracker=' . $this->getTracker()->getId());
     }
 }
 function getPostData()
 {
     $var = new HTTPRequest();
     $username = $var->get('username');
     $password = $var->get('password');
     //$option=$var->get('option');
     $this->check($username, $password);
 }
示例#3
0
 public function updateProject(HTTPRequest $request)
 {
     $token = new CSRFSynchronizerToken('/admin/svn/svn_tokens.php?action=update_project');
     $token->check();
     $project_to_add = $request->get('project-to-allow');
     if ($request->get('allow-project') && !empty($project_to_add)) {
         $this->allowSVNTokensForProject($project_to_add);
     }
     $project_ids_to_remove = $request->get('project-ids-to-revoke');
     if ($request->get('revoke-project') && !empty($project_ids_to_remove)) {
         $this->revokeProjectsAuthorization($project_ids_to_remove);
     }
     $GLOBALS['Response']->redirect('/admin/svn/svn_tokens.php?action=index');
 }
 function getPostData()
 {
     $var = new HTTPRequest();
     $user_id = $var->get('user_id');
     //var_dump($user_id);
     //$password=$var->get('password');
     //$option=$var->get('option');
     $this->vehicleDetails($user_id);
 }
 public function displayHeader(HTTPRequest $request, $title)
 {
     $toolbar = array();
     if ($this->userIsAdmin($request->getCurrentUser())) {
         $toolbar[] = array('title' => $GLOBALS['Language']->getText('global', 'Administration'), 'url' => MEDIAWIKI_BASE_URL . '/forge_admin?' . http_build_query(array('group_id' => $request->get('group_id'))));
     }
     $title = $title . ' - ' . $GLOBALS['Language']->getText('plugin_mediawiki', 'service_lbl_key');
     $breadcrumbs = array();
     parent::displayHeader($title, $breadcrumbs, $toolbar);
 }
 public function return_to()
 {
     $request_uri = $_SERVER['REQUEST_URI'];
     if ($this->isUserTryingToLogIn($request_uri)) {
         return urlencode($this->request->get('return_to'));
     }
     if ($this->isUserTryingToRegister($request_uri)) {
         return false;
     }
     return $request_uri;
 }
示例#7
0
 public function route(HTTPRequest $request, Layout $response)
 {
     $valid_route = new Valid_WhiteList('func', $this->routes);
     $valid_route->required();
     if ($request->valid($valid_route)) {
         $route = $request->get('func');
         $controller = new OpenId_LoginController($this->logger, new OpenId_AccountManager(new Openid_Dao(), UserManager::instance()), $request, $response);
         $controller->{$route}();
     } else {
         $response->addFeedback(Feedback::ERROR, 'Invalid request for ' . __CLASS__);
         $response->redirect('/');
     }
 }
示例#8
0
/**
 * Checks to see if a new version of Lilina is available
 * @author WordPress
 */
function lilina_version_check()
{
    if (strpos($_SERVER['REQUEST_URI'], 'install.php') !== false || defined('LILINA_INSTALLING') || !is_admin()) {
        return;
    }
    $lilina_version = LILINA_CORE_VERSION;
    $php_version = phpversion();
    // We need this for unique identification of installations, but we take the hash of it
    $id = sha1(get_option('baseurl'));
    $data = new DataHandler();
    $current = $data->load('core-update-check.data');
    if ($current !== null) {
        $current = unserialize($current);
    }
    $locale = get_option('locale');
    if (isset($current->last_checked) && 43200 > time() - $current->last_checked && $current->version_checked == $lilina_version) {
        return false;
    }
    $new_option = '';
    $new_option->last_checked = time();
    // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
    $new_option->version_checked = $lilina_version;
    try {
        $headers = apply_filters('update_http_headers', array('X-Install-ID' => $id));
        $request = new HTTPRequest('', 2);
        $response = $request->get("http://api.getlilina.org/core/version-check/1.2/?version={$lilina_version}&php={$php_version}&locale={$locale}", $headers);
    } catch (Exception $e) {
        $response = (object) array('success' => false);
    }
    if (!$response->success) {
        // Save it anyway
        $data->save('core-update-check.data', serialize($new_option));
        return false;
    }
    $body = trim($response->body);
    $body = str_replace(array("\r\n", "\r"), "\n", $body);
    $returns = explode("\n", $body);
    $new_option->response = $returns[0];
    if (isset($returns[1])) {
        $new_option->url = $returns[1];
    }
    if (isset($returns[2])) {
        $new_option->download = $returns[2];
    }
    if (isset($returns[3])) {
        $new_option->version = $returns[3];
    }
    $data->save('core-update-check.data', serialize($new_option));
    return $new_option;
}
 /**
  * Process the monitoring request
  *
  * @param HTTPRequest $request      HTTP request
  * @param PFUser        $currentUser  Current user
  * @param Integer     $groupId      Id of the project
  * @param Integer     $fileModuleId Id of the package
  * @param UserManager $um           UserManager instance
  * @param UserHelper  $userHelper   UserHelper instance
  *
  * @return String
  */
 public function processEditMonitoringAction($request, $currentUser, $groupId, $fileModuleId, $um, $userHelper)
 {
     $frspf = new FRSPackageFactory();
     $package = $frspf->getFRSPackageFromDb($fileModuleId);
     if ($frspf->userCanAdmin($currentUser, $groupId)) {
         if ($request->valid(new Valid_WhiteList('action', array('add_monitoring', 'delete_monitoring')))) {
             $action = $request->get('action');
             switch ($action) {
                 case 'add_monitoring':
                     $users = array_map('trim', preg_split('/[,;]/', $request->get('listeners_to_add')));
                     foreach ($users as $userName) {
                         if (!empty($userName)) {
                             $user = $um->findUser($userName);
                             $this->addUserMonitoring($user, $groupId, $fileModuleId, $package, $frspf, $userHelper);
                         }
                     }
                     break;
                 case 'delete_monitoring':
                     $users = $request->get('delete_user');
                     $this->stopMonitoringForUsers($users, $groupId, $fileModuleId, $package, $um, $userHelper);
                     break;
                 default:
                     break;
             }
         }
     }
 }
示例#10
0
 public function processAdmin(HTTPRequest $request)
 {
     $wiki = new PHPWikiServiceAdmin($request->get('group_id'));
     $wiki->process();
 }
示例#11
0
 /**
  * Validate the HTTP request for the user members pane
  *
  * @param Integer     $groupId Id of the project
  * @param HTTPRequest $request HTTP request
  *
  * @return Array
  */
 public function validateRequest($groupId, $request)
 {
     $userDao = new UserDao();
     $res = $userDao->firstUsernamesLetters();
     $allowedBeginValues = array();
     foreach ($res as $data) {
         $allowedBeginValues[] = $data['capital'];
     }
     $result['allowed_begin_values'] = $allowedBeginValues;
     $validBegin = new Valid_WhiteList('begin', $allowedBeginValues);
     $validBegin->required();
     $validInProject = new Valid_UInt('in_project');
     $validInProject->required();
     $result['offset'] = $request->exist('browse') ? 0 : $request->getValidated('offset', 'uint', 0);
     $result['number_per_page'] = $request->exist('number_per_page') ? $request->getValidated('number_per_page', 'uint', 0) : 15;
     $result['search'] = $request->getValidated('search', 'string', '');
     $result['begin'] = $request->getValidated('begin', $validBegin, '');
     $result['in_project'] = $request->getValidated('in_project', $validInProject, $groupId);
     $result['user'] = $request->get('user');
     $result['add_user_name'] = $request->get('add_user_name');
     return $result;
 }
 /**
  * Display date reminders
  *
  * @param HTTPRequest $request HTTP request
  *
  * @return Void
  */
 public function displayDateReminders(HTTPRequest $request)
 {
     $output = '<h2>' . $GLOBALS['Language']->getText('project_admin_utils', 'tracker_date_reminder_title') . '</h2>';
     $output .= '<fieldset>';
     if ($request->get('action') == 'delete_reminder') {
         $output .= $this->displayConfirmDelete($request->get('reminder_id'));
     }
     $output .= $this->displayAllReminders();
     $output .= '<div id="tracker_reminder" style="display:none;"><p><label for="New Reminder">' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'tracker_date_reminder_add_title') . '<input type="image" src="' . util_get_image_theme('ic/add.png') . '" id="add_reminder" value="' . (int) $this->tracker->id . '"></label></div>';
     $output .= '<noscript>
     <p><a href="?func=admin-notifications&amp;tracker=' . (int) $this->tracker->id . '&amp;action=add_reminder" id="add_reminder">' . $GLOBALS['Language']->getText('plugin_tracker_date_reminder', 'tracker_date_reminder_add_title') . '</a>
     </noscript>';
     if ($request->get('action') == 'add_reminder') {
         $output .= $this->getNewDateReminderForm();
     } elseif ($request->get('action') == 'update_reminder') {
         $output .= '<div id="update_reminder"></div>';
         $output .= $this->editDateReminder($request->get('reminder_id'));
     }
     $output .= '</fieldset>';
     echo $output;
 }
 private function requestIsRestore(HTTPRequest $request)
 {
     return $request->get('restore') != null;
 }
 /**
  * Validate request values
  *
  * @param HTTPRequest $request request containing form values
  *
  * @return Array
  */
 function validateRequest($request)
 {
     $status = true;
     $invalid = array();
     $valid = new Valid_String('request_summary');
     $valid->required();
     $summary = trim($request->get('request_summary'));
     if ($request->valid($valid) && strlen($summary) < self::MAX_SUMMARY_LENGTH && $summary != '') {
         $params['summary'] = $summary;
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'summary');
     }
     $valid = new Valid_Text('request_description');
     $valid->required();
     $description = trim($request->get('request_description'));
     $defaultDescription = $GLOBALS['Language']->getText('plugin_requesthelp', 'requesthelp_default_description');
     if ($request->valid($valid) && strlen($description) < self::MAX_DESCRIPTION_LENGTH && $description != '' && $description != $defaultDescription) {
         $params['description'] = $description;
     } else {
         $status = false;
         $invalid[] = 'Description';
     }
     $valid = new Valid_UInt('type');
     $valid->required();
     if ($request->valid($valid)) {
         $requestType = $request->get('type');
         $params['type'] = $requestType;
         switch ($requestType) {
             case RequestHelp::TYPE_SUPPORT:
                 $params['text_type'] = $this->_getPluginProperty('support_request');
                 break;
             case RequestHelp::TYPE_ENHANCEMENT:
                 $params['text_type'] = $this->_getPluginProperty('enhancement_request');
                 break;
             default:
                 $status = false;
                 $invalid[] = 'Type';
                 break;
         }
     } else {
         $status = false;
         $invalid[] = 'Type';
     }
     $valid = new Valid_UInt('severity');
     $valid->required();
     if ($request->valid($valid)) {
         $severity = $request->get('severity');
         $params['severity'] = $severity;
         switch ($severity) {
             case RequestHelp::SEVERITY_MINOR:
                 $params['text_severity'] = 'Minor';
                 break;
             case RequestHelp::SEVERITY_SERIOUS:
                 $params['text_severity'] = 'Serious';
                 break;
             case RequestHelp::SEVERITY_CRITICAL:
                 $params['text_severity'] = 'Critical';
                 break;
             default:
                 $status = false;
                 $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
                 break;
         }
     } else {
         $status = false;
         $invalid[] = $GLOBALS['Language']->getText('plugin_requesthelp', 'severity');
     }
     $cc = array();
     $mails = array_map('trim', preg_split('/[,;]/', $request->get('cc')));
     $rule = new Rule_Email();
     $um = $this->_getUserManager();
     $invalidCc = array();
     foreach ($mails as $mail) {
         if ($rule->isValid($mail)) {
             $cc[] = $mail;
         } else {
             if (trim($mail) != '') {
                 $user = $um->findUser($mail);
                 if ($user) {
                     $mail = $user->getUserName();
                     if ($mail) {
                         $cc[] = $mail;
                     } else {
                         $invalidCc[] = $mail;
                     }
                 } else {
                     $invalidCc[] = $mail;
                 }
             }
         }
     }
     if (!empty($invalidCc)) {
         $c = $this->getController();
         $c->addWarn($GLOBALS['Language']->getText('plugin_requesthelp', 'requesthelp_invalid_cc', implode(", ", $invalidCc)));
     }
     $params['cc'] = implode(";", $cc);
     return array('status' => $status, 'params' => $params, 'invalid' => $invalid);
 }
 private function userAskedForHTTP(HTTPRequest $request)
 {
     return !$request->get('stay_in_ssl');
 }
 protected function displayAdminNotifications_Global(HTTPRequest $request)
 {
     $hp = Codendi_HTMLPurifier::instance();
     echo '<h3><a name="GlobalEmailNotification"></a>' . $GLOBALS['Language']->getText('plugin_tracker_include_type', 'global_mail_notif') . ' ' . help_button('TrackerV5Administration.html#TrackerV5GlobalEmailNotification') . '</h3>';
     $notifs = $this->getGlobalNotifications();
     $nb_notifs = count($notifs);
     if ($this->tracker->userIsAdmin()) {
         echo '<p>' . $GLOBALS['Language']->getText('plugin_tracker_include_type', 'admin_note') . '</p>';
         $id = 0;
         if ($nb_notifs) {
             echo '<div id="global_notifs">';
             foreach ($notifs as $key => $nop) {
                 $id = (int) $nop->getId();
                 $addresses = $nop->getAddresses();
                 $all_updates = $nop->isAllUpdates();
                 $check_permissions = $nop->isCheckPermissions();
                 echo '<div>';
                 echo $this->getGlobalNotificationForm($id, $addresses, $all_updates, $check_permissions);
                 echo '</div>';
             }
             echo '</div>';
         }
         echo '<p><a href="?func=admin-notifications&amp;tracker=' . (int) $this->tracker->id . '&amp;action=add_global" id="add_global">' . $GLOBALS['Language']->getText('plugin_tracker_include_type', 'add') . '</a></p>';
         echo '<script type="text/javascript">' . "\n            document.observe('dom:loaded', function() {\n                \$('add_global').observe('click', function (evt) {\n                    var self = arguments.callee;\n                    if (!self.counter) {\n                        self.counter = {$id};\n                    }\n                    self.counter++;\n                    var number = self.counter;\n                    \n                    var div = new Element('div');\n                    div.insert('" . $this->getGlobalNotificationForm($id = "'+number+'", $addresses = '', $all_updates = 1, $check_permissions = 0) . "');\n                    \n                    Element.insert(\$('global_notifs'), div);\n                    \n                    Event.stop(evt);\n                    return false;\n                });\n            });\n            </script>";
         if ($request->get('action') == 'add_global') {
             echo $this->getGlobalNotificationForm($nb_notifs, '', 1, 0);
         }
     } else {
         $ok = false;
         if ($nb_notifs) {
             reset($notifs);
             while (!$ok && (list($id, ) = each($notifs))) {
                 $ok = $notifs[$id]->getAddresses();
             }
         }
         if ($ok) {
             echo $GLOBALS['Language']->getText('plugin_tracker_include_type', 'admin_conf');
             foreach ($notifs as $key => $nop) {
                 if ($notifs[$key]->getAddresses()) {
                     echo '<div>' . $notifs[$key]->getAddresses() . '&nbsp;&nbsp;&nbsp; ';
                     echo $GLOBALS['Language']->getText('plugin_tracker_include_type', 'send_all_or_not', $notifs[$key]->isAllUpdates() ? $GLOBALS['Language']->getText('global', 'yes') : $GLOBALS['Language']->getText('global', 'no'));
                     echo '</div>';
                 }
             }
         } else {
             echo $GLOBALS['Language']->getText('plugin_tracker_include_type', 'admin_not_conf');
         }
     }
 }
示例#17
0
 /**
  * Find the feed's icon
  *
  * @param SimplePie $feed SimplePie object to retrieve logo for
  * @return string URL to feed icon
  */
 protected static function discover_favicon($feed, $id)
 {
     if ($return = $feed->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon')) {
         $favicon = SimplePie_Misc::absolutize_url($return[0]['data'], $feed->get_base($return[0]));
     } elseif (($url = $feed->get_link()) !== null && preg_match('/^http(s)?:\\/\\//i', $url)) {
         $filename = $id . '.ico';
         $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
     } else {
         return false;
     }
     $cache = new DataHandler(get_option('cachedir'));
     $request = new HTTPRequest();
     $file = $request->get($favicon, array('X-Forwarded-For' => $_SERVER['REMOTE_ADDR']));
     if ($file->success && strlen($file->body) > 0) {
         $sniffer = new $feed->content_type_sniffer_class($file);
         if (substr($sniffer->get_type(), 0, 6) === 'image/') {
             $body = array('type' => $sniffer->get_type(), 'body' => $file->body);
             return $cache->save($filename, serialize($body));
         } else {
             return false;
         }
     }
     return false;
 }
 private function getProjectFromRequest()
 {
     $project_id = $this->request->get('project_id');
     $project_manager = ProjectManager::instance();
     return $project_manager->getValidProject($project_id);
 }
示例#19
0
 protected function import()
 {
     if (!empty($_POST['cancel']) && $_POST['cancel'] == 'cancel') {
         header('HTTP/1.1 302 Found', true, 302);
         header('Location: ' . get_option('baseurl') . 'admin/feed-import.php');
         die;
     }
     if (empty($_POST['url']) && empty($_FILES['file'])) {
         $_POST['step']--;
         $this->dispatch();
         return;
     }
     admin_header(_r('Other (OPML) Importer'));
     try {
         $opml = '';
         if (!empty($_POST['url'])) {
             $http = new HTTPRequest('', 10, 'Lilina/' . LILINA_CORE_VERSION);
             $opml = $http->get($opml_url);
             $opml = $opml->body;
         }
         if (!empty($_FILES['file'])) {
             $opml = file_get_contents($_FILES['file']['tmp_name']);
         }
         $feeds = $this->import_opml($opml);
         import($feeds);
     } catch (Exception $e) {
         $this->error($e);
     }
     admin_footer();
     return;
 }
示例#20
0
 /**
  * Handle the HTTP request
  *
  * @param HTTPRequest $request HTTP request
  *
  * @return Void
  */
 public function handleRequest(HTTPRequest $request)
 {
     $validAction = new Valid_WhiteList('action', array('add', 'delete'));
     if ($request->valid($validAction)) {
         $action = $request->get('action');
         switch ($action) {
             case 'add':
                 $this->csrf->check();
                 $validProject = new Valid_String('project');
                 $validProject->required();
                 $project = null;
                 if ($request->valid($validProject)) {
                     $project = $request->get('project');
                 }
                 $validRequester = new Valid_String('requester');
                 $validRequester->required();
                 $requester = null;
                 if ($request->valid($validRequester)) {
                     $requester = $request->get('requester');
                 }
                 $validQuota = new Valid_UInt('quota');
                 $validQuota->required();
                 $quota = null;
                 if ($request->valid($validQuota)) {
                     $quota = $request->get('quota');
                 }
                 $validMotivation = new Valid_Text('motivation');
                 $validMotivation->required();
                 $motivation = null;
                 if ($request->valid($validMotivation)) {
                     $motivation = $request->get('motivation');
                 }
                 $this->projectQuotaManager->addQuota($project, $requester, $quota, $motivation);
                 break;
             case 'delete':
                 $this->csrf->check();
                 $list = $request->get('delete_quota');
                 $projects = array();
                 $validProjectId = new Valid_UInt();
                 foreach ($list as $projectId) {
                     if ($validProjectId->validate($projectId)) {
                         $project = $this->projectManager->getProject($projectId);
                         if ($project) {
                             $projects[$project->getId()] = $project->getPublicName();
                         }
                     }
                 }
                 $this->projectQuotaManager->deleteCustomQuota($projects);
                 break;
             default:
                 break;
         }
     } else {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_statistics', 'invalid_action'));
     }
 }