david40 Posted February 23, 2009 Share Posted February 23, 2009 I am moving from Fedora Core 2 to CentOS 5. I have Apache 2.2.3, php 5.1.6, mysql 5.0.45. This was all installed using yum. I am trying to move some sites that were coded using php to use a custom CMS. At first I was getting some errors about the Config.php not existing. The include_path was different from my old server so I tar'ed the old directory up and FTP'ed to the new include_path location which is now /usr/share/php and /usr/share/pear. Now when I try to load the site I get a Fatal Error: Class 'Config' not found in /home/website/public_html/includes/run.loadconfig.php on line 11. Below is the run.loadconfig.php. <?php if (!defined('_CMS_')) { die('Invalid Request'); } ob_start(); // LOAD CONFIGURATION DATA require_once('Config.php'); $conf = new Config(); $root =& $conf->parseConfig(_HOME_DIR_.'config/config.xml', 'XML'); if (PEAR::isError($root)) { die('<strong>Unable to Load Configuration Data.</strong><br />'.$root->getMessage()); } $settings = $root->toArray(); $settings = $settings['root']['Configuration']; //print '<pre>'; print_r($settings); print '</pre>'; // INITIALIZE LOG FILE require_once('Log.php'); $logConf = array('mode' => 0600, 'timeFormat' => '%X %x'); $log = &Log::singleton('file', $settings['System']['localpath'].'config/cms.log', 'cmslog', $logConf, LOG_INFO); if (PEAR::isError($log)) { die('<strong>Unable to Initialize Logfile.</strong><br />'.$log->getMessage()); } if ($settings['System']['logging'] == 'enabled') { $log->log($_SERVER['PHP_SELF'].' Requested by '.$_SERVER['REMOTE_ADDR']); } // CONNECT TO DATABASE require_once('DB.php'); require_once('DB/QueryTool.php'); require_once('DB/QueryTool/Result.php'); $dsn = $settings['Database']; $options = array('debug' => 2); $db =& DB::connect($dsn, $options); if (DB::isError($db)) { if ($settings['System']['logging'] == 'enabled') { $log->log($_SERVER['PHP_SELF'].' '.$db->getMessage()); } $_SESSION['Message'] .= ':<strong>Unable to Establish Database Connection.</strong><br />'.$db->getMessage(); } $db->setFetchMode(DB_FETCHMODE_ASSOC); // LOAD CLASS FILES $dh = opendir($settings['System']['localpath'].'includes/'); while (false !== ($file = readdir($dh))) { if (preg_match('/class\./i', $file)) require_once($file); } // MISC session_start(); ?> Link to comment https://forums.phpfreaks.com/topic/146583-fatal-error-class-not-found/ Share on other sites More sharing options...
samshel Posted February 23, 2009 Share Posted February 23, 2009 1) place your code in blocks. 2) make sure your Config.php is included using some prints in it 3) make sure there is Config class in your Config.php 4) make sure the class is instantiated using print in constructor - although u cannot check this as at the moment, it cannot find the class. Link to comment https://forums.phpfreaks.com/topic/146583-fatal-error-class-not-found/#findComment-769533 Share on other sites More sharing options...
david40 Posted February 23, 2009 Author Share Posted February 23, 2009 1) place your code in Code: [select]blocks. Sorry about that this is my first time on the forums. 2) make sure your Config.php is included using some prints in it Is this what you are talking about? This is my run.loadconfig.php // LOAD CONFIGURATION DATA require_once('Config.php'); $conf = new Config(); 3) make sure there is Config class in your Config.php Is this what you are talking about? This is my Config.php which is located in my include_path. class Config { /** * Datasource * Can be a file url, a dsn, an object... * @var mixed */ var $datasrc; /** * Type of datasource for config * Ex: IniCommented, Apache... * @var string */ var $configType = ''; ........... ........... ?> 4) make sure the class is instantiated using print in constructor - although u cannot check this as at the moment, it cannot find the class. Im not really sure on how to do this. Link to comment https://forums.phpfreaks.com/topic/146583-fatal-error-class-not-found/#findComment-769559 Share on other sites More sharing options...
samshel Posted February 23, 2009 Share Posted February 23, 2009 echo "Inside Config.php..."; class Config { echo something just before your class def...it will tell u whether it is including that file or not. Link to comment https://forums.phpfreaks.com/topic/146583-fatal-error-class-not-found/#findComment-769643 Share on other sites More sharing options...
david40 Posted February 24, 2009 Author Share Posted February 24, 2009 Well the Config.php in my include path was not being processed. It is still not. I added the echo to it and hardcaoded the path in my run.loadconfig.php and I can see it processing now. However another error comes up. I feel like this is going to be a never ending saga. Anymore help would be greatly appreciated. Now I get a Fatal Error: Cannot redeclare class system in /home/.../class.system.php on line 14. I do not understand where the redeclaration is happening. I will paste the code of the run.loadconfig.php and class.system.php to see if anyone can help me find anything. If you need further information to help solve this or just have comments please feel free to speak up. Thanks run.loadconfig.php <?php if (!defined('_CMS_')) { die('Invalid Request'); } ob_start(); // LOAD CONFIGURATION DATA require_once('/usr/share/php/Config.php'); $conf = new Config(); $root =& $conf->parseConfig(_HOME_DIR_.'config/config.xml', 'XML'); if (PEAR::isError($root)) { die('<strong>Unable to Load Configuration Data.</strong><br />'.$root->getMessage()); } $settings = $root->toArray(); $settings = $settings['root']['Configuration']; //print '<pre>'; print_r($settings); print '</pre>'; // INITIALIZE LOG FILE require_once('Log.php'); $logConf = array('mode' => 0600, 'timeFormat' => '%X %x'); $log = &Log::singleton('file', $settings['System']['localpath'].'config/cms.log', 'cmslog', $logConf, LOG_INFO); if (PEAR::isError($log)) { die('<strong>Unable to Initialize Logfile.</strong><br />'.$log->getMessage()); } if ($settings['System']['logging'] == 'enabled') { $log->log($_SERVER['PHP_SELF'].' Requested by '.$_SERVER['REMOTE_ADDR']); } // CONNECT TO DATABASE require_once('DB.php'); require_once('DB/QueryTool.php'); require_once('DB/QueryTool/Result.php'); $dsn = $settings['Database']; $options = array('debug' => 2); $db =& DB::connect($dsn, $options); if (DB::isError($db)) { if ($settings['System']['logging'] == 'enabled') { $log->log($_SERVER['PHP_SELF'].' '.$db->getMessage()); } $_SESSION['Message'] .= ':<strong>Unable to Establish Database Connection.</strong><br />'.$db->getMessage(); } $db->setFetchMode(DB_FETCHMODE_ASSOC); // LOAD CLASS FILES $dh = opendir($settings['System']['localpath'].'includes/'); while (false !== ($file = readdir($dh))) { if (preg_match('/class\./i', $file)) require_once($file); } // MISC session_start(); ?> class.system.php <?php if (!defined('_CMS_')) { die('Invalid Request'); } $allowedTags = '<h1><h2><h3><h4><h5><h6><b><i><a><ul><em><strong><ol><dl><dd><li><pre><hr><blockquote><img><map><area>'; $stripAttrib = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|'. 'onmousemove|onmouseout|onkeypress|onkeydown|onkeyup'; function void($val) { return $val; } class System { function ExtractFilename($str) { $parts = explode('/', $str); $filename = $parts[count($parts)-1]; return $filename; } function DatePicker($form, $field, $status = 'Date Picker', $overlib = 'Open Calendar') { print '<a href="javascript:show_calendar(\''.$form.'.'.$field.'\');" onmouseover="window.status=\''.$status.'\'; overlib(\''.$overlib.'\'); return true;" onmouseout="window.status=\'\'; nd(); return true;"><img src="images/show-calendar.gif" border="0"></a>'; } function Br($count = 1) { $str = ''; for ($i = 0; $i < $count; $i++) { $str .= '<br />'; } print($str); } function Out($arg) { print($arg); } function Halt($arg) { die($arg); } function Dump($arg) { print '<pre>'; print_r($arg); print '</pre>'; } function Void($val) { return $val; } function EscapeString($str) { $fn = ESCAPE_FUNCTION; return $fn($str); } function Redirect($url, $count, $hard = 0) { if ($hard) { header('Location: '.$url); } else { print '<meta http-equiv="refresh" content="' . $count . '; url=' . $url . '" />'; } } function Popup($linkText, $winName, $winParams, $winTarget) { $return = '<a href="#" onClick="javascript:window.open(\''.$winTarget.'\', \''.$winName.'\', \''.$winParams.'\')">'.$linkText.'</a>'; return $return; } function StripTags($str) { return System::removeTags($str); } function removeTags($source) { global $allowedTags; $source = strip_tags($source, $allowedTags); return preg_replace('/<(.*?)>/ie', "'<'.System::removeAttributes('\\1').'>'", $source); } function removeAttributes($tagSource) { global $stripAttrib; return stripslashes(preg_replace("/$stripAttrib/i", 'forbidden', $tagSource)); } function GetSnippet($text, $numChars) { if (strlen($text) > $numChars) { $words = stripslashes(substr($text, 0, $numChars)); $words = substr($words, 0, strrpos($words, ' ')).'...'; } else { $words = $text; } if (strlen($words) < 350) { $words = $text; } return $words; } function GetDays($day) { $days = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31); foreach($days as $d) { print '<option value="'.$d.'" '.($d == $day ? 'selected' : '').'>'.$d.'</option>'; } } function GetMonths($month) { $months = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); foreach($months as $m) { print '<option value="'.$m.'" '.($m == $month ? 'selected' : '').'>'.$m.'</option>'; } } function GetYears($year) { $years = array(date('Y'), date('Y') + 1, date('Y') + 2, date('Y') + 3, date('Y') + 4); foreach($years as $y) { print '<option value="'.$y.'" '.($y == $year ? 'selected' : '').'>'.$y.'</option>'; } } function GetHours($hour) { $hours = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); foreach($hours as $h) { print '<option value="'.$h.'" '.($h == $hour ? 'selected' : '').'>'.$h.'</option>'; } } function GetMinutes($minute){ while ($minute % 5 != 0) { $minute++; } $minutes = array(0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55); foreach($minutes as $m) { print '<option value="'.$m.'" '.($m == $minute ? 'selected' : '').'>'.$m.'</option>'; } } function GetAMPM($ampm) { $ampms = array('am', 'pm'); foreach($ampms as $a) { print '<option value="'.$a.'" '.($a == $ampm ? 'selected' : '').'>'.$a.'</option>'; } } function GetStates($state = '') { print '<option value="" '.(!$state ? 'selected' : '').'>Select State</option> <option value="AL" '.($state == 'AL' ? 'selected' : '').'>Alabama</option> <option value="AK" '.($state == 'AK' ? 'selected' : '').'>Alaska</option> <option value="AZ" '.($state == 'AZ' ? 'selected' : '').'>Arizona</option> <option value="AR" '.($state == 'AR' ? 'selected' : '').'>Arkansas</option> <option value="CA" '.($state == 'CA' ? 'selected' : '').'>California</option> <option value="CO" '.($state == 'CO' ? 'selected' : '').'>Colorado</option> <option value="CT" '.($state == 'CT' ? 'selected' : '').'>Connecticut</option> <option value="DE" '.($state == 'DE' ? 'selected' : '').'>Delaware</option> <option value="DC" '.($state == 'DC' ? 'selected' : '').'>District of Columbia</option> <option value="FL" '.($state == 'FL' ? 'selected' : '').'>Florida</option> <option value="GA" '.($state == 'GA' ? 'selected' : '').'>Georgia</option> <option value="HI" '.($state == 'HI' ? 'selected' : '').'>Hawaii</option> <option value="ID" '.($state == 'ID' ? 'selected' : '').'>Idaho</option> <option value="IL" '.($state == 'IL' ? 'selected' : '').'>Illinois</option> <option value="IN" '.($state == 'IN' ? 'selected' : '').'>Indiana</option> <option value="IA" '.($state == 'IA' ? 'selected' : '').'>Iowa</option> <option value="KS" '.($state == 'KS' ? 'selected' : '').'>Kansas</option> <option value="KY" '.($state == 'KY' ? 'selected' : '').'>Kentucky</option> <option value="LA" '.($state == 'LA' ? 'selected' : '').'>Louisiana</option> <option value="ME" '.($state == 'ME' ? 'selected' : '').'>Maine</option> <option value="MD" '.($state == 'MD' ? 'selected' : '').'>Maryland</option> <option value="MA" '.($state == 'MA' ? 'selected' : '').'>Massachusetts</option> <option value="MI" '.($state == 'MI' ? 'selected' : '').'>Michigan</option> <option value="MN" '.($state == 'MN' ? 'selected' : '').'>Minnesota</option> <option value="MS" '.($state == 'MS' ? 'selected' : '').'>Mississippi</option> <option value="MO" '.($state == 'MO' ? 'selected' : '').'>Missouri</option> <option value="MT" '.($state == 'MT' ? 'selected' : '').'>Montana</option> <option value="NE" '.($state == 'NE' ? 'selected' : '').'>Nebraska</option> <option value="NV" '.($state == 'NV' ? 'selected' : '').'>Nevada</option> <option value="NH" '.($state == 'NH' ? 'selected' : '').'>New Hampshire</option> <option value="NJ" '.($state == 'NJ' ? 'selected' : '').'>New Jersey</option> <option value="NM" '.($state == 'NM' ? 'selected' : '').'>New Mexico</option> <option value="NY" '.($state == 'NY' ? 'selected' : '').'>New York</option> <option value="NC" '.($state == 'NC' ? 'selected' : '').'>North Carolina</option> <option value="ND" '.($state == 'ND' ? 'selected' : '').'>North Dakota</option> <option value="OH" '.($state == 'OH' ? 'selected' : '').'>Ohio</option> <option value="OK" '.($state == 'OK' ? 'selected' : '').'>Oklahoma</option> <option value="OR" '.($state == 'OR' ? 'selected' : '').'>Oregon</option> <option value="PA" '.($state == 'PA' ? 'selected' : '').'>Pennsylvania</option> <option value="RI" '.($state == 'RI' ? 'selected' : '').'>Rhode Island</option> <option value="SC" '.($state == 'SC' ? 'selected' : '').'>South Carolina</option> <option value="SD" '.($state == 'SD' ? 'selected' : '').'>South Dakota</option> <option value="TN" '.($state == 'TN' ? 'selected' : '').'>Tennessee</option> <option value="TX" '.($state == 'TX' ? 'selected' : '').'>Texas</option> <option value="UT" '.($state == 'UT' ? 'selected' : '').'>Utah</option> <option value="VT" '.($state == 'VT' ? 'selected' : '').'>Vermont</option> <option value="VA" '.($state == 'VA' ? 'selected' : '').'>Virginia</option> <option value="WA" '.($state == 'WA' ? 'selected' : '').'>Washington</option> <option value="WV" '.($state == 'WV' ? 'selected' : '').'>West Virginia</option> <option value="WI" '.($state == 'WI' ? 'selected' : '').'>Wisconsin</option> <option value="WY" '.($state == 'WY' ? 'selected' : '').'>Wyoming</option> <option value="PR" '.($state == 'PR' ? 'selected' : '').'>Puerto Rico</option> <option value="VI" '.($state == 'VI' ? 'selected' : '').'>Virgin Island</option> <option value="MP" '.($state == 'MP' ? 'selected' : '').'>Northern Mariana Islands</option> <option value="GU" '.($state == 'GU' ? 'selected' : '').'>Guam</option> <option value="AS" '.($state == 'AS' ? 'selected' : '').'>American Samoa</option> <option value="PW" '.($state == 'PW' ? 'selected' : '').'>Palau</option> '; } } ?> 219,1 Bot Link to comment https://forums.phpfreaks.com/topic/146583-fatal-error-class-not-found/#findComment-770240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.