vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Php Code Integration... (https://vborg.vbsupport.ru/showthread.php?t=159484)

John3971 10-04-2007 07:02 PM

Php Code Integration...
 
Hey i have some php codes that i wanna use with the template of my forum and i also wan´t this php pages use the usergroup access so i can put one that only moderators and higher can visit and so on...

Opserty 10-04-2007 07:08 PM

<a href="https://vborg.vbsupport.ru/showthread.php?t=62164" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=62164</a>

That what you need?

John3971 10-04-2007 07:11 PM

Quote:

Originally Posted by Opserty (Post 1353012)

no i can?t use php there and it don?t have so you can choose who should have access to different pages..

Opserty 10-04-2007 07:16 PM

Why not?

You can, did you even read the page I linked to?
Quote:

Instructions:
Create a new file, whatever you want to call it (let's say test.php).
Open up test.php and add the following (replace TEST with whatever template you want to show):
<php code>
Its a PHP file...you can write PHP in it.

Regarding your second statement: https://vborg.vbsupport.ru/showthrea...is_member_of#3

Or in php:
PHP Code:

if(!is_member_of($vbulletin->userinfo6XYZ))
{
    
// You aren't a member of group X Y or Z
    
print_no_permission();



John3971 10-04-2007 07:19 PM

Can you give me an example of how i should do it?

John3971 10-05-2007 08:21 PM

Bump

Opserty 10-05-2007 09:09 PM

Quote:

Can you give me an example of how i should do it?
How you should do what?

John3971 10-06-2007 03:58 PM

i can´t put the php code in the template it wont work so how do i fix this?

Opserty 10-06-2007 04:19 PM

Login would dictate that you put the PHP code in the PHP file...

Then call the template in the PHP file.

Did you read the link I gave you? Everything is there which you need to create a custom page to display information that you want.

John3971 10-06-2007 04:33 PM

yes but were in that file should i put my php code????

Can you show me an example??

i don´t now anything about php..

Opserty 10-06-2007 05:53 PM

Put it under the bit which says:
PHP Code:

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

I would go and learn a little PHP at least, so that you know what is going on. Otherwise you run the risk of ruining your vB installation.

John3971 10-06-2007 06:10 PM

when i put it right under that the code will come above the header.

Leon44 10-06-2007 09:49 PM

yes i would like to do that samething on that portal hack with this code

PHP Code:

<tr>
                 <td height="44" valign="top" class="text-padding" 
align="center"><?php
$number 
"10";
include(
"/home/gamelair/public_html/cutenews/show_news.php");
?> 
</td>
                </tr>

but it shows nothing when i put it there.

John3971 10-08-2007 11:34 AM

Bump

Opserty 10-08-2007 02:54 PM

vB templates operates different, you save your code in a variable and then put it in a template. The final code is outputted when the script finishes executing, only then is the data displayed.

vB: Processing -> Output
Other small PHP files: Output (header) -> Processing -> Output (Dynamic content) -> (Processing e.t.c.)

If you don't want to do it that way then just use the HTML output from a vB and try and hack it up to fix your custom page.

John3971 10-08-2007 06:12 PM

can you give me an example because i don´t understand what you mean..

(im bad in english)

Dismounted 10-09-2007 08:18 AM

Can you post your whole custom page code that you have now?

John3971 10-09-2007 08:22 AM

i don?t have any other then this https://vborg.vbsupport.ru/showthread.php?t=62164 right now and i don?t now how i should do thats why im asking for an example..

Dismounted 10-09-2007 09:58 AM

Okay, in your file, find:
PHP Code:

require_once('./global.php'); 

Add below:
PHP Code:

if (!is_member_of($vbulletin->userinfoX))
{
    
print_no_permission();


Replace "X" with a comma-separated group of user ids allowed to view the page.

John3971 10-09-2007 10:04 AM

Quote:

Originally Posted by Dismounted (Post 1356148)
Okay, in your file, find:
PHP Code:

require_once('./global.php'); 

Add below:
PHP Code:

if (!is_member_of($vbulletin->userinfoX))
{
    
print_no_permission();


Replace "X" with a comma-separated group of user ids allowed to view the page.

and how do i fix the php codes in there?

Dismounted 10-09-2007 12:04 PM

Fix what? It can't get any easier...Simply Find that line in the PHP file and add something below. Then replace the X with usergroup ids...

John3971 10-09-2007 12:06 PM

Quote:

Originally Posted by Dismounted (Post 1356195)
Fix what? It can't get any easier...Simply Find that line in the PHP file and add something below. Then replace the X with usergroup ids...

if i add something below that code it will show up in the top of the pages and i want it under header and above footer..

edgecutioner 10-09-2007 12:21 PM

Quote:

Originally Posted by John3971 (Post 1356196)
if i add something below that code it will show up in the top of the pages and i want it under header and above footer..

Dude just try it before you jump to conclusions:down: and besides, the template you create in ACP will dictate on how it looks:o

John3971 10-09-2007 12:25 PM

Quote:

Originally Posted by edgecutioner (Post 1356205)
Dude just try it before you jump to conclusions:down: and besides, the template you create in ACP will dictate on how it looks:o

i have try it and like i said it show above everything..

Dismounted 10-10-2007 06:03 AM

You don't put it in the template. You put it in the PHP file...

John3971 10-10-2007 07:34 AM

Quote:

Originally Posted by Dismounted (Post 1356689)
You don't put it in the template. You put it in the PHP file...

yes i now that is what im doing i but it shows above everything and i want it to be under header and above footer..

i put the code in the php file like you said and it shows above everything and i have tried to put it in template file but then its not working..

Dismounted 10-11-2007 10:15 AM

Show me your PHP file and your template.

John3971 10-11-2007 11:31 AM

here is the test.php file:

Code:

<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'test'); // 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(
    'TEST',
);

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

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');
if (!is_member_of($vbulletin->userinfo, 6))
{
    print_no_permission();


$PHP_SELF = $_SERVER['PHP_SELF'];
$send = $_GET['send'];
$FNamn = $_POST['FNamn'];
$Kon = $_POST['Kon'];

if(isset($send) && !empty($Kon) && !empty($FNamn)){
  //Om man skickat n?got inkluderas f?rst statistiska centralbyr?ns sida...
  $scb = implode('', file('http://www.scb.se/templates/Namnstatistik/NamnSokResultat____50725.asp?FNamn='.$FNamn.'&Kon='.$Kon));
  // Tar bort on?diga delar som deras menyer....
  $scb = explode('<td valign="top" width="546">', $scb);
  // ... Och deras nederdel...
  if($Kon != 3){
      $second_explode = "<br>";
  }
  else{
      $second_explode = "</td>";
  }
 
  $scb = explode($second_explode, $scb[1]);
  echo $scb[0]."<br><a href=\"$PHP_SELF\">Tillbaka</a>";
}
elseif(isset($send)){
  echo "Du har inte fyllt i alla f?lten! <a href=\"".$PHP_SELF."\">Tillbaka</a>";
}
else{
?>
<form action="<?=$PHP_SELF;?>?send=" method="post">
<input type="radio" name="Kon" value="1">Man&nbsp;
<input type="radio" name="Kon" value="2">Kvinna&nbsp;
<input type="radio" name="Kon" value="3">Efternamn<br>
<input type="text" name="FNamn">&nbsp;<input type="submit" value="Kolla!">
</form>
<?php
}

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

$navbits = array();
$navbits[$parent] = 'Test Page';

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

?>

And here is what i have in template TEST
Code:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header

$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
        <td class="tcat">Title</td>
</tr>
<tr>
        <td class="alt1">Text</td>
</tr>
</table>

$footer
</body>
</html>


Dismounted 10-12-2007 11:11 AM

You're meant to put all your HTML in the template, and all your processing in the PHP file.

John3971 10-12-2007 11:13 AM

Quote:

Originally Posted by Dismounted (Post 1358177)
You're meant to put all your HTML in the template, and all your processing in the PHP file.

that i can?t do because i need to have php in the form..

Dismounted 10-12-2007 11:14 AM

Yes, you assign variables and use those variables in your template. See how most vBulletin templates have variables in them?

John3971 10-12-2007 11:17 AM

Quote:

Originally Posted by Dismounted (Post 1358182)
Yes, you assign variables and use those variables in your template. See how most vBulletin templates have variables in them?

can you give example because i don?t now what you talking about..

Dismounted 10-12-2007 11:35 AM

Look in the postbit template. Look at all those variables used. You can do the same thing.

John3971 10-15-2007 02:44 PM

nobody that can an easier way?

edgecutioner 10-16-2007 07:24 AM

Look if you won't help us by trying it first, then how can we help you back? That code is very easy to do, even my 5-year old niece can do it

ragtek 10-16-2007 08:26 AM

Quote:

Originally Posted by John3971 (Post 1360778)
nobody that can an easier way?

i know an easier way => click here https://vborg.vbsupport.ru/showthread.php?t=156992 on Support Developer , pay me 25$ and i'm your for one hour and make that, what you want ;)


as the other said

if you have no idee of php,html, etc than you should check some books or online tutorials first, if you don't know/understand what the people here are writing


All times are GMT. The time now is 04:38 PM.

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.01343 seconds
  • Memory Usage 1,824KB
  • 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
  • (2)bbcode_code_printable
  • (7)bbcode_php_printable
  • (11)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (36)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