PDA

View Full Version : Would you be interested in a version which .....


sv1cec
03-12-2005, 05:04 AM
Gentlemen,

I have a friend here, who keeps bugging me to edit the code of AWS, to use $vboptions variables, instead of storing the warning system options in a separate table. This, reduces the number of queries AWS does, by one, every time you run Warn.php to warn someone or to view someone warnings. It doesn't query the `warning_options` table, the info is now stored in the `setting` table and cached in the $vboptions variables.

Admitedly, this friend has done a lot of work to help me change AWS to this form, but there is still work to be done by me, and of course, I need to use my live board as a test engironment, for this version (my Sun decided that it had enough and started going south on me, so I do not have another test environment).

So, if you are so kind, please vote in the poll here, to let me know if such a change would interest you.

Kind regards

lasto
03-12-2005, 05:18 AM
well tbh anything that uses less queries would be of great benefit and if u can release this top hack with same functions,with less then im all for it.

SkyShadow
03-12-2005, 07:36 AM
I think it would be great for the performance.
I vote for a change.
Also it would be fine if you can make a "fully phrased" version.

Revan
03-12-2005, 08:20 AM
Guess 15 times what I voted ;)

What other work needs to be done? Unless the native warning templates contain references to $warn_opts (I know I forgot to bundle these) then it does work.
(So if you are referencing to these new templates then I will make an .xml file)

sv1cec
03-12-2005, 08:35 AM
Guess 15 times what I voted ;)

What other work needs to be done? Unless the native warning templates contain references to $warn_opts (I know I forgot to bundle these) then it does work.
(So if you are referencing to these new templates then I will make an .xml file)
So, do you mean, that I can go ahead and use this version on my active site, and it will work, as is? I do not think the templates contain references to $warn_opts, but I can check that out easily. Is Warn.php done already? I didn't check everything you send me, just the installation script and the admin_warn.php.

Back to do more work.

Revan
03-12-2005, 04:44 PM
Yes, every single file and file/template edit will work as is.

sv1cec
03-14-2005, 08:30 AM
Yes, every single file and file/template edit will work as is.
Well, I uploaded the files and then run your script. It looks as if the $vboptions are set properly, BUT when you go to admin_warn to see (or reset them, AdminCP/Manage Warning Options) they do not show up correctly. What's the issue?

From what I saw, the script updated the $vboptions, with "Yes" and "No" values, instead of "1" and "0" values. The admin_warn.php expects to find 1 and zeros. All the program expects Yes and Nos, so I guess the admin_warn should be changed accordingly, to use Yes or Nos, these are used in templates as well.

Also, in the files you send me, there are a lot of things you have changed for your own environment (rpg_user for example). Could you please remove them?

Thanks and Rgds

Revan
03-14-2005, 02:29 PM
First of all, the Warning Options shows up just fine here.
Second, if you look through the Warn.php and the template edits, you will see it expects to see 1 and 0 too. As for the templates, this is something you have to change for yourself as I already stated I did not do those.
Thirdly, there is no such reference to "rpg_user" on my forum, as this would cause errors (since no such table exists). I will check it out though, and edit this post.

As I thought, NO files I sent you contain such a code. I have checked EVERY file. Please recheck your facts and files.
The word "rpg" appears a few times, because you included some redundant code that looks like ZT wrote, "rpg_option" and sum sh*t you obviously don't need.

Could you be more specific as to what exactly does not work in the warning options?
Error messages?

sv1cec
03-14-2005, 02:55 PM
First of all, the Warning Options shows up just fine here.
Second, if you look through the Warn.php and the template edits, you will see it expects to see 1 and 0 too. As for the templates, this is something you have to change for yourself as I already stated I did not do those.
Thirdly, there is no such reference to "rpg_user" on my forum, as this would cause errors (since no such table exists). I will check it out though, and edit this post.

As I thought, NO files I sent you contain such a code. I have checked EVERY file. Please recheck your facts and files.
The word "rpg" appears a few times, because you included some redundant code that looks like ZT wrote, "rpg_option" and sum sh*t you obviously don't need.

Could you be more specific as to what exactly does not work in the warning options?
Error messages?
Revan,

you were right about the rpg_ whatever thing, it is not your code. It's something ZT wrote and I inherited, I'll have to go through it and remove it.

The problem with the warning options is that when I run your warn_install_setting.php script, the $vboptions values are populated with 'Yes' and 'No's for the fields which are a Yes/No field. Then the admin_warn compares these values to 1's and 0's and of course, it never finds the proper values.

I am going to try it again, but I did follow your instructions, uploaded the files and run the script. The values in the `setting` table are 'Yes' and 'No's. If Warn.php checks for 1/0s and if the instructions for the template edits are for 1/0's then your script should set the value of the $vboptions not to Yes/No but to 1/0.

Does it make sense?

Update: I cleaned up the setting table and the phrase table and then re_run the script. The problem exists for the Yes/No fields. Again, the values it enters in the setting table are NOT 1 and 0 they are Yes and No. I assume you need to change your script a little so that when it finds a value of Yes, it replaces that with 1 and when it finds a value of No (in warning_options) it replaces that with 0.

Rgds

Revan
03-14-2005, 03:39 PM
Of course of course of the back of a horse! NOW I see!
I will write you a parser to fix this right away :)

Ok, this should do the trick.
In warn_install_setting.php, find (both instances of)

if ($custom == true)
{

Add AFTER

if ($insert == 'Yes')
{
$insert = 1;
}
else if ($insert == 'No')
{
$insert = 0;
}

sv1cec
03-15-2005, 07:06 AM
OK, I have the admin_warn.php working OK. There is one thing I want. How can I remove the Warning Hack line from the vBulletin Options? I want the options handled only from the Warning System menu.

I still want to figure out how the Upgrade Instructions need to be written. The people who are already using this hack, need to do several edits in their templates and files. The hack templates can be deleted and recreated from a new .xml file, which has the $vboption changes, so I need to come up with an upgrade script that will do that. The problem will be with the other changes in existing templates and in the php files.

I'll keep you posted.

Revan
03-15-2005, 11:30 AM
You cannot remove that line.
The only thing you can do is put all the Warning Options under a different category, which would serve no purpose.
EDIT: Actually, it would be possible through hacking the admincp/options.php file, but I must say I am highly against such an edit. It is 100% unneeded and adding more hassle to upgrading is not something anyone needs :p

As for the template delete, you have been smart enough to name all your templates with a prefix of warn_, so you can just place this somewhere:
$DB_site->query("DELETE FROM `" . TABLE_PREFIX . "template` WHERE `title` LIKE 'warn%' ");
(SELECT *
FROM `template`
WHERE title LIKE 'warn%' to test it )

sv1cec
03-15-2005, 12:12 PM
You cannot remove that line.
The only thing you can do is put all the Warning Options under a different category, which would serve no purpose.
EDIT: Actually, it would be possible through hacking the admincp/options.php file, but I must say I am highly against such an edit. It is 100% unneeded and adding more hassle to upgrading is not something anyone needs :p

As for the template delete, you have been smart enough to name all your templates with a prefix of warn_, so you can just place this somewhere:
$DB_site->query("DELETE FROM `" . TABLE_PREFIX . "template` WHERE `title` LIKE 'warn%' ");
(SELECT *
FROM `template`
WHERE title LIKE 'warn%' to test it )
That I've solved. I now have the following issue:

In admin_warn, where the program saves the warning options in the setting table, you have the following code:


foreach ($options as $opt => $value)
{
if (in_array($opt, $vboptions))
{
$DB_site->query("
UPDATE " . TABLE_PREFIX . "setting
SET value = '$value'
WHERE varname = '" . addslashes($opt) . "'
");
}
}


For some reason, the if does not seem to work. Whatever I change in the warning options page, does not get saved in the settings table. If I remove the conditional, then everything is saved fine. Any ideas?

Revan
03-15-2005, 03:51 PM
It works for me, but I can see how the if() is not needed.

sv1cec
03-16-2005, 03:25 AM
It works for me, but I can see how the if() is not needed.
That's what I though. Now you gave me an interesting day, having to change all the files because you decided to use 1/0's instead of 'Yes' and 'No' with those fields, and I am sure the users will have an equally fun time changing back all those things. But at least it seems as if it is working OK.

I am not sure I'll release it as it is. I think it will be too frustrating for the existing users to change everything to 1/0s. I may take the time to switch back to Yes and Nos again, just to help them out.

Rgds

Revan
03-16-2005, 05:19 AM
I am curious, exactly what changes do your users have to make? And I am equally curious as to why YOU had to change the files? I did provide you with all files and vB file edits 100% (if we disregard the if() problem above) working, so if you are indeed saying that you manually changed all files from YesNo to 1/0, then...meh I will keep my comments to myself :p
It's not like you have provided patch instructions for file upgrades for a long time, you always just say "reupload $files".
Of course, you CAN use Yes/No with the $vboptions as they are setup now, but it's more "vBish" to use 1/0 :p
Yes/No, 1/0, whatever. It is of no difference :p

sv1cec
03-16-2005, 05:35 AM
I am curious, exactly what changes do your users have to make? And I am equally curious as to why YOU had to change the files? I did provide you with all files and vB file edits 100% (if we disregard the if() problem above) working, so if you are indeed saying that you manually changed all files from YesNo to 1/0, then...meh I will keep my comments to myself :p
It's not like you have provided patch instructions for file upgrades for a long time, you always just say "reupload $files".
Of course, you CAN use Yes/No with the $vboptions as they are setup now, but it's more "vBish" to use 1/0 :p
Yes/No, 1/0, whatever. It is of no difference :p
Revan,

You are right, I do not provide patch instructions for AWS files. But you are forgetting one thing. AWS users have to change other php files too, such as showthread, editpost etc. The files you provided are perfect for a new installation (some minor issues were corrected, not important), but what about the other files? Files where checks are made to "Yes" or "No"? Also, they have to edit their already-changed templates, to change the comparisons from $hierarchical=='Yes' to $hierarchical==1 for example.When I come out with a new version, instructions are given on how to patch your files, in order to bring AWS up to the latest version. If you want to see what the instructions are (at this moment), have a look:


UPGRADE FROM VERSION 3.2.0 TO VERSION 3.3.0
-------------------------------------------

THIS IS A MAJOR UPDATE, SO PLEASE BACKUP YOUR DATABASE BEFORE PROCEEDING. ALSO, BACKUP YOUR php FILES BEFORE CHANGING ANYTHING.

With this release, one of the hack's tables is ommited and it is replaced with a new settings group. The reason for this, was to reduce the number of queries generated by the warning system. Even though this is not a query-intensive hack, I decided to do this change, in order to improve it even further. The idea behind this change originated from Revan (in vBulletin.org) who was instrumental in pushing me to do it.

In order to complete the update, several steps should be made, in the right order and in the proper sequence. Here are the steps you should follow.


1. Shut down your forums. This is not absolutely necessary, but it is a good precaution.


2. Upload all the files found in the zip file to your web server, in the proper directories.


3. Execute the following script from your admincp directory:

http://www.yoursite.com/admincp/vboptions_update.php

(replace the url above with the proper one. Also, make sure you enter the proper location for your admincp, in case it is not the standard one)

This step deletes the previous set of templates that AWS was using and is replacing them with new ones, which use the $vboptions variables.


4. Execute the following script from your admincp directory:

http://www.yoursite.com/admincp/warn_install_setting.php

This step will read your warning_options table and generate the necessary $vboptions variables, in your system.


5. Open your admincp/index.php file and find:

$DB_site->reporterror = 0;
$query="select * from ".TABLE_PREFIX."warning_options where oid='1'";
$DB_site->query($query);
$errornum = $DB_site->geterrno();
if ($errornum == '1146')
{
$aws='0';
}
else
{
$DB_site->reporterror = 1;
$warn_opts=$DB_site->query_first("select * from ".TABLE_PREFIX." warning_options where oid='1'");
$aws='1';
}


Delete that part entirely. It was used to make sure the warning_options table existed. Now this table is obsolete.

In the same file find:

// *************************************
// AWS Reminder
if ($aws=='0')
{
print_form_header('index', 'reminder');
print_table_header('Attention: Your files contain AWS code',1);
print_description_row('This file (admincp/index.php) probably contains code, associated with the Advanced Warning System (AWS).<p>If you have removed AWS from your system, you should also remove all the changes that you have done, in your PHP files and templates. Failing to do so, will lead to unexpected results. <p>Please clean up your files from changes done by AWS.');
print_table_footer();
}

Delete that section.

In the same file, find:

if ($warn_opts['automaticpm'] == 'Yes')
{
construct_nav_option ( 'View Auto-Warned PMs', 'admin_warn.php?act=viewwarnedpms', '<br />' ) ;
}

Replace that with:

if ($vboptions['warn_automaticpm'] == 1)
{
construct_nav_option('View Auto-Warned PMs', 'admin_warn.php?act=viewwarnedpms', '<br />');
}

Save file and upload.


6. Edit the following files:

showthread.php
member.php
newreply.php
editpost.php
private.php
newthread.php

In all those files, find every occurence of the text:

$warn_opts['

and replace it with the text

$vboptions['warn_

In the following files:

newreply.php
editpost.php
newthread.php

now find:

if ($vboptions['warn_automatic'] == 'Yes')

Replace that with:

if ($vboptions['warn_automatic'] == 1)

In the file private.php, find:

if ($vboptions['warn_automaticpm'] == 'Yes')

Replace that with:

if ($vboptions['warn_automaticpm'] == 1)

Save and upload all files.


7. Edit functions.php and find:

$warn_opts=$DB_site->query_first("select * from ".TABLE_PREFIX."warning_options where oid='1'");

Delete that line.

In the same file find every occurence of text:

$warn_opts['

and replace it with the text

$vboptions['warn_


8. Open your MEMBERINFO template and find:

$warn_opts[allowoffpost]=='Yes'

Replace that with

$vboptions[warn_allowoffpost]==1

Also find replace occurence of

$hierarchical=='No'

with

$hierarchical==0

and every occurence of

$hierarchical=='Yes'

with

$hierarchical==1


9. Open your postbit/postbit_legacy templates and replace every occurence of

$hierarchical=='No'

with

$hierarchical==0

and every occurence of

$hierarchical=='Yes'

with

$hierarchical==1


On the other hand, if I change the AWS files, (basically admin_warn.php. Warn.php, functions_warning.php and your install script as it was initially) to use Yes/No, instead of 1/0, then the existing users of the hack, have to change only one thing in their files and templates : $warn_opts[' to $vboptions['warn_ and that's it.

Revan
03-16-2005, 05:37 AM
Hm. I see your point.
EDIT: Now I remember why 1/0 or Yes/No is important! It is the vBoption setting type "yesno" or blank.
yesno makes it 1/0.
To still use Yes/No in your hack, you will have to alter all the settings from "yesno" to blank.

The idea behind this change originated from Revan (in vBulletin.org) who was instrumental in pushing me to do it.LMFAO :banana:

sv1cec
03-16-2005, 08:41 AM
Revan,

I am getting ready to release this thing, after I have ironed out some issues. My question to you is:

What is your suggested installation procedure? The upgrade is easy. Run your script and then make the changes listed above. But for a new user, does your script requires that the warning_options table exist? Since this table is no longer needed, it shouldn't be included in the install_warn.php file. But I am not sure your script will work without it. Please let me know.

Rgds

Revan
03-16-2005, 01:30 PM
It will work without it, because it sets reporterror to 0 before querying the table.
To make it better, do the follwoing edits to warn_install_setting:
Add after the kill_setting:
// This function queries a table to check if it exists
function verify_table_exists($table)
{
global $DB_site;

if (empty($table))
{
return false;
}

$DB_site->reporterror = 0;
$DB_site->query("SELECT COUNT(*) AS count FROM " . TABLE_PREFIX . "$table");
$DB_site->reporterror = 1;
return true;
}

find
$custom = true;
$DB_site->reporterror = 0;
$custset = $DB_site->query_first("SELECT * FROM " . TABLE_PREFIX . "warning_options");
$DB_site->reporterror = 1;

replace with
$custom = false;
if (verify_table_exists('warning_options'))
{
$custom = true;
}

sv1cec
03-18-2005, 07:49 AM
Revan, please have a look at the thread, where I announced the new version. A member complained that the settings were not copied over from the warning_options table. Can you please check the warn_install_setting.php script and make sure it is correct?

Rgds