jmeyers Posted December 12, 2012 Share Posted December 12, 2012 hxxp:\\www.owsleykyhist.net is the site I'm working on. I'm trying to help the site administrator fix an issue that happened after they were trying to change something. I can't seem to figure out what they messed up, they seem to think it was an outside attack, but I'm not familiar with the cpanel or coding to figure out whats wrong. I've read through the site error log and seem to be coming up with this error since the problem started: Call to undefined function themeheader() in /home/owsley/public_html/header.php on line 52 I've replaced the header.php file (from public_html/header.php), as well as the theme.php (public_html/themes/Sand_Journey/theme.php) with versions from a site backup from 2008. Still having this issue repeatedly in the error log since then. Anyone got any ideas? Just to clarify, this error wasn't happening before a few days ago, so I'm not sure why the old files wouldn't correct it, but again, I'm not an expert at coding so I'm not sure what the issue is. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/ Share on other sites More sharing options...
jmeyers Posted December 12, 2012 Author Share Posted December 12, 2012 <?php /************************************************************************/ /* PHP-NUKE: Advanced Content Management System */ /* ============================================ */ /* */ /* Copyright (c) 2005 by Francisco Burzi */ /* http://phpnuke.org */ /* */ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /************************************************************************/ if (stristr($_SERVER['SCRIPT_NAME'], "header.php")) { Header("Location: index.php"); die(); } @require_once("mainfile.php"); ################################################## # Include some common header for HTML generation # ################################################## $header = 1; function head() { global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle; @include("includes/ipban.php"); $ThemeSel = get_theme(); @include("themes/$ThemeSel/theme.php"); echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"; echo "<html>\n"; echo "<head>\n"; echo "<title>$sitename $pagetitle</title>\n"; @include("includes/meta.php"); @include("includes/javascript.php"); if (file_exists("themes/$ThemeSel/images/favicon.ico")) { echo "<link REL=\"shortcut icon\" HREF=\"themes/$ThemeSel/images/favicon.ico\" TYPE=\"image/x-icon\">\n"; } echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"backend.php\">\n"; echo "<LINK REL=\"StyleSheet\" HREF=\"themes/$ThemeSel/style/style.css\" TYPE=\"text/css\">\n\n\n"; if (file_exists("includes/custom_files/custom_head.php")) { @include_once("includes/custom_files/custom_head.php"); } echo "\n\n\n</head>\n\n"; if (file_exists("includes/custom_files/custom_header.php")) { @include_once("includes/custom_files/custom_header.php"); } themeheader(); } online(); head(); @include("includes/counter.php"); global $home; if ($home == 1) { message_box(); blocks(Center); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399041 Share on other sites More sharing options...
jmeyers Posted December 12, 2012 Author Share Posted December 12, 2012 Since this file has been the same throughout, anyone that is familiar with code mind telling me what this is pointing at that is making like 52 have an error? If i can fix the file its referencing maybe I can fix the problem. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399042 Share on other sites More sharing options...
NomadicJosh Posted December 13, 2012 Share Posted December 13, 2012 Is the file that contains themeheader(); loading before this function has to be called. Also, is the function spelled correctly? Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399043 Share on other sites More sharing options...
Psycho Posted December 13, 2012 Share Posted December 13, 2012 There error is self explanatory. You are calling a function called themeheader() and the function has not been defined. When a page loads there can be any number of include files and even the file above could have been (and probably was) included from a different file. You need to figure our in which file themeheader() is defined and figure out where that file should be included. So, look at the include files in that script above first. Then you might have to trace from the page that the user first accesses to the script above. Also, as a quick test, I notice that all of your include()'s have an ampersand in front of them which would suppress an error. So, it could be that one or more of those include files have been moved or deleted (and one of them is where the function was defined). Remove those ampersands and see if any errors are reported. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399045 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Please don't take offense, I'm actually trying to follow your instructions, and I do appreciate your help immensely. I don't know if its because you were in a hurry, or possibly English is not your first language, but I don't understand a few of the things you're saying, could you please elaborate on a few things so I can make sure I understand them. "Then you might have to trace from the page that the user first accesses to the script above." "have an ampersand in front of them" I thought an ampersand was &. Could you type the symbol you mean so I can make sure I remove the right thing? Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399050 Share on other sites More sharing options...
MDCode Posted December 13, 2012 Share Posted December 13, 2012 Yes an ampersand is an & symbol. But psycho was referring to the @ sign. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399054 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Ok, thanks! I wish I could just take this themeheader() part of the code out and call it good. I'll try taking the @ out and see what I get. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399060 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Taking out all the @ symbols hasn't changed the error message I'm receiving. I'll keep looking into it. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399062 Share on other sites More sharing options...
Psycho Posted December 13, 2012 Share Posted December 13, 2012 "Then you might have to trace from the page that the user first accesses to the script above." I *assume* that the user is not typing www.yourdomain.com/header.php into their browser but is instead going to www.yourdomain.com/somepage.php and it is the somepage.php that is including some files and it either directly including header.php or one of the files that it is including is ultimately including header.php. When a user requests a page in their browser the server could be processing one file or hundreds - which are chained together through includes or requires. Somewhere in the processing of all those files the function themeheader() needs to be defined before you call the function. There is no way for us to know where that function is defined or how the page where it is defined was/is included. It could be that the function was removed or renamed or that the file which defines that function was removed, renamed or moved to a different location. "have an ampersand in front of them" I thought an ampersand was &. Could you type the symbol you mean so I can make sure I remove the right thing? Ok, so I said ampersand instead of apetail (i.e. at symbol). But seriously, you couldn't deduce that is what I meant? Every single one of the include statements begins with the same character. Here is another suggestion. Find a utility that will search the contents of all of the files and look for "function themeheader" and find out what page that file is defined in. Then do a search for any includes for that file. That should get you going in the right direction. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399067 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Sorry guys, I don't mean to sound like an idiot, but I've never dealt with this stuff before. I'm trying to help an elderly site admin who basically only knows how to add pictures and posts through an FTP program, someone made the site 8 years ago and then left the organization, so I'm really lost, but since I know a little about computers I'm just trying to get their homepage working again for them. Do you have any suggestions about a utility that can search the files? I've been using cpanel because it was the only way i knew of to get into the site files. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399068 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2012 Share Posted December 13, 2012 (edited) You need to download (FTP) a copy of all the current files so that you can perform searches and/or get the site running on a local development system. Edit: Actually, since you have a previous backup copy of the files, you should be searching the backup files to find where the function is defined at. Edit2: A programming editor, like notepad++, will have a "search all files within folder" function that you can use to find where the function is defined, assuming the name in the function call has not be altered. Edited December 13, 2012 by PFMaBiSmAd Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399069 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Found the function definition and copied and pasted it into the code, and seems like its needed in a lot of places, since I've corrected about 5 undefined functions in different files so far. Also my blank white pages are suddenly blue lol! Seems like I'm making progress, thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399076 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2012 Share Posted December 13, 2012 The step after finding the file where the function is defined, would be to find out why that particular file is not being included by the rest of the code or why the code in that file is not being seen as being php code. In the file where you found the function definition, were all the opening php tags full ones <?php or where they short ones <? Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399078 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 They were full ones. function themeheader() { global $user, $banners, $sitename, $slogan, $cookie, $prefix, $db; cookiedecode($user); $username = $cookie[1]; if ($username == "") { $username = "Anonymous"; } echo "<body bgcolor=\"#004080\" text=\"#000000\" link=\"#004080\" vlink=\"#004080\" alink=\"#004080\">"; if ($banners) { include("banners.php"); } $topics_list = "<select name=\"topic\" onchange='submit()'>\n"; $topics_list .= "<option value=\"\">All Topics</option>\n"; $toplist = $db->sql_query("select topicid, topictext from ".$prefix."_topics order by topictext"); while(list($topicid, $topics) = $db->sql_fetchrow($toplist)) { $topicid = intval($topicid); if ($topicid==$topic) { $sel = "selected "; } $topics_list .= "<option $sel value=\"$topicid\">$topics</option>\n"; $sel = ""; } if ($username == "Anonymous") { $theuser = " <a href=\"modules.php?name=Your_Account\">Create an account"; } else { $theuser = " Welcome $username!"; } $public_msg = public_message(); $tmpl_file = "themes/Odyssey/header.html"; $thefile = implode("", file($tmpl_file)); $thefile = addslashes($thefile); $thefile = "\$r_file=\"".$thefile."\";"; eval($thefile); print $r_file; blocks(left); $tmpl_file = "themes/Odyssey/left_center.html"; $thefile = implode("", file($tmpl_file)); $thefile = addslashes($thefile); $thefile = "\$r_file=\"".$thefile."\";"; eval($thefile); print $r_file; } This was what was in the file, and it started with a <?php, then had various other functions defined, in fact, it looked like a template from phpnuke.org defining the various functions, as there was greyed-out text above each one, giving a small description from them, but it had been modified by the site designers when they initially started, since there were numerous additions and specifics about the site. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399084 Share on other sites More sharing options...
jmeyers Posted December 13, 2012 Author Share Posted December 13, 2012 Needless to say, I'm at a stopping point as there are no errors in the log, but the links that point to things, such as one that would say siteinfo/modules.php?name=Topics, are still directing me to screens that are either completely blank, or completely blank with a blue background. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399085 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2012 Share Posted December 13, 2012 The next step would be - to find out why that particular file is not being included by the rest of the code By copy/pasting the function definition into the files where it is called, is only fixing a symptom, the one error message. The actual problem remains. The other things in that file are needed by the application, otherwise they wouldn't have been present in that file along with the themeheader() function definition. Is that file present on the server? Is the file on the server identical to the file in the backup? Where and how is that file being included by the main/other files making up the application? Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399089 Share on other sites More sharing options...
Psycho Posted December 13, 2012 Share Posted December 13, 2012 I'll add the following: OK, so you've found the file where the function is defined. So, somewhere that file was previously being included. There are a few things you can to figure out the cause: 1. The file was moved from it's previous location so the include() can't find it. You can check this by doing a search of the files for the file name. If you find any includes see if the path matches the file's actual location 2. The file name was changed so, again, the include() cannot find the file. I would suggest removing the at symbol from the front of every include() in all your files. 3. The last possibility is that the line of code to include the file has been removed. If this is the case, well, I don't know. It would be difficult to figure out where the include should be unless there are appropriate comments in the code. Quote Link to comment https://forums.phpfreaks.com/topic/271931-call-to-undefined-function-themeheader/#findComment-1399093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.