Large diffs are not rendered by default.

@@ -72,6 +72,8 @@
mb_internal_encoding("UTF-8");
}



function exception_handler($e)
{
$code = $e->getCode();
@@ -105,7 +107,6 @@ function fastcgi_finish_request()

set_exception_handler('exception_handler');


$lampcmsClasses = LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'Lampcms' . DIRECTORY_SEPARATOR;

require $lampcmsClasses . 'Interfaces' . DIRECTORY_SEPARATOR . 'All.php';
@@ -118,6 +119,7 @@ function fastcgi_finish_request()
require $lampcmsClasses . 'Config' . DIRECTORY_SEPARATOR . 'Ini.php';
require $lampcmsClasses . 'Log.php';
require $lampcmsClasses . 'Request.php';

require $lampcmsClasses . DIRECTORY_SEPARATOR . 'Mongo' . DIRECTORY_SEPARATOR . 'DB.php';
require $lampcmsClasses . DIRECTORY_SEPARATOR . 'Mongo' . DIRECTORY_SEPARATOR . 'Doc.php'; // User extends it
require $lampcmsClasses . 'User.php'; // User is always used
@@ -3,7 +3,7 @@
*
* License, TERMS and CONDITIONS
*
* This software is licensed under the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) version 3
* This software is lisensed under the GNU LESSER GENERAL PUBLIC LICENSE (LGPL) version 3
* Please read the license here : http://www.gnu.org/licenses/lgpl-3.0.txt
*
* Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
* the website's Questions/Answers functionality is powered by lampcms.com
* An example of acceptable link would be "Powered by <a href="http://www.lampcms.com">LampCMS</a>"
* The location of the link is not important, it can be in the footer of the page
* but it must not be hidden by style attributes
* but it must not be hidden by style attibutes
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@@ -83,6 +83,7 @@ class Ini extends \Lampcms\LampcmsArray
* Constructor
*
* @param string $iniFile
*
* @throws IniException if unable to parse ini file
*
*/
@@ -110,6 +111,7 @@ public function __construct($iniFile = null)
* object
*
* @param string $name
*
* @throws IniException if CONSTANTS key
* does not exist OR if var
* does not exist and is a required var
@@ -144,18 +146,18 @@ public function getVar($name)
}


if (!\array_key_exists($name, $aConstants) && !$this->offsetExists($name)) {
if (!array_key_exists($name, $aConstants) && !$this->offsetExists($name) && ('LOG_FILE_PATH' !== $name)) {

throw new IniException('Error: configuration param: ' . $name . ' does not exist in config file ' . $this->iniFile);
}

if ('MAGIC_MIME_FILE' === $name) {
if (!empty($aConstants['MAGIC_MIME_FILE']) && !\is_readable($aConstants['MAGIC_MIME_FILE'])) {
if (!empty($aConstants['MAGIC_MIME_FILE']) && !is_readable($aConstants['MAGIC_MIME_FILE'])) {
throw new IniException('magic mime file does not exist in this location or not readable: ' . $aConstants['MAGIC_MIME_FILE']);
}
}

switch ($name) {
switch ( $name ) {
case 'SITE_URL':
if (empty($aConstants['SITE_URL'])) {
throw new IniException('Value of SITE_URL in ' . $this->iniFile . ' file SHOULD NOT be empty!');
@@ -211,11 +213,18 @@ public function getVar($name)
}
break;


case 'LOG_DIR':
$ret = (empty($aConstants['LOG_DIR'])) ? \dirname(LAMPCMS_WWW_DIR) . DIRECTORY_SEPARATOR . 'logs' : \rtrim($aConstants['LOG_DIR'], DIRECTORY_SEPARATOR);
break;

case 'LOG_FILE_PATH':
if ((\substr(PHP_SAPI, 0, 3) === 'cli') || (\substr(PHP_SAPI, 0, 3) === 'cgi')) {
$ret = $aConstants['LOG_FILE_PATH_CGI'];
if (\substr(PHP_SAPI, 0, 3) === 'cli') {
$ret = $this->__get('LOG_DIR') . DIRECTORY_SEPARATOR . 'cli-php.log';
} elseif ((\substr(PHP_SAPI, 0, 3) === 'cgi')) {
$ret = $this->__get('LOG_DIR') . DIRECTORY_SEPARATOR . 'cgi-php.log';
} else {
$ret = $aConstants['LOG_FILE_PATH'];
$ret = $this->__get('LOG_DIR') . DIRECTORY_SEPARATOR . 'php.log';
}
break;

@@ -253,7 +262,9 @@ public function getVar($name)
* most of the times
*
* @return string a value of $name
*
* @param string $name
*
* @throws LampcmsIniException if $name
* does not exist as a key in this->aIni
*
@@ -302,7 +313,7 @@ public function getSection($name)
*
* @param string $name name of section in !config.ini file
*
* @param array $val array of values for this section
* @param array $val array of values for this section
*
* @return object $this
*/
@@ -58,6 +58,7 @@

class Editprofile extends WebPage
{

/**
* Pre-check to deny non-logged in user
* access to this page
@@ -71,6 +72,7 @@ class Editprofile extends WebPage
*
* Viewer must have edit_profile
* permission to access this page
*
* @var string
*/
protected $permission = 'edit_profile';
@@ -104,10 +106,10 @@ class Editprofile extends WebPage
protected function main()
{
$this->getUser();
$this->Form = new \Lampcms\Forms\Profile($this->Registry);
$this->Form->formTitle = $this->aPageVars['title'] = '@@Edit Profile@@';
$this->Form = new \Lampcms\Forms\Profile($this->Registry);
$this->Form->formTitle = $this->aPageVars['title'] = '@@Edit Profile@@';

if ($this->Form->isSubmitted() && $this->Form->validate()) {
if ($this->Form->isSubmitted() && $this->Form->validate()) {
$this->Registry->Dispatcher->post($this->Form, 'onBeforeProfileUpdate');
//try{
$this->saveProfile();
@@ -122,7 +124,7 @@ protected function main()
$this->setForm();
$this->aPageVars['body'] = $this->Form->getForm();
}
}
}


/**
@@ -158,24 +160,24 @@ protected function getUser()
protected function setForm()
{

$this->Form->username = $this->User['username'];
$this->Form->username = $this->User['username'];
$this->Form->usernameLabel = '@@Username@@';
$this->Form->fn = $this->User['fn'];
$this->Form->mn = $this->User['mn'];
$this->Form->ln = $this->User['ln'];
$this->Form->gender = $this->getGenderOptions();
$this->Form->dob = $this->User['dob'];
$this->Form->cc = $this->getCountryOptions();
$this->Form->state = $this->User['state'];
$this->Form->city = $this->User['city'];
$this->Form->url = $this->User['url'];
$this->Form->zip = $this->User['zip'];
$this->Form->description = $this->User['description'];
$this->Form->avatarSrc = $this->User->getAvatarSrc();
$this->Form->width = $this->Registry->Ini->AVATAR_SQUARE_SIZE;
$this->Form->uid = $this->User->getUid();
$this->Form->fn = $this->User['fn'];
$this->Form->mn = $this->User['mn'];
$this->Form->ln = $this->User['ln'];
$this->Form->gender = $this->getGenderOptions();
$this->Form->dob = $this->User['dob'];
$this->Form->cc = $this->getCountryOptions();
$this->Form->state = $this->User['state'];
$this->Form->city = $this->User['city'];
$this->Form->url = $this->User['url'];
$this->Form->zip = $this->User['zip'];
$this->Form->description = $this->User['description'];
$this->Form->avatarSrc = $this->User->getAvatarSrc();
$this->Form->width = $this->Registry->Ini->AVATAR_SQUARE_SIZE;
$this->Form->uid = $this->User->getUid();
$this->Form->maxAvatarSize = $this->Registry->Ini->MAX_AVATAR_UPLOAD_SIZE;
$this->Form->timezone = \Lampcms\TimeZone::getMenu($this->User->getTimezone());
$this->Form->timezone = $this->getTimeZonesMenu(); //\Lampcms\TimeZone::getMenu($this->User->getTimezone());

$this->Form->avatarTos = \sprintf('@@Upload Image. Maximum size of@@ %sMb<br><span class="smaller">@@By uploading a file you certify that you have the right to distribute this picture and that it does not violate the Terms of Service@@</span>', \floor($this->Registry->Ini->MAX_AVATAR_UPLOAD_SIZE / 1000000));

@@ -192,6 +194,14 @@ protected function setForm()
}


protected function getTimeZonesMenu(){
$menu = $this->_('time_zones');
$current = $this->User->getTimezone();

return \str_replace('value="'.$current.'"', 'value="'.$this->User->getTimezone().'" selected="selected"', $menu );
}


/**
* Save changed to user profile
* using ProfileParser class
@@ -221,23 +231,23 @@ protected function saveProfile()
* menu for Country selection
*
* @todo use 'cc' key from USER as value
* and country name only as label! Don NOT
* set 'country' key at all!
* For this we need an array that translates
* and country name only as label! Don NOT
* set 'country' key at all!
* For this we need an array that translates
* 2-letter country code 'cc' to the full country name
*
* @return string html string
*/
protected function getCountryOptions()
{
$s = '';
$current = \strtoupper($this->Registry->Viewer['cc']);
$tpl = '<option value="%1$s"%2$s>%3$s</option>';
$s = '';
$current = \strtoupper($this->Registry->Viewer['cc']);
$tpl = '<option value="%1$s"%2$s>%3$s</option>';
$aCountries = \array_combine(\Lampcms\Geo\Location::getCodes(), \Lampcms\Geo\Location::getNames());

foreach ($aCountries as $key => $val) {
$selected = ($current == $key) ? ' selected' : '';
$name = (empty($val)) ? '@@Select country@@' : $val;
$name = (empty($val)) ? '@@Select country@@' : $val;

$s .= \vsprintf($tpl, array($key, $selected, $name));
}
@@ -258,9 +268,9 @@ protected function getCountryOptions()
protected function getGenderOptions()
{
$current = $this->Registry->Viewer['gender'];
$s = '';
$a = array('' => '@@Select Gender@@', 'M' => '@@Male@@', 'F' => '@@Female@@');
$tpl = '<option value="%1$s"%2$s>%3$s</option>';
$s = '';
$a = array('' => '@@Select Gender@@', 'M' => '@@Male@@', 'F' => '@@Female@@');
$tpl = '<option value="%1$s"%2$s>%3$s</option>';
foreach ($a as $key => $val) {
$selected = ($key === $current) ? ' selected' : '';
$s .= \vsprintf($tpl, array($key, $selected, $val));
@@ -116,7 +116,8 @@ class H2t
* Constructor, cannot be called
* directly, only via factory!
*
* @return void
* @throws Exception
* @return \Lampcms\H2t
*/
protected function __construct()
{
@@ -205,7 +206,7 @@ public function loadHtml($sHtml)
protected function makeXslProcessor()
{
$xsl = new \DOMDocument;
$tpl = LAMPCMS_PATH . DIRECTORY_SEPARATOR . $this->templateFile;
$tpl = LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . $this->templateFile;
if (!is_file($tpl)) {
throw new HTML2TextException('XSL template not found here: ' . $tpl);
}
@@ -254,5 +255,3 @@ public function __toString()
}
}


?>
@@ -52,7 +52,8 @@

namespace Lampcms;

const JS_MIN_ID = '122411';
//const JS_MIN_ID = '@package_version@';
const VERSION_ID = '@package_version@';

const LF = "\n";
const CR = "\r";
@@ -64,20 +65,6 @@
const LB = "\n<br/>";


/**
* name of directory where the index.php
* is located. This is NOT a full path, just a directory name!
* Default is www and should not be changed unless
* you must have specific name of your root www dir
* maybe a web host requires this directory
* to be named 'htdocs' or something else, then you would
* copy everything from 'www' to this 'htdocs' and then
* put 'htdocs' as a value of WWW_DIR here
*
* @deprecated
*/
//const WWW_DIR = 'www';


/**
* These constants should not be changed
@@ -399,6 +386,7 @@ public function serialize()
* @see ArrayObject::unserialize()
*
* @param string $serialized
* @return mixed|void
*/
public function unserialize($serialized)
{
@@ -586,7 +574,7 @@ public final function checkOffset($name)
*
* @param string $name
*
* @return unknown
* @return mixed null|string|int
*/
public function offsetGet($name)
{
@@ -616,7 +604,7 @@ public function setDefaultValue($val)

/**
* Getter method for $this->defaultValue
* this is not very usefull, usually only used
* this is not very useful, usually only used
* when you want to see what the defaultValue is
* (mostly during debugging)
*
@@ -679,6 +667,7 @@ public function serialize()
* @see Lampcms.LampcmsArray::unserialize()
*
* @param string $serialized
* @return mixed|void
*/
public function unserialize($serialized)
{
@@ -69,7 +69,7 @@ class Paginator
* This is how this object is usually
* instantiated
* No parameters are necessary
* but for backward compatability it
* but for backward compatibility it
* can accept one param, but it's totally ignored
* This is because originally it used to accept Registry object
* and other methods still passing Registry to it but
@@ -118,32 +118,29 @@ public function paginate($arrData = null, $perPage, $arrExtraParams = array())
$arrParams = array('mode' => 'Sliding', 'fileName' => '{_PAGER_PREFIX_}%d{_PAGER_EXT_}', 'path' => '', 'append' => false, 'perPage' => $perPage, 'delta' => 2, 'urlVar' => 'pageID');

if (!empty($arrData)) {
if (is_array($arrData)) {
if (\is_array($arrData)) {
d('arrData: ' . print_r($arrData, true));
$arrParams['itemData'] = $arrData;
} elseif (is_numeric($arrData)) {
} elseif (\is_numeric($arrData)) {
d('totalItems: ' . $arrData);
$arrParams['totalItems'] = $arrData;
} elseif (is_object($arrData) && ($arrData instanceof \MongoCursor)) {
} elseif (\is_object($arrData) && ($arrData instanceof \MongoCursor)) {
d('got mongo cursor');
$mongoCursor = $arrData;
$arrParams['totalItems'] = $mongoCursor->count(true);
d('totalItems: ' . $arrParams['totalItems']);
}

else {
throw new DevException('Wrong type for $arrData param. It must be array or numeric value. Passed: ' . gettype($arrData) . ' ' . \get_class($arrData));
throw new DevException('Wrong type for $arrData param. It must be array or numeric value. Passed: ' . \gettype($arrData) . ' ' . \get_class($arrData));
}
}

if (!empty($arrExtraParams)) {
$arrParams = array_merge($arrParams, $arrExtraParams); // this way we can pass extra parameters here
$arrParams = \array_merge($arrParams, $arrExtraParams); // this way we can pass extra parameters here
}

include_once(LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'Pear' . DIRECTORY_SEPARATOR . 'Pager.php');
include_once(LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'Pear' . DIRECTORY_SEPARATOR . 'Pager' . DIRECTORY_SEPARATOR . 'Common.php');

$this->oPager = \Pager::factory($arrParams);
$this->oPager = \Pear\Pager::factory($arrParams);

if (null !== $mongoCursor) {
$curPage = $this->oPager->getCurrentPageID();
@@ -84,6 +84,7 @@ class SplClassLoader
* @todo use constant LAMPCMS_LIB_DIR if $includePath not passed
*
* @param string $ns The namespace to use.
* @param string $includePath
*/
public function __construct($ns = null, $includePath = LAMPCMS_LIB_DIR)
{
@@ -180,6 +181,8 @@ public function unregister()
* Loads the given class or interface.
*
* @param string $className The name of the class to load.
*
* @throws \OutOfBoundsException if class file not found or cannot be included
* @return void
*/
public function loadClass($className)
@@ -427,15 +427,16 @@ protected function initPageVars()
$this->aPageVars['comments_timeout'] = $Ini->COMMENT_EDIT_TIME;
$this->aPageVars['layoutID'] = $this->layoutID;
$this->aPageVars['DISABLE_AUTOCOMPLETE'] = $Ini->DISABLE_AUTOCOMPLETE;
$this->aPageVars['JS_MIN_ID'] = JS_MIN_ID;
$this->aPageVars['VERSION_ID'] = VERSION_ID;
$this->aPageVars['home'] = $this->_('Home');

/**
* @todo later can change to something like
* $this->Registrty->Viewer->getStyleID()
* To load style selected by user
*
*/
$css = (true === LAMPCMS_DEBUG) ? '/_main.css?t='.time() : '/main.css';
$css = (true === LAMPCMS_DEBUG || '@package_version@' === VERSION_ID) ? '/_main.css?t='.time() : '/main.css';
$this->aPageVars['main_css'] = $Ini->CSS_SITE . '{_DIR_}/style/' . STYLE_ID . '/' . VTEMPLATES_DIR . $css;

$aFacebookConf = $Ini->getSection('FACEBOOK');
@@ -464,8 +465,8 @@ protected function initPageVars()
*/
$this->addMetaTag('fb', ('' !== (string)$Viewer->getFacebookToken()));

$js = (true === LAMPCMS_DEBUG) ? '/qa.js?t='.time() : '/min/qa_' . JS_MIN_ID . '.js';
//$js = (true === LAMPCMS_DEBUG) ? '/temp1.js' : '/min/qa_'.JS_MIN_ID.'.js';
$js = (true === LAMPCMS_DEBUG || '@package_version@' === VERSION_ID) ? '/qa.js?t='.time() : '/min/qa_' . VERSION_ID . '.js';

$src = $Ini->JS_SITE . '{_DIR_}/js' . $js;

$this->aPageVars['JS'] = $src;
@@ -36,7 +36,7 @@
*
*/

//namespace Pear;
namespace Pear;


/**
@@ -65,11 +65,7 @@ class Pager
public static function factory($options = array())
{
$mode = (isset($options['mode']) ? ucfirst($options['mode']) : 'Jumping');
$classname = 'Pager_' . $mode;
$classfile = DIRECTORY_SEPARATOR . 'Pager' . DIRECTORY_SEPARATOR . $mode . '.php';
//$common = DIRECTORY_SEPARATOR . 'Pager' . DIRECTORY_SEPARATOR . 'Common.php';

include_once(LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'Pear' . $classfile);
$classname = '\\Pear\\Pager\\'.$mode;
$pager = new $classname($options);

return $pager;
@@ -39,6 +39,8 @@

//namespace Pear;

namespace Pear\Pager;

/**
* Two constants used to guess the path- and file-name of the page
* when the user doesn't set any other value
@@ -79,7 +81,7 @@
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
* @link http://pear.php.net/package/Pager
*/
abstract class Pager_Common
abstract class Common
{

const PAGER_OK = 0;
@@ -1520,6 +1522,7 @@ public function setOptions($options)
*
* @param string $name option name
*
* @throws Exception
* @return mixed option value
* @access public
*/

Large diffs are not rendered by default.

@@ -42,7 +42,7 @@
*/
//require_once 'Pager/Common.php';

///namespace Pear;
namespace Pear\Pager;

/**
* Pager_Sliding - Generic data paging class ("sliding window" style)
@@ -55,7 +55,7 @@
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
* @link http://pear.php.net/package/Pager
*/
class Pager_Sliding extends Pager_Common
class Sliding extends Common
{
// {{{ Pager_Sliding()

@@ -64,6 +64,7 @@ class Pager_Sliding extends Pager_Common
*
* @param array $options Associative array of option names and their values
*
* @throws \Exception
* @access public
*/
public function __construct($options = array())
File renamed without changes.
@@ -116,8 +116,8 @@
define('DEFAULT_LANG', 'en');
define('LAMPCMS_COOKIE_DOMAIN', '');
define('SITE_URL', '');
define('LAMPCMS_IMAGE_SITE', 'http://img.lampcms.com');
define('LAMPCMS_AVATAR_IMG_SITE', 'http://img.lampcms.com');
//define('LAMPCMS_IMAGE_SITE', 'http://img.lampcms.com');
//define('LAMPCMS_AVATAR_IMG_SITE', 'http://img.lampcms.com');
/**
* This is very important!
* Use test databases!
@@ -96,15 +96,11 @@ protected static function func(&$a)
*/
$rid = $a['_id'];
$uid = $a['i_uid'];
//$reply = $a['reply'];
//$reply_t = $a['reply_t'];

$f = function(&$data) use ($rid, $uid)
{
$data['resource_id'] = $rid;
$data['owner_id'] = $uid;
//$data['reply'] = $reply;
//$data['reply_t'] = $reply_t;
};

$a['comments_html'] = tplComment::loop($a['a_comments'], true, $f);
@@ -120,7 +116,7 @@ protected static function func(&$a)
'i_votes' => '', // 6
'i_uid' => '0', // 7 // answer author id
'accepted_text' => '', //8
'accepted_class' => '@@accept_answer@@', // 9
'accepted_class' => '@@Accept answer@@', // 9
'vote_up' => "\xE2\x87\xA7", // 10 \xE2\x87\xA7
'vote_down' => "\xE2\x87\xA9", //11
'accept_link' => '&nbsp', // 12,
@@ -87,7 +87,7 @@ class tplMain extends Lampcms\Template\Fast
'show_comments' => '5', //36
'comments_timeout' => '5', //37
'max_comments' => '0', // 38
'JS_MIN_ID' => '', // 39
'VERSION_ID' => '', // 39
'DISABLE_AUTOCOMPLETE' => '', // 40
'langsForm' => '', //41
'home' => 'Home', // 42