/**
  * Returns true if the file is a valid upload, after making it go through all
  * our tests.
  *
  * @param upload An FileUpload object containing information about the file
  * @return Returns true if it is valid or a negative value meaning an error otherwise:
  * <ul><li>ERROR_UPLOAD_TOO_BIG (-1): The file bigger than the maximum allowed size</li>
  * <li>ERROR_FORBIDDEN_EXTENSION: The file has a forbidden extension.</li></ul>
  */
 function validate($upload)
 {
     $config =& Config::getConfig();
     $forbiddenFilesStr = $config->getValue("upload_forbidden_files");
     $maxUploadSize = $config->getValue("maximum_file_upload_size");
     // check if we received an object of the right type, or else just quit
     if ($upload == null) {
         return false;
     }
     // first of all, check the size
     if ($maxUploadSize != 0 && $upload->getSize() > $maxUploadSize) {
         return UPLOAD_VALIDATOR_ERROR_UPLOAD_TOO_BIG;
     }
     // return true if there's nothing to do
     if (empty($forbiddenFilesStr) || !$forbiddenFilesStr) {
         return true;
     }
     // check if the filename extension is forbidden or not
     $fileName = basename($upload->getFileName());
     foreach (explode(" ", $forbiddenFilesStr) as $file) {
         if (Glob::myFnmatch($file, $fileName)) {
             return UPLOAD_VALIDATOR_ERROR_FORBIDDEN_EXTENSION;
         }
     }
     return true;
 }
Example #2
0
    public function testGetConfig()
    {
        $this->baseDir->expects($this->any())->method('getRelativePath')->will($this->returnCallback(function ($path) {
            return 'relative/' . $path;
        }));
        $this->baseDir->expects($this->any())->method('readFile')->will($this->returnCallback(function ($file) {
            return $file . ' content';
        }));
        $fileOne = $this->getMock('\\Magento\\Framework\\View\\File', array(), array(), '', false);
        $fileOne->expects($this->once())->method('getFilename')->will($this->returnValue('file_one.js'));
        $fileOne->expects($this->once())->method('getModule')->will($this->returnValue('Module_One'));
        $fileTwo = $this->getMock('\\Magento\\Framework\\View\\File', array(), array(), '', false);
        $fileTwo->expects($this->once())->method('getFilename')->will($this->returnValue('file_two.js'));
        $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
        $this->design->expects($this->once())->method('getDesignTheme')->will($this->returnValue($theme));
        $this->fileSource->expects($this->once())->method('getFiles')->with($theme, Config::CONFIG_FILE_NAME)->will($this->returnValue(array($fileOne, $fileTwo)));
        $expected = <<<expected
(function(require){
relative/%s/paths-updater.js content

(function() {
relative/file_one.js content
require.config(mageUpdateConfigPaths(config, 'Module_One'))
})();
(function() {
relative/file_two.js content
require.config(mageUpdateConfigPaths(config, ''))
})();

})(require);
expected;
        $actual = $this->object->getConfig();
        $this->assertStringMatchesFormat($expected, $actual);
    }
 function perform()
 {
     // update the plugin configurations to blog setting
     $config =& Config::getConfig();
     $config->setValue("plugin_moblog_mailserver", $this->_mailServer);
     $config->setValue("plugin_moblog_port", $this->_port);
     $config->setValue("plugin_moblog_username", $this->_userName);
     $config->setValue("plugin_moblog_password", $this->_password);
     $config->setValue("plugin_moblog_pseudobatch", $this->_pseudoBatch);
     if (!$config->save()) {
         $this->_view = new AdminMoblogBatchPluginSettingsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new AdminMoblogBatchPluginSettingsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("moblog_settings_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 /**
  * Constructor.
  *
  * @param actionInfo An ActionInfo object as provided by the constroller
  * @param request A valid HTTP request
  */
 function AdminAction($actionInfo, $request)
 {
     $this->Action($actionInfo, $request);
     // get information about the session
     $session = HttpVars::getSession();
     $this->_session = $session["SessionInfo"];
     $this->_config =& Config::getConfig();
     // get the information about the user and quit if we don't have it...
     $this->_getUserInfo();
     if ($this->_userInfo == "") {
         header("HTTP/1.0 403 Forbidden");
         print $this->mustAuthenticatePage();
         die;
     }
     // do the same with the information about the blog
     $this->_getBlogInfo();
     if ($this->_blogInfo == "") {
         if ($this->_actionInfo->getActionParamValue() != "blogSelect") {
             header("HTTP/1.0 403 Forbidden");
             print $this->mustAuthenticatePage();
             die;
         }
     }
     // prepare the plugin manager in case we'd like to throw events
     $this->_pm =& PluginManager::getPluginManager();
     // fetch the site locale
     $this->_locale =& $this->getLocale();
     $users =& new Users();
     $this->_userBlogs = $users->getUsersBlogs($this->_userInfo->getId(), BLOG_STATUS_ACTIVE);
 }
 public function configureTemplateAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/playouthistory/configuretemplate.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $this->view->headLink()->appendStylesheet($baseUrl . 'css/history_styles.css?' . $CC_CONFIG['airtime_version']);
     try {
         $templateId = $this->_getParam('id');
         $historyService = new Application_Service_HistoryService();
         $template = $historyService->loadTemplate($templateId);
         $templateType = $template["type"];
         $supportedTypes = $historyService->getSupportedTemplateTypes();
         if (!in_array($templateType, $supportedTypes)) {
             throw new Exception("Error: {$templateType} is not supported.");
         }
         $getMandatoryFields = "mandatory" . ucfirst($templateType) . "Fields";
         $mandatoryFields = $historyService->{$getMandatoryFields}();
         $this->view->template_id = $templateId;
         $this->view->template_name = $template["name"];
         $this->view->template_fields = $template["fields"];
         $this->view->template_type = $templateType;
         $this->view->fileMD = $historyService->getFileMetadataTypes();
         $this->view->fields = $historyService->getFieldTypes();
         $this->view->required_fields = $mandatoryFields;
         $this->view->configured = $historyService->getConfiguredTemplateIds();
     } catch (Exception $e) {
         Logging::info("Error?");
         Logging::info($e);
         Logging::info($e->getMessage());
         $this->_forward('index', 'playouthistorytemplate');
     }
 }
 function perform()
 {
     // fetch the data
     $this->_userName = $this->_request->getValue("userName");
     $this->_userEmail = $this->_request->getValue("userEmail");
     // try to see if there is a user who has this username and uses the
     // given mailbox as the email address
     $users = new Users();
     $userInfo = $users->getUserInfoFromUsername($this->_userName);
     // if the user doesn't exist, quit
     if (!$userInfo) {
         $this->_view = new SummaryView("resetpassword");
         $this->_form->setFieldValidationStatus("userName", false);
         $this->setCommonData(true);
         return false;
     }
     // if the user exists but this is not his/her mailbox, then quit too
     if ($userInfo->getEmail() != $this->_userEmail) {
         $this->_view = new SummaryView("resetpassword");
         $this->_form->setFieldValidationStatus("userEmail", false);
         $this->setCommonData(true);
         return false;
     }
     // if everything's fine, then send out the email message with a request to
     // reset the password
     $requestHash = SummaryTools::calculatePasswordResetHash($userInfo);
     $config =& Config::getConfig();
     $baseUrl = $config->getValue("base_url");
     $resetUrl = $baseUrl . "/summary.php?op=setNewPassword&a={$requestHash}&b=" . md5($userInfo->getUsername());
     SummaryTools::sendResetEmail($userInfo, $resetUrl);
     $this->_view = new SummaryMessageView($this->_locale->tr("password_reset_message_sent_ok"));
     $this->setCommonData();
     return true;
 }
 function render()
 {
     // call the render method in the main view class... it will take care of sending the headers
     // for us and so on...
     parent::render();
     // if there is no resource to send... then we can quit right away!
     if ($this->_resource == null) {
         return;
     }
     // let's see if we really need to send some data or not...
     // send also some headers that will help caching, if configured to do so
     $config =& Config::getConfig();
     $useCaching = $config->getValue('resource_server_http_cache_enabled');
     if ($useCaching) {
         // send the "Last-Modified" header
         $resDate = $this->_resource->getTimestamp();
         $lastModified = $resDate->getDate(DATE_FORMAT_UNIXTIME);
         $cacheLifetime = $config->getValue('resource_server_http_cache_lifetime', DEFAULT_HTTP_CACHE_LIFETIME);
         // check if we have to resent the data and if not, then we're done!
         if (HttpCache::httpConditional($lastModified, $cacheLifetime)) {
             exit;
         }
     }
     // if we need to send something, then let's do it now and finish
     if ($this->_mode == RESOURCE_VIEW_MODE_PREVIEW) {
         print $this->_resource->getPreview();
     } elseif ($this->_mode == RESOURCE_VIEW_MODE_MEDIUM) {
         print $this->_resource->getMediumSizePreview();
     } else {
         while ($chunk =& $this->_resource->getDataChunk(RESOURCE_DEFAULT_CHUNK_SIZE)) {
             echo $chunk;
         }
     }
     return true;
 }
 /**
  * Constructor. 
  *
  * @param templateFile Complete path to the template file we are going to render
  */
 function Template($templateFile)
 {
     // initialize logging
     $this->log =& LoggerManager::getLogger("default");
     // create the Smarty object and set the security values
     $this->Smarty();
     $this->caching = false;
     //$this->cache_lifetime =  $cacheLifetime;
     $config =& Config::getConfig();
     $this->cache_dir = $config->getValue('temp_folder');
     $this->_templateFile = $templateFile;
     // enable the security settings
     $this->php_handling = false;
     // code is not allowed in the templates by default, unless specified otherwise
     /*if( $config->getValue( 'allow_php_code_in_templates', false ))
       	$this->security = true;
       else
       	$this->security = false;*/
     $this->security = (bool) (!$config->getValue('allow_php_code_in_templates', false));
     //$this->security = true;
     $this->secure_dir = array("./templates/admin", "./templates/");
     // default folders
     $this->compile_dir = $config->getValue('temp_folder');
     $this->template_dir = $config->getValue('template_folder');
     $this->compile_check = $config->getValue('template_compile_check', true);
     // this helps if php is running in 'safe_mode'
     $this->use_sub_dirs = false;
     // register dynamic block for every template instance
     $this->register_block('dynamic', 'smarty_block_dynamic', false);
 }
Example #9
0
 public function init()
 {
     $CC_CONFIG = Config::getConfig();
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/login.phtml'))));
     // Add username element
     $this->addElement('text', 'username', array('label' => _('Username:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper')));
     // Add password element
     $this->addElement('password', 'password', array('label' => _('Password:'******'class' => 'input_text', 'required' => true, 'value' => isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1 ? 'admin' : '', 'filters' => array('StringTrim'), 'validators' => array('NotEmpty'), 'decorators' => array('ViewHelper')));
     $locale = new Zend_Form_Element_Select("locale");
     $locale->setLabel(_("Language:"));
     $locale->setMultiOptions(Application_Model_Locale::getLocales());
     $locale->setDecorators(array('ViewHelper'));
     $this->addElement($locale);
     $recaptchaNeeded = false;
     if (Application_Model_LoginAttempts::getAttempts($_SERVER['REMOTE_ADDR']) >= 3) {
         $recaptchaNeeded = true;
     }
     if ($recaptchaNeeded) {
         // recaptcha
         $this->addRecaptcha();
     }
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => _('Login'), 'class' => 'ui-button ui-widget ui-state-default ui-button-text-only center', 'decorators' => array('ViewHelper')));
 }
Example #10
0
 /**
  * Test the fetch of just one configuration key
  */
 public function testGetConfigOneKey()
 {
     $path = __DIR__ . '/' . $this->path;
     $config = new Config($path);
     $result = $config->getConfig('event/add');
     $this->assertTrue($result instanceof \Psecio\Invoke\RouteContainer);
 }
 function unpack($file, $destFolder)
 {
     // get the paths where tar and gz are
     $config =& Config::getConfig();
     $tarPath = $config->getValue("path_to_tar");
     if ($tarPath == "") {
         $tarPath = DEFAULT_TAR_PATH;
     }
     $gzipPath = $config->getValue("path_to_gzip");
     if ($gzipPath == "") {
         $gzipPath = DEFAULT_GZIP_PATH;
     }
     // and now build the command
     //$file = escapeshellarg($file);
     //$destFolder = escapeshellarg($destFolder);
     //
     // :DANGER:
     // what if the user voluntarily sets the path of gzip and tar
     // to something else? we are doing no checks here to make sure that
     // the user is giving us a valid commnand so... how could we make
     // sure that it'll work?
     //
     $cmd = "{$gzipPath} -dc {$file} | {$tarPath} xv -C {$destFolder}";
     $result = exec($cmd, $output, $retval);
     //
     // :KLUDGE:
     // apparently, we should get something in $retval but there's nothing
     // to the only way I've found to check if the command finished
     // successfully was checking if the $output array is full or empty
     //
     if (empty($output)) {
         return false;
     }
     return true;
 }
 public static function GetMonitStatus($p_ip)
 {
     $CC_CONFIG = Config::getConfig();
     $monit_user = $CC_CONFIG['monit_user'];
     $monit_password = $CC_CONFIG['monit_password'];
     $url = "http://{$p_ip}:2812/_status?format=xml";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERPWD, "{$monit_user}:{$monit_password}");
     //wait a max of 3 seconds before aborting connection attempt
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
     $result = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     $docRoot = null;
     if ($result !== FALSE && $info["http_code"] === 200) {
         if ($result != "") {
             $xmlDoc = new DOMDocument();
             $xmlDoc->loadXML($result);
             $docRoot = $xmlDoc->documentElement;
         }
     }
     return $docRoot;
 }
 /**
  * Checks whether incoming comments are not bigger than our configurable threshold, via
  * the 'maximum_comment_size' config setting
  *
  * @return A PipelineResult object
  */
 function filter()
 {
     // check if we're posting a comment
     $request = $this->_pipelineRequest->getHttpRequest();
     if ($request->getValue("op") != "AddComment") {
         return new PipelineResult();
     }
     // get the value of the maximum size of a comment, in bytes
     $config =& Config::getConfig();
     $maxSize = $config->getValue("maximum_comment_size");
     // if it's 0 or negative, it can be as big
     // as needed
     if ($maxSize <= 0) {
         return new PipelineResult();
     }
     // otherwise, let's check
     $commentSize = strlen($request->getValue("commentText"));
     $topicSize = strlen($request->getValue("commentTopic"));
     if ($commentSize >= $maxSize || $topicSize >= $maxSize) {
         $result = new PipelineResult(false, COMMENT_FILTER_MAXIMUM_SIZE_EXCEEDED, "The comment is too big");
         return $result;
     }
     $result = new PipelineResult();
     return $result;
 }
Example #14
0
 protected static function write($type, $msg)
 {
     $config = \Config::getConfig();
     $error_level = $config->get('log_level', self::HAYATE_LOG_OFF);
     if ($type <= $error_level) {
         $logdir = $config->get('log_dir', FALSE);
         try {
             if (is_dir($logdir) || @mkdir($logdir)) {
                 $filename = rtrim($logdir, '\\//') . '/log-' . date('Y-m-d') . '.log';
                 $logfile = new \SplFileObject($filename, 'a');
                 self::header($type, $logfile);
                 if (!is_string($msg)) {
                     $msg = print_r($msg, TRUE);
                 }
                 $logfile->fwrite($msg);
                 self::footer($logfile);
             } else {
                 throw new \Exception(sprintf(_('Log directory %s does not exists and could not be created.'), $logdir));
             }
         } catch (\Exception $ex) {
             if (!isset($filename)) {
                 $filename = 'not found';
             }
             trigger_error(sprintf(_('Failed to write to log file: "%s", %s'), $filename, $ex->getMessage()), E_USER_NOTICE);
         }
     }
 }
Example #15
0
 public static function setModuleMessages($moduleName = '', $prefix = 'ms_')
 {
     $prefix = strtolower($prefix);
     $moduleName = strtolower($moduleName);
     $lang = Config::getConfig('LANG');
     if ($moduleName == '' || $moduleName == 'core') {
         $root = Config::getConfig('CORE_ROOT');
         $prefix .= 'core_';
     } else {
         $root = Config::getConfig('PACKAGES_ROOT') . $moduleName . '/';
         $prefix .= $moduleName . '_';
     }
     $dir = $root . 'loc/' . $lang . '/';
     if (is_dir($dir)) {
         if ($dh = opendir($dir)) {
             while (($file = readdir($dh)) !== false) {
                 if ($file != '.' && $file != '..') {
                     $arMessages = array();
                     require_once $dir . $file;
                     foreach ($arMessages as $field => $text) {
                         static::$arMessage[strtoupper($prefix) . strtoupper($field)] = $text;
                     }
                 }
             }
             closedir($dh);
         }
     }
 }
 /**
  * Goes through the array of files and processes them accordingly.
  * The result is an array of the appropiate Resource class that has been
  * created using the ResourceFactory class.
  *
  * @return An array of Upload objects that have already been moved to a safer
  * location.
  */
 function process($destinationFolder)
 {
     // first, check if the upload feature is available
     $config =& Config::getConfig();
     if (!$config->getValue("uploads_enabled")) {
         return FILE_UPLOADS_NOT_ENABLED;
     }
     // array used to store the files that have already been saved
     $uploads = array();
     if ($destinationFolder[strlen($destinationFolder - 1)] != "/") {
         $destinationFolder .= "/";
     }
     foreach ($this->_files as $file) {
         $upload = new FileUpload($file);
         $fileName = $upload->getFileName();
         if ($this->my_move_uploaded_file($upload->getTmpName(), $destinationFolder . $fileName)) {
             $upload->setFolder($destinationFolder);
             $upload->setError(0);
         } else {
             $upload->setError(1);
         }
         array_push($uploads, $upload);
     }
     return $uploads;
 }
 function render()
 {
     // load some configuration settings
     $config =& Config::getConfig();
     $mailServer = $config->getValue("plugin_moblog_mailserver");
     $port = $config->getValue("plugin_moblog_port");
     if ($port == "") {
         $port = "110";
     }
     $userName = $config->getValue("plugin_moblog_username");
     $password = $config->getValue("plugin_moblog_password");
     $pseudoBatch = $config->getValue("plugin_moblog_pseudobatch");
     if ($pseudoBatch == "") {
         $pseudoBatch = "Off";
     }
     $lastUpdate = $config->getValue("plugin_moblog_lastupdate");
     // create a view and export the settings to the template
     $this->setValue("mailServer", $mailServer);
     $this->setValue("port", $port);
     $this->setValue("userName", $userName);
     $this->setValue("password", $password);
     $this->setValue("pseudoBatch", $pseudoBatch);
     $this->setValue("lastUpdate", $lastUpdate);
     parent::render();
 }
 public function passwordRestoreAction()
 {
     $CC_CONFIG = Config::getConfig();
     $baseUrl = Application_Common_OsPath::getBaseDir();
     $this->view->headScript()->appendFile($baseUrl . 'js/airtime/login/password-restore.js?' . $CC_CONFIG['airtime_version'], 'text/javascript');
     $request = $this->getRequest();
     Application_Model_Locale::configureLocalization($request->getcookie('airtime_locale', 'en_CA'));
     if (!Application_Model_Preference::GetEnableSystemEmail()) {
         $this->_redirect('login');
     } else {
         //uses separate layout without a navigation.
         $this->_helper->layout->setLayout('login');
         $form = new Application_Form_PasswordRestore();
         $request = $this->getRequest();
         if ($request->isPost() && $form->isValid($request->getPost())) {
             if (is_null($form->username->getValue()) || $form->username->getValue() == '') {
                 $user = CcSubjsQuery::create()->filterByDbEmail($form->email->getValue())->findOne();
             } else {
                 $user = CcSubjsQuery::create()->filterByDbEmail($form->email->getValue())->filterByDbLogin($form->username->getValue())->findOne();
             }
             if (!empty($user)) {
                 $auth = new Application_Model_Auth();
                 $success = $auth->sendPasswordRestoreLink($user, $this->view);
                 if ($success) {
                     $this->_helper->redirector('password-restore-after', 'login');
                 } else {
                     $form->email->addError($this->view->translate(_("Email could not be sent. Check your mail server settings and ensure it has been configured properly.")));
                 }
             } else {
                 $form->email->addError($this->view->translate(_("Given email not found.")));
             }
         }
         $this->view->form = $form;
     }
 }
 function PasswordValidator()
 {
     $this->Validator();
     $config =& Config::getConfig();
     $this->addRule(new NonEmptyRule());
     $this->addRule(new RangeRule($config->getValue("minimum_password_length", MIN_PASSWORD_LENGTH_DEFAULT), 32));
 }
 /**
  * logs a simple message to the log file, using the "debug" priority
  */
 function Log($message)
 {
     $config =& Config::getConfig();
     if ($config->getValue("moblog_logging_enabled")) {
         $logger =& LoggerManager::getLogger();
         $logger->debug($message);
     }
 }
 public function updateVariables()
 {
     $CC_CONFIG = Config::getConfig();
     $isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
     $master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL();
     $live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
     $this->setDecorators(array(array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url' => $master_dj_connection_url, 'live_dj_connection_url' => $live_dj_connection_url, 'isDemo' => $isDemo))));
 }
 /**
  * @covers ::__construct
  * @dataProvider constructorProvider
  */
 public function testConstructor($args, $bucket_name, $sqs_url, $send_to_s3)
 {
     $configuration = new Config($args, $bucket_name, $sqs_url, $send_to_s3);
     $this->assertSame($args, $configuration->getConfig());
     $this->assertSame($bucket_name, $configuration->getBucketName());
     $this->assertSame($sqs_url, $configuration->getSqsUrl());
     $this->assertSame($send_to_s3, $configuration->getSendToS3());
 }
Example #23
0
 public function __construct()
 {
     require_once './config/Config.php';
     $config = Config::getConfig();
     if (self::$conn == null) {
         self::$conn = mysqli_connect($config['host'], $config['username'], $config['password'], $config['dbname']);
     }
 }
Example #24
0
 public function setPassword($password)
 {
     $Config = Config::getConfig();
     if ($Config->useHashedPasswords === true) {
         $this->password = sha1($password . $Config->authSalt);
     } else {
         $this->password = $password;
     }
 }
 protected function isMethod()
 {
     $str = Config::getConfig('method');
     $methods = explode(',', $str);
     if (!in_array($this->request->method, $methods)) {
         $message = StatusCodeManager::getTranslation('405');
         throw new ZebraStatusException($message, '405');
     }
 }
Example #26
0
 public static function record($str, $priority, $scope = "")
 {
     $pid = getmypid();
     if (self::$recordMode == NULL) {
         $mode = Config::getConfig('mode');
         self::$recordMode = RecordModeFactory::getRecord($mode);
     }
     self::$recordMode->record($str, "WARN", $scope);
 }
 /**
  * The constructor only initializes the validator and depending on the 
  * value of check_email_address_validity, it will also add a EmailDnsRule
  * rule to check for the validity of the mailbox in the given email server
  */
 function EmailValidator()
 {
     $this->Validator();
     $this->addRule(new EmailFormatRule());
     $config =& Config::getConfig();
     if ($config->getValue("check_email_address_validity")) {
         $this->addRule(new EmailDnsRule());
     }
 }
 /**
  * Fetches the information for this blog from the database since we are going to need it
  * almost everywhere.
  */
 function _getBlogInfo()
 {
     // see if we're using subdomains
     $config =& Config::getConfig();
     if ($config->getValue("subdomains_enabled")) {
         $subdomainInfo = Subdomains::getSubdomainInfoFromRequest();
         if ($subdomainInfo["username"] != "" && $this->_request->getValue('blogUserName') == "") {
             $this->_request->setValue('blogUserName', $subdomainInfo["username"]);
         }
         if ($subdomainInfo["blogname"] != "" && $this->_request->getValue('blogName') == "") {
             $this->_request->setValue('blogName', $subdomainInfo["blogname"]);
         }
     }
     $blogId = $this->_request->getValue('blogId');
     $blogName = $this->_request->getValue('blogName');
     $userId = $this->_request->getValue('userId');
     $userName = $this->_request->getValue('blogUserName');
     // if there is a "blogId" parameter, it takes precedence over the
     // "user" parameter.
     if (!$blogId && !$blogName) {
         // check if there was a user parameter
         if (!empty($userName)) {
             // if so, check to which blogs the user belongs
             $users = new Users();
             $userInfo = $users->getUserInfoFromUsername($userName);
             // if the user exists and is valid...
             if ($userInfo) {
                 $userBlogs = $users->getUsersBlogs($userInfo->getId(), BLOG_STATUS_ACTIVE);
                 // check if he or she belogs to any blog. If he or she does, simply
                 // get the first one (any better rule for this?)
                 if (!empty($userBlogs)) {
                     $blogId = $userBlogs[0]->getId();
                 } else {
                     $blogId = $this->_config->getValue('default_blog_id');
                 }
             } else {
                 $blogId = $this->_config->getValue('default_blog_id');
             }
         } else {
             // if there is no user parameter, we take the blogId from the session
             if ($this->_session->getValue('blogId') != '') {
                 $blogId = $this->_session->getValue('blogId');
             } else {
                 // get the default blog id from the database
                 $blogId = $this->_config->getValue('default_blog_id');
             }
         }
     }
     // fetch the BlogInfo object
     $blogs = new Blogs();
     if ($blogId) {
         $this->_blogInfo = $blogs->getBlogInfo($blogId);
     } else {
         $this->_blogInfo = $blogs->getBlogInfoByName($blogName);
     }
 }
 public function checkAuth()
 {
     $CC_CONFIG = Config::getConfig();
     $api_key = $this->_getParam('api_key');
     if (!in_array($api_key, $CC_CONFIG["apiKey"]) && is_null(Zend_Auth::getInstance()->getStorage()->read())) {
         header('HTTP/1.0 401 Unauthorized');
         print _('You are not allowed to access this resource.');
         exit;
     }
 }
 function UsernameValidator()
 {
     $this->Validator();
     $this->addRule(new NonEmptyRule());
     $this->addRule(new RegExpRule(ONLY_ALPHANUMERIC_REGEXP));
     $config =& Config::getConfig();
     $forbiddenUsernames = $config->getValue("forbidden_usernames", "");
     $forbiddenUsernamesArray = explode(" ", $forbiddenUsernames);
     $this->addRule(new FilteredWordsRule($forbiddenUsernamesArray));
 }