PDA

View Full Version : [release] PAPI, a phpinclude API


filburt1
12-15-2002, 10:00 PM
Version 1.0.9
to download PAPI, see the attached papi.zip several posts down

Author: filburt1
Description: The swiss army knife of the phpinclude template. A phpinclude API that allows for simpler and more readable coding of phpinclude mods. By itself, PAPI doesn't do anything. You have to write or use mods that are powered by it to actually do something.
Screenshot/Demo: n/a

DO NOT REMOVE THE COPYRIGHT NOTICE INCLUDED WITH PAPI! "Some template modifications powered by PAPI" must appear in your header or footer so I can get some recognition for writing the near-1000 lines by scratch.

Installation instructions are included in the PAPI download.

Mods that use PAPI: (reply to this thread if a mod is missing)

Last Thread Titles on Forumhome (Cleaner) (http://www.vbulletintemplates.com/mods/showthread.php?s=&threadid=2365)
Forum Header Bar/Icon Legend has it's own Template (http://www.vbulletintemplates.com/mods/showthread.php?s=&threadid=2473)
Hottest Attachment (PAPI; more features) (http://www.vbulletintemplates.com/mods/showthread.php?threadid=3113)
Last Title on forumhome IB Look (http://www.vbulletintemplates.com/mods/showthread.php?threadid=2471)
Show Multiple Announcements in forumdisplay (http://www.vbulletintemplates.com/mods/showthread.php?threadid=2457)
Spambot Protection (http://www.vbulletintemplates.com/mods/showthread.php?threadid=3347)


Features and the actual mod coming up in the next few posts.


1.0.9 (3/9/03)
Bug fixes in floodcheck() when checking simultaneously for threads and replies
1.0.8 (3/8/03)

floodcheck() can now efficiently check for flooding of both replies and threads at the same time
Various bug fixes, tweaks, and comment edits

1.0.7 (3/8/03)

Behavior change for floodcheck(); now is inclusive for $count instead of exclusive
functions to ban a user, and (given a userid) lock all threads, hide all threads, delete all threads including their replies, delete all posts, hide all posts, and split all posts into one thread added

1.0.6 (3/5/03)

Automatic syntax check implicitly made (errors will reference the correct line numbers in papi.php should you choose to made errors); adding papisyntaxcheck=1 has no effect anymore
Various bug and security fixes
PAPI now encapsulated in its own file for theoretically drastically improved performance and a much less crowded phpinclude template
englishboolean() added; returns a string version of a boolean value
floodcheck() added for an upcoming mod; returns true if a given user has posted more than a given number of threads/replies in a given time period
Extra small functions added

1.0.5 (12/26/02):

Bug fix in mysqlresultlessquery() (bug exists only in PAPI 1.0.3 and 1.0.4). Before the fix, mysqlresultlessquery() might echo a PHP error referencing mysql_fetch_array() and db_mysql.php.
updatethreadtitlecache() redocumented and new feature added; updating by threadid is now possible.

1.0.4 (12/23/02):

function added: cleanstring(). This takes a string and runs it through the censor and then converts HTML characters to their entities to avoid HTML injection.
function added: prettydate(). Given a date, formats it using vbdate and optionally even the {timecolor} replacement
Existing functions converted to use cleanstring() instead of htmlspecialchars(censortext()).

1.0.3 (12/19/02):

debug mode consolidated; now a single constant (PAPI_DEBUG_MODE) defines all debugging messages to be on or off globally. As a result, the first argument ($unused, previously $debugmode) in updatethreadtitlecache() is ignored and is now deprecated and runs the risk of being removed in 1.1.0.
Global query counter; $papiquerycount increments every time you call one of PAPI's mysql...() functions.
Function mysqlresulthandle() added (see the function's comments for details). This allows for simple queries to be included in $papiquerycounter

1.0.2 (12/16/02): provided enhanced copyright notice and version number to the actual code for clarity (no functional changes)
1.0.1 (12/16/02): fixed HTML injection issues with updatethreadtitlecache
1.0.0 (12/16/02): initial release

Nairb
12-16-2002, 05:42 PM
Attach something?

filburt1
12-16-2002, 05:44 PM
Features (functions included and misc junk; this list is only for 1.0.0 and many new features have been added since)

find out what script is running
make template eval code
echo the last mysql error or a message if no error occured
return the only row from a mysql query
return the only VALUE from a mysql query
execute a mysql query (UPDATE, DELETE, etc) where the result doesn't matter
find out if the current user is in one of a given list of usergroups
set a bunch of variables to empty at once
find out if the user is a guest
get the moderator permissions for a given forumid or threadid for the logged in user
get an array of all granted moderator permissions
stick/unstick a thread taking permissions into effect
close/open a thread taking permissions into effect
find out what "action" ($_GET['action'] and $_POST['action'] is
print_r a given array in a preformatted block in a given color
add ... to a string if it is greater than a certain length
run multiple queries at once
update the last thread title cache all at once or for one given forum (this is proprietary to a soon-to--be-released mod)
emulate register_globals for a given list of $_POST vars
automatically run a syntax check on PAPI itself


Yeesh!

As per the syntax check on PAPI itself, just tack &papisyntaxcheck=1 onto any URL and it will echo "PAPI syntax check ok" if so.

File coming up.

The copyright notice it adds and that you cannot remove (except for the version number):

filburt1
12-16-2002, 05:45 PM
Download for PAPI:

Nairb
12-16-2002, 05:48 PM
Lol, Ok
Thx :D

Is there a way you could give examples of all those codes, but writen in PAPI? O_o

filburt1
12-16-2002, 05:49 PM
I'm going to release a completely rewritten version of my last thread titles on forumhome mod soon that requires PAPI to run, so you can tear apart that.

filburt1
12-16-2002, 06:14 PM
1.0.1 updated (see version history)

Brad
12-16-2002, 07:04 PM
Now that its final i can start using it, look for a mod with it included from me soon.

Rufus69
12-16-2002, 10:57 PM
o_o

I'm going to try and install it, if it messes up imma kill you!

Cypher720
12-16-2002, 11:36 PM
same...lol

filburt1
12-16-2002, 11:37 PM
By itself it won't do anything, remember, other than add the copyright notice to the footer. You'll know if it's reasonably working if the page looks the same before and after.

Tony G
12-17-2002, 12:50 AM
Brilliant, nice work! Time to get stuck into phpinclude. ;)

filburt1
12-17-2002, 12:52 AM
I do intend to release all my future mods to require PAPI except for very simple ones because it makes it so much faster for me to write them. :)

Tony G
12-17-2002, 12:54 AM
I was just wondering, would you like any copyright etc. for your work in PAPI in the mod or the text file?

filburt1
12-17-2002, 12:56 AM
The mod automatically adds a copyright notice for itself in the footer. It even syntax-checks itself if you want. Christ, it's like this thing is alive :D

Tony G
12-17-2002, 12:58 AM
Okay, and do you want any recongnition in any PAPI mods text file?

filburt1
12-17-2002, 01:02 AM
Just a link to this thread.

I did just add a commented copyright notice and a version number so 1.0.2 will be uploaded in a few minutes (no functionality changes).

assassingod
12-17-2002, 06:13 AM
You really are a genius filbby:p

Ill wait til some mods come out for it before I use it:)

filburt1
12-20-2002, 04:54 PM
1.0.3 released, see the version history.

filburt1
12-24-2002, 01:59 AM
1.0.4 released, see the version history.

filburt1
12-27-2002, 02:44 AM
1.0.5 released, see the version history. This update includes a bug fix.

imported_cono
12-27-2002, 10:40 PM
i get this error?

Parse error: parse error in /home/sites/site178/web/vbb/global.php(318) : eval()'d code on line 1

filburt1
12-27-2002, 11:06 PM
You didn't install it properly then. What's in your phpinclude template? PLEASE ATTACH THE CONTENTS AS A TEXT FILE, NOT DIRECTLY IN THE POST

imported_cono
12-28-2002, 06:58 AM
here is my phpinclude file

filburt1
12-28-2002, 01:30 PM
Well no wonder, you never followed any of the PAPI installation steps...

imported_cono
12-28-2002, 02:17 PM
i removed it so i dont get the errors. LOL

when i copyied the script to the template i would get the error, when i remove it from the template, everything works fine.

filburt1
12-28-2002, 02:19 PM
What I meant was to see it when you had PAPI installed, albeit unsuccessfully.

imported_cono
12-29-2002, 05:55 PM
here it is with papi included.

all i did was copy and paste whatever was in that index file on the download?

thanks,

filburt1
12-29-2002, 05:57 PM
As the instructions state, copy everything between the leading <? and the trailing ?>. The only reason those two things are there are so Dreamweaver will color-code the PHP properly.

imported_cono
12-29-2002, 06:02 PM
OMG, ok, i now feel like the biggest idiot on the earth. LOL i cant believe i missed that. LOL

thanks for pointing that out, i just fixed it and it works great. LOL

DAH!

filburt1
12-29-2002, 06:50 PM
Glad to help :)

Orfejs
01-31-2003, 08:49 AM
amazing grace

Erwin
02-05-2003, 12:45 AM
Nice work, filburt. :) I'm impressed.

Tony G
02-05-2003, 03:03 AM
I finally got the time to test install this, now to create/install some papi mods when I get more time. :)

filburt1
02-10-2003, 12:36 AM
* filburt1 cracks whip

So create them already! :p

Bad Bunny
02-11-2003, 01:28 AM
Now, this seems really odd to me. It sounds really cool and exciting, only I am sort of dumb with code things.
When installing mods with this, does it add extra queries?

filburt1
02-11-2003, 01:30 AM
Mods that use PAPI might depending on what they do. PAPI by itself doesn't add queries or change anything else other than your footer copyright notice.

Bad Bunny
02-11-2003, 01:31 AM
I'll try it out, and add a mod or two.
If I decide I don't want it anymore, is it easy to uninstall?

filburt1
02-11-2003, 01:32 AM
Yes, just delete everything between the Begin PAPI and End PAPI comments.

imported_atticus
03-04-2003, 07:00 PM
What exactly does this do?

Vb-Hispano
03-04-2003, 07:57 PM
What exactly does this do?

read this http://www.vbulletintemplates.com/mods/showthread.php?threadid=3271

filburt1
03-06-2003, 12:52 AM
1.0.6 done. WDF has been running on it for months but I never got around to releasing it because there were only small changes. This one now puts PAPI in its own file. I strongly recommend that everybody upgrade to this version for performance reasons.

Brad
03-06-2003, 01:19 AM
Heh, ill start writing papi mods now that all that code is outside the template. Might release a few custom scripts and call them like that to :)

filburt1
03-08-2003, 05:06 AM
1.0.7 released.

filburt1
03-10-2003, 12:17 AM
1.0.9 released for bug fix.

Sliderx
03-10-2003, 07:57 PM
thx for papy

TalkGaming
07-31-2003, 04:26 PM
I'm being a complete idiot here for sure... but when you say in step 3 of your instructions file to

Add the following to the very beginning of phpinclude on its own line:

include("./customscripts/papi.php");

I assume you mean in my templetes, ok.. well in the phpinclude templetes section there is phpinclude_start and phpinclude_end I added it to the start one and I dont see the copyright info or anything like that. Am I being a complete tired idiot or did something change with VB3 beta 4?

TalkGaming
07-31-2003, 08:19 PM
ok, i just noticed i was in the vb2 forum... plz move this where it needs to go, sorry bout that