php in template.html php in template.html
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

php in template.html

Started by Crazymodder, October 13, 2007, 12:48:22 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Crazymodder

Hello it is possible to inclue a php in the template.php.
I have adrotation.php and I want to inlucde this on the right side of my gallery. If I only have one banner I can take it into the template.html and then it would be display but konw I want to take this php so that every time there is another banner.
It would be very nice if you can help me thx :)
If you need some code please tell me

Best Regards
Crazymodder

Joachim Müller

From the documentation: Editing template.html:
Quote2.3.6.4 Editing template.html

The file template.html is the core file of each theme: it can only contain HTML/CSS/JavaScript code (no PHP!) plus some placeholder tokens that will get replaced with content when the theme is being parsed (i.e. when the HTML output of a gallery page is being generated). Template.html determines the overall layout of your gallery pages. Use it to make your gallery match the overall look of your entire website.

Crazymodder

Ok thx for this Information but is there another way to include a php on the right sidebar?
at the theme.php?
I don't know I hope you have a Idea thx :)

best regards
Crazymodder

Joachim Müller

Sure, just create a custom token (something like {MY_CUSTOM_INCLUDE}) and put it into template.html before the {GALLERY}-token. Then edit theme.php, find the pageheader function (copy it from the sample theme if it doesn't exist) and add the definition for the custom token you added above. Has been asked and answered already - search the board for details.

Crazymodder


Crazymodder

Hello there is another Problem ???
I have created a custom footer an include a php.
I the php looks like so:

<?php
echo('Here is the AD');
?>


Than it works great.
But if I want to include my AD PHP it wouldn't be displayed.
<?php

$sac_error_reporting 
= @ error_reporting(E_ALL E_NOTICE);


// $sac_config_dir = "/www/user234/cats/scaradcontrol/";

$sac_config_dir "";


$sac_debug=1;
$sac_ip_block_time 86400;

if (
version_compare(phpversion(), "4.1.0") == 1) {
if (isset ($_SERVER["HTTP_X_FORWARDED_FOR"]))
$sac_ip $_SERVER["HTTP_X_FORWARDED_FOR"];
else
if (isset ($_SERVER["HTTP_CLIENT_IP"]))
$sac_ip $_SERVER["HTTP_CLIENT_IP"];
else
$sac_ip $_SERVER["REMOTE_ADDR"];
} else {
if (getenv('HTTP_X_FORWARDED_FOR'))
$sac_ip getenv('HTTP_X_FORWARDED_FOR');
else
if (getenv('HTTP_CLIENT_IP'))
$sac_ip getenv('HTTP_CLIENT_IP');
else
$sac_ip getenv('REMOTE_ADDR');
}
if (
strstr($sac_ip',')) {
$sac_ips explode(','$sac_ip);
$sac_ip $sac_ips[0];
}


$PHP_SELF $_SERVER['PHP_SELF'];

if (isset (
$_REQUEST["sac_java"])) {
$sac_java $_REQUEST["sac_java"];
}
if (isset (
$_REQUEST["sac_show"])) {
$sac_show $_REQUEST["sac_show"];
}
if (isset (
$_REQUEST["sac_cat"])) {
$sac_cat $_REQUEST["sac_cat"];
}
if (isset (
$_REQUEST["sac_id"])) {
$sac_id $_REQUEST["sac_id"];
}
if (isset (
$_REQUEST["sac_stat"])) {
$sac_stat $_REQUEST["sac_stat"];
}
if (isset (
$_REQUEST["sac_bild"])) {
$sac_bild $_REQUEST["sac_bild"];
}
if (isset (
$_REQUEST["sac_no_link"])) {
$sac_no_link $_REQUEST["sac_no_link"];
}

###  Einbinden der Konfigurationen
if (!file_exists($sac_config_dir."admin/config.inc.php")) {
die("<br><br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> Konfigurationsdatei konnte nicht gefunden werden</b><br><br><br>");
}
include_once(
$sac_config_dir."admin/config.inc.php");

###  Verbindungsaufbau zur Datenbank
$sac_connect = @ mysql_connect($sac_db_server$sac_db_user$sac_db_pass) or die("<br><br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> Konnte keien Verbindung zur Datenbank aufbaun.</b><br><br><br>");

### functionen
if (!function_exists("file_get_contents")) {
function file_get_contents($sac_bild_url) {
$sac_imagefileopen fopen($sac_bild_url"rb") or die("<br><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> kann das Bild nicht oeffnen!");
$sac_temp fread($sac_imagefileopen200000);
fclose($sac_imagefileopen);
return $sac_temp;
}
}
if (!
function_exists("sac_query") && !function_exists("sac_show_ad")) {
function sac_query($sql) {
GLOBAL $sac_db$sac_connect$sac_debug;
$sql_rs = @ mysql_db_query($sac_db$sql$sac_connect);
if (mysql_errno() != 0) {
if ($sac_debug == 1) {
echo ("<br><br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a></b> Es kam zu einem Fehler bei der Ausfuehrung einer SQL Abfrage. <br>Error-NR: ".mysql_errno()."<br>Error-Msg: ".mysql_error()." <br>SQL: <b>$sql</b><br> Sollte dieser Fehler weiterhin auftreten, wenden Sie sich bitte an den Webmaster.<br><br>");
} else {
echo ("<br><br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a></b> Es kam zu einem Fehler bei der Ausfuehrung einer SQL Abfrage. <br> Sollte dieser Fehler weiterhin auftreten, wenden Sie sich bitte an den Webmaster.<br><br>");
}
return;
} else {
return $sql_rs;
}
}

function sac_show_ad($sac_array) {

GLOBAL $sac_java$sac_url$sac_copyright$sac_banner_www$sac_db_tbl_pre$sac_no_link;

if (isset ($_REQUEST["sac_onlylink"])) {
sac_query("UPDATE ".$sac_db_tbl_pre."banner SET views=views+1, klicks=klicks+1 WHERE id='".$sac_array["id"]."'");

header("Location: ".$sac_array["link"]);
die();
} else {

$sac_abmessung explode("x"$sac_array["abmessung"]);
$sac_abmessung["0"] = ((int) $sac_abmessung["0"] > 0) ? "width=\"".(int) $sac_abmessung["0"]."\"" "";
$sac_abmessung["1"] = ((int) $sac_abmessung["1"] > 0) ? "height=\"".(int) $sac_abmessung["1"]."\"" "";

switch ($sac_array["type"]) {
case "1" :
if ($sac_array["werbeblock"] == "1") {
$sac_bild_url = ($sac_url."?sac_bild=".$sac_array["id"]."&check=".md5(time()));
} else {
$sac_bild_url $sac_banner_www."/".$sac_array["bild"];
}
if ($sac_no_link == false) {
$sac_temp = ("\n<a href=\"".$sac_url."?sac_id=".$sac_array["id"]."\" target=\"".$sac_array["link_target"]."\"><img src=\"".$sac_bild_url."\" border=0 alt=\"".$sac_array["beschreibung"]."\" $sac_abmessung[0] $sac_abmessung[1]></a>\n");
} else {
$sac_temp = ("\n<img src=\"".$sac_bild_url."\" border=0 alt=\"".$sac_array["beschreibung"]."\" $sac_abmessung[0] $sac_abmessung[1]>\n");
}
break;
case "2" :
if ($sac_array["werbeblock"] == "1") {
$sac_bild_url = ($sac_url."?sac_bild=".$sac_array["id"]."&check=".md5(time()));
} else {
$sac_bild_url $sac_array["bild"];
}
if ($sac_no_link == false) {
$sac_temp = ("\n<a href=\"".$sac_url."?sac_id=".$sac_array["id"]."\" target=\"".$sac_array["link_target"]."\"><img src=\"".$sac_bild_url."\" border=0 alt=\"".$sac_array["beschreibung"]."\" $sac_abmessung[0] $sac_abmessung[1]></a>\n");
} else {
$sac_temp = ("\n<img src=\"".$sac_bild_url."\" border=0 alt=\"".$sac_array["beschreibung"]."\" $sac_abmessung[0] $sac_abmessung[1]>\n");
}
break;
case "3" :
if (!empty ($sac_array["link"])) {
$sac_temp str_replace($sac_array["link"], $sac_url."?sac_id=".$sac_array["id"], $sac_array["html"]);
} else {
$sac_temp $sac_array["html"];
}
break;
case "4" :
$sac_temp = ("\n<a href=\"".$sac_url."?sac_id=".$sac_array["id"]."\" title=\"".$sac_array["beschreibung"]."\" target=\"".$sac_array["link_target"]."\">".$sac_array["html"]."</a>\n");
break;
}

if (isset ($sac_java)) {
for ($sac_i 0$sac_i strlen($sac_temp); $sac_i ++) {
if ($sac_temp[$sac_i] != chr(13)) {
$sac_temp[$sac_i] == "\n" $sac_temp_temp .= " " $sac_temp_temp .= $sac_temp[$sac_i];
}
}
echo str_replace("{BANNER}"$sac_temp_temp"document.write('".str_replace("'""\\'"$sac_copyright)."');");
} else {
echo str_replace("{BANNER}"$sac_temp"\n\n".$sac_copyright."\n\n");
}

sac_query("UPDATE ".$sac_db_tbl_pre."banner SET views=views+1 WHERE id='".$sac_array["id"]."'");
}

return;
}
}

###  loeschen der alten IP-Block-Daten
sac_query("DELETE FROM ".$sac_db_tbl_pre."ip_block WHERE  time<='". (time() - $sac_ip_block_time)."'");

###  CopyRight! Das entfernen oder Veraendern ist nicht gestattet!
$sac_copyright = ("<!-- START - [ Powered by ScarAdControl, Copyright by Scar4U.de - Christian Kerl ] - -->{BANNER}<!-- ENDE - [ Powered by ScarAdControl, Copyright by Scar4U.de - Christian Kerl ] - -->");

### app
if (!empty ($sac_bild)) {
$sac_bild_array = @ mysql_fetch_array(@ sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner WHERE id='".$sac_bild."'"));
if (!$sac_bild_array) {
die("<br><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> Ad kann nicht gefunden werden!<br>");
}

if ($sac_bild_array["type"] == 1) {
$sac_bild_url $sac_banner_www."/".$sac_bild_array["bild"];
}
elseif ($sac_bild_array["type"] == 2) {
$sac_bild_url $sac_bild_array["bild"];
}
$sac_temp file_get_contents($sac_bild_url);

$sac_now gmdate("D, d M Y H:i:s")." GMT";

header("Date: $sac_now");
header("Expires: $sac_now");
header("Last-Modified: $sac_now");
header("Pragma: no-cache");

$sac_bild_header getimagesize($sac_bild_url);
switch ($sac_bild_header[2]) {
case "1" :
header("Content-type: image/gif");
break;
case "2" :
header("Content-type: image/jpeg");
break;
case "3" :
header("Content-type: image/png");
break;
case "4" :
header("Content-type: image/swf");
break;
default :
header("Content-type: image/gif");
break;
}
echo $sac_temp;
die();

}
elseif (!empty (
$sac_id) && !$sac_stat) {

$sac_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner WHERE id='".$sac_id."'");
if (@ mysql_num_rows($sac_rs) > 0) {
$sac_array = @ mysql_fetch_array($sac_rs);
} else {
$sac_array = @ mysql_fetch_array(sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner ORDER BY RAND(NOW()) LIMIT 1"));
}

sac_query("UPDATE ".$sac_db_tbl_pre."banner SET klicks=klicks+1 WHERE id='".$sac_array["id"]."'");

if ($sac_array["block"] == "1") {

$sac_ip_block_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."ip_block WHERE ip='".$sac_ip."'");
if (@ mysql_num_rows($sac_ip_block_rs) > 0) {
$sac_ip_block_array = @ mysql_fetch_array($sac_ip_block_rs);
sac_query("UPDATE ".$sac_db_tbl_pre."ip_block SET block = '".$sac_ip_block_array["block"]."-".$sac_array["id"]."',
                                                                         time  = '"
.time()."'

                                                                         WHERE ip='"
.$sac_ip."' ");

} else {
sac_query("INSERT INTO ".$sac_db_tbl_pre."ip_block (id,ip,block,time)
                                  VALUES ('','"
.$sac_ip."','".$sac_array["id"]."','".time()."') ");
}

}

header("Location: ".$sac_array["link"]);

exit;

}
elseif (!empty (
$sac_show)) {

$sac_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner WHERE id='".$sac_show."'");

if (@ mysql_num_rows($sac_rs) < 1) {

if (!isset ($sac_java)) {
echo str_replace("{BANNER}""\n<br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> Der gewuenschte Banner kann nicht gefunden werden</b><br>\n""\n".$sac_copyright."\n");
} else {
echo str_replace("{BANNER}""<br><b><a href=\"http://www.scar4u.de\" target=\"_blank\">[ScarAdControl]</a> Der gewuenschte Banner kann nicht gefunden werden</b><br>""document.write('".$sac_copyright."');");
}

} else {

$sac_array = @ mysql_fetch_array($sac_rs);
sac_show_ad($sac_array);

}

}
elseif (!empty (
$sac_stat)) {

if (!empty ($sac_id)) {

if ($sac_stat == "klicks") {

$sac_stat_array = @ mysql_fetch_array(sac_query("SELECT klicks FROM  ".$sac_db_tbl_pre."banner WHERE id='".$sac_id."'"));
$sac_stat_zahl $sac_stat_array["klicks"];

}
elseif ($sac_stat == "views") {

$sac_stat_array = @ mysql_fetch_array(sac_query("SELECT views FROM  ".$sac_db_tbl_pre."banner WHERE id='".$sac_id."'"));
$sac_stat_zahl $sac_stat_array["views"];

}

}
elseif (!empty ($sac_cat)) {

if ($sac_stat == "klicks") {

$sac_stat_rs sac_query("SELECT klicks FROM ".$sac_db_tbl_pre."banner WHERE cat='".$sac_cat."'");
while ($sac_stat_array = @ mysql_fetch_array($sac_stat_rs)) {
$sac_stat_zahl += $sac_stat_array["klicks"];
}

}
elseif ($sac_stat == "views") {

$sac_stat_rs sac_query("SELECT views FROM ".$sac_db_tbl_pre."banner WHERE cat='".$sac_cat."'");
while ($sac_stat_array = @ mysql_fetch_array($sac_stat_rs)) {
$sac_stat_zahl += $sac_stat_array["views"];
}

}

}
elseif ($sac_stat == "klicks") {

$sac_stat_rs sac_query("SELECT klicks FROM ".$sac_db_tbl_pre."banner");
while ($sac_stat_array = @ mysql_fetch_array($sac_stat_rs)) {
$sac_stat_zahl += $sac_stat_array["klicks"];
}

}
elseif ($sac_stat == "views") {

$sac_stat_rs sac_query("SELECT views FROM ".$sac_db_tbl_pre."banner");
while ($sac_stat_array = @ mysql_fetch_array($sac_stat_rs)) {
$sac_stat_zahl += $sac_stat_array["views"];
}

}

if (!isset ($sac_java)) {
echo str_replace("{BANNER}"$sac_stat_zahl"\n\n".$sac_copyright."\n\n");
} else {
echo str_replace("{BANNER}"$sac_stat_zahl"document.write('".$sac_copyright."');");
}

} else {

## sql where generierung START
$sac_ip_block_found "";
$sac_sql "";
$sac_ip_block_rs sac_query("SELECT block FROM ".$sac_db_tbl_pre."ip_block WHERE ip='".$sac_ip."'");
if (@ mysql_num_rows($sac_ip_block_rs) > 0) {
$sac_ip_block_array = @ mysql_fetch_array($sac_ip_block_rs);
if (!empty ($sac_ip_block_array["block"])) {
$sac_ip_block_found "1";
$sac_ip_block_array_sub explode("-"$sac_ip_block_array["block"]);
for ($sac_i 0$sac_i count($sac_ip_block_array_sub); $sac_i ++) {
if (!empty ($sac_ip_block_array_sub[$sac_i])) {
$sac_sql .= (" id!='".$sac_ip_block_array_sub[$sac_i]."' ");

if (($sac_i +1) < count($sac_ip_block_array_sub))
$sac_sql .= (" && ");

}
}
}
}

if (!empty ($sac_cat) && $sac_ip_block_found == "1") {
$sac_sql = (" && ".$sac_sql." && cat='".$sac_cat."' ");
}
elseif (!empty ($sac_cat) && $sac_ip_block_found != "1") {
$sac_sql = (" && cat='".$sac_cat."' ");
}
elseif (empty ($sac_cat) && $sac_ip_block_found == "1") {
$sac_sql = (" && ".$sac_sql." ");
}
## sql where generierung ENDE

$sac_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner
                                                         WHERE (   ( views  < max_views  || max_views  = 0 )
                                                                && ( klicks < max_klicks || max_klicks = '0' ) )
                                                               "
.$sac_sql."
                                                               "
. (($sac_cat) ? "&& view_cat!='1'" "&& view_all != '1'")."
                                                         ORDER BY RAND(NOW())
                                                         LIMIT 1"
);

if (@ mysql_num_rows($sac_rs) < 1) {
if (!empty ($sac_cat)) {
sac_query("UPDATE ".$sac_db_tbl_pre."banner SET view_cat='0' WHERE cat='".$sac_cat."'");
$sac_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner WHERE cat='".$sac_cat."'
                                                                                &&  (   ( views  < max_views  || max_views  = 0 )
                                                                                && ( klicks < max_klicks || max_klicks = '0' ) ) ORDER BY RAND(NOW()) LIMIT 1"
);
} else {
sac_query("UPDATE ".$sac_db_tbl_pre."banner SET view_all='0'");
$sac_rs sac_query("SELECT * FROM ".$sac_db_tbl_pre."banner WHERE (   ( views  < max_views  || max_views  = 0 )
                                                                                && ( klicks < max_klicks || max_klicks = '0' ) )
                                                                             ORDER BY RAND(NOW()) LIMIT 1"
);
}
}

$sac_array = @ mysql_fetch_array($sac_rs);

if (!empty ($sac_cat)) {
sac_query("UPDATE ".$sac_db_tbl_pre."banner SET view_cat='1' WHERE id='$sac_array[id]'");
} else {
sac_query("UPDATE ".$sac_db_tbl_pre."banner SET view_all='1' WHERE id='$sac_array[id]'");
}

sac_show_ad($sac_array);

}

mysql_close($sac_connect);
error_reporting($sac_error_reporting);

?>


I hope you can help me and tell me what I have to change so that it works:)
If I insert this php via javascript it works also great but if I have some javascript ad this wouldn't be displayed so I need to include it via PHP.

Crazymodder

So thx for your help now I have included via javascript and it realy works fine :)