vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Community Lounge (https://vborg.vbsupport.ru/forumdisplay.php?f=13)
-   -   Would you like it if I released a phpinclude API? (https://vborg.vbsupport.ru/showthread.php?t=85537)

filburt1 12-04-2002 01:40 AM

Would you like it if I released a phpinclude API?
 
It would greatly simplify making phpinclude mods, and what's more even speed them up, depending on the situation. Also it would become so easy that you don't really need an inner working knowledge of vB to start making them.

For example, this code (sorry about the indenting, the code tag's doublespacing is incredibly irritating):

if (strpos($_SERVER['PHP_SELF'], 'showthread.php') != false)
{
if (in_array($bbuserinfo['usergroupid'], array(5, 6, 7)))
{
if ($thread['notes'] == '') $thread['notes'] = 'None.';
eval("\$threadnotes = \"" . gettemplate("showthread_threadnotes") . "\";");
}
else $threadnotes = '';
}

Would be simplified to:

if (thisis("showthread"))
{
if (userisingroup("5,6,7"))
{
if ($thread['notes'] == "") $thread['notes'] = "None.";
evaltemplate("showthread_threadnotes", "threadnotes");
}
else $threadnotes = "";
}



And another example:

if (strpos($_SERVER['PHP_SELF'], 'index.php') != false)
{
$totalchars = $DB_site->query("SELECT SUM(LENGTH(pagetext)) AS totalchars FROM post");
$totalchars = $DB_site->fetch_array($totalchars);
$totalchars = number_format($totalchars['totalchars']);
}

becomes:

if (thisis("index"))
{
$totalchars = numberformat(mysqlonlyresult("SELECT SUM(LENGTH(pagetext)) AS totalchars FROM post"));
}

Tony G 12-04-2002 05:40 AM

Thats one big change in code, guess it could help. :)

filburt1 12-04-2002 06:46 PM

Okay, since it seems to be welcomed I'll do it (or rather continue it since I had already started it).

It's more of a wrapper set of functions than an API but useful nonetheless. What I've coded but not tested so far:

function thisis($filename)
// returns true if $phpself contains $filename

function evaltemplate($templatename, $storagevar)
// evals $templatename and stores the output in $storagevar

function mysqlonlyresult($query)
// returns the first result array of $query

function userisingroup($usergroupids)
// returns true of the current user is a member of the given
// comma-delimited list of usergroupids

function setempty($varlist)
// sets the variable names in $varlist (comma-delimited, no
// leading $) to empty (''). This avoids security issues,
// particurally those arising where register_globals allows
// users to directly edit variable contents by simply
// changing the page's URL.

I'll be looking for testers, soon. :)

Cypher720 12-04-2002 08:09 PM

i honestly dont know whawt this is...but if it helps make coding easier for mods...why not!

Rufus69 12-05-2002 12:02 AM

heh I have no idea what it is either :( but if it helps :p

what someone needs to do is make a WYSIWYG program so even stupid people like me can make mods :Dl

Cypher720 12-05-2002 12:19 PM

lol...that would be funny;)

imported_plattopus 12-05-2002 12:26 PM

It's just a set of functions designed to make things easier for people creating mods that use the phpinclude. It's basically a time-saver (and a very good one at that).


All times are GMT. The time now is 07:33 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.00975 seconds
  • Memory Usage 1,721KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete