I'm testing a mod I created (first try :D) and when including code, the package parser returns a "Hacking Attempt" message.
I checked the Error Log, it seems this query is the problem:
ALTER TABLE {$db_prefix}boards ADD hideBoard TINYINT NOT NULL DEFAULT '0';
Any help? Thanks :]
What is the full error message in the error log?
"Hacking attempt...
ALTER TABLE (my database prefix)_boards ADD hideBoard TINYINT NOT NULL DEFAULT '0';
File: /home/themfu5/public_html/test/Packages/temp/addSetting.php
Line: 10"
Can I see the addSetting.php?
It's just:
<?php
$result = db_query("
ALTER TABLE {$db_prefix}boards ADD hideBoard TINYINT NOT NULL DEFAULT '0';", __FILE__, __LINE__);
?>
Am I not supposed to do that? o_O
Nope, you need to add this before the query so that SMF doesn't think some random hacker is doing it:
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
Check out the reference add_settings.php in the package SDK ;)
Thanks. Now it looks like this:
<?php
// If SSI.php is in the same place as this file, and SMF isn't defined, this is being run standalone.
if (file_exists(dirname(__FILE__) . '/SSI.php') && !defined('SMF'))
require_once(dirname(__FILE__) . '/SSI.php');
// Hmm... no SSI.php and no SMF?
elseif (!defined('SMF'))
die('<b>Error:</b> Cannot install - please verify you put this in the same place as SMF\'s index.php.');
$result = db_query("
ALTER TABLE {$db_prefix}boards ADD hideBoard TINYINT NOT NULL DEFAULT '0';", __FILE__, __LINE__);
?>
but it still doesn't work.
ok, just get rid of what i told you to add and throw this in:
define('SMF');
Sorry, but it still doesn't work.
I tried to shorten the query to:
ALTER TABLE {$db_prefix}boards ADD hideBoard;
but it still doesn't work. I took the code out completely and it worked.
You're using TINYINT (an integer type), not a varchar, so instead of this:
TINYINT NOT NULL DEFAULT '0';
try using this:
TINYINT NOT NULL DEFAULT 0;
I figured out the problem: I removed the semicolon at the end.
Apparently this (Subs.php, line 303) was causing the problem:
// Comments? We don't use comments in our queries, we leave 'em outside!
elseif (strpos($clean, '/*') > 2 || strpos($clean, '--') !== false || strpos($clean, ';') !== false)
$fail = true;