Skip to content

Commit

Permalink
Merge pull request #166 from norv/misc
Browse files Browse the repository at this point in the history
Misc
  • Loading branch information
norv committed Feb 26, 2013
2 parents 97d1490 + 6a20420 commit 6b5b9d5
Show file tree
Hide file tree
Showing 141 changed files with 394 additions and 285 deletions.
22 changes: 19 additions & 3 deletions install/install.php
Expand Up @@ -375,6 +375,11 @@ function installExit($fallThrough = false)
die();
}

/**
* Welcome screen.
* It makes a few basic checks for compatibility
* and informs the user if there are problems.
*/
function action_welcome()
{
global $incontext, $txt, $databases, $installurl;
Expand Down Expand Up @@ -1368,7 +1373,7 @@ function action_deleteInstall()

require(dirname(__FILE__) . '/Settings.php');
load_database();

if (!defined('SUBSDIR'))
define('SUBSDIR', dirname(__FILE__) . '/sources/subs');

Expand Down Expand Up @@ -1850,6 +1855,13 @@ function close()
}
}

/**
* Write out the contents of Settings.php file.
* This function will add the variables passed to it in $vars,
* to the Settings.php file.
*
* @param array $vars the configuration variables to write out.
*/
function updateSettingsFile($vars)
{
// Modify Settings.php.
Expand Down Expand Up @@ -1919,6 +1931,9 @@ function updateSettingsFile($vars)
return true;
}

/**
* Write the db_last_error file.
*/
function updateDbLastError()
{
// Write out the db_last_error file with the error timestamp
Expand All @@ -1927,7 +1942,8 @@ function updateDbLastError()
}

/**
* Create an .htaccess file to prevent mod_security. Elkarte has filtering built-in.
* Create an .htaccess file to prevent mod_security.
* Elkarte has filtering built-in.
*/
function fixModSecurity()
{
Expand Down Expand Up @@ -2578,4 +2594,4 @@ function doTheDelete()
', sprintf($txt['go_to_your_forum'], $boardurl . '/index.php'), '<br />
<br />
', $txt['good_luck'];
}
}
2 changes: 1 addition & 1 deletion sources/BrowserDetect.class.php
Expand Up @@ -16,7 +16,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* This class is an experiment for the job of correctly detecting browsers and settings needed for them.
Expand Down
2 changes: 1 addition & 1 deletion sources/Combine.class.php
Expand Up @@ -9,7 +9,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Used to combine css or js files in to a single file
Expand Down
2 changes: 1 addition & 1 deletion sources/CurlFetchWeb.class.php
Expand Up @@ -10,7 +10,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Simple cURL class to fetch a web page
Expand Down
2 changes: 1 addition & 1 deletion sources/Dispatcher.class.php
Expand Up @@ -10,7 +10,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Dispatch the request to the function or method registered to handle it.
Expand Down
2 changes: 1 addition & 1 deletion sources/DumpDatabase.php
Expand Up @@ -18,7 +18,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Dumps the database.
Expand Down
2 changes: 1 addition & 1 deletion sources/Errors.php
Expand Up @@ -20,7 +20,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Log an error, if the error logging is enabled.
Expand Down
69 changes: 60 additions & 9 deletions sources/Load.php
Expand Up @@ -18,7 +18,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Load the $modSettings array.
Expand Down Expand Up @@ -280,7 +280,7 @@ function loadUserSettings()

if(!empty($modSettings['avatar_default']) && empty($user_settings['avatar']) && empty($user_settings['filename']))
$user_settings['avatar'] = $settings['images_url'] . '/default_avatar.png';

if (!empty($modSettings['cache_enable']) && $modSettings['cache_enable'] >= 2)
cache_put_data('user_settings-' . $id_member, $user_settings, 60);
}
Expand Down Expand Up @@ -1686,6 +1686,60 @@ function smfAutoTask()
$context['theme_loaded'] = true;
}

/**
* This loads the bare minimum data.
* Needed by scheduled tasks, and any other code that needs language files
* before the forum (the theme) is loaded.
*/
function loadEssentialThemeData()
{
global $settings, $modSettings, $smcFunc, $mbname, $context;

// Get all the default theme variables.
$result = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE id_member = {int:no_member}
AND id_theme IN (1, {int:theme_guests})',
array(
'no_member' => 0,
'theme_guests' => $modSettings['theme_guests'],
)
);
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$settings[$row['variable']] = $row['value'];

// Is this the default theme?
if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
$settings['default_' . $row['variable']] = $row['value'];
}
$smcFunc['db_free_result']($result);

// Check we have some directories setup.
if (empty($settings['template_dirs']))
{
$settings['template_dirs'] = array($settings['theme_dir']);

// Based on theme (if there is one).
if (!empty($settings['base_theme_dir']))
$settings['template_dirs'][] = $settings['base_theme_dir'];

// Lastly the default theme.
if ($settings['theme_dir'] != $settings['default_theme_dir'])
$settings['template_dirs'][] = $settings['default_theme_dir'];
}

// Assume we want this.
$context['forum_name'] = $mbname;

// Check loadLanguage actually exists!
if (!function_exists('loadLanguage'))
require_once(SOURCEDIR . '/Subs.php');

loadLanguage('index+Modifications');
}

/**
* Load a template - if the theme doesn't include it, use the default.
* What this function does:
Expand Down Expand Up @@ -2035,10 +2089,7 @@ function loadLanguage($template_name, $lang = '', $fatal = true, $force_reload =

// Make sure we have $settings - if not we're in trouble and need to find it!
if (empty($settings['default_theme_dir']))
{
require_once(SOURCEDIR . '/ScheduledTasks.php');
loadEssentialThemeData();
}

// What theme are we in?
$theme_name = basename($settings['theme_url']);
Expand Down Expand Up @@ -2540,7 +2591,7 @@ function loadDatabase()
}
/**
* Determine the user's avatar type and return the information as an array
*
*
* @param array $profile
* @param type $max_avatar_width
* @param type $max_avatar_height
Expand Down Expand Up @@ -2577,7 +2628,7 @@ function determineAvatar($profile, $max_avatar_width, $max_avatar_height)
{
// Gravatars URL.
$gravatar_url = 'http://www.gravatar.com/avatar/' . md5(strtolower($profile['email_address'])) . 'd=' . $modSettings['avatar_max_height_external'] . (!empty($modSettings['gravatar_rating']) ? ('&r=' . $modSettings['gravatar_rating']) : '');

$avatar = array(
'name' => $profile['avatar'],
'image' => '<img src="' . $gravatar_url . '" alt="" class="avatar" border="0" />',
Expand All @@ -2592,7 +2643,7 @@ function determineAvatar($profile, $max_avatar_width, $max_avatar_height)
$avatar = array(
'name' => $profile['avatar'],
'image' => '<img class="avatar" src="' . $modSettings['avatar_url'] . '/' . $profile['avatar'] . '" alt="" />',
'href' => $modSettings['avatar_url'] . '/' . $profile['avatar'],
'href' => $modSettings['avatar_url'] . '/' . $profile['avatar'],
'url' => $modSettings['avatar_url'] . '/' . $profile['avatar'],
);
}
Expand All @@ -2605,7 +2656,7 @@ function determineAvatar($profile, $max_avatar_width, $max_avatar_height)
'image' => '<img src="' . $settings['images_url'] . '/default_avatar.png' . '" alt="" class="avatar" border="0" />',
'href' => $settings['images_url'] . '/default_avatar.png',
'url' => 'http://',
);
);
}
//finally ...
else
Expand Down
2 changes: 1 addition & 1 deletion sources/Logging.php
Expand Up @@ -18,7 +18,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Put this user in the online log.
Expand Down
2 changes: 1 addition & 1 deletion sources/QueryString.php
Expand Up @@ -19,7 +19,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* Clean the request variables - add html entities to GET and slashes if magic_quotes_gpc is Off.
Expand Down
76 changes: 6 additions & 70 deletions sources/ScheduledTasks.php
Expand Up @@ -18,7 +18,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* This function works out what to do!
Expand Down Expand Up @@ -1193,62 +1193,7 @@ function next_time($regularity, $unit, $offset)
}

/**
* This loads the bare minimum data to allow us to load language files!
*/
function loadEssentialThemeData()
{
global $settings, $modSettings, $smcFunc, $mbname, $context;

// Get all the default theme variables.
$result = $smcFunc['db_query']('', '
SELECT id_theme, variable, value
FROM {db_prefix}themes
WHERE id_member = {int:no_member}
AND id_theme IN (1, {int:theme_guests})',
array(
'no_member' => 0,
'theme_guests' => $modSettings['theme_guests'],
)
);
while ($row = $smcFunc['db_fetch_assoc']($result))
{
$settings[$row['variable']] = $row['value'];

// Is this the default theme?
if (in_array($row['variable'], array('theme_dir', 'theme_url', 'images_url')) && $row['id_theme'] == '1')
$settings['default_' . $row['variable']] = $row['value'];
}
$smcFunc['db_free_result']($result);

// Check we have some directories setup.
if (empty($settings['template_dirs']))
{
$settings['template_dirs'] = array($settings['theme_dir']);

// Based on theme (if there is one).
if (!empty($settings['base_theme_dir']))
$settings['template_dirs'][] = $settings['base_theme_dir'];

// Lastly the default theme.
if ($settings['theme_dir'] != $settings['default_theme_dir'])
$settings['template_dirs'][] = $settings['default_theme_dir'];
}

// Assume we want this.
$context['forum_name'] = $mbname;

// Check loadLanguage actually exists!
if (!function_exists('loadLanguage'))
{
require_once(SOURCEDIR . '/Load.php');
require_once(SOURCEDIR . '/Subs.php');
}

loadLanguage('index+Modifications');
}

/**
* This retieves data (e.g. last version of ELKARTE)
* This retrieves data (e.g. last version of ELKARTE)
*/
function scheduled_fetchFiles()
{
Expand Down Expand Up @@ -1315,7 +1260,8 @@ function scheduled_fetchFiles()
}

/**
* Happy birthday!!
* Schedule birthday emails.
* (aka "Happy birthday!!")
*/
function scheduled_birthdayemails()
{
Expand Down Expand Up @@ -1688,18 +1634,8 @@ function scheduled_remove_temp_attachments()
global $modSettings;

// We need to know where this thing is going.
if (!empty($modSettings['currentAttachmentUploadDir']))
{
if (!is_array($modSettings['attachmentUploadDir']))
$modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);

// Just use the current path for temp files.
$attach_dirs = $modSettings['attachmentUploadDir'];
}
else
{
$attach_dirs = array($modSettings['attachmentUploadDir']);
}
require_once(SUBSDIR . '/Attachment.subs.php');
$attach_dirs = attachmentPaths();

foreach ($attach_dirs as $attach_dir)
{
Expand Down
2 changes: 1 addition & 1 deletion sources/SearchAPI-Custom.class.php
Expand Up @@ -16,7 +16,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* SearchAPI-Custom.php, Custom Search API class .. used when custom ELKARTE index is used
Expand Down
2 changes: 1 addition & 1 deletion sources/SearchAPI-Fulltext.class.php
Expand Up @@ -16,7 +16,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* SearchAPI-Fulltext.php, Fulltext API, used when an SQL fulltext index is used
Expand Down
2 changes: 1 addition & 1 deletion sources/SearchAPI-Sphinx.class.php
Expand Up @@ -16,7 +16,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* SearchAPI-Sphinx.php, used when an Sphinx search daemon is used and access is via
Expand Down
2 changes: 1 addition & 1 deletion sources/SearchAPI-Sphinxql.class.php
Expand Up @@ -16,7 +16,7 @@
*/

if (!defined('ELKARTE'))
die('Hacking attempt...');
die('No access...');

/**
* SearchAPI-Sphinxql.php, used when an Sphinx search daemon is used and you want to access it
Expand Down

0 comments on commit 6b5b9d5

Please sign in to comment.