b2evolution PHP Cross Reference Blogging Systems

Source: /inc/settings/model/_generalsettings.class.php - 399 lines - 14953 bytes - Summary - Text - Print

Description: This file implements the GeneralSettings class, which handles Name/Value pairs. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the GeneralSettings class, which handles Name/Value pairs.
   4   *
   5   * This file is part of the evoCore framework - {@link http://evocore.net/}
   6   * See also {@link http://sourceforge.net/projects/evocms/}.
   7   *
   8   * @copyright (c)2003-2014 by Francois Planque - {@link http://fplanque.com/}
   9   * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10   *
  11   * {@internal License choice
  12   * - If you have received this file as part of a package, please find the license.txt file in
  13   *   the same folder or the closest folder above for complete license terms.
  14   * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
  15   *   then you must choose one of the following licenses before using the file:
  16   *   - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17   *   - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18   * }}
  19   *
  20   * {@internal Open Source relicensing agreement:
  21   * Daniel HAHLER grants Francois PLANQUE the right to license
  22   * Daniel HAHLER's contributions to this file and the b2evolution project
  23   * under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24   * }}
  25   *
  26   * @package evocore
  27   *
  28   * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  29   * @author fplanque: Francois PLANQUE
  30   * @author blueyed: Daniel HAHLER
  31   *
  32   * @version $Id: _generalsettings.class.php 6136 2014-03-08 07:59:48Z manuel $
  33   */
  34  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  35  
  36  load_class( 'settings/model/_abstractsettings.class.php', 'AbstractSettings' );
  37  
  38  /**
  39   * Class to handle the global settings.
  40   *
  41   * @package evocore
  42   */
  43  class GeneralSettings extends AbstractSettings
  44  {
  45      /**
  46       * The default settings to use, when a setting is not given
  47       * in the database.
  48       *
  49       * @todo Allow overriding from /conf/_config_TEST.php?
  50       * @access protected
  51       * @var array
  52       */
  53      var $_defaults = array(
  54          'admin_skin' => 'chicago',
  55  
  56          'antispam_last_update' => '2000-01-01 00:00:00',
  57          'antispam_threshold_publish' => '-90',
  58          'antispam_threshold_delete' => '100', // do not delete by default!
  59          'antispam_block_spam_referers' => '0',    // By default, let spam referers go in silently (just don't log them). This is in case the blacklist is too paranoid (social media, etc.)
  60          'antispam_report_to_central' => '1',
  61  
  62          'evonet_last_update' => '1196000000',        // just around the time we implemented this ;)
  63          'evonet_last_attempt' => '1196000000',        // just around the time we implemented this ;)
  64  
  65          'log_public_hits' => '1',
  66          'log_admin_hits' => '0',
  67          'log_spam_hits' => '0',
  68          'auto_prune_stats_mode' => 'page',  // 'page' is the safest mode for average installs (may be "off", "page" or "cron")
  69          'auto_prune_stats' => '15',         // days (T_hitlog and T_sessions)
  70  
  71          'outbound_notifications_mode' => 'immediate', // 'immediate' is the safest mode for average installs (may be "off", "immediate" or "cron")
  72          'notification_sender_email' => '', // notification emails will be sent from this email. The real default value is set in the constructor.
  73          'notification_return_path' => '', // erroneous emails will be sent to this email address. The real default value is set in the constructor.
  74          'notification_sender_name' => 'b2evo mailer', // notification emails will be sent with this sender name
  75          'notification_short_name' => 'This site', // notification emails will use this as short site name
  76          'notification_long_name' => '', // notification emails will use this as long site name
  77          'notification_logo' => '', // notification emails will use this as url to site logo
  78  
  79          'fm_enable_create_dir' => '1',
  80          'fm_enable_create_file' => '1',
  81          'fm_enable_roots_blog' => '1',
  82          'fm_enable_roots_user' => '1',
  83          'fm_enable_roots_shared' => '1',
  84          'fm_enable_roots_skins' => '1',
  85  
  86          'fm_showtypes' => '0',
  87          'fm_showfsperms' => '0',
  88  
  89          'fm_default_chmod_file' => '664',
  90          'fm_default_chmod_dir' => '775',
  91  
  92          // Image options
  93          'exif_orientation' => '1',
  94          'fm_resize_enable' => '0',
  95          'fm_resize_width' => '2880',
  96          'fm_resize_height' => '1800',
  97          'fm_resize_quality' => '95',
  98  
  99          'newusers_canregister' => '0',
 100          'newusers_mustvalidate' => '1',
 101          'newusers_revalidate_emailchg' => '1',
 102          'validation_process' => 'easy',
 103          'activate_requests_limit' => '300', // Only one activation email can be sent to the same email address in the given interval ( value is in seconds )
 104          'newusers_findcomments' => '1',
 105          'after_email_validation' => 'return_to_original', // where to redirect after account activation. Values: return_to_original, or the previously set specific url
 106          'after_registration' => 'return_to_original', // where to redirect after new user registration. Values: return_to_original redirect_to url, or return to the previously set specific url
 107          'newusers_level' => '1',
 108          'registration_require_gender' => 'hidden',
 109          'registration_ask_locale' => '0',
 110  
 111          // Default user settings
 112          'def_enable_PM' => '1',
 113          'def_enable_email' => '0',
 114          'def_notify_messages' => '1',
 115          'def_notify_unread_messages' => '1',
 116          'def_notify_published_comments' => '1',
 117          'def_notify_comment_moderation' => '1',
 118          'def_notify_post_moderation' => '1',
 119          'def_newsletter_news' => '1',
 120          'def_newsletter_ads' => '0',
 121          'def_notification_email_limit' => '3',
 122          'def_newsletter_limit' => '1',
 123  
 124          'allow_avatars' => 1,
 125          'min_picture_size' => 160, // minimum profile picture dimensions in pixels (width and height)
 126          'messages_link_to' => 'admin',        // message link on the notification email should link to the admin or to a blog
 127  
 128          // Welcome private message
 129          'welcomepm_enabled' => 0,
 130          'welcomepm_from'    => 'admin',    // User login
 131          'welcomepm_title'   => 'Welcome to our community!',
 132          'welcomepm_message' => '',
 133  
 134          'regexp_filename' => '^[a-zA-Z0-9\-_. ]+$', // TODO: accept (spaces and) special chars / do full testing on this
 135          'regexp_dirname' => '^[a-zA-Z0-9\-_]+$', // TODO: accept spaces and special chars / do full testing on this
 136          'reloadpage_timeout' => '300',
 137          'smart_view_count' => '0',
 138          'time_difference' => '0',
 139          'timeout_sessions' => '604800',             // seconds (604800 == 7 days)
 140          'timeout_online' => '1200',                 // seconds (1200 == 20 minutes)
 141          'upload_enabled' => '1',
 142          'upload_maxkb' => '10000',                    // 10 MB
 143          'evocache_foldername' => '.evocache',
 144          'blogs_order_by' => 'ID',                    // blogs order in backoffice menu and other places
 145          'blogs_order_dir' => 'ASC',                    // blogs order direction in backoffice menu and other places
 146  
 147          'user_minpwdlen' => '5',
 148          'js_passwd_hashing' => '1',                    // Use JS password hashing by default
 149          'passwd_special' => '0',                    // Do not require a special character in password by default
 150          'strict_logins' => 1,                        // Allow only plain ACSII characters in user login
 151  
 152          'webhelp_enabled' => '1',
 153  
 154          'allow_moving_chapters' => '0',                // Do not allow moving chapters by default
 155          'chapter_ordering' => 'alpha',
 156  
 157          'cross_posting' => 0,                        // Allow additional categories from other blogs
 158          'cross_posting_blog' => 0,                    // Allow to choose main category from another blog
 159  
 160          'subscribe_new_blogs' => 'public', // Subscribing to new blogs: 'page', 'public', 'all'
 161  
 162          'system_lock' => 0,
 163          'general_cache_enabled' => 0,
 164          'newblog_cache_enabled' => 0,
 165          'newblog_cache_enabled_widget' => 0,
 166  
 167          //Default blogs skin setting
 168          'def_normal_skin_ID' => '1',                // Default normal skin ID
 169          'def_mobile_skin_ID' => '0',                // 0 means same as normal skin
 170          'def_tablet_skin_ID' => '0',                // 0 means same as normal skin
 171  
 172          // Post by Email
 173          'eblog_enabled' => 0,
 174          'eblog_method' => 'imap',
 175          'eblog_encrypt' => 'none',
 176          'eblog_server_port' => 143,
 177          'eblog_default_category' => 1,
 178          'eblog_add_imgtag' => 0,
 179          'eblog_body_terminator' => '___',
 180          'eblog_subject_prefix' => 'blog:',
 181          'eblog_html_tag_limit' => 1,
 182          'eblog_delete_emails' => 1,
 183          'eblog_renderers' => array('default'),
 184  
 185          // Returned Emails
 186          'repath_enabled' => 0,
 187          'repath_method' => 'imap',
 188          'repath_encrypt' => 'none',
 189          'repath_server_port' => 143,
 190          'repath_subject' => 'Returned mail:
 191  Mail delivery failed:
 192  Undelivered Mail Returned to Sender
 193  Delivery Status Notification (Failure)
 194  delayed 24 hours
 195  delayed 48 hours
 196  delayed 72 hours
 197  failure notice
 198  Undeliverable:',
 199          'repath_body_terminator' => '---------- Forwarded message ----------
 200  ------ This is a copy of the message, including all the headers. ------
 201  ----- Transcript of session follows -----
 202  Received: from
 203  --- Below this line is a copy of the message.',
 204          'repath_errtype' => 'C ^101
 205  C ^111
 206  T ^421
 207  T ^431
 208  T ^432
 209  T ^441
 210  T ^450
 211  T ^452
 212  C ^500
 213  C ^501
 214  C ^502
 215  C ^503
 216  C ^504
 217  T ^512
 218  T ^523
 219  P ^510
 220  P ^511
 221  S ^541
 222  S ^550[ \-]5\.4\.1
 223  P ^550([ \-]5\.1\.1)?
 224  C ^551
 225  S DNSBL
 226  S Blacklist
 227  S reputation
 228  S client host .* blocked
 229  S verification failed
 230  S verify failed
 231  S policy reasons
 232  S not authorized
 233  S refused
 234  S spammer
 235  S DYN:T1
 236  S (CON:B1)
 237  T currently suspended
 238  T temporarily disabled
 239  T unrouteable address
 240  T Mailbox is inactive
 241  T over quota
 242  T account has been disabled
 243  T timeout exceeded
 244  T quota exceeded
 245  T Delivery attempts will continue
 246  P is unavailable
 247  P not available
 248  P user doesn\'t have a .+ account
 249  P invalid recipient
 250  P does not like recipient
 251  P not our customer
 252  P no such user
 253  P addressee unknown
 254  P address rejected
 255  P permanent delivery error
 256  P permanent error
 257  P mailbox unavailable
 258  P no mailbox here by that name
 259  P mailbox has been blocked
 260  C relay denied
 261  C relaying denied
 262  C message size exceeds',
 263  
 264          'general_xmlrpc' => 1,
 265          'xmlrpc_default_title' => '',                // default title for posts created throgh blogger api
 266  
 267          'nickname_editing'   => 'edited-user',        // "never" - Never allow; "default-no" - Let users decide, default to "no" for new users; "default-yes" - Let users decide, default to "yes" for new users; "always" - Always allow
 268          'firstname_editing'  => 'edited-user',        // "edited-user" - Can be edited by user; "edited-admin" - Can be edited by admins only, "hidden" - Hidden for all
 269          'lastname_editing'   => 'edited-user',        // "edited-user" - Can be edited by user; "edited-admin" - Can be edited by admins only, "hidden" - Hidden for all
 270          'location_country'   => 'optional', // Editing mode of country for user:   "optional" | "required" | "hidden"
 271          'location_region'    => 'optional', // Editing mode of region for user:    "optional" | "required" | "hidden"
 272          'location_subregion' => 'optional', // Editing mode of subregion for user: "optional" | "required" | "hidden"
 273          'location_city'      => 'optional', // Editing mode of city for user:      "optional" | "required" | "hidden"
 274          'minimum_age'        => '13', // Minimum age for user forms
 275          'multiple_sessions'  => 'userset_default_no', // multiple sessions settings -- overriden for demo mode in contructor
 276          'emails_msgform'     => 'adminset', // Receiving emails through a message form is allowed: "never" | "adminset" | "userset"
 277  
 278      // Display options:
 279          'use_gravatar' => 1, // Use gravatar if a user has not uploaded a profile picture
 280          'default_gravatar' => 'b2evo', // Gravatar type: 'b2evo', '', 'identicon', 'monsterid', 'wavatar', 'retro'
 281          'bubbletip' => 1, // Display bubletips in the Back-office
 282          'bubbletip_size_admin' => 'fit-160x160', // Avatar size in the bubbletip in the Back-office
 283          'bubbletip_size_front' => 'fit-160x160', // Avatar size in the bubbletip in the Front-office
 284          'bubbletip_anonymous' => 1, // Display bubbletips in Front-office for anonymous users
 285          'bubbletip_size_anonymous' => 'fit-160x160-blur-18', // Avatar size in the bubbletip in the Front-office for anonymous users
 286          'bubbletip_overlay' => "Log in to\r\nsee this\r\nimage",// Overlay text on the profile image for anonymous users
 287          'allow_anonymous_user_list' => 1, // Allow anonymous users to see user list (disp=users)
 288          'allow_anonymous_user_profiles' => 0, // Allow anonymous users to see the user display ( disp=user )
 289  
 290      // Back-end settings, these can't be modified by the users:
 291          'last_invalidation_timestamp' => 0,
 292      );
 293  
 294  
 295      /**
 296       * Constructor.
 297       *
 298       * This loads the general settings and checks db_version.
 299       *
 300       * It will also turn off error-reporting/halting of the {@link $DB DB object}
 301       * temporarily to present a more decent error message if tables do not exist yet.
 302       *
 303       * Because the {@link $DB DB object} itself creates a connection when it gets
 304       * created "Error selecting database" occurs before we can check for it here.
 305       */
 306  	function GeneralSettings()
 307      {
 308          global $new_db_version, $DB, $demo_mode, $instance_name, $basehost;
 309  
 310          $save_DB_show_errors = $DB->show_errors;
 311          $save_DB_halt_on_error = $DB->halt_on_error;
 312          $DB->halt_on_error = false;
 313          $DB->show_errors = false;
 314  
 315          // Init through the abstract constructor. This should be the first DB connection.
 316          parent::AbstractSettings( 'T_settings', array( 'set_name' ), 'set_value', 0 );
 317  
 318          // check DB version:
 319          if( $this->get( 'db_version' ) != $new_db_version )
 320          { // Database is not up to date:
 321              if( $DB->last_error )
 322              {
 323                  $error_message = '<p>MySQL error:</p>'.$DB->last_error;
 324              }
 325              else
 326              {
 327                  $error_message = '<p>Database schema is not up to date!</p>'
 328                      .'<p>You have schema version &laquo;'.(integer)$this->get( 'db_version' ).'&raquo;, '
 329                      .'but we would need &laquo;'.(integer)$new_db_version.'&raquo;.</p>';
 330              }
 331              global $adminskins_path;
 332              require $adminskins_path.'conf_error.main.php'; // error & exit
 333          }
 334  
 335          $DB->halt_on_error = $save_DB_halt_on_error;
 336          $DB->show_errors = $save_DB_show_errors;
 337  
 338  
 339          if( $demo_mode )
 340          { // Demo mode requires to allow multiple concurrent sessions:
 341              $this->_defaults['multiple_sessions'] = 'always';
 342          }
 343  
 344          // set those defaults which needs some global variables
 345          $this->_defaults['notification_sender_email'] = $instance_name.'-noreply@'.preg_replace( '/^www\./i', '', $basehost );
 346          $this->_defaults['notification_return_path'] = $instance_name.'-return@'.preg_replace( '/^www\./i', '', $basehost );
 347      }
 348  
 349  
 350      /**
 351       * Get a 32-byte string that can be used as salt for public keys.
 352       *
 353       * @return string
 354       */
 355  	function get_public_key_salt()
 356      {
 357          $public_key_salt = $this->get( 'public_key_salt' );
 358          if( empty($public_key_salt) )
 359          {
 360              $public_key_salt = generate_random_key(32);
 361              $this->set( 'public_key_salt', $public_key_salt );
 362              $this->dbupdate();
 363          }
 364          return $public_key_salt;
 365      }
 366  
 367  
 368      /**
 369       * Get a member param by its name
 370       *
 371       * @param mixed Name of parameter
 372       * @param boolean true to return param's real value
 373       * @return mixed Value of parameter
 374       */
 375  	function get( $parname, $real_value = false )
 376      {
 377          if( $real_value )
 378          {
 379              return parent::get( $parname );
 380          }
 381  
 382          switch($parname)
 383          {
 384              case 'allow_avatars':
 385                  return ( parent::get( $parname ) && isset($GLOBALS['files_Module']) );
 386                  break;
 387  
 388              case 'upload_enabled':
 389                  return ( parent::get( $parname ) && isset($GLOBALS['files_Module']) );
 390                  break;
 391  
 392              default:
 393                  return parent::get( $parname );
 394          }
 395      }
 396  
 397  }
 398  
 399  ?>

title

Description

title

Description

title

Description

title

title

Body