i belive fopen is whats its called, the system used for the agreement, for my admin nopepad mod would that be beter or worse than storing it in the db, also if i use that how would i tell it to ask for ftp info to chmod the AdminNotes.txt file to 777, or can i not do that?
I would recommend you use the database, personally - a row in the settings table, for example. A flat file is better for something that rarely changes, and an "admin notepad" is something I would expect to (if used) change every once and a while. For that, the database is probably better.
-[Unknown]
ok, and it would require a bit more work ratheer than basically copying the agreement file code over, lol, but ok, now i have to figure out how to setup the query.
Maybe something like this:
http://www.w3schools.com/sql/sql_insert.asp
http://www.w3schools.com/sql/sql_update.asp
http://www.w3schools.com/sql/sql_create.asp
im still learning but those are useful.
ok i think i got a query
QuoteSELECT value
FROM `smf_settings`
WHERE variable 'AdminPad'
LIMIT 0 , 30
and
QuoteSELECT value
FROM `smf_settings`
WHERE variable IS 'AdminPad'
LIMIT 0 , 30
after adding a valude AdminPad in the settings table with valuse being what is show in the adminpad. The problem is is that when i try this query in phpmyadmin to make sure it will work i get this error
QuoteMySQL said:
#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near ''AdminPad' LIMIT 0, 30' at line 1
I thought in the smf_settings table it would find the row where varibale is adminpad and return what the value is. How would I do that? And http://www.w3schools.com/sql/sql_select.asp didn't really help, that just proved to me i got the basic syantax right. :-\
Quote from: Trekkie101 on February 24, 2005, 11:39:21 AM
Maybe something like this:
http://www.w3schools.com/sql/sql_insert.asp
http://www.w3schools.com/sql/sql_update.asp
http://www.w3schools.com/sql/sql_create.asp
im still learning but those are useful.
If it's for SMF, you would be better off using the SMF database functions.
ok....those would be?
Have a look at how smf does it's queries elsewhere, I don't have the sources in front of me right now.
It's actually very easy ^_^. Examples:
Get the admin notes:
echo $modSettings['admin_notes'];
Set the admin notes:
updateSettings(array('admin_notes' => $_POST['admin_notes']));
Delete said notes:
updateSettings(array('admin_notes' => ''));
-[Unknown]
ok seems easy enough, here is my code:
echo ("<textarea name=\"adminpad\" height=\"6\" width=\"40\">") echo $modSettings['admin_notes']; echo ("</textarea>")
echo ("<br> <input name=\"update\" type=\"button\" onclick=\"updateSettings(array('admin_notes' => $_POST['admin_notes']));\">")
Any one wanna bet there are multipule syantax errors in it, lol.
Quote from: RyanB on February 25, 2005, 12:40:54 AM
ok seems easy enough, here is my code:
echo ("<textarea name=\"adminpad\" height=\"6\" width=\"40\">") echo $modSettings['admin_notes']; echo ("</textarea>")
echo ("<br> <input name=\"update\" type=\"button\" onclick=\"updateSettings(array('admin_notes' => $_POST['admin_notes']));\">")
Any one wanna bet there are multipule syantax errors in it, lol.
Actually, no, that won't quite work...
if (isset($_POST['adminpad']))
updateSettings(array('adminpad' => $_POST['adminpad']));
echo '
<form action=", $scripturl, '?action=admin" method="post">
<textarea name="adminpad" height="6" width="40">', $modSettings['adminpad'], '</textarea><br />
<input type="submit" value="Update" />
</form>';-[Unknown]
ok that makes sense, and that goes in admin.php right, then is anything needed in a theme file?
I am almost done...I think...
Quote from: RyanB on February 25, 2005, 01:41:54 AM
ok that makes sense, and that goes in admin.php right, then is anything needed in a theme file?
I am almost done...I think...
Actually, that could all go in the theme file and it would work. Otherwise, youi'd have to put the echo part in the template and the other part in Admin.php.
-[Unknown]
ok, yay, then my first mod is nearly done!
ok add_settings.php
<?php
// Set the below to true to overwrite already existing settings with the defaults. (not recommended.)
$overwrite_old_settings = false;
// List settings here in the format: setting_key => default_value. Escape any "s. (" => \")
$mod_settings = array(
'variable' => 'adminpad',
'value' => 'Admin Notepad!',
);
/******************************************************************************/
// 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.');
// Turn the array defined above into a string of MySQL data.
$string = '';
foreach ($mod_settings as $k => $v)
$string .= '
(\'' . $k . '\', \'' . $v . '\'),';
// Sorted out the array defined above - now insert the data!
if ($string != '')
$result = db_query("
" . ($overwrite_old_settings ? 'REPLACE' : 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" . substr($string, 0, -1));
// Uh-oh spaghetti-oh!
if ($result === false)
echo '<b>Error:</b> Database modifications failed!';
?>
ok so is that right?
Yep, that looks fine. And, for the package-info.xml, etc... all I should note is two things:
1. The id should have your name in it (e.g. ryanb:adminpad)...
2. The id should not have a version number in it, except maybe major.
-[Unknown]
yah i got that much, i tried the add_settings.php file out and got this error
QuoteWarning: Missing argument 2 for db_query() in /home/chf/public_html/forums/Sources/Subs.php on line 216
Warning: Missing argument 3 for db_query() in /home/chf/public_html/forums/Sources/Subs.php on line 216
line 216 of subs.php reads
function db_query($db_string, $file, $line)
Sorry, that's an older version I think. Just add:
, __FILE__, __LINE__
To the lines that look like this:
$result = db_query("
" . ($overwrite_old_settings ? 'REPLACE' : 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" . substr($string, 0, -1));
Like so:
$result = db_query("
" . ($overwrite_old_settings ? 'REPLACE' : 'INSERT IGNORE') . " INTO {$db_prefix}settings
(variable, value)
VALUES" . substr($string, 0, -1), __FILE__, __LINE__);
-[Unknown]
ok thanks i tested it and it worked, thanks for all your help
as for this being moved this is NOT a tip or trick its a mod, i was going to delete it cause i am not quite ready to release it but now the code is here, so if you were going to do this, why did i spend an hour or two packaging it up?