vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Moding question. (https://vborg.vbsupport.ru/showthread.php?t=123051)

sokol 08-04-2006 08:27 PM

Moding question.
 
MY INFO:
Vbulletin: 3.5.4
Vbadvanced: 2.1.0
GARS: 2.0 RC2 [commercial script]
Photopost: vbulletin enhanced [commercial script]

Ok, I run The Vanguard Library @ vanguardlibrary.com

I've been very busy getting my site layed out, and am now needing some very specic pages.

What I am looking for is ANY links and info on how to make custom pages with my own data read from the database, and another form for posting to the database.

MORE DETAIL:
Vanguard Library is a fansite for The Vanguard Saga of Heros game. I will be having info for races/classes/skills/spells etc.

I'm trying to determine the best way to go about this.
I need an admin page where people with admin rights can add/edit this info.
I need a user page where they will see the data entered.
I need a submit page that users can submit info and it will await for approval from an admin, then be posted.

All of the data pages I need will be very different.

I need any links or info on how to go about creating these.

My first thought was to use GARS however it does not seem like it is what I'm after here.

My second thought was to create the raceshow.php racesubmit.php etc...
The problem is I want it to use the vbulletin DB and I'm unsure of how to do this.
I can make my own db connection script, and use a different database, howver I then wont have the ability to use vbulletins permissions.

I know I've rambled, and if some kind soul PM's me I'd be glad to give more info and examples.

Thank you,
Sokol

Paul M 08-04-2006 11:51 PM

Maybe the webtemplates mod by logician ?

sokol 08-05-2006 12:14 AM

Unless I misunderstood, Logicians Web templates are for reading from the DB, not wrting to.

Now I'm a newbie php coder, and code from example alot; so I'm mostly familiar with the code examples I've been.

I have a custom page, the custom page uses a custom template. Now all I need is to access the Vbulletin databse query functions. However I'm unsure how certain things differ.
For instance:

Code:

        // Validate the email address.       
        if (!empty($_POST['email'])) {
                $rn = escape_data($_POST['race_name']);
        } else {
                echo '<p><font color="red" size="+1">Please enter a Race Name address!</font></p>';
                $rn = FALSE;
        }

I think would now be

Code:

        // Validate the email address.       
        if (!empty($_POST['race_name'])) {
                $rn = escape_string($_POST['race_name']);
        } else {
                echo '<p><font color="red" size="+1">Please enter a Race Name</font></p>';
                $rn = FALSE;
        }

Ok I'm not certain but I think that would be correct for making sure the user entered info.

Now reading and writing to the Db confuses me abit more.

Code:

        if ($rn) { // If everything's OK.

                // Make sure the email address is available.
                $query = "SELECT race_name FROM races WHERE race_name='$rn'";               
                $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
               
                if (mysql_num_rows($result) == 0) { // Available.

This checks to make sure the race_name is available.

But how does vbulletin handle mysql_num_rows?

And how about writing to the database?

Code:

                        $query = "INSERT INTO races (race_name) VALUES ('$rn',  NOW() )";               
                        $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());


Again I'm pretty new to PHP and can code and adapt by example, but i'm abit stumped as to vbulletins mysql handling syntax.


-Sokol

Here is the NON vbulletin php file that I began to make.

Quote:

<?php
// This page allows users to add URL's to the database.
require_once('includes/mysql_connect.php'); //connect to the database [NOTE: change to default dir "../includes/mysql_connect" for production site.
if(isset($_POST['submitted'])) // Handle the form.
{
// Check for a URL title.
if(!empty($_POST['race_name']))
{
$rn = escape_data($_POST['race_name']);
}
else
{
$rn = FALSE;
echo '<p><font color="red">Please enter a Race Name.</font></p>';
}

if($rn) // If everything is filled in and OK.
{
// Add the user.
$raceid = @mysql_insert_id();
$query = "INSERT INTO races (race_name) VALUES ('$rn')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$raceid = @mysql_insert_id();

if($raceid > 0) // New URL has been added.
{
// Make the URL associations.
// Build query.
$query = 'INSERT INTO races (raceid) VALUES';
$query .= "($raceid), ";
$result = @mysql_query($query); // run the query.

// Send the email.
$body = "Thank you for posting a new Race.\n\n";
mail($_POST['dhoracek1@cox.net'], 'Registration Confirmation', $body, 'From: info@vanguardlibrary.com');
}

}
}
?>

<form action="race.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>">
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
mysql_close(); // Close the database connection.
?>
I can get it to work just fine adding race_name and auto incrementing.

Here is my vbulletin RACESUBMIT template

Quote:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title><phrase 1=$vboptions[bbtitle]>$vbphrase[x_powered_by_vbulletin]</phrase></title>
$headinclude
</head>
<body>
$header
$navbar
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>&nbsp;

<form action="racesubmit.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" >
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>
</td>
</tr>
</table>
$footer
</body>
</html>
NOTE the value of the race_name field is not:
value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>
Anyw ay I can get my template file to allow me to add php into the template?

Here is my vbulletin code that formats my form into my vbulletin format.

Quote:

<?php
/* ADDED BY SOKOL for vba modules in forums */
define('VBA_PORTAL', true);
define('VBA_PAGE', 'include');
/* END ADD -SOKOL- */
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'racesubmit'); // change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(

);

// pre-cache templates used by all actions
$globaltemplates = array(
'RACESUBMIT',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################

$navbits = array();
$navbits[$parent] = 'Race Submit';

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('RACESUBMIT') . '");');

// ################################################## #####################
// ######################## START DB SCRIPT ############################
// ################################################## #####################

// This page allows users to add URL's to the database.
require_once('includes/mysql_connect.php'); //connect to the database [NOTE: change to default dir "../includes/mysql_connect" for production site.
if(isset($_POST['submitted'])) // Handle the form.
{
// Check for a URL title.
if(!empty($_POST['race_name']))
{
$rn = escape_data($_POST['race_name']);
}
else
{
$rn = FALSE;
echo '<p><font color="red">Please enter a Race Name.</font></p>';
}

if($rn) // If everything is filled in and OK.
{
// Add the user.

$raceid = @mysql_insert_id();
$query = "INSERT INTO races (race_name) VALUES ('$rn')";
$result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error());
$raceid = @mysql_insert_id();

if($raceid > 0) // New URL has been added.
{
// Make the URL associations.
// Build query.
$query = 'INSERT INTO races (raceid) VALUES';
$query .= "($raceid), ";
$result = @mysql_query($query); // run the query.

// Send the email.
$body = "Thank you for posting a new Race.\n\n";
mail($_POST['dhoracek1@cox.net'], 'Registration Confirmation', $body, 'From: info@vanguardlibrary.com');
}

}
}
?>

<form action="racesubmit.php" method="post">
Race Name:
<input name="race_name" type="text" size="10" maxlength="20" value="<?php if(isset($_POST['race_name'])) echo $_POST['race_name']; ?>">
<input type="submit" name="submit" value="Submit" />
<input type="hidden" name="submitted" value="TRUE" />
</form>

<?php
mysql_close(); // Close the database connection.
?>

So now my form displays: http://vanguardlibrary.com/racesubmit.php

and it seems to submit, but it will not update the database, and I'm assuming it's due to my RACESUBMIT template.

Any ideas?

Thanks a bunch,
Sokol


All times are GMT. The time now is 02:13 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.01049 seconds
  • Memory Usage 1,754KB
  • 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
  • (4)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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