コード例 #1
0
ファイル: setup.php プロジェクト: jstanden/portsensor
 function saveLicensesAction()
 {
     $translate = DevblocksPlatform::getTranslationService();
     $settings = DevblocksPlatform::getPluginSettingsService();
     $worker = PortSensorApplication::getActiveWorker();
     if (!$worker || !$worker->is_superuser) {
         echo $translate->_('common.access_denied');
         return;
     }
     @($key = DevblocksPlatform::importGPC($_POST['key'], 'string', ''));
     @($email = DevblocksPlatform::importGPC($_POST['email'], 'string', ''));
     @($do_delete = DevblocksPlatform::importGPC($_POST['do_delete'], 'integer', 0));
     if (!empty($do_delete)) {
         $settings->set('portsensor.core', PortSensorSettings::LICENSE, '');
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings')));
         return;
     }
     if (empty($key) || empty($email)) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'empty')));
         return;
     }
     if (null == ($valid = PortSensorLicense::validate($key, $email)) || 5 != count($valid)) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings', 'invalid')));
         return;
     }
     /*
      * [IMPORTANT -- Yes, this is simply a line in the sand.]
      * You're welcome to modify the code to meet your needs, but please respect 
      * our licensing.  Buy a legitimate copy to help support the project!
      * http://www.portsensor.com/
      */
     $license = $valid;
     $settings->set('portsensor.core', PortSensorSettings::LICENSE, serialize($license));
     DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('setup', 'settings')));
 }
コード例 #2
0
ファイル: classes.php プロジェクト: sluther/portsensor
 function saveLicenseAction()
 {
     @($key = DevblocksPlatform::importGPC($_POST['key'], 'string', ''));
     if (empty($key)) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'license', 'empty')));
         return;
     }
     // Clean off the wrapper
     @($lines = explode("\r\n", trim($key)));
     $company = '';
     $features = array();
     $key = '';
     $valid = 0;
     if (is_array($lines)) {
         foreach ($lines as $line) {
             if (0 == strcmp(substr($line, 0, 3), '---')) {
                 $valid++;
                 continue;
             }
             if (preg_match("/^(.*?)\\: (.*?)\$/", $line, $matches)) {
                 if (0 == strcmp($matches[1], "Company")) {
                     $company = $matches[2];
                 }
                 if (0 == strcmp($matches[1], "Feature")) {
                     $features[$matches[2]] = true;
                 }
             } else {
                 $key .= trim($line);
             }
         }
     }
     if (2 != $valid || 0 != $key % 4) {
         DevblocksPlatform::setHttpResponse(new DevblocksHttpResponse(array('config', 'license', 'invalid')));
         return;
     }
     // Save for reuse in form in case we need to redraw on error
     $settings = PortSensorSettings::getInstance();
     //		$settings->set('company', trim($company));
     ksort($features);
     /*
      * [IMPORTANT -- Yes, this is simply a line in the sand.]
      * You're welcome to modify the code to meet your needs, but please respect 
      * our licensing.  Buy a legitimate copy to help support the project!
      * http://www.portsensor.com/
      */
     $license = PortSensorLicense::getInstance();
     // $license['name'] = CerberusHelper::strip_magic_quotes($company,'string');
     $license['name'] = $company;
     $license['features'] = $features;
     $license['key'] = PortSensorHelper::base64_decode_strings($company, $key);
     $settings->set(PortSensorSettings::LICENSE, serialize($license));
     DevblocksPlatform::redirect(new DevblocksHttpResponse(array('config', 'license')));
 }
コード例 #3
0
ファイル: Model.class.php プロジェクト: jstanden/portsensor
 function hasPriv($priv_id)
 {
     // We don't need to do much work if we're a superuser
     if ($this->is_superuser) {
         return true;
     }
     $settings = DevblocksPlatform::getPluginSettingsService();
     $acl_enabled = $settings->get('portsensor.core', PortSensorSettings::ACL_ENABLED);
     // ACL is a paid feature (please respect the licensing and support the project!)
     $license = PortSensorLicense::getInstance();
     if (!$acl_enabled || !isset($license['serial']) || isset($license['a'])) {
         return "core.setup" == substr($priv_id, 0, 11) ? false : true;
     }
     // Check the aggregated worker privs from roles
     $acl = DAO_WorkerRole::getACL();
     $privs_by_worker = $acl[DAO_WorkerRole::CACHE_KEY_PRIVS_BY_WORKER];
     if (!empty($priv_id) && isset($privs_by_worker[$this->id][$priv_id])) {
         return true;
     }
     return false;
 }
コード例 #4
0
 public function writeResponse(DevblocksHttpResponse $response)
 {
     $path = $response->path;
     // [JAS]: Ajax? // [TODO] Explore outputting whitespace here for Safari
     //	    if(empty($path))
     //			return;
     $tpl = DevblocksPlatform::getTemplateService();
     $session = DevblocksPlatform::getSessionService();
     $settings = DevblocksPlatform::getPluginSettingsService();
     $translate = DevblocksPlatform::getTranslationService();
     $active_worker = PortSensorApplication::getActiveWorker();
     $visit = $session->getVisit();
     $page_manifests = $this->_getAllowedPages();
     $controller = array_shift($path);
     // Default page [TODO] This is supposed to come from framework.config.php
     if (empty($controller)) {
         $controller = 'home';
     }
     // [JAS]: Require us to always be logged in for PortSensor pages
     if (empty($visit) && 0 != strcasecmp($controller, 'login')) {
         $query = array();
         if (!empty($response->path)) {
             $query = array('url' => urlencode(implode('/', $response->path)));
         }
         DevblocksPlatform::redirect(new DevblocksHttpRequest(array('login'), $query));
     }
     $page_id = $this->_getPageIdByUri($controller);
     @($page = DevblocksPlatform::getExtension($page_id, true));
     /* @var $page PortSensorPageExtension */
     if (empty($page)) {
         header("Status: 404");
         return;
         // [TODO] 404
     }
     // [JAS]: Listeners (Step-by-step guided tour, etc.)
     $listenerManifests = DevblocksPlatform::getExtensions('devblocks.listener.http');
     foreach ($listenerManifests as $listenerManifest) {
         /* @var $listenerManifest DevblocksExtensionManifest */
         $inst = $listenerManifest->createInstance();
         /* @var $inst DevblocksHttpRequestListenerExtension */
         $inst->run($response, $tpl);
     }
     $tpl->assign('active_worker', $active_worker);
     $tour_enabled = false;
     if (!empty($visit) && !is_null($active_worker)) {
         $tour_enabled = intval(DAO_WorkerPref::get($active_worker->id, 'assist_mode', 1));
         $keyboard_shortcuts = intval(DAO_WorkerPref::get($active_worker->id, 'keyboard_shortcuts', 1));
         $tpl->assign('pref_keyboard_shortcuts', $keyboard_shortcuts);
         //	    	$active_worker_memberships = $active_worker->getMemberships();
         //	    	$tpl->assign('active_worker_memberships', $active_worker_memberships);
         $unread_notifications = DAO_WorkerEvent::getUnreadCountByWorker($active_worker->id);
         $tpl->assign('active_worker_notify_count', $unread_notifications);
         DAO_Worker::logActivity($active_worker->id, $page->getActivity());
     }
     $tpl->assign('tour_enabled', $tour_enabled);
     // [JAS]: Variables provided to all page templates
     $tpl->assign('settings', $settings);
     $tpl->assign('session', $_SESSION);
     $tpl->assign('translate', $translate);
     $tpl->assign('visit', $visit);
     $tpl->assign('license', PortSensorLicense::getInstance());
     $tpl->assign('page_manifests', $page_manifests);
     $tpl->assign('page', $page);
     $tpl->assign('response_uri', implode('/', $response->path));
     $core_tpl = APP_PATH . '/features/portsensor.core/templates/';
     $tpl->assign('core_tpl', $core_tpl);
     // Prebody Renderers
     $preBodyRenderers = DevblocksPlatform::getExtensions('portsensor.renderer.prebody', true);
     if (!empty($preBodyRenderers)) {
         $tpl->assign('prebody_renderers', $preBodyRenderers);
     }
     // Postbody Renderers
     $postBodyRenderers = DevblocksPlatform::getExtensions('portsensor.renderer.postbody', true);
     if (!empty($postBodyRenderers)) {
         $tpl->assign('postbody_renderers', $postBodyRenderers);
     }
     // Timings
     $tpl->assign('render_time', microtime(true) - DevblocksPlatform::getStartTime());
     if (function_exists('memory_get_usage') && function_exists('memory_get_peak_usage')) {
         $tpl->assign('render_memory', memory_get_usage() - DevblocksPlatform::getStartMemory());
         $tpl->assign('render_peak_memory', memory_get_peak_usage() - DevblocksPlatform::getStartPeakMemory());
     }
     $tpl->display($core_tpl . 'border.tpl');
     //		$cache = DevblocksPlatform::getCacheService();
     //		$cache->printStatistics();
 }