Permalink
Browse files

Merge branch 'SMF_tools'

Conflicts:
	README.md
	repair_settings.php
  • Loading branch information...
2 parents de4026d + db9a843 commit 8d3c867747f8f010c28b43398fe92a95e8c5d09d @emanuele45 emanuele45 committed Sep 21, 2012
Showing with 80 additions and 11 deletions.
  1. +25 −0 DCO.txt
  2. +18 −1 README.md
  3. +37 −10 repair_settings.php
View
@@ -0,0 +1,25 @@
+Developer's Certificate of Origin 1.1
+
+ By making a contribution to this project, I certify that:
+
+ (a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+ (b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+ (c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+ (d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
View
@@ -17,4 +17,21 @@ All scripts in this repository are under BSD 3-clause license, unless specified
# Tools download
-Apart from cloning the repo, you can find the files more useful to end-users at the [download page](https://github.com/emanuele45/tools/downloads)
+Apart from cloning the repo, you can find the files more useful to end-users at the [download page](https://github.com/emanuele45/tools/downloads)
+=======
+SMF Tools repository.
+
+This repository contains a few useful scripts for SMF, such as install/upgrade or repair scripts, database cleaning up, etc.
+All scripts in this repository are under [BSD 3-clause license](http://www.opensource.org/licenses/BSD-3-Clause) license, unless specified otherwise.
+
+Feel free to fork this repository and make your desired changes.
+
+Please see the [Developer's Certificate of Origin](https://github.com/norv/tools/blob/master/DCO.txt) in the repository:
+by signing off your contributions, you acknowledge that you can and do license your submissions under the license of the software.
+
+######How to contribute:
+* fork the repository. If you are not used to Github, please check out [fork a repository](http://help.github.com/fork-a-repo).
+* branch your repository, to commit the desired changes.
+* sign-off your commits, to acknowledge your submission under the license of the project.
+ * an easy way to do so, is to define an alias for the git commit command, which includes -s switch (reference: [How to create Git aliases](http://githacks.com/post/1168909216/how-to-create-git-aliases))
+* send a pull request to us.
View
@@ -25,6 +25,7 @@
$txt['other_possible_value'] = 'Other possible value';
$txt['no_default_value'] = 'No recommended value';
$txt['save_settings'] = 'Save Settings';
+$txt['remove_hooks'] = 'Remove all hooks';
$txt['restore_all_settings'] = 'Restore all settings';
$txt['not_writable'] = 'Settings.php cannot be written to by your webserver. Please modify the permissions on this file to allow write access.';
$txt['recommend_blank'] = '<em>(blank)</em>';
@@ -93,6 +94,8 @@
if (isset($_POST['submit']))
set_settings();
+if (isset($_POST['remove_hooks']))
+ remove_hooks();
// try to find the smflogo: could be a .gif or a .png
$smflogo = "Themes/default/images/smflogo.png";
@@ -229,17 +232,24 @@ function initialize_inputs()
ini_set('session.save_handler', 'files');
@session_start();
- // Add slashes, as long as they aren't already being added.
- if (!function_exists('get_magic_quotes_gpc') || @get_magic_quotes_gpc() == 0)
+ // Slashes as soo old-fashion...
+ if (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc() != 0)
{
foreach ($_POST as $k => $v)
- {
if (is_array($v))
foreach ($v as $k2 => $v2)
- $_POST[$k][$k2] = addslashes($v2);
+ $_POST[$k][$k2] = stripslashes($v2);
else
- $_POST[$k] = addslashes($v);
- }
+ $_POST[$k] = stripslashes($v);
+ }
+
+ foreach ($_POST as $k => $v)
+ {
+ if (is_array($v))
+ foreach ($v as $k2 => $v2)
+ $_POST[$k][$k2] = addcslashes($v2, '\'');
+ else
+ $_POST[$k] = addcslashes($v, '\'');
}
// This is really quite simple; if ?delete is on the URL, delete the installer...
@@ -305,7 +315,7 @@ function show_settings()
if (isset($settingsArray[$i][0]) && $settingsArray[$i][0] != '.')
{
- preg_match('~^[$]([a-zA-Z_]+)\s*=\s*(["\'])?(.*?)(?:\\2)?;~', $settingsArray[$i], $match);
+ preg_match('~^[$]([a-zA-Z_]+)\s*=\s*(?:(["\'])(.*?["\'])(?:\\2)?|(.*?)(?:\\2)?);~', $settingsArray[$i], $match);
if (isset($match[3]))
{
if ($match[3] == 'dirname(__FILE__)')
@@ -555,7 +565,7 @@ function restoreAll()
elseif ($info[1] == 'string')
{
echo '
- <input type="text" name="', $info[0], 'settings[', $setting, ']" id="', $setting, '" value="', isset($settings[$setting]) ? $settings[$setting] : '', '" size="', $settings_section == 'path_url_settings' || $settings_section == 'theme_path_url_settings' ? '60" style="width: 80%;' : '30', '" class="input_text" />';
+ <input type="text" name="', $info[0], 'settings[', $setting, ']" id="', $setting, '" value="', isset($settings[$setting]) ? htmlspecialchars($settings[$setting]) : '', '" size="', $settings_section == 'path_url_settings' || $settings_section == 'theme_path_url_settings' ? '60" style="width: 80%;' : '30', '" class="input_text" />';
if (isset($info[2]))
echo '
@@ -642,7 +652,8 @@ function restoreAll()
else
echo '
[<a href="javascript:restoreAll();">', $txt['restore_all_settings'], '</a>]
- <input type="submit" name="submit" value="', $txt['save_settings'], '" class="button_submit" />';
+ <input type="submit" name="submit" value="', $txt['save_settings'], '" class="button_submit" />', $context['is_legacy'] ? '' : '
+ <input type="submit" name="remove_hooks" value="' . $txt['remove_hooks'] . '" class="button_submit" />';
echo '
</div>
@@ -757,7 +768,7 @@ function set_settings()
continue;
}
- if (isset($settingsArray[$i][0]) && $settingsArray[$i][0] != '.' && preg_match('~^[$]([a-zA-Z_]+)\s*=\s*(["\'])?(.*?)(?:\\2)?;~', $settingsArray[$i], $match) == 1)
+ if (isset($settingsArray[$i][0]) && $settingsArray[$i][0] != '.' && preg_match('~^[$]([a-zA-Z_]+)\s*=\s*(?:(["\'])(.*?["\'])(?:\\2)?|(.*?)(?:\\2)?);~', $settingsArray[$i], $match) == 1)
$settings[$match[1]] = stripslashes($match[3]);
foreach ($file_updates as $var => $val)
@@ -865,6 +876,22 @@ function set_settings()
);
}
+function remove_hooks()
+{
+ global $smcFunc;
+
+ $smcFunc['db_query']('', '
+ DELETE FROM {db_prefix}settings
+ WHERE variable LIKE {string:variable}%',
+ array(
+ 'variable' => 'integrate_'
+ )
+ );
+
+ // Now fixing the cache...
+ cache_put_data('modsettings', null, 0);
+}
+
// Compat mode!
function smc_compat_initiate($db_server, $db_name, $db_user, $db_passwd, $db_prefix, $db_options = array())
{

0 comments on commit 8d3c867

Please sign in to comment.