PDA

View Full Version : Javascript with PHP? code inside***


Shaven_LTS
08-17-2009, 07:47 AM
hey guys... I have purchased an online magazine program thing or whatever. I am trying to limit only subscribers that have donated to the site to view the content... however the code I found and was using disables or seems to disable the .js files in a way. if possible could anyone that has any idea about this or knows of a good external authentication script to use please help me.

something in this code below is either cramping the .js or what let me know if yall see anything wrong with it. btw i highlighted where my coding for the magazine setup is placed in this.

<?php

// ################################################## ######################
// ####################### START CONFIGURATION ############################
// ################################################## ######################

// set allowed usergroups - separate with a comma
define('UGS','6,7,9,5,10,11,13,2,15');

// set the full path to your main forum directory
define('FWD','/forum');

// set vB version you are using - use 307 or 350
define('VBN','350');

// set the name of this script - no .php extension
define('THIS_SCRIPT','example');

// ################################################## ######################
// ######################## END CONFIGURATION #############################
// ################################################## ######################

// ####################### SET PHP ENVIRONMENT ############################
// report all errors except notice level errors
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS ########################
// deglobalize variables in vB < 350 - vB 350 does deglobalize
if (VBN != '350')
{
define('NO_REGISTER_GLOBALS', 1);
}

// ################### 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(
'header',
'headinclude',
'navbar',
'footer'
);

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

// ######################### REQUIRE BACK-END #############################
// define current directory
define('BWD', (($getcwd = getcwd()) ? $getcwd : '.'));

chdir(FWD);
require_once('./global.php');
chdir(BWD);

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

// ######################## SET SOME VARIABLES ############################
if (VBN == '350')
{
// to make compatible with vB 307 code - TMTOWTDI !
$vboptions['homeurl'] = $vbulletin->options['homeurl'];
$vboptions['bburl'] = $vbulletin->options['bburl'];
$vboptions['bbtitle'] = $vbulletin->options['bbtitle'];
$vboptions['forumhome'] = $vbulletin->options['forumhome'];
$vboptions['contactuslink'] = $vbulletin->options['contactuslink'];
$bbuserinfo['userid'] = $vbulletin->userinfo['userid'];
$bbuserinfo['usergroupid'] = $vbulletin->userinfo['usergroupid'];
$bbuserinfo['username'] = $vbulletin->userinfo['username'];
$bbuserinfo['email'] = $vbulletin->userinfo['email'];
$session['sessionurl'] = $vbulletin->session->vars['sessionurl'];
$session['sessionhash'] = $vbulletin->session->vars['sessionhash'];
// and so forth ...
}

$src_input = array(
'url(',
'var IMGDIR_MISC = "',
'href="',
'src="',
'action="'
);
$src_output = '';
$src_link = $vboptions['bburl'];

$user_groups = explode(",",ereg_replace("[[:space:]]+","",UGS));
$usergroup_id = $bbuserinfo['usergroupid'];

// #################### CHECK USERGROUP FOR ACCESS ########################
if (!in_array($usergroup_id,$user_groups))
{ // LOGIN PAGE
$show['permission_error'] = true;
eval('$src_output = "' . fetch_template('STANDARD_ERROR') . '";');
}
else
{ // CONTENT PAGE
eval('$navbar = "' . fetch_template('navbar') . '";');
// here you can set $src_output to a custom template like follows
// eval('$src_output = "' . fetch_template('CUSTOM_TEMPLATE') . '";');
// for this example script $src_output is set from make_page_content
// make sure not to set $src_output to something like config.php - duh
$src_output = make_page_content();
}
make_absolute_links($src_input,$src_output,$src_li nk); // prints page

// ################################################## ######################
// ######################### END MAIN SCRIPT ##############################
// ################################################## ######################

// ######################## START MAKEPAGECONTENT #########################
function make_page_content()
{
$src_output = <<<END
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Gorenje Kitchen 2008 online catalogue</title>
<link href="css/liquid-green.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/liquid.js"></script>
<script type="text/javascript" src="js/swfobject.js"></script>
<script type="text/javascript" src="js/flippingbook.js"></script>
<script type="text/javascript" src="js/bookSettings.js"></script>
</head>
<body>
<div id="fbContainer">
<a class="altlink" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"><div id="altmsg">Download Adobe Flash Player.</div></a>
</div>
<div id="fbFooter">
<div id="fbContents">
<select id="fbContentsMenu" name="fbContentsMenu"></select>
<span class="fbPaginationMinor">p.&nbsp;</span>
<span id="fbCurrentPages">1</span>
<span id="fbTotalPages" class="fbPaginationMinor"></span>
</div>
<div id="fbMenu">
<img src="img/btnZoom.gif" width="36" height="40" border="0" id="fbZoomButton" /><img src="img/btnPrint.gif" width="36" height="40" border="0" id="fbPrintButton" /><img src="img/btnDownload.gif" width="36" height="40" border="0" id="fbDownloadButton" /><img src="img/btnDiv.gif" width="13" height="40" border="0" /><img src="img/btnPrevious.gif" width="36" height="40" border="0" id="fbBackButton" /><img src="img/btnNext.gif" width="36" height="40" border="0" id="fbForwardButton" /></div>
</div>
</body>
</html>
END;
return $src_output;
}

// ####################### START MAKEABSOLUTELINKS ########################
function make_absolute_links($src_input,$src_output,$src_li nk)
{
$src_output_arr = explode("\n",$src_output);
foreach ($src_output_arr as $sopa_key => $sopa_value)
{
for ($i=0; $i<count($src_input); $i++)
{
if (eregi("(.*)(".preg_quote($src_input[$i]).")(.*)",$sopa_value,$sopa_regs))
{
if (!eregi("^(javascript:|mailto:|ftp:|news:|http[s]?:)",$sopa_regs[3]))
{
$sopa_value = $sopa_regs[1].$sopa_regs[2].$src_link."/".$sopa_regs[3];
}
}
}
echo $sopa_value."\n";
}
exit();
}

?>

--------------- Added 1250537052 at 1250537052 ---------------

bump for urgency