Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > Premium Archives > Advanced Warning System (AWS)
FAQ Community Calendar Today's Posts Search

Closed Thread
 
Thread Tools
Would you be interested in a version which ..... Details »»
Would you be interested in a version which .....
Version: , by sv1cec sv1cec is offline
Developer Last Online: Mar 2022 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 03-12-2005 Last Update: Never Installs: 0
 
No support by the author.

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

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 03-15-2005, 07:06 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
  #13  
Old 03-15-2005, 11:30 AM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

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 )
  #14  
Old 03-15-2005, 12:12 PM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Revan
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

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:

PHP 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?
  #15  
Old 03-15-2005, 03:51 PM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works for me, but I can see how the if() is not needed.
  #16  
Old 03-16-2005, 03:25 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Revan
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
  #17  
Old 03-16-2005, 05:19 AM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
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
Yes/No, 1/0, whatever. It is of no difference
  #18  
Old 03-16-2005, 05:35 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Revan
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
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
Yes/No, 1/0, whatever. It is of no difference
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:

Code:
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.
  #19  
Old 03-16-2005, 05:37 AM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.

Quote:
The idea behind this change originated from Revan (in vBulletin.org) who was instrumental in pushing me to do it.
LMFAO :banana:
  #20  
Old 03-16-2005, 08:41 AM
sv1cec sv1cec is offline
 
Join Date: May 2004
Location: Athens, Greece
Posts: 2,091
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
  #21  
Old 03-16-2005, 01:30 PM
Revan's Avatar
Revan Revan is offline
 
Join Date: Jan 2004
Location: Norway
Posts: 1,671
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
PHP Code:
// 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
PHP Code:
$custom true;
    
$DB_site->reporterror 0;
    
$custset $DB_site->query_first("SELECT * FROM " TABLE_PREFIX "warning_options");
    
$DB_site->reporterror 1
replace with
PHP Code:
    $custom false;
    if (
verify_table_exists('warning_options'))
    {
        
$custom true;
    } 
Closed Thread


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:10 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.13084 seconds
  • Memory Usage 2,340KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete