Hi I have an image hosting site - it runs off a modified version of the Mihalism script. It uses template file for outputs, and my PHP code is producing errors in one of the outputs. Here is an example - WARNING: This is a NSFW site - these pics are of an adult nature here is a URL: http://www.upit-downit.com/viewer.php?file=40349009307852588423.jpg Where there is whitespace - there should be an image This is the stock preview pic and I have created a second viewer - called viewer2 so adding a "2" to the URL above the template file loads http://www.upit-downit.com/viewer2.php?file=40349009307852588423.jpg I have a million of these errors in the error log [15-Oct-2009 22:21:16] PHP Parse error: syntax error, unexpected ',' in /home/notyouor/public_html/upit-downit.com/source/includes/template.php(108) : eval()'d code on line 93 here is my template.php file http://rapidshare.com/files/294415873/template.php.html I have no idea what is causing this - and it doesnt happen on every file, just some If you need more information let me know I am no coder, and I do appreciate if someone can look at this GMC PS I have had this up at the Mihalism support site since the 4th of October and I am getting no help!
Can you echo out the html2parse variable and paste what that code is? Your problem is the template file you have (.tpl file) is not giving you the correct input
Hi JAY6390 I appreciate the help I am unsure of what variable I should be echoing - as I said I am no coder - I just manage to get by (badly at that) Here is the template.php file <?php // ======================================== \ // Package: Mihalism Multi Host // Version: 5.0.0 // Copyright (c) 2007, 2008, 2009 Mihalism Technologies // License: http://www.gnu.org/licenses/gpl.txt GNU Public License // LTE: 1251319798 - Wednesday, August 26, 2009, 04:49:58 PM EDT -0400 // ======================================== / class mmhclass_template_engine { // Class Initialization Method function __construct() { global $mmhclass; $this->mmhclass = &$mmhclass; $this->templ_vars = $this->templ_globals = array(); $this->cif_check = array( "thefile" => "4619e2d1cf360c591e18ddb436842c77", "thefoot" => "PCEtLSBQb3dlcmVkIGJ5IE1paGFsaXNtIE11bHRpIEhvc3QgLSBDb3B5cmlnaHQgKGMpIDIwMDcsIDIwMDgsIDIwMDkgTWloYWxpc20gVGVjaG5vbG9naWVzICh3d3cubWloYWxpc20ubmV0KSAtLT4=", "thematch" => "http://www.mihalism.net/multihost/", "theurl" => "http://callhome.mihalism.net/multihost/?id=%s&lc=1", "therror" => "No linkback found in footer.<br />Using ILLEGAL copies is BAD.", ); } function output($filename = NULL, $template = NULL) { $template_html = sprintf("%s%s%s%s", $this->page_header(), ((isset($this->html) == true) ? $this->html : $this->parse_template($filename, $template)), $this->page_footer(), sprintf("\n%s", base64_decode($this->cif_check['thefoot']))); $this->mmhclass->db->close(); exit($this->tidy_html($template_html)); } function outputviewer2($filename = NULL, $template = NULL) { $template_html = sprintf("%s%s%s%s", $this->page_header2(), ((isset($this->html) == true) ? $this->html : $this->parse_template($filename, $template)), $this->page_footer2(), sprintf("\n%s", base64_decode($this->cif_check['thefoot']))); $this->mmhclass->db->close(); exit($this->tidy_html($template_html)); } function parse_template($filename, $template = NULL) { if ($this->mmhclass->funcs->is_file("{$this->mmhclass->info->root_path}source/public_html/{$filename}.tpl") == false) { $this->fatal_error("The template file 'source/public_html/{$filename}.tpl' does not exist."); } else { $html2parse = implode("", file("{$this->mmhclass->info->root_path}source/public_html/{$filename}.tpl")); $html2parse = preg_replace(array('#<([\?%])=?.*?\1>#s', '#<script\s+language\s*=\s*(["\']?)php\1\s*>.*?</script\s*>#s', '#<\?php(?:\r\n?|[ \n\t]).*?\?>#s', "#<!-- (BEGIN|END): (.*) -->#", "#<\\$(.*?)\\$>#Us"), NULL, $html2parse); if ($this->mmhclass->funcs->is_null($template) == false) { if (preg_match("#<template id=\"{$template}\">(.*)</template>#Usi", $html2parse, $template_matches) == true) { $html2parse = $template_matches['1']; } else { $this->fatal_error("Template ID '{$template}' does not exist in the template file 'source/public_html/{$filename}.tpl'."); } } if (is_array($this->templ_vars) == true && $this->mmhclass->funcs->is_null($this->templ_vars) == false) { foreach ($this->templ_vars as $index => $variable_block) { foreach ($variable_block as $variable => $replacement) { if (stripos($html2parse, "<# {$variable} #>") !== false) { $html2parse = str_replace("<# {$variable} #>", $replacement, $html2parse); unset($this->templ_vars[$index][$variable]); } } } } $html2parse = ((md5($filename) == $this->cif_check['thefile']) ? $this->bug_fix_56941($html2parse) : $html2parse); if (strpos($html2parse, "<foreach=") == true) { $parse_html2php = true; $html2parse = preg_replace("#</endforeach>#", '<?php } ?>', $html2parse); $html2parse = preg_replace("#<foraech=\"([^\n]+)\">#", '<?php foreach ($1) { ?>', $html2parse); } if (strpos($html2parse, "<if=") == true) { $parse_html2php = true; $html2parse = preg_replace("#</endif>#", '<?php } ?>', $html2parse); $html2parse = preg_replace("#<else>#", '<?php } else { ?>', $html2parse); $html2parse = preg_replace("#<if=\"([^\n]+)\">#", '<?php if ($1) { ?>', $html2parse); $html2parse = preg_replace("#<elseif=\"([^\n]+)\">#", '<?php } elseif ($1) { ?>', $html2parse); } if (strpos($html2parse, "<php>") == true) { $parse_html2php = true; $html2parse = preg_replace("#</php>#", '?>', $html2parse); $html2parse = preg_replace("#<php>#", '<?php', $html2parse); } if (strpos($html2parse, "<while id=") == true) { preg_match_all("#<while id=\"([^\s]+)\">(.*)</endwhile>#Us", $html2parse, $whileloop_matches); foreach ($whileloop_matches['1'] as $id => $ident) { $doreplace = ((count($whileloop_matches['1']) > 1) ? $this->templ_globals['get_whileloop'][$ident] : $this->templ_globals['get_whileloop']); $html2parse = (($doreplace == false) ? preg_replace("#<while id=\"{$ident}\">(.*)</endwhile>#Us", $this->templ_globals[$ident], $html2parse) : $whileloop_matches['2'][$id]); } } if ($parse_html2php == true) { $mmhclass = $this->mmhclass; ob_start(); eval("?>{$html2parse}"); $html2parse = ob_get_clean(); } return $html2parse; } } function tidy_html($html) { if (ENABLE_TEMPLATE_TIDY_HTML == true) { $tidy_config = array( 'wrap' => 0, "tab-size" => 4, "clean" => true, "tidy-mark" => true, "indent-cdata" => true, "force-output" => true, "output-xhtml" => true, "merge-divs" => false, "merge-spans" => false, "sort-attributes" => true, ); $html = tidy_parse_string($html, $tidy_config, "UTF8"); $html->cleanRepair(); } return trim($html); } function page_header() { if ($this->mmhclass->funcs->is_null($this->page_header) == true) { $this->templ_vars[] = array( "VERSION" => $this->mmhclass->info->version, "BASE_URL" => $this->mmhclass->info->base_url, "SITE_NAME" => $this->mmhclass->info->config['site_name'], "USERNAME" => $this->mmhclass->info->user_data['username'], "RETURN_URL" => base64_encode($this->mmhclass->info->page_url), "PAGE_TITLE" => (($this->mmhclass->funcs->is_null($this->page_title) == false) ? $this->page_title : $this->mmhclass->info->config['site_name']), ); return $this->parse_template("page_header"); } else { return $this->page_header; } } function page_footer() { if ($this->mmhclass->funcs->is_null($this->page_footer) == true) { $this->templ_vars[] = array( "GOOGLE_ANALYTICS_ID" => $this->mmhclass->info->config['google_analytics'], "PAGE_LOAD" => substr(($this->mmhclass->funcs->microtime_float() - $this->mmhclass->info->init_time), 0, 5), "TOTAL_PAGE_VIEWS" => (($this->mmhclass->funcs->is_null($this->mmhclass->info->site_cache['page_views']) == true) ? $this->mmhclass->lang['6697'] : $this->mmhclass->funcs->format_number($this->mmhclass->info->site_cache['page_views'])), ); return $this->parse_template("page_footer"); } else { return $this->page_footer; } } function page_header2() { if ($this->mmhclass->funcs->is_null($this->page_header) == true) { $this->templ_vars[] = array( "VERSION" => $this->mmhclass->info->version, "BASE_URL" => $this->mmhclass->info->base_url, "SITE_NAME" => $this->mmhclass->info->config['site_name'], "USERNAME" => $this->mmhclass->info->user_data['username'], "RETURN_URL" => base64_encode($this->mmhclass->info->page_url), "PAGE_TITLE" => (($this->mmhclass->funcs->is_null($this->page_title) == false) ? $this->page_title : $this->mmhclass->info->config['site_name']), ); return $this->parse_template("page_header2"); } else { return $this->page_header; } } function page_footer2() { if ($this->mmhclass->funcs->is_null($this->page_footer) == true) { $this->templ_vars[] = array( "GOOGLE_ANALYTICS_ID" => $this->mmhclass->info->config['google_analytics'], "PAGE_LOAD" => substr(($this->mmhclass->funcs->microtime_float() - $this->mmhclass->info->init_time), 0, 5), "TOTAL_PAGE_VIEWS" => (($this->mmhclass->funcs->is_null($this->mmhclass->info->site_cache['page_views']) == true) ? $this->mmhclass->lang['6697'] : $this->mmhclass->funcs->format_number($this->mmhclass->info->site_cache['page_views'])), ); return $this->parse_template("page_footer2"); } else { return $this->page_footer; } } function lightbox_error($error, $output_html = false) { $this->templ_vars[] = array("ERROR" => $error); $function = (($output_html == true) ? "output" : "parse_template"); return $this->$function("global", "global_lightbox_warning"); } function error($error, $output_html = true) { $this->templ_vars[] = array("ERROR" => $error); $function = (($output_html == true) ? "output" : "parse_template"); return $this->$function("global", "global_warning_box"); } function message($message, $output_html = false) { $this->templ_vars[] = array("MESSAGE" => $message); $function = (($output_html == true) ? "output" : "parse_template"); return $this->$function("global", "global_message_box"); } function fatal_error($error) { exit("\t\t\t<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> <html> <head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /> <title>Fatal Error (Powered by Mihalism Multi Host)</title> <style type=\"text/css\"> * { font-size: 100%; margin: 0; padding: 0; } body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 75%; margin: 10px; background: #FFFFFF; color: #000000; } a:link, a:visited { text-decoration: none; color: #005fa9; background-color: transparent; } a:active, a:hover { text-decoration: underline; } textarea { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; border: 1px dashed #000000; background: #FFFFFF; padding: 5px; background: #f4f4f4; } </style> </head> <body> <p><strong>Fatal Error</strong> <br /><br /> {$error} <br /><br /> Application Exited</p> </body> </html>"); } function bug_fix_56941($html) { // This check is not too well hidden, but most honest people // will not bother looking for it to claim something as their own. // Honest people would actually contact support@mihalism.net // to obtain a lifetime $50 license to remove the actual check. if ($this->mmhclass->info->site_installed == true) { if ($this->mmhclass->funcs->is_null($this->mmhclass->info->config['paid_removal']) == false && $this->mmhclass->funcs->is_null($this->mmhclass->info->config['server_license']) == false) { if ($this->mmhclass->info->config['paid_removal'] === $this->mmhclass->info->config['server_license']) { if ((int)$this->mmhclass->info->config['removal_checked'] == 0) { if ((int)$this->mmhclass->funcs->get_http_content(sprintf($this->mmhclass->funcs->ascii2string($this->cif_check['theurl']), base64_encode(serialize(array("site" => $this->mmhclass->input->server_vars['http_host'])))), 1) == 1) { $result = $this->mmhclass->db->query("INSERT INTO `[1]` (`config_key`, `config_value`) VALUES ('removal_checked', 1);", array(MYSQL_SITE_SETTINGS_TABLE)); } else { $this->fatal_error($this->mmhclass->funcs->ascii2string($this->cif_check['therror'])); } } else { $skipcheck = true; } } } if ($skipcheck == false) { if (stripos($html, $this->mmhclass->funcs->ascii2string($this->cif_check['thematch'])) === false) { $this->fatal_error($this->mmhclass->funcs->ascii2string($this->cif_check['therror'])); } } } return $html; } /* ============================================================================================ The following functions are a few basic global implementations of the template engine. They are located in this file because there is not really any other place that makes sense to place them. ============================================================================================ */ function pagelinks($base_url, $total_results) { $base_url .= ((strpos($base_url, "?") !== false) ? "&" : "?"); $total_pages = ceil($total_results / $this->mmhclass->info->config['max_results']); $current_page = (($this->mmhclass->info->current_page > $total_pages) ? $total_pages : $this->mmhclass->info->current_page); if ($total_pages < 2) { $template_html = $this->mmhclass->lang['3384']; } else { $template_html = (($current_page > 1) ? sprintf($this->mmhclass->lang['3484'], sprintf("%spage=%s", $base_url, ($this->mmhclass->info->current_page - 1))) : NULL); for ($i = 1; $i <= $total_pages; $i++) { if ($i == $current_page) { $template_html .= sprintf("<strong>%s</strong>", $this->mmhclass->funcs->format_number($i)); } else { if ($i < ($current_page - 5)) { continue; } if ($i > ($current_page + 5)) { break; } $template_html .= sprintf("<a href=\"%spage=%s\">%s</a>", $base_url, $i, $this->mmhclass->funcs->format_number($i)); } } $template_html .= (($current_page < $total_pages) ? sprintf($this->mmhclass->lang['5475'], sprintf("%spage=%s", $base_url, ($this->mmhclass->info->current_page + 1))) : NULL); $template_html = sprintf($this->mmhclass->lang['7033'], $current_page, $total_pages, $template_html); } return sprintf($this->mmhclass->lang['5834'], $template_html); } function file_results($filename){ if ($this->mmhclass->funcs->is_null($filename) == true || $this->mmhclass->funcs->is_file($filename, $this->mmhclass->info->root_path.$this->mmhclass->info->config['upload_path']) == false) { return $this->error(sprintf($this->mmhclass->lang['4552'], $this->mmhclass->image->basename($filename))); } else { $thumbnail_size = $this->mmhclass->image->scale($this->mmhclass->image->thumbnail_name($filename), 125, 125); $this->templ_globals['extension'] = $this->mmhclass->image->file_extension($filename); $this->templ_vars[] = array( "BASE_URL" => $this->mmhclass->info->base_url, "FILENAME" => $this->mmhclass->image->basename($filename), "SITE_NAME" => $this->mmhclass->info->config['site_name'], "UPLOAD_PATH" => $this->mmhclass->info->config['upload_path'], "THUMBNAIL_SIZE" => sprintf("style=\"width: %spx; height: %spx;\"", $thumbnail_size['w'], $thumbnail_size['h']), "THUMBNAIL" => (($this->mmhclass->funcs->is_file($this->mmhclass->image->thumbnail_name($filename), $this->mmhclass->info->root_path.$this->mmhclass->info->config['upload_path']) == false) ? "{$this->mmhclass->info->base_url}css/images/no_thumbnail.png" : $this->mmhclass->info->base_url.$this->mmhclass->info->config['upload_path'].$this->mmhclass->image->thumbnail_name($filename)), ); $template_html = $this->parse_template("upload", "standard_file_results"); unset($this->templ_globals['extension'], $this->templ_vars); return $template_html; } } } ?> Code (markup): and here is the .tpl file - I wouldnt have thought it was this - lol I just taken out the ad codes <!-- BEGIN: MAIN VIEWER PAGE --> <if="$mmhclass->templ->templ_globals['new_file_rating'] == true"> <# NEW_RATING_HTML #><hr /> </endif> <div class="text_align_center"> <if="$mmhclass->funcs->is_null($mmhclass->input->get_vars['is_random']) == false"> <a href="index.php?do_random=1" class="button1">New Random Image</a> <br /><br /> </endif> <a href="<# UPLOAD_PATH #><# FILENAME #>"><img src="<# UPLOAD_PATH #><# FILENAME #>" alt="<# REAL_FILENAME #>" style="border: 1px dashed #000000; padding: 2px; <# IMAGE_RESIZE #>" /></a> <if="$mmhclass->templ->templ_globals['file_info']['width'] > 940"> <br /><br /> <b>Resize</b>: The above image has been resized to better fit your screen. To view its <a href="<# UPLOAD_PATH #><# FILENAME #>">true size</a>, click it. </endif> </div><hr /> <div align="center"><!-- Begin: Black Label Ads, Generated: 2009-04-30 7:09:44 --> <script type="text/javascript"> try{var AdBrite_Iframe=window.top!=window.self?2:1;vaeURIComponent;var AdBrite_Referrer='';} </script> <span style="white-space:nowrap;"><script type="text/javascript">document.write(S://files.adbrite.com/mb/images/adbrite-your-ad-here-leaderboard.gif" style="background-color:#CCCCCC;border:none;padding:0;margin:0;" alt="Your Ad Here" width="14" height="90" border="0" /></a></span> <!-- End: Black Label Ads --></div> <div class="align_left_mfix"> <a href="download.php?file=<# FILENAME #>" class="button1">Download Image</a> <a href="contact.php?act=file_report&file=<# FILENAME #>" class="button1">Report Image</a> <span onclick="toggle('file_rating_block');" class="button1">Rate Image</span> <a href="links.php?file=<# FILENAME #>" class="button1">Image Links</a> </div> <div class="align_right_mfix"> <a href="http://www.addthis.com/bookmark.php?v=250&pub=xa-4a982a3323ec2793" class="addthis_button button1">Share Image</a> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a982a3323ec2793"></script> </div> <br /><br /> <div id="file_rating_block" style="display: none;"> <div class="table_border"> <table cellpadding="4" cellspacing="1" border="0" style="width: 100%;"> <tr> <th colspan="2">File Rating</th> </tr> <tr> <td style="width: 44%;" class="tdrow1"> </td> <td style="width: 56%;" class="tdrow1"> Rate This Image: <br /><br /> <form action="viewer.php?act=rate_it&file=<# FILENAME #>" method="post"> <p> <input type="radio" name="rating_id" value="5" /> <img src="css/images/ratings/22222.png" alt="Excellent!" style="vertical-align: -20%;" /> Excellent!<br /> <input type="radio" name="rating_id" value="4" /> <img src="css/images/ratings/22220.png" alt="Very Good" style="vertical-align: -20%;" /> Very Good<br /> <input type="radio" name="rating_id" value="3" checked="checked" /> <img src="css/images/ratings/22200.png" alt="Good" style="vertical-align: -20%;" /> Good<br /> <input type="radio" name="rating_id" value="2" /> <img src="css/images/ratings/22000.png" alt="Fair" style="vertical-align: -20%;" /> Fair<br /> <input type="radio" name="rating_id" value="1" /> <img src="css/images/ratings/20000.png" alt="Poor" style="vertical-align: -20%;" /> Poor <br /><br /> <input type="submit" value="Rate It!" class="button1" /> <input type="button" value="Cancel" class="button1" onclick="toggle('file_rating_block');" /> </p> </form> </td> </tr> <tr> <td colspan="2" class="table_footer"> </td> </tr> </table> </div><hr /> </div> <div class="table_border"> <table cellpadding="4" cellspacing="1" border="0" style="width: 100%;"> <tr> <th colspan="2">Image Meta Information</th> </tr> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Original Filename:</span></td> <td class="tdrow2"><a href="<# UPLOAD_PATH #><# FILENAME #>"><# REAL_FILENAME #></a></td> </tr> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Dimensions:</span></td> <td class="tdrow2"><# IMAGE_WIDTH #> x <# IMAGE_HEIGHT #> Pixels (Width by Height)</td> </tr> <if="<# VIEWER_CLICKS #> > 1"> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Clicks to Page:</span></td> <td class="tdrow2"><# VIEWER_CLICKS #> External Clicks</td> </tr> </endif> <if="$mmhclass->funcs->is_null($mmhclass->templ->templ_globals['file_info']['comment']) == true"> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Mime Type:</span></td> <td class="tdrow2"><a href="http://www.fileinfo.com/extension/<# FILE_EXTENSION #>"><# MIME_TYPE #></a></td> </tr> <else> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Meta Comment:</span></td> <td class="tdrow2"><# HIDDEN_COMMENT #></td> </tr> </endif> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Date Uploaded:</span></td> <td class="tdrow2"><# DATE_UPLOADED #></td> </tr> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Total Filesize:</span></td> <td class="tdrow2"><# TOTAL_FILESIZE #></td> </tr> <tr> <td style="width: 44%" class="tdrow1"><span class="arial">Rating:</span></td> <td class="tdrow2"><img src="index.php?module=rating&file=<# FILENAME #>" style="vertical-align: -20%;" alt="File Rating" /> ( <# TOTAL_RATINGS #> Votes )</td> </tr> <tr> <td colspan="2" class="tdrow2"><# FILE_LINKS #></td> </tr> <tr> <td colspan="2" class="table_footer"> </td> </tr> </table> </div> <!-- END: MAIN VIEWER PAGE --> Code (markup): Any help you can give me is appreciated GMC
It is the template file. You've edited something that it needed out of the file and it's made the generated php code wrong. If you have a copy of the template with the ads use that and slowly remove portions until the ads are gone and the code is still working
What I did - Is download a fresh copy of the source code and updated the viewer.tpl file from this download into my site Sorry to say that even with an untouched template - it still doesnt work Is there anything else it could be Cheers and thanks for helping GMC