Example #1
0
/**
 * Campsite render function plugin
 *
 * Type:     function
 * Name:     render
 * Purpose:  template rendering
 *
 * @param array
 *     $p_params
 * @param object
 *     $p_smarty The Smarty object
 *
 * @return
 *     rendered content
 */
function smarty_function_render($p_params, &$p_smarty)
{
    if (empty($p_params['file'])) {
        return null;
    }
    $smarty = clone $p_smarty;
    if (SystemPref::Get('TemplateCacheHandler')) {
        $campsiteVector = $smarty->campsiteVector;
        foreach ($campsiteVector as $key => $value) {
            if (isset($p_params[$key])) {
                if (empty($p_params[$key])) {
                    $campsiteVector[$key] = null;
                }
                if (is_int($p_params[$key])) {
                    $campsiteVector[$key] = $p_params[$key];
                }
            }
        }
        if (isset($p_params['params'])) {
            $campsiteVector['params'] = $p_params['params'];
        }
        $smarty->campsiteVector = $campsiteVector;
        if (empty($p_params['cache'])) {
            $template = new Template($p_params['file']);
            $smarty->cache_lifetime = (int)$template->getCacheLifetime();
        } else {
            $smarty->cache_lifetime = (int)$p_params['cache'];
        }
    }
    return $smarty->display($p_params['file']);

} // fn smarty_function_render
    /**
     * Loads the handler specified by the given name.
     * @param $p_handlerName
     * @return object
     */
    public static function factory($p_handlerName = null, $p_path = null)
    {
        static $handlers;

        if (!$p_handlerName) {
            $p_handlerName = SystemPref::Get('TemplateCacheHandler');
        }
        if (!$p_handlerName) {
            return null;
        }
        if (!empty($handlers[$p_handlerName])) {
            return $handlers[$p_handlerName];
        }
        if (is_null($p_path)) {
            $path = dirname(__FILE__) . DIR_SEP. 'cache';
        } else {
            $path = $p_path;
        }
        $filePath = "$path/TemplateCacheHandler_$p_handlerName.php";
        if (file_exists($filePath)) {
            require_once($filePath);
            $className = "TemplateCacheHandler_$p_handlerName";
            if (class_exists($className)) {
                $handlerObj = new $className;
                if ($handlerObj->isSupported()) {
                    $handlers[$p_handlerName] = $handlerObj;
                    return $handlerObj;
                }
            }
        }
        return null;
    }
Example #3
0
/**
 * Campsite render function plugin
 *
 * Type:     function
 * Name:     render
 * Purpose:  template rendering
 *
 * @param array
 *     $p_params
 * @param object
 *     $p_smarty The Smarty object
 *
 * @return
 *     rendered content
 */
function smarty_function_render($p_params, &$p_smarty)
{
    if (empty($p_params['file'])) {
        return null;
    }
    $smarty = CampTemplate::singleton();
    $cache_lifetimeBak = $smarty->cache_lifetime;
    $campsiteVectorBak = $smarty->campsiteVector;
    if (SystemPref::Get('TemplateCacheHandler')) {
        $campsiteVector = $smarty->campsiteVector;
        foreach ($campsiteVector as $key => $value) {
            if (isset($p_params[$key])) {
                if (empty($p_params[$key]) || strtolower($p_params[$key]) == 'off') {
                    $campsiteVector[$key] = null;
                }
                if (is_int($p_params[$key])) {
                    $campsiteVector[$key] = $p_params[$key];
                }
            }
        }
        if (isset($p_params['params'])) {
            $campsiteVector['params'] = $p_params['params'];
        }
        $smarty->campsiteVector = $campsiteVector;
        if (empty($p_params['cache'])) {
            $template = new Template(CampSite::GetURIInstance()->getThemePath() . $p_params['file']);
            $smarty->cache_lifetime = (int) $template->getCacheLifetime();
        } else {
            $smarty->cache_lifetime = (int) $p_params['cache'];
        }
    }
    $smarty->display($p_params['file']);
    $smarty->cache_lifetime = $cache_lifetimeBak;
    $smarty->campsiteVector = $campsiteVectorBak;
}
Example #4
0
/**
 * Campsite teaser modifier plugin
 *
 * Type:     modifier
 * Name:     teaser
 * Purpose:  build an teaser our of input
 *
 * @param string
 *     $p_input the string or object
 * @param string
 *     $p_format the date format wanted
 *
 * @return
 *     string the formatted date
 *     null in case a non-valid format was passed
 */
function smarty_modifier_teaser($p_input)
{
    $pattern = '/<!-- *break *-->/i';
    
    if (is_object($p_input) && method_exists($p_input, '__toString')) {
        $input = $p_input->__toString();
    } else {
         $input = (string) $p_input;
    }
    
    if (preg_match($pattern, $input, $matches, PREG_OFFSET_CAPTURE)) {
        $length = $matches[0][1];
        $output = substr($input, 0, $length);
        $output .= '[...]';
    } else {
        static $length;
        
        if (empty($length)) {
            $length = is_null(SystemPref::Get('teaser_length')) ? 150 : SystemPref::Get('teaser_length');
        }
        $output = mb_substr($input, 0, $length, 'UTF-8');
        $output .= '[...]';
    }
    
    return $output;
} // fn smarty_modifier_camp_date_format
/**
 * Send token via email
 *
 * @param string $p_email
 * @param string $p_token
 * @return void
 */
function send_token($p_email, $p_token)
{
    global $Campsite;

    // reset link
    $link = sprintf('%s/admin/password_check_token.php?token=%s&f_email=%s',
        $Campsite['WEBSITE_URL'],
        $p_token,
        $p_email);

    // email message
    $message = getGS("Hi, \n\nfor password recovery, please follow this link: $1", $link);

    // get from email
    $from = SystemPref::Get('PasswordRecoveryFrom');
    if (empty($from)) {
        $from = 'no-reply@' . $_SERVER['SERVER_NAME'];
    }

    // set headers
    $headers = array(
        'MIME-Version: 1.0',
        'Content-type: text/plain; charset=UTF-8',
        "From: $from",
    );

    // send mail
    mail($p_email,
        '=?UTF-8?B?' . base64_encode(getGS('Password recovery')) . '?=',
        trim(html_entity_decode(strip_tags($message), ENT_QUOTES, 'UTF-8')),
        implode("\r\n", $headers));
}
Example #6
0
 public function postDispatch()
 {
     // run internal cron scheduler
     if (SystemPref::Get('ExternalCronManagement') == 'N') {
         camp_cron();
     }
 }
Example #7
0
 /**
  * Get maximum upload file size
  *
  * @return string
  */
 public function maxFileSize()
 {
     $maxFileSize = SystemPref::Get('MaxUploadFileSize');
     if (!$maxFileSize) {
         $maxFileSize = ini_get('upload_max_filesize');
     }
     return strtolower((string) $maxFileSize) . 'b';
 }
 /**
  * @return boolean
  */
 public function validate()
 {
     $privateKey = SystemPref::Get('PLUGIN_RECAPTCHA_PRIVATE_KEY');
     $resp = recaptcha_check_answer($privateKey,
         $_SERVER['REMOTE_ADDR'],
         $_POST['recaptcha_challenge_field'],
         $_POST['recaptcha_response_field']);
     return $resp->is_valid;
 }
Example #9
0
	/**
	 * Try to connect the resource based on supplied parameter.
	 *
	 * @param string (optional)
     *      Host/Server alias [online | local]
     *
	 * @return boolean|PEAR_Error
     *
	 */
	public function connect($host = null)
	{
		global $Campsite;
		global $g_ado_db;

		if ($host == 'local') {
			if (isset($g_ado_db)
				&& $g_ado_db->host == $Campsite['DATABASE_SERVER_ADDRESS']) {
				return true;
			} else {
				$g_ado_db = ADONewConnection('mysql');
				$g_ado_db->SetFetchMode(ADODB_FETCH_ASSOC);
				if ($g_ado_db->Connect($Campsite['DATABASE_SERVER_ADDRESS'],
							$Campsite['DATABASE_USER'],
							$Campsite['DATABASE_PASSWORD'],
							$Campsite['DATABASE_NAME'])) {
					return true;
				} else {
					return false;
				}
			}
		}

		$g_ado_db_tmp = $g_ado_db;

       	$this->m_rDbName = $Campsite['DATABASE_NAME'];
		$this->m_rDbHost = SystemPref::Get('DBReplicationHost')
                           . ':'
                           . SystemPref::Get('DBReplicationPort');
		$this->m_rDbUser = SystemPref::Get('DBReplicationUser');
		$this->m_rDbPass = SystemPref::Get('DBReplicationPass');

		if (isset($g_ado_db) && $g_ado_db->host == $this->m_rDbHost) {
			return true;
		}
		if ($this->m_rDbHost == ':'
				|| is_null($this->m_rDbUser)
				|| is_null($this->m_rDbPass)) {
			return false;
		}
		$g_ado_db = ADONewConnection('mysql');
		$g_ado_db->SetFetchMode(ADODB_FETCH_ASSOC);
		if ($g_ado_db->Connect($this->m_rDbHost,
					$this->m_rDbUser,
					$this->m_rDbPass,
					$this->m_rDbName) == false) {
			$g_ado_db = $g_ado_db_tmp;
			return false;
		} else {
			return true;
		}
	} // fn connect
Example #10
0
 public function preDispatch()
 {
     $uri = CampSite::GetURIInstance();
     $themePath = $uri->getThemePath();
     $this->view = new Newscoop\SmartyView();
     $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/')->addScriptPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}"));
     $this->view->addPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}"));
     $this->getHelper('viewRenderer')->setView($this->view)->setViewScriptPathSpec(':controller_:action.:suffix')->setViewSuffix('tpl');
     $this->getHelper('layout')->disableLayout();
     $this->view->publication = $this->getRequest()->getServer('SERVER_NAME', 'localhost');
     $this->view->site = \SystemPref::Get('SiteTitle');
     $this->_helper->contextSwitch()->addActionContext('comment-notify', 'xml')->initContext();
 }
Example #11
0
 private static function GetImageFormats()
 {
     $formats[] = array('width' => 100, 'height' => 100);
     $format_prefs = SystemPref::Get("PLUGIN_BLOG_IMAGE_DERIVATES");
     
     if (strlen($format_prefs)) {
         foreach (explode("\n", $format_prefs) as $format) {
             if (preg_match('/([0-9]*) *[xX] *([0-9]*)/', $format, $matched)) {
                 $formats[] = array('width' => $matched[1], 'height' => $matched[2]);
             }   
         }
     }
     return (array) $formats;
 }
Example #12
0
/**
 * Campsite teaser modifier plugin
 *
 * Type:     modifier
 * Name:     teaser
 * Purpose:  build an teaser our of input
 *
 * @param string
 *     $p_input the string or object
 * @param string
 *     $p_format the date format wanted
 *
 * @return
 *     string the formatted date
 *     null in case a non-valid format was passed
 */
function smarty_modifier_teaser($p_input, $p_length = null)
{
    if (empty($length)) {
        $length = is_null(SystemPref::Get('teaser_length')) ? 100 : SystemPref::Get('teaser_length');
    }
    $pattern = '/<!-- *break *-->/i';
    if (is_object($p_input) && method_exists($p_input, '__toString')) {
        $input = $p_input->__toString();
    } else {
        $input = (string) $p_input;
    }
    $output = node_teaser($input, null, $length);
    return $output;
}
Example #13
0
 /**
  *  Constructor - pelase DON'T CALL IT, use factory method instead
  *
  *  @param mdefs array, hash array with methods description
  *  @param debug int, XMLRPC debug flag
  *  @param verbose boolean, verbosity flag
  *
  *  @return this
  */
 public function XR_CcClient($mdefs, $debug = 0, $verbose = FALSE)
 {
     $this->mdefs = $mdefs;
     $this->debug = $debug;
     $this->verbose = $verbose;
     $serverPath = "http://" . SystemPref::Get('CampcasterHostName') . ":" . SystemPref::Get('CampcasterHostPort') . SystemPref::Get('CampcasterXRPCPath') . SystemPref::Get('CampcasterXRPCFile');
     if ($this->verbose) {
         echo "serverPath: {$serverPath}\n";
     }
     $url = parse_url($serverPath);
     if ($url === false) {
         $this->client = null;
     } else {
         $this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
     }
 }
Example #14
0
    private function __construct()
    {
        parent::Smarty();

        $config = CampSite::GetConfigInstance();

        $this->debugging = $config->getSetting('smarty.debugging');
        $this->force_compile = $config->getSetting('smarty.force_compile');
        $this->compile_check = $config->getSetting('smarty.compile_check');
        $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs');

        // cache settings
        $cacheHandler = SystemPref::Get('TemplateCacheHandler');
        if ($cacheHandler) {
            $this->caching = 1;
            $this->cache_handler_func = "TemplateCacheHandler_$cacheHandler::handler";
            require_once CS_PATH_SITE.DIR_SEP.'classes'.DIR_SEP.'cache'.DIR_SEP."TemplateCacheHandler_$cacheHandler.php";
        } else {
            $this->caching = 0;
        }

        // define dynamic uncached block
        require_once CS_PATH_SMARTY.DIR_SEP.'campsite_plugins/block.dynamic.php';
        $this->register_block('dynamic', 'smarty_block_dynamic', false);

        // define render function
        require_once CS_PATH_SMARTY.DIR_SEP.'campsite_plugins/function.render.php';
        $this->register_function('render', 'smarty_function_render', false);

        $this->left_delimiter = $config->getSetting('smarty.left_delimeter');
        $this->right_delimiter = $config->getSetting('smarty.right_delimeter');

        $this->cache_dir = CS_PATH_SITE.DIR_SEP.'cache';
        $this->config_dir = CS_PATH_SMARTY.DIR_SEP.'configs';

        $plugin_smarty_camp_plugin_paths = array();
        foreach (CampPlugin::GetEnabled() as $CampPlugin) {
            $plugin_smarty_camp_plugin_paths[] = CS_PATH_SITE.DIR_SEP.$CampPlugin->getBasePath().DIR_SEP.'smarty_camp_plugins';
        }

        $this->plugins_dir = array_merge(array(CS_PATH_SMARTY.DIR_SEP.'campsite_plugins',
                                               CS_PATH_SMARTY.DIR_SEP.'plugins'),
                                         $plugin_smarty_camp_plugin_paths);
        $this->template_dir = CS_PATH_TEMPLATES;
        $this->compile_dir = CS_PATH_SITE.DIR_SEP.'templates_cache';
    } // fn __constructor
Example #15
0
	/**
     * Checks if failed login attempts exceeds the number of
     * failed login attempts saved in the System Preferences.
     *
	 * @return boolean
	 */
	public static function MaxLoginAttemptsExceeded()
	{
		global $g_ado_db;
		$userIp = getenv('REMOTE_ADDR');
		$maxFailuresAllowed = SystemPref::Get('LoginFailedAttemptsNum');
		if (is_null($maxFailuresAllowed)) {
			$maxFailuresAllowed = 3;
		}
		$queryStr = "SELECT COUNT(*) FROM FailedLoginAttempts WHERE ip_address='".$userIp."'";
		$ip_num = $g_ado_db->GetOne($queryStr);

		if ($ip_num >= $maxFailuresAllowed) {
			return true;
		} else {
			return false;
		}
	} // fn MaxLoginAttemptsExceeded
    /**
     * Performs the action; returns true on success, false on error.
     *
     * @param $p_context - the current context object
     * @return bool
     */
    public function takeAction(CampContext &$p_context)
    {
        $p_context->default_url->reset_parameter('f_'.$this->m_name);
        $p_context->url->reset_parameter('f_'.$this->m_name);

        if (!is_null($this->m_error)) {
            return false;
        }

        $user = $p_context->user;
        
        if ($user->defined) {
            $this->m_properties['user_name'] = $p_context->user->name;
            $this->m_properties['user_email'] = $p_context->user->email;
        } else {
            switch(SystemPref::Get('PLUGIN_BLOGCOMMENT_MODE')) {                
                case 'name':
                    if (!strlen($this->m_properties['user_name'])) {
                        $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME);
                        return false;
                    } 
                break;   
                
                case 'email':
                    if (!strlen($this->m_properties['user_name'])) {
                        $this->m_error = new PEAR_Error('Name was empty.', ACTION_BLOGCOMMENT_ERR_NO_NAME);
                        return false;    
                    }
                    if (!CampMail::ValidateAddress($this->m_properties['user_email'])) {
                        $this->m_error = new PEAR_Error('Email was empty or invalid.', ACTION_BLOGCOMMENT_ERR_NO_EMAIL); 
                        return false;   
                    } 
                break;
                
                case 'registered':
                default:
                    $this->m_error = new PEAR_Error('Only registered users can post comments.', ACTION_BLOGCOMMENT_ERR_NOT_REGISTERED);
                    return false;     
                break;
            }
        }
        
        $this->m_error = ACTION_OK;
        return true;
    }
Example #17
0
 /**
  * Set session lifetime
  *
  * @return void
  */
 private function setSessionLifetime()
 {
     $auth = Zend_Auth::getInstance();
     $session = new Zend_Session_Namespace($auth->getStorage()->getNamespace());
     $seconds = SystemPref::Get('SiteSessionLifeTime');
     $gc_works = ini_get('session.gc_probability');
     if (!empty($gc_works)) {
         $max_seconds = 0 + ini_get('session.gc_maxlifetime');
         if (!empty($max_seconds)) {
             if ($seconds > $max_seconds) {
                 $seconds = $max_seconds;
             }
         }
     }
     if ($seconds > 0) {
         $session->setExpirationSeconds($seconds);
     }
 }
Example #18
0
    /**
     * Class constructor.
     *
     * @param integer $p_imageId
     *      The image identifier
     * @param integer $p_imageRatio
     *      The ratio for image resize
     * @param integer $p_imageWidth
     *      The max width for image resize
     * @param integer $p_imageHeight
     *      The max height for image resize
     */
    public function __construct($p_imageId, $p_imageRatio=100, $p_imageWidth = 0, $p_imageHeight = 0)
    {
        $this->m_basePath = $GLOBALS['g_campsiteDir'].'/images/';
        $this->m_ttl = SystemPref::Get('ImagecacheLifetime');

        if (empty($p_imageId) || !is_numeric($p_imageId)) {
            $this->ExitError('Invalid parameters');
        }
        if($p_imageRatio > 0 && $p_imageRatio < 100) {
            $this->m_ratio = $p_imageRatio;
        }
        if($p_imageWidth > 0) {
            $this->m_resizeWidth = $p_imageWidth;
        }
        if($p_imageHeight > 0) {
            $this->m_resizeHeight = $p_imageHeight;
        }
        $this->GetImage($p_imageId);
    }   // fn __construct
Example #19
0
 /**
  */
 public function __construct()
 {
     parent::__construct();
     $config = CampSite::GetConfigInstance();
     $this->debugging = $config->getSetting('smarty.debugging');
     $this->force_compile = $config->getSetting('smarty.force_compile');
     $this->compile_check = $config->getSetting('smarty.compile_check');
     $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs');
     $this->allow_php_tag = true;
     // cache settings
     $cacheHandler = SystemPref::Get('TemplateCacheHandler');
     $auth = Zend_Auth::getInstance();
     if ($cacheHandler) {
         $this->caching = 1;
         $this->caching_type = 'newscoop';
         CampTemplateCache::factory();
     } else {
         $this->caching = 0;
     }
     if (self::isDevelopment()) {
         $this->force_compile = true;
     }
     // define dynamic uncached block
     require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php';
     $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false);
     // define render function
     require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php';
     $this->registerPlugin('function', 'render', 'smarty_function_render', false);
     $this->left_delimiter = '{{';
     $this->right_delimiter = '}}';
     $this->auto_literal = false;
     $this->cache_dir = APPLICATION_PATH . '/../cache';
     $this->config_dir = APPLICATION_PATH . '/../configs';
     $this->compile_dir = APPLICATION_PATH . '/../cache';
     $this->plugins_dir = array_merge((array) $this->plugins_dir, array(APPLICATION_PATH . self::PLUGINS), self::getPluginsPluginsDir());
     $this->template_dir = array(APPLICATION_PATH . '/../themes/', APPLICATION_PATH . '/../themes/unassigned/system_templates/', APPLICATION_PATH . self::SCRIPTS);
     if (isset($GLOBALS['controller'])) {
         $this->assign('view', $GLOBALS['controller']->view);
     }
 }
Example #20
0
 /**
  * Class constructor.
  *
  * @param integer $p_imageId
  *      The image identifier
  * @param integer $p_imageRatio
  *      The ratio for image resize
  * @param integer $p_imageWidth
  *      The max width for image resize
  * @param integer $p_imageHeight
  *      The max height for image resize
  */
 public function __construct($p_imageId, $p_imageRatio = 100, $p_imageWidth = 0, $p_imageHeight = 0, $p_imageCrop = null, $p_resizeCrop = null)
 {
     $this->m_basePath = $GLOBALS['g_campsiteDir'] . '/images/';
     $this->m_ttl = SystemPref::Get('ImagecacheLifetime');
     if (empty($p_imageId) || !is_numeric($p_imageId)) {
         $this->ExitError('Invalid parameters');
     }
     if ($p_imageRatio > 0 && $p_imageRatio < 100) {
         $this->m_ratio = $p_imageRatio;
     }
     if ($p_imageWidth > 0) {
         $this->m_resizeWidth = $p_imageWidth;
     }
     if ($p_imageHeight > 0) {
         $this->m_resizeHeight = $p_imageHeight;
     }
     if (!is_null($p_imageCrop)) {
         $availableCropOptions = array('top-left', 'top-right', 'bottom-left', 'bottom-right', 'center-left', 'center-right', 'top-center', 'bottom-center', 'top', 'bottom', 'left', 'right', 'center', 'center-center');
         if (in_array($p_imageCrop, $availableCropOptions)) {
             if ($p_imageCrop == 'top' || $p_imageCrop == 'bottom') {
                 $p_imageCrop = $p_imageCrop . '-center';
             }
             if ($p_imageCrop == 'left' || $p_imageCrop == 'right') {
                 $p_imageCrop = 'center-' . $p_imageCrop;
             }
             if ($p_imageCrop == 'center') {
                 $p_imageCrop = 'center-center';
             }
             $this->m_crop = $p_imageCrop;
         }
     }
     if (!is_null($p_resizeCrop)) {
         $availableCropOptions = array('top', 'bottom', 'left', 'right', 'center');
         if (in_array($p_resizeCrop, $availableCropOptions)) {
             $this->m_resizeCrop = $p_resizeCrop;
         }
     }
     $this->GetImage($p_imageId);
 }
Example #21
0
    /**
     * Process the image statement given in Campsite internal formatting.
     * Returns a standard image URL.
     *
     * @param array $p_matches
     * @return string
     */
    public static function ProcessImageLink(array $p_matches) {
    	$context = CampTemplate::singleton()->context();
    	$oldImage = $context->image;
        $uri = $context->url;
        if ($uri->article->number == 0) {
            return '';
        }

        $imageNumber = $p_matches[1];
        $detailsString = $p_matches[2];
        $detailsArray = array();
        if (trim($detailsString) != '') {
        	$imageAttributes = 'align|alt|sub|width|height|ratio|\w+';
        	preg_match_all("/[\s]+($imageAttributes)=\"([^\"]+)\"/i", $detailsString, $detailsArray1);
        	$detailsArray1[1] = array_map('strtolower', $detailsArray1[1]);
        	if (count($detailsArray1[1]) > 0) {
        		$detailsArray1 = array_combine($detailsArray1[1], $detailsArray1[2]);
        	} else {
        		$detailsArray1 = array();
        	}
        	preg_match_all("/[\s]+($imageAttributes)=([^\"\s]+)/i", $detailsString, $detailsArray2);
        	$detailsArray2[1] = array_map('strtolower', $detailsArray2[1]);
        	if (count($detailsArray2[1]) > 0) {
        		$detailsArray2 = array_combine($detailsArray2[1], $detailsArray2[2]);
        	} else {
        		$detailsArray2 = array();
        	}
        	$detailsArray = array_merge($detailsArray1, $detailsArray2);
        }

        $articleImage = new ArticleImage($uri->article->number, null, $imageNumber);
        $imageObj = $articleImage->getImage();
        $image = new MetaImage($articleImage->getImageId());
        $context->image = $image;
        $imageSize = @getimagesize($imageObj->getImageStorageLocation());
        unset($imageObj);

        $imageOptions = '';
        $defaultOptions = array('ratio'=>'EditorImageRatio', 'width'=>'EditorImageResizeWidth',
        'height'=>'EditorImageResizeHeight');
        foreach (array('ratio', 'width', 'height') as $imageOption) {
        	$defaultOption = (int)SystemPref::Get($defaultOptions[$imageOption]);
        	if (isset($detailsArray[$imageOption]) && $detailsArray[$imageOption] > 0) {
        		$imageOptions .= " $imageOption " . (int)$detailsArray[$imageOption];
        	} elseif ($imageOption != 'ratio' && $defaultOption > 0) {
        		$imageOptions .= " $imageOption $defaultOption";
        	} elseif ($imageOption == 'ratio' && $defaultOption != 100) {
        		$imageOptions .= " $imageOption $defaultOption";
        	}
        }
        $imageOptions = trim($imageOptions);

        $imgZoomLink = '';
        if (SystemPref::Get("EditorImageZoom") == 'Y' && strlen($imageOptions) > 0) {
        	$uri->uri_parameter = "image";
            $imgZoomLink = '<a href="' . $uri->uri . '" class="photoViewer" ';
            if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
                $imgZoomLink .= 'title="' . $detailsArray['sub'] . '">';
            } else {
                $imgZoomLink .= 'title="">';
            }
        }

        $isCentered = false;
        $imgString = '</p><div class="cs_img"';
        if (isset($detailsArray['align']) && !empty($detailsArray['align'])) {
            if ($detailsArray['align'] == 'middle') {
                $imgString = '</p><div align="center"><div class="cs_img"';
                $isCentered = true;
            } else {
                $imgString .= ' style="float:' . $detailsArray['align'] . ';"';
            }
        }
        $imgString .= '>';
        $imgString .= (strlen($imgZoomLink) > 0) ? '<p>'.$imgZoomLink : '<p>';
        $uri->uri_parameter = "image $imageOptions";
        $imgString .= '<img src="' . $uri->uri . '"';
        if (isset($detailsArray['alt']) && !empty($detailsArray['alt'])) {
            $imgString .= ' alt="' . $detailsArray['alt'] . '"';
        }
        if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
            $imgString .= ' title="' . $detailsArray['sub'] . '"';
        }
        $imgString .= ' border="0"/>';
        $imgString .= (strlen($imgZoomLink) > 0) ? '</a></p>' : '</p>';
        if (isset($detailsArray['sub']) && !empty($detailsArray['sub'])) {
            $imgString .= '<p class="cs_img_caption">';
            $imgString .= $detailsArray['sub'] . '</p>';
        }
        if ($isCentered) {
            $imgString .= '</div></div><p>';
        } else {
            $imgString .= '</div><p>';
        }
        $context->image = $oldImage;

        return $imgString;
    }
Example #22
0
?>
:</td>
  <td><input type="text" name="f_soundcloud_username" class="input_text" size="50"
    value="<?php 
p(SystemPref::Get('PLUGIN_SOUNDCLOUD_USERNAME'));
?>
" /></td>
</tr>
<tr>
  <td><?php 
putGS('Enter password');
?>
:</td>
  <td><input type="text" name="f_soundcloud_password" class="input_text" size="50"
    value="<?php 
p(SystemPref::Get('PLUGIN_SOUNDCLOUD_PASSWORD'));
?>
" /></td>
</tr>
<tr>
  <td colspan="2" align="center" style="padding-top: 10px;">
    <input type="submit" name="save" value="<?php 
putGS('Save');
?>
" class="button" />
    <input type="submit" name="check" value="<?php 
putGS('Check connection');
?>
" class="button" />
  </td>
</tr>
Example #23
0
 public static function GetTopicInfoByPref($p_prefName, $p_languageId = null)
 {
     //global $g_ado_db;
     $topic_name_str = SystemPref::Get($p_prefName);
     if (empty($topic_name_str)) {
         return null;
     }
     $topic_name_obj = new TopicName($topic_name_str, $p_languageId);
     if (!$topic_name_obj->m_exists) {
         return null;
     }
     /*
             'SELECT fk_topic_id FROM TopicName WHERE name = ? AND fk_language_id = ?';
     
     		$rows = $g_ado_db->GetAll($sql);
     		foreach ($rows as $row) {
     			$tmpObj = new TopicName();
     			$tmpObj->fetch($row);
     			$names[$row['fk_language_id']] = $tmpObj;
     		}
     		return $names;
     */
     return array('name' => $topic_name_str, 'id' => $topic_name_obj->getTopicId());
 }
Example #24
0
    //if ($needs_menu) {
        //$content .= "</td></tr>\n</table>\n";
    //}
    //$content .= "</html>\n";
    echo $content;

    camp_html_clear_msgs(true);
} elseif (file_exists($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script")) {
    readfile($Campsite['HTML_DIR'] . "/$ADMIN_DIR/$call_script");
} else {
    header("HTTP/1.1 404 Not found");
    exit;
}

// run internal cron scheduler
if (SystemPref::Get('ExternalCronManagement') == 'N') {
    flush();
    camp_cron();
}

/**
 * Sets a user-defined error function.
 *
 *  The function set_error_handler() works differently in PHP 4 & 5.
 *  This function is a wrapper interface, to both versions of
 *  set_error_handler.
 *
 * @param $p_function The function to execute on error
 * @return void
 */
function camp_set_error_handler($p_function)
Example #25
0
    /**
     * @param string $p_value
     * @return boolean
     */
    public function setKeywords($p_value)
    {
        require_once($GLOBALS['g_campsiteDir'].'/classes/SystemPref.php');
        $keywordsSeparator = SystemPref::Get('KeywordSeparator');
        $p_value = str_replace($keywordsSeparator, ",", $p_value);
        CampCache::singleton()->clear('user');

        return parent::setProperty('Keywords', $p_value);
    } // fn setKeywords
 function __construct(&$smarty)
 {
     $this->smarty = $smarty;
     $this->cacheClass = 'TemplateCacheHandler_' . SystemPref::Get('TemplateCacheHandler');
 }
Example #27
0
<?php
    exit;
}

if (!$g_user->hasPermission('CommentModerate')) {
	camp_html_add_msg(getGS("You do not have the right to moderate comments." ));
?>
<script type="text/javascript">
window.close();
window.opener.location.reload();
</script>
<?php
	exit;
}

if (SystemPref::Get("UseDBReplication") == 'Y') {
    $dbReplicationObj = new DbReplication();
    $connectedToOnlineServer = $dbReplicationObj->connect();
    if ($connectedToOnlineServer == false) {
        camp_html_add_msg(getGS("Comments Disabled: you are either offline or not able to reach the Online server"));
?>
<script type="text/javascript">
window.close();
window.opener.location.reload();
</script>
<?php
		exit;
    }
}

if (!isset($connectedToOnlineServer)
Example #28
0
 /**
  * Return an regular expression to filter template lists
  *
  * @param boolean $p_sql indicates usage for sql query
  * @return string
  */
 public static function GetTemplateFilterRegex($p_sql = false)
 {
     $filters = array();
     if ($filterStr = SystemPref::Get('TemplateFilter')) {
         foreach (explode(',', $filterStr) as $filter) {
             if ($p_sql) {
                 $filter = preg_quote(trim($filter), '/');
                 // quote the filter
                 $filter = str_replace('\\', '\\\\', $filter);
                 $filter = str_replace('\\*', '.*', $filter);
                 // * becomes .*
                 $filter = str_replace('\\?', '.', $filter);
                 //  becomes .
                 $filter1 = "(^{$filter}\$)";
                 $filters[] = $filter1;
                 $filter2 = "(/{$filter}\$)";
                 $filters[] = $filter2;
                 $filter1 = "(^{$filter}/)";
                 $filters[] = $filter1;
                 $filter2 = "(/{$filter}/)";
                 $filters[] = $filter2;
             } else {
                 $filter = preg_quote(trim($filter), '/');
                 // quote the filter
                 $filter = str_replace('\\*', '.*', $filter);
                 // * becomes .*
                 $filter = str_replace('\\?', '.', $filter);
                 //  becomes .
                 $filter = "(^{$filter}\$)";
                 $filters[] = $filter;
             }
         }
     }
     $filterRegex = implode('|', $filters);
     return $filterRegex;
 }
Example #29
0
</table>

<form name="recaptcha_prefs" method="post">
<?php echo SecurityToken::FormParameter(); ?>
<table border="0" width="600" cellspacing="0" cellpadding="0" class="box_table">
<tr>
  <td align="left"><?php putGS('Enable reCAPTCHA for comments'); ?></td>
  <td><input type="checkbox" name="f_recaptcha_enabled" value="Y" <?php if (SystemPref::Get('PLUGIN_RECAPTCHA_ENABLED') == 'Y') p('checked'); ?> /></td>
</tr>
<tr>
  <td align="left"><?php putGS('Enable reCAPTCHA for subscriptions'); ?></td>
  <td><input type="checkbox" name="f_recaptcha_subscriptions_enabled" value="Y" <?php if (SystemPref::Get('PLUGIN_RECAPTCHA_SUBSCRIPTIONS_ENABLED') == 'Y') p('checked'); ?> /></td>
</tr>
<tr>
  <td><?php putGS('Enter your reCAPTCHA public key'); ?>:</td>
  <td><input type="text" name="f_recaptcha_public_key" class="input_text" size="40"
    value="<?php p(SystemPref::Get('PLUGIN_RECAPTCHA_PUBLIC_KEY')); ?>" /></td>
</tr>
<tr>
  <td><?php putGS('Enter your reCAPTCHA private key'); ?>:</td>
  <td><input type="text" name="f_recaptcha_private_key" class="input_text" size="40"
    value="<?php p(SystemPref::Get('PLUGIN_RECAPTCHA_PRIVATE_KEY')); ?>" /></td>
</tr>
<tr>
  <td colspan="2" align="center" style="padding-top: 10px;">
    <input type="submit" name="save" value="<?php putGS('Save'); ?>" class="button" />
  </td>
</tr>
</table>
</form>
Example #30
0
    /**
     * Renders the document.
     *
     * Displays the document after parsing it.
     *
     * @param array $p_params
     *
     * @return void
     */
    public function render($p_params)
    {
        $siteinfo = array();
        $context = $p_params['context'];
        $template = $p_params['template'];

        $siteinfo['info_message'] = isset($p_params['info_message']) ? $p_params['info_message'] : null;
        $siteinfo['error_message'] = isset($p_params['error_message']) ? $p_params['error_message'] : null;
        $siteinfo['templates_path'] = isset($p_params['templates_dir'])
                            ? $p_params['templates_dir'] : CS_TEMPLATES_DIR;
        $siteinfo['title'] = $this->getTitle();
        $siteinfo['content_type'] = $this->getMetaTag('Content-Type', true);
        $siteinfo['generator'] = $this->getGenerator();
        $siteinfo['keywords'] = $this->getMetaTag('keywords');
        $siteinfo['description'] = $this->getMetaTag('description');

        if (!file_exists(CS_PATH_SITE.DIR_SEP.$siteinfo['templates_path'].DIR_SEP.$template)
                || $template === false) {
            if (empty($template)) {
                $siteinfo['error_message'] = "No template set for display.";
            } else {
                $siteinfo['error_message'] = "The template '$template' does not exist in the templates directory.";
            }
            $template = CS_SYS_TEMPLATES_DIR.DIR_SEP.'_campsite_error.tpl';
            $siteinfo['templates_path'] = CS_TEMPLATES_DIR;
        }

        $tpl = CampTemplate::singleton();
        $tpl->template_dir = $siteinfo['templates_path'];
        $subdir = $this->m_config->getSetting('SUBDIR');
        if (!empty($subdir)) {
            $siteinfo['templates_path'] = substr($subdir, 1) . '/' . $siteinfo['templates_path'];
        }
        $tpl->assign('gimme', $context);
        $tpl->assign('siteinfo', $siteinfo);

        // on template caching add additional info
        if (SystemPref::Get('TemplateCacheHandler')) {
            $uri = CampSite::GetURIInstance();
            $tpl->campsiteVector = $uri->getCampsiteVector();
            $templateObj = new Template($template);
            $tpl->cache_lifetime = (int)$templateObj->getCacheLifetime();
        }

        try {
            $tpl->display($template);
        }
        catch (Exception $ex) {
            CampTemplate::trigger_error($ex->getMessage(), $tpl);
        }
    } // fn render