Question

PHP Controller redirection isn't working?

Asked by: snowball77

Hi there,
I have set up a login process here:
http://widowspeak.com.au/index.php

If you login you go through the process etc but once you login the page it redirects to is BLANK!!

I set up the redirection to go to:

// Check to see if they're logged in, because they don't need activating!
            if ($user->get('id')) {
                  // They're already logged in, so redirect them to the home page
                  $mainframe->redirect( 'index.php?option=com_joomunity&Itemid=57' );
            }

            if ($allowUserRegistration == '0' || $userActivation == '0') {
                  JError::raiseError( 403, JText::_( 'Access Forbidden' ));
                  return;
            }

However it doesn't go to this page
http://widowspeak.com.au/index.php?option=com_joomunity&Itemid=57

as I requested?

What am I doing wrong?

I have attached the whole controller.php page that controls the login process.
I hope someone can help

<?php
/**
 * @version		$Id: controller.php 10094 2008-03-02 04:35:10Z instance $
 * @package		Joomla
 * @subpackage	Content
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */
 
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die( 'Restricted access' );
 
jimport('joomla.application.component.controller');
 
/**
 * User Component Controller
 *
 * @package		Joomla
 * @subpackage	Weblinks
 * @since 1.5
 */
class UserController extends JController
{
	/**
	 * Method to display a view
	 *
	 * @access	public
	 * @since	1.5
	 */
	function display()
	{
		parent::display();
	}
 
	function edit()
	{
		global $mainframe, $option;
 
		$db		=& JFactory::getDBO();
		$user	=& JFactory::getUser();
 
		if ( $user->get('guest')) {
			JError::raiseError( 403, JText::_('Access Forbidden') );
			return;
		}
 
		JRequest::setVar('layout', 'form');
 
		parent::display();
	}
 
	function save()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		$user	 =& JFactory::getUser();
		$userid = JRequest::getVar( 'id', 0, 'post', 'int' );
 
		// preform security checks
		if ($user->get('id') == 0 || $userid == 0 || $userid <> $user->get('id')) {
			JError::raiseError( 403, JText::_('Access Forbidden') );
			return;
		}
 
		//clean request
		$post = JRequest::get( 'post' );
		$post['username']	= JRequest::getVar('username', '', 'post', 'username');
		$post['password']	= JRequest::getVar('password', '', 'post', 'string', JREQUEST_ALLOWRAW);
		$post['password2']	= JRequest::getVar('password2', '', 'post', 'string', JREQUEST_ALLOWRAW);
 
		// do a password safety check
		if(strlen($post['password']) || strlen($post['password2'])) { // so that "0" can be used as password e.g.
			if($post['password'] != $post['password2']) {
				$msg	= JText::_('PASSWORDS_DO_NOT_MATCH');
				$this->setRedirect($_SERVER['HTTP_REFERER'], $msg);
				return false;
			}
		}
 
		// we don't want users to edit certain fields so we will unset them
		unset($post['gid']);
		unset($post['block']);
		unset($post['usertype']);
		unset($post['registerDate']);
		unset($post['activation']);
 
		// store data
		$model = $this->getModel('user');
 
		if ($model->store($post)) {
			$msg	= JText::_( 'Your settings have been saved.' );
		} else {
			//$msg	= JText::_( 'Error saving your settings.' );
			$msg	= $model->getError();
		}
 
		$this->setRedirect( $_SERVER['HTTP_REFERER'], $msg );
	}
 
	function cancel()
	{
		$this->setRedirect( 'index.php' );
	}
 
	function login()
	{
		// Check for request forgeries
		JRequest::checkToken('request') or jexit( 'Invalid Token' );
 
		global $mainframe;
 
		if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
			$return = base64_decode($return);
		}
 
		$options = array();
		$options['remember'] = JRequest::getBool('remember', false);
		$options['return'] = $return;
 
		$credentials = array();
		$credentials['username'] = JRequest::getVar('username', '', 'method', 'username');
		$credentials['password'] = JRequest::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);
 
		//preform the login action
		$error = $mainframe->login($credentials, $options);
 
 
	}
 
	function logout()
	{
		global $mainframe;
 
		//preform the logout action
		$error = $mainframe->logout();
 
		if(!JError::isError($error))
		{
			if ($return = JRequest::getVar('return', '', 'method', 'base64')) {
				$return = base64_decode($return);
			}
 
			// Redirect if the return url is not registration or login
			if ( $return && !( strpos( $return, 'com_user' )) ) {
				$mainframe->redirect( $return );
			}
		} else {
			parent::display();
		}
	}
 
	/**
	 * Prepares the registration form
	 * @return void
	 */
	function register()
	{
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		if (!$usersConfig->get( 'allowUserRegistration' )) {
			JError::raiseError( 403, JText::_( 'Access Forbidden' ));
			return;
		}
 
		JRequest::setVar('view', 'register');
 
		parent::display();
	}
 
	/**
	 * Save user registration and notify users and admins if required
	 * @return void
	 */
	function register_save()
	{
		global $mainframe;
 
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// Get required system objects
		$user 		= clone(JFactory::getUser());
		$pathway 	=& $mainframe->getPathway();
		$config		=& JFactory::getConfig();
		$authorize	=& JFactory::getACL();
		$document   =& JFactory::getDocument();
 
		// If user registration is not allowed, show 403 not authorized.
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		if ($usersConfig->get('allowUserRegistration') == '0') {
			JError::raiseError( 403, JText::_( 'Access Forbidden' ));
			return;
		}
 
		// Initialize new usertype setting
		$newUsertype = $usersConfig->get( 'new_usertype' );
		if (!$newUsertype) {
			$newUsertype = 'Registered';
		}
 
		// Bind the post array to the user object
		if (!$user->bind( JRequest::get('post'), 'usertype' )) {
			JError::raiseError( 500, $user->getError());
		}
 
		// Set some initial user values
		$user->set('id', 0);
		$user->set('usertype', '');
		$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
 
		$date =& JFactory::getDate();
		$user->set('registerDate', $date->toMySQL());
 
		// If user activation is turned on, we need to set the activation information
		$useractivation = $usersConfig->get( 'useractivation' );
		if ($useractivation == '1')
		{
			jimport('joomla.user.helper');
			$user->set('activation', md5( JUserHelper::genRandomPassword()) );
			$user->set('block', '1');
		}
 
		// If there was an error with registration, set the message and display form
		if ( !$user->save() )
		{
			JError::raiseWarning('', JText::_( $user->getError()));
			$this->register();
			return false;
		}
 
		// Send registration confirmation mail
		$password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
		$password = preg_replace('/[\x00-\x1F\x7F]/', '', $password); //Disallow control chars in the email
		UserController::_sendMail($user, $password);
 
		// Everything went fine, set relevant message depending upon user activation state and display message
		if ( $useractivation == 1 ) {
			$message  = JText::_( 'REG_COMPLETE_ACTIVATE' );
		} else {
			$message = JText::_( 'REG_COMPLETE' );
		}
 
		//TODO :: this needs to be replace by raiseMessage
		JError::raiseNotice('', $message);
		$this->register(); $this->setRedirect('index.php?option=com_content&view=article&id=46');
	}
 
	function activate()
	{
		global $mainframe;
 
		// Initialize some variables
		$db			=& JFactory::getDBO();
		$user 		=& JFactory::getUser();
		$document   =& JFactory::getDocument();
		$pathway 	=& $mainframe->getPathWay();
 
		$usersConfig = &JComponentHelper::getParams( 'com_users' );
		$userActivation			= $usersConfig->get('useractivation');
		$allowUserRegistration	= $usersConfig->get('allowUserRegistration');
 
		// Check to see if they're logged in, because they don't need activating!
		if ($user->get('id')) {
			// They're already logged in, so redirect them to the home page
			$mainframe->redirect( 'index.php?option=com_joomunity&Itemid=57' );
		}
 
		if ($allowUserRegistration == '0' || $userActivation == '0') {
			JError::raiseError( 403, JText::_( 'Access Forbidden' ));
			return;
		}
 
		// create the view
		require_once (JPATH_COMPONENT.DS.'views'.DS.'register'.DS.'view.html.php');
		$view = new UserViewRegister();
 
		$message = new stdClass();
 
		// Do we even have an activation string?
		$activation = JRequest::getVar('activation', '', '', 'alnum' );
		$activation = $db->getEscaped( $activation );
 
		if (empty( $activation ))
		{
			// Page Title
			$document->setTitle( JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' ) );
			// Breadcrumb
			$pathway->addItem( JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' ));
 
			$message->title = JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' );
			$message->text = JText::_( 'REG_ACTIVATE_NOT_FOUND' );
			$view->assign('message', $message);
			$view->display('message');
			return;
		}
 
		// Lets activate this user
		jimport('joomla.user.helper');
		if (JUserHelper::activateUser($activation))
		{
			// Page Title
			$document->setTitle( JText::_( 'REG_ACTIVATE_COMPLETE_TITLE' ) );
			// Breadcrumb
			$pathway->addItem( JText::_( 'REG_ACTIVATE_COMPLETE_TITLE' ));
 
			$message->title = JText::_( 'REG_ACTIVATE_COMPLETE_TITLE' );
			$message->text = JText::_( 'REG_ACTIVATE_COMPLETE' );
		}
		else
		{
			// Page Title
			$document->setTitle( JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' ) );
			// Breadcrumb
			$pathway->addItem( JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' ));
 
			$message->title = JText::_( 'REG_ACTIVATE_NOT_FOUND_TITLE' );
			$message->text = JText::_( 'REG_ACTIVATE_NOT_FOUND' );
		}
 
		$view->assign('message', $message);
		$view->display('message');
	}
 
	/**
	 * Password Reset Request Method
	 *
	 * @access	public
	 */
	function requestreset()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// Get the input
		$email		= JRequest::getVar('email', null, 'post', 'string');
 
		// Get the model
		$model = &$this->getModel('Reset');
 
		// Request a reset
		if ($model->requestReset($email) === false)
		{
			$message = JText::sprintf('PASSWORD_RESET_REQUEST_FAILED', $model->getError());
			$this->setRedirect('index.php?option=com_user&view=reset', $message);
			return false;
		}
 
		$this->setRedirect('index.php?option=com_user&view=reset&layout=confirm');
	}
 
	/**
	 * Password Reset Confirmation Method
	 *
	 * @access	public
	 */
	function confirmreset()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// Get the input
		$token = JRequest::getVar('token', null, 'post', 'alnum');
 
		// Get the model
		$model = &$this->getModel('Reset');
 
		// Verify the token
		if ($model->confirmReset($token) === false)
		{
			$message = JText::sprintf('PASSWORD_RESET_CONFIRMATION_FAILED', $model->getError());
			$this->setRedirect('index.php?option=com_user&view=reset&layout=confirm', $message);
			return false;
		}
 
		$this->setRedirect('index.php?option=com_user&view=reset&layout=complete');
	}
 
	/**
	 * Password Reset Completion Method
	 *
	 * @access	public
	 */
	function completereset()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// Get the input
		$password1 = JRequest::getVar('password1', null, 'post', 'string', JREQUEST_ALLOWRAW);
		$password2 = JRequest::getVar('password2', null, 'post', 'string', JREQUEST_ALLOWRAW);
 
		// Get the model
		$model = &$this->getModel('Reset');
 
		// Reset the password
		if ($model->completeReset($password1, $password2) === false)
		{
			$message = JText::sprintf('PASSWORD_RESET_FAILED', $model->getError());
			$this->setRedirect('index.php?option=com_user&view=reset&layout=complete', $message);
			return false;
		}
 
		$message = JText::_('PASSWORD_RESET_SUCCESS');
		$this->setRedirect('index.php?option=com_user&view=login', $message);
	}
 
	/**
	 * Username Reminder Method
	 *
	 * @access	public
	 */
	function remindusername()
	{
		// Check for request forgeries
		JRequest::checkToken() or jexit( 'Invalid Token' );
 
		// Get the input
		$email = JRequest::getVar('email', null, 'post', 'string');
 
		// Get the model
		$model = &$this->getModel('Remind');
 
		// Send the reminder
		if ($model->remindUsername($email) === false)
		{
			$message = JText::sprintf('USERNAME_REMINDER_FAILED', $model->getError());
			$this->setRedirect('index.php?option=com_user&view=remind', $message);
			return false;
		}
 
		$message = JText::sprintf('USERNAME_REMINDER_SUCCESS', $email);
		$this->setRedirect('index.php?option=com_user&view=login', $message);
	}
 
	function _sendMail(&$user, $password)
	{
		global $mainframe;
 
		$db		=& JFactory::getDBO();
 
		$name 		= $user->get('name');
		$email 		= $user->get('email');
		$username 	= $user->get('username');
 
		$usersConfig 	= &JComponentHelper::getParams( 'com_users' );
		$sitename 		= $mainframe->getCfg( 'sitename' );
		$useractivation = $usersConfig->get( 'useractivation' );
		$mailfrom 		= $mainframe->getCfg( 'mailfrom' );
		$fromname 		= $mainframe->getCfg( 'fromname' );
		$siteURL		= JURI::base();
 
		$subject 	= sprintf ( JText::_( 'Account details for' ), $name, $sitename);
		$subject 	= html_entity_decode($subject, ENT_QUOTES);
 
		if ( $useractivation == 1 ){
			$message = sprintf ( JText::_( 'SEND_MSG_ACTIVATE' ), $name, $sitename, $siteURL."index.php?option=com_user&task=activate&activation=".$user->get('activation'), $siteURL, $username, $password);
		} else {
			$message = sprintf ( JText::_( 'SEND_MSG' ), $name, $sitename, $siteURL);
		}
 
		$message = html_entity_decode($message, ENT_QUOTES);
 
		//get all super administrator
		$query = 'SELECT name, email, sendEmail' .
				' FROM #__users' .
				' WHERE LOWER( usertype ) = "super administrator"';
		$db->setQuery( $query );
		$rows = $db->loadObjectList();
 
		// Send email to user
		if ( ! $mailfrom  || ! $fromname ) {
			$fromname = $rows[0]->name;
			$mailfrom = $rows[0]->email;
		}
 
		JUtility::sendMail($mailfrom, $fromname, $email, $subject, $message);
 
		// Send notification to all administrators
		$subject2 = sprintf ( JText::_( 'Account details for' ), $name, $sitename);
		$subject2 = html_entity_decode($subject2, ENT_QUOTES);
 
		// get superadministrators id
		foreach ( $rows as $row )
		{
			if ($row->sendEmail)
			{
				$message2 = sprintf ( JText::_( 'SEND_MSG_ADMIN' ), $row->name, $sitename, $name, $email, $username);
				$message2 = html_entity_decode($message2, ENT_QUOTES);
				JUtility::sendMail($mailfrom, $fromname, $row->email, $subject2, $message2);
			}
		}
	}
}
?>

                                  
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:
476:
477:
478:
479:
480:
481:
482:
483:
484:
485:
486:
487:
488:
489:
490:
491:
492:
493:
494:
495:
496:
497:
498:
499:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-07-19 at 21:47:30ID24583164
Tags

PHP

,

JOOMLA

Topics

PHP Scripting Language

,

Web Development

,

Joomla

Participating Experts
2
Points
500
Comments
23

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Access /index.php is OK, accessing / is forbidden!!
    Hi all, this is my config DocumentRoot "e:" <Directory /> Options FollowSymLinks indexes AllowOverride None Order deny,allow <Files "index.php"> allow from all </Files> </Directory> <Directory "e:"&...
  2. php forbidden
    i have a strange problem with the server strange bcose i have another server and i did the same settings, perhaps i miss something :( in this new server every page .php won't work giving me the forbidden message in internet explorer. IIS -> DeafultApplicationPool is runn...
  3. Redirect index.html to index.php with 301 redirect in .…
    I have a 301 redirect for my old index page to the new php one like this: redirect 301 /index.html http://www.mydomain.com/index.php What I don't like is that when someone goes to http://www.mydomain.com, it appends the index.php to the end of it where it didn't use to befo...
  4. http 403 forbidden
    I have been trying all day to upload my php website but whenever I type my URL http://www.bidandplay.co.uk I get the following message in my browser HTTP 403 Forbidden I think it may be something to do with IIS not being properly configured for mylittleadmin This is the firs...
  5. Joomla redirecting to /installation/index.php
    Hello, I've installed mXcomment component on joomla, now every time I click on the configuration tab of the component through Admin panel, it redirects me to http://www.blabla.com/installation/index.php And I'm getting a 404 error. I've checked that the configuration.php f...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kevin_uPosted on 2009-07-19 at 23:14:09ID: 24892690

A blank page usually means there was a PHP error and error reporting is supressed.

Check the error_log (apache), or the corresponding error log if you're using windows.  That will most likely tell you what is going wrong.

 

by: snowball77Posted on 2009-07-20 at 00:06:33ID: 24892908

I did something to the code which you can read about here
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_24578126.html#a24892905

Did this change anything

 

by: kevin_uPosted on 2009-07-20 at 11:38:43ID: 24897667

It could have broken it, but really, you need to check for error messages.  Do you know where to look for your error log?  If not, let me know what web server is being used (iis? apache?) Then I can let you know how to display error messages right on the page that is failing.

 

by: snowball77Posted on 2009-07-20 at 12:52:06ID: 24898366

Is this the info you need?
Apache version      2.2.6 (Unix)
PHP version      5.2.5
MySQL version      4.1.22-standard

I don't know how to check the error log, but I would love to know how

 

by: kevin_uPosted on 2009-07-20 at 14:00:55ID: 24898997

Do you know where your server log files are?   If so, there is a file called error_log, and it will contain the error messages.

Alternatively, if you want to modify .htaccess, you can add these lines to make php display errors on the page.

php_flag display_errors on
php_value error_reporting 2047

 

by: snowball77Posted on 2009-07-20 at 20:26:09ID: 24901138

hi there,
I need a little bit more explanation.  Do I just write those two lines in the .htaccess and then how do I get the errors?

If I run the page will they just show up on the page, so everyone can see it?

 

by: kevin_uPosted on 2009-07-21 at 09:20:23ID: 24906401

yes you just write those two lines into .htaccess.

The errors will appear on the page itself, and everyone can see it, but so will you, so you can track down where the fix is needed.   You can remove those lines (or comment them out) after you get the information you need.

 

by: snowball77Posted on 2009-07-21 at 12:41:17ID: 24908482

Hi There,
I actually found the error log.  This is what it said
[16-Jul-2009 05:36:01] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141
[20-Jul-2009 12:27:37] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141
[20-Jul-2009 12:27:50] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141

I have attached the router.php code.  It looks like this section is the offending code:
//Only an Itemid ? Get the full information from the itemid
            if(count($this->getVars()) == 1)
            {
                  $item = $menu->getItem($this->getVar('Itemid'));
                  $vars = $vars + $item->query;
            }

hmmm, so whats happening.  I am going to try to add your code also to see if I can find something specific when I log on etc.

<?php
/**
* @version		$Id: router.php 8180 2007-07-23 05:52:29Z eddieajau $
* @package		Joomla.Framework
* @subpackage	Application
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
 
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
 
/**
 * Class to create and parse routes for the site application
 *
 * @author		Johan Janssens <johan.janssens@joomla.org>
 * @package 	Joomla
 * @since		1.5
 */
class JRouterSite extends JRouter
{
	/**
	 * Class constructor
	 *
	 * @access public
	 */
	function __construct($options = array()) {
		parent::__construct($options);
	}
 
	function parse(&$uri)
	{
		$vars = array();
 
		// Get the path
		$path = $uri->getPath();
 
		//Remove the suffix
		if($this->_mode == JROUTER_MODE_SEF)
		{
			// Get the application
			$app =& JFactory::getApplication();
 
			if($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/'))
			{
				if($suffix = pathinfo($path, PATHINFO_EXTENSION))
				{
					$path = str_replace('.'.$suffix, '', $path);
					$vars['format'] = $suffix;
				}
			}
		}
 
		//Remove basepath
		$path = substr_replace($path, '', 0, strlen(JURI::base(true)));
 
		//Remove prefix
		$path = str_replace('index.php', '', $path);
 
		//Set the route
		$uri->setPath(trim($path , '/'));
 
		$vars += parent::parse($uri);
 
		return $vars;
	}
 
	function &build($url)
	{
		$uri =& parent::build($url);
 
		// Get the path data
		$route = $uri->getPath();
 
		//Add the suffix to the uri
		if($this->_mode == JROUTER_MODE_SEF && $route)
		{
			$app =& JFactory::getApplication();
 
			if($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/'))
			{
				if($format = $uri->getVar('format', 'html'))
				{
					$route .= '.'.$format;
					$uri->delVar('format');
				}
			}
 
			if($app->getCfg('sef_rewrite'))
			{
				//Transform the route
				$route = str_replace('index.php/', '', $route);
			}
		}
 
		//Add basepath to the uri
		$uri->setPath(JURI::base(true).'/'.$route);
 
		return $uri;
	}
 
	function _parseRawRoute(&$uri)
	{
		$vars   = array();
 
		$menu =& JSite::getMenu(true);
 
		//Handle an empty URL (special case)
		if(!$uri->getVar('Itemid') && !$uri->getVar('option'))
		{
			$item = $menu->getDefault();
			if(!is_object($item)) return $vars; // No default item set
 
			//Set the information in the request
			$vars = $item->query;
 
			//Get the itemid
			$vars['Itemid'] = $item->id;
 
			// Set the active menu item
			$menu->setActive($vars['Itemid']);
 
			return $vars;
		}
 
		//Get the variables from the uri
		$this->setVars($uri->getQuery(true));
 
		//Get the itemid, if it hasn't been set force it to null
		$this->setVar('Itemid', JRequest::getInt('Itemid', null));
 
		//Only an Itemid ? Get the full information from the itemid
		if(count($this->getVars()) == 1)
		{
			$item = $menu->getItem($this->getVar('Itemid'));
			$vars = $vars + $item->query;
		}
 
		// Set the active menu item
		$menu->setActive($this->getVar('Itemid'));
 
		return $vars;
	}
 
	function _parseSefRoute(&$uri)
	{
		$vars   = array();
 
		$menu  =& JSite::getMenu(true);
		$route = $uri->getPath();
 
		//Get the variables from the uri
		$vars = $uri->getQuery(true);
 
		//Handle an empty URL (special case)
		if(empty($route))
		{
 
			//If route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately
			if(isset($vars['option']) || isset($vars['Itemid'])) {
				return $this->_parseRawRoute($uri);
			}
 
			$item = $menu->getDefault();
 
			//Set the information in the request
			$vars = $item->query;
 
			//Get the itemid
			$vars['Itemid'] = $item->id;
 
			// Set the active menu item
			$menu->setActive($vars['Itemid']);
 
			return $vars;
		}
 
 
		/*
		 * Parse the application route
		 */
 
		if(substr($route, 0, 9) == 'component')
		{
			$segments	= explode('/', $route);
			$route      = str_replace('component/'.$segments[1], '', $route);
 
			$vars['option'] = 'com_'.$segments[1];
			$vars['Itemid'] = null;
		}
		else
		{
			//Need to reverse the array (highest sublevels first)
			$items = array_reverse($menu->getMenu());
 
			foreach ($items as $item)
			{
				$lenght = strlen($item->route); //get the lenght of the route
 
				if($lenght > 0 && strpos($route.'/', $item->route.'/') === 0 && $item->type != 'menulink')
				{
					$route   = substr($route, $lenght);
 
					$vars['Itemid'] = $item->id;
					$vars['option'] = $item->component;
					break;
				}
			}
		}
 
		// Set the active menu item
		if ( isset($vars['Itemid']) ) {
			$menu->setActive(  $vars['Itemid'] );
		}
 
		//Set the variables
		$this->setVars($vars);
 
		/*
		 * Parse the component route
		 */
		if(!empty($route) && isset($this->_vars['option']) )
		{
			$segments = explode('/', $route);
			array_shift($segments);
 
			// Handle component	route
			$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $this->_vars['option']);
 
			// Use the component routing handler if it exists
			$path = JPATH_BASE.DS.'components'.DS.$component.DS.'router.php';
 
			if (file_exists($path) && count($segments))
			{
				if ($component != "com_search") { // Cheep fix on searches
					//decode the route segments
					$segments = $this->_decodeSegments($segments);
				}
 
				require_once $path;
				$function =  substr($component, 4).'ParseRoute';
				$vars =  $function($segments);
 
				$this->setVars($vars);
			}
		}
		else
		{
			//Set active menu item
			if($item =& $menu->getActive()) {
				$vars = $item->query;
			}
		}
 
		return $vars;
	}
 
	function _buildRawRoute(&$uri)
	{
	}
 
	function _buildSefRoute(&$uri)
	{
		// Get the route
		$route = $uri->getPath();
 
		// Get the query data
		$query = $uri->getQuery(true);
 
		if(!isset($query['option'])) {
			return;
		}
 
		$menu =& JSite::getMenu();
 
		/*
		 * Build the component route
		 */
		$component	= preg_replace('/[^A-Z0-9_\.-]/i', '', $query['option']);
		$tmp 		= '';
 
		// Use the component routing handler if it exists
		$path = JPATH_BASE.DS.'components'.DS.$component.DS.'router.php';
 
		// Use the custom routing handler if it exists
		if (file_exists($path) && !empty($query))
		{
			require_once $path;
			$function	= substr($component, 4).'BuildRoute';
			$parts		= $function($query);
 
			// encode the route segments
			if ($component != "com_search") { // Cheep fix on searches
				$parts = $this->_encodeSegments($parts);
			}
 
			$result = implode('/', $parts);
			$tmp	= ($result != "") ? '/'.$result : '';
		}
 
		/*
		 * Build the application route
		 */
		$built = false;
		if (isset($query['Itemid']) && !empty($query['Itemid']))
		{
			$item = $menu->getItem($query['Itemid']);
 
			if (is_object($item) && $query['option'] == $item->component) {
				$tmp = !empty($tmp) ? $item->route.'/'.$tmp : $item->route;
				$built = true;
			}
		}
 
		if(!$built) {
			$tmp = 'component/'.substr($query['option'], 4).'/'.$tmp;
		}
 
		$route .= '/'.$tmp;
 
		// Unset unneeded query information
		unset($query['Itemid']);
		unset($query['option']);
 
		//Set query again in the URI
		$uri->setQuery($query);
		$uri->setPath($route);
	}
 
	function _processParseRules(&$uri)
	{
		// Process the attached parse rules
		$vars = parent::_processParseRules($uri);
 
		// Process the pagination support
		if($this->_mode == JROUTER_MODE_SEF)
		{
			$app =& JFactory::getApplication();
 
			if($start = $uri->getVar('start'))
			{
				$uri->delVar('start');
				$vars['limitstart'] = $start;
			}
		}
 
		return $vars;
	}
 
	function _processBuildRules(&$uri)
	{
		// Make sure any menu vars are used if no others are specified
		if(($this->_mode != JROUTER_MODE_SEF) && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2)
		{
			$menu =& JSite::getMenu();
 
			// Get the active menu item
			$itemid = $uri->getVar('Itemid');
			$item   = $menu->getItem($itemid);
 
			$uri->setQuery($item->query);
			$uri->setVar('Itemid', $itemid);
		}
 
		// Process the attached build rules
		parent::_processBuildRules($uri);
 
		// Get the path data
		$route = $uri->getPath();
 
		if($this->_mode == JROUTER_MODE_SEF && $route)
		{
			$app =& JFactory::getApplication();
 
			if ($limitstart = $uri->getVar('limitstart'))
			{
				$uri->setVar('start', (int) $limitstart);
				$uri->delVar('limitstart');
			}
		}
 
		$uri->setPath($route);
	}
 
	function &_createURI($url)
	{
		//Create the URI
		$uri =& parent::_createURI($url);
 
		// Set URI defaults
		$menu =& JSite::getMenu();
 
		// Get the itemid form the URI
		$itemid = $uri->getVar('Itemid');
 
		if(is_null($itemid))
		{
			if($option = $uri->getVar('option'))
			{
				$item  = $menu->getItem($this->getVar('Itemid'));
				if(isset($item) && $item->component == $option) {
					$uri->setVar('Itemid', $item->id);
				}
			}
			else
			{
				if($option = $this->getVar('option')) {
					$uri->setVar('option', $option);
				}
 
				if($itemid = $this->getVar('Itemid')) {
					$uri->setVar('Itemid', $itemid);
				}
			}
		}
		else
		{
			if(!$uri->getVar('option'))
			{
				$item  = $menu->getItem($itemid);
				$uri->setVar('option', $item->component);
			}
		}
 
		return $uri;
	}
}
                                              
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:

Select allOpen in new window

 

by: snowball77Posted on 2009-07-21 at 12:44:06ID: 24908515

Hi Again,
I added the two lines you mentioned into .htaccess and when I tried to go to the webpage I got this error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@widowspeak.com.au and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

 

by: kevin_uPosted on 2009-07-21 at 20:44:09ID: 24911422

ok, it means that your hosting provider isn't allowing you to those things to .htaccess.

Without knowing the error messages, I can't go much further.

of course remove those lines from htaccess.

Perhaps you'll want to close this question, or request attention to get some fresh eyes on this one.

 

by: RQuadlingPosted on 2009-07-24 at 08:02:34ID: 24935588

Hopefully you can confirm that line 141 is ...

$vars = $vars + $item->query;


The + wants to add 2 numbers together.

What are the types for $var and $item->query ?

Are they strings? Use $vars = $vars . $item->query;

Are they arrays? Use $vars[] = $item->query;

Are they something else?

If you are not sure, use the following debug lines (i.e. put them in, run the code, record the output, remove the lines).

var_dump($vars, $item->query);
die();

What do you get?

 

by: snowball77Posted on 2009-07-24 at 23:42:46ID: 24940903

Hi,
I am not sure what you want from line 141?
In the controller.php you can see its:
//preform the logout action
            $error = $mainframe->logout();

Anyway, where in the code that I have shown should I add the code you have written?
Should I put it at the end of the controller.php code then run the script??

 

by: RQuadlingPosted on 2009-07-27 at 04:12:06ID: 24950319

The code in your comment http://#24908482 on this question -  line 141

The errors are in router.php

[16-Jul-2009 05:36:01] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141
[20-Jul-2009 12:27:37] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141
[20-Jul-2009 12:27:50] PHP Fatal error:  Unsupported operand types in /home/widowspe/public_html/includes/router.php on line 141

Not the controller.

Line 141 is ...

$vars = $vars + $item->query;

...

and repeat my last message at this point.


 

by: snowball77Posted on 2009-07-27 at 13:14:12ID: 24955500

Ah, sorry, YES the line at 141 is:
      $vars = $vars + $item->query;

I think they are arrays  [ ]

I have attached the whole router.php code to confirm..

<?php
/**
* @version		$Id: router.php 8180 2007-07-23 05:52:29Z eddieajau $
* @package		Joomla.Framework
* @subpackage	Application
* @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
 
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
 
/**
 * Class to create and parse routes for the site application
 *
 * @author		Johan Janssens <johan.janssens@joomla.org>
 * @package 	Joomla
 * @since		1.5
 */
class JRouterSite extends JRouter
{
	/**
	 * Class constructor
	 *
	 * @access public
	 */
	function __construct($options = array()) {
		parent::__construct($options);
	}
 
	function parse(&$uri)
	{
		$vars = array();
 
		// Get the path
		$path = $uri->getPath();
 
		//Remove the suffix
		if($this->_mode == JROUTER_MODE_SEF)
		{
			// Get the application
			$app =& JFactory::getApplication();
 
			if($app->getCfg('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/'))
			{
				if($suffix = pathinfo($path, PATHINFO_EXTENSION))
				{
					$path = str_replace('.'.$suffix, '', $path);
					$vars['format'] = $suffix;
				}
			}
		}
 
		//Remove basepath
		$path = substr_replace($path, '', 0, strlen(JURI::base(true)));
 
		//Remove prefix
		$path = str_replace('index.php', '', $path);
 
		//Set the route
		$uri->setPath(trim($path , '/'));
 
		$vars += parent::parse($uri);
 
		return $vars;
	}
 
	function &build($url)
	{
		$uri =& parent::build($url);
 
		// Get the path data
		$route = $uri->getPath();
 
		//Add the suffix to the uri
		if($this->_mode == JROUTER_MODE_SEF && $route)
		{
			$app =& JFactory::getApplication();
 
			if($app->getCfg('sef_suffix') && !(substr($route, -9) == 'index.php' || substr($route, -1) == '/'))
			{
				if($format = $uri->getVar('format', 'html'))
				{
					$route .= '.'.$format;
					$uri->delVar('format');
				}
			}
 
			if($app->getCfg('sef_rewrite'))
			{
				//Transform the route
				$route = str_replace('index.php/', '', $route);
			}
		}
 
		//Add basepath to the uri
		$uri->setPath(JURI::base(true).'/'.$route);
 
		return $uri;
	}
 
	function _parseRawRoute(&$uri)
	{
		$vars   = array();
 
		$menu =& JSite::getMenu(true);
 
		//Handle an empty URL (special case)
		if(!$uri->getVar('Itemid') && !$uri->getVar('option'))
		{
			$item = $menu->getDefault();
			if(!is_object($item)) return $vars; // No default item set
 
			//Set the information in the request
			$vars = $item->query;
 
			//Get the itemid
			$vars['Itemid'] = $item->id;
 
			// Set the active menu item
			$menu->setActive($vars['Itemid']);
 
			return $vars;
		}
 
		//Get the variables from the uri
		$this->setVars($uri->getQuery(true));
 
		//Get the itemid, if it hasn't been set force it to null
		$this->setVar('Itemid', JRequest::getInt('Itemid', null));
 
		//Only an Itemid ? Get the full information from the itemid
		if(count($this->getVars()) == 1)
		{
			$item = $menu->getItem($this->getVar('Itemid'));
			$vars = $vars + $item->query;
		}
 
		// Set the active menu item
		$menu->setActive($this->getVar('Itemid'));
 
		return $vars;
	}
 
	function _parseSefRoute(&$uri)
	{
		$vars   = array();
 
		$menu  =& JSite::getMenu(true);
		$route = $uri->getPath();
 
		//Get the variables from the uri
		$vars = $uri->getQuery(true);
 
		//Handle an empty URL (special case)
		if(empty($route))
		{
 
			//If route is empty AND option is set in the query, assume it's non-sef url, and parse apropriately
			if(isset($vars['option']) || isset($vars['Itemid'])) {
				return $this->_parseRawRoute($uri);
			}
 
			$item = $menu->getDefault();
 
			//Set the information in the request
			$vars = $item->query;
 
			//Get the itemid
			$vars['Itemid'] = $item->id;
 
			// Set the active menu item
			$menu->setActive($vars['Itemid']);
 
			return $vars;
		}
 
 
		/*
		 * Parse the application route
		 */
 
		if(substr($route, 0, 9) == 'component')
		{
			$segments	= explode('/', $route);
			$route      = str_replace('component/'.$segments[1], '', $route);
 
			$vars['option'] = 'com_'.$segments[1];
			$vars['Itemid'] = null;
		}
		else
		{
			//Need to reverse the array (highest sublevels first)
			$items = array_reverse($menu->getMenu());
 
			foreach ($items as $item)
			{
				$lenght = strlen($item->route); //get the lenght of the route
 
				if($lenght > 0 && strpos($route.'/', $item->route.'/') === 0 && $item->type != 'menulink')
				{
					$route   = substr($route, $lenght);
 
					$vars['Itemid'] = $item->id;
					$vars['option'] = $item->component;
					break;
				}
			}
		}
 
		// Set the active menu item
		if ( isset($vars['Itemid']) ) {
			$menu->setActive(  $vars['Itemid'] );
		}
 
		//Set the variables
		$this->setVars($vars);
 
		/*
		 * Parse the component route
		 */
		if(!empty($route) && isset($this->_vars['option']) )
		{
			$segments = explode('/', $route);
			array_shift($segments);
 
			// Handle component	route
			$component = preg_replace('/[^A-Z0-9_\.-]/i', '', $this->_vars['option']);
 
			// Use the component routing handler if it exists
			$path = JPATH_BASE.DS.'components'.DS.$component.DS.'router.php';
 
			if (file_exists($path) && count($segments))
			{
				if ($component != "com_search") { // Cheep fix on searches
					//decode the route segments
					$segments = $this->_decodeSegments($segments);
				}
 
				require_once $path;
				$function =  substr($component, 4).'ParseRoute';
				$vars =  $function($segments);
 
				$this->setVars($vars);
			}
		}
		else
		{
			//Set active menu item
			if($item =& $menu->getActive()) {
				$vars = $item->query;
			}
		}
 
		return $vars;
	}
 
	function _buildRawRoute(&$uri)
	{
	}
 
	function _buildSefRoute(&$uri)
	{
		// Get the route
		$route = $uri->getPath();
 
		// Get the query data
		$query = $uri->getQuery(true);
 
		if(!isset($query['option'])) {
			return;
		}
 
		$menu =& JSite::getMenu();
 
		/*
		 * Build the component route
		 */
		$component	= preg_replace('/[^A-Z0-9_\.-]/i', '', $query['option']);
		$tmp 		= '';
 
		// Use the component routing handler if it exists
		$path = JPATH_BASE.DS.'components'.DS.$component.DS.'router.php';
 
		// Use the custom routing handler if it exists
		if (file_exists($path) && !empty($query))
		{
			require_once $path;
			$function	= substr($component, 4).'BuildRoute';
			$parts		= $function($query);
 
			// encode the route segments
			if ($component != "com_search") { // Cheep fix on searches
				$parts = $this->_encodeSegments($parts);
			}
 
			$result = implode('/', $parts);
			$tmp	= ($result != "") ? '/'.$result : '';
		}
 
		/*
		 * Build the application route
		 */
		$built = false;
		if (isset($query['Itemid']) && !empty($query['Itemid']))
		{
			$item = $menu->getItem($query['Itemid']);
 
			if (is_object($item) && $query['option'] == $item->component) {
				$tmp = !empty($tmp) ? $item->route.'/'.$tmp : $item->route;
				$built = true;
			}
		}
 
		if(!$built) {
			$tmp = 'component/'.substr($query['option'], 4).'/'.$tmp;
		}
 
		$route .= '/'.$tmp;
 
		// Unset unneeded query information
		unset($query['Itemid']);
		unset($query['option']);
 
		//Set query again in the URI
		$uri->setQuery($query);
		$uri->setPath($route);
	}
 
	function _processParseRules(&$uri)
	{
		// Process the attached parse rules
		$vars = parent::_processParseRules($uri);
 
		// Process the pagination support
		if($this->_mode == JROUTER_MODE_SEF)
		{
			$app =& JFactory::getApplication();
 
			if($start = $uri->getVar('start'))
			{
				$uri->delVar('start');
				$vars['limitstart'] = $start;
			}
		}
 
		return $vars;
	}
 
	function _processBuildRules(&$uri)
	{
		// Make sure any menu vars are used if no others are specified
		if(($this->_mode != JROUTER_MODE_SEF) && $uri->getVar('Itemid') && count($uri->getQuery(true)) == 2)
		{
			$menu =& JSite::getMenu();
 
			// Get the active menu item
			$itemid = $uri->getVar('Itemid');
			$item   = $menu->getItem($itemid);
 
			$uri->setQuery($item->query);
			$uri->setVar('Itemid', $itemid);
		}
 
		// Process the attached build rules
		parent::_processBuildRules($uri);
 
		// Get the path data
		$route = $uri->getPath();
 
		if($this->_mode == JROUTER_MODE_SEF && $route)
		{
			$app =& JFactory::getApplication();
 
			if ($limitstart = $uri->getVar('limitstart'))
			{
				$uri->setVar('start', (int) $limitstart);
				$uri->delVar('limitstart');
			}
		}
 
		$uri->setPath($route);
	}
 
	function &_createURI($url)
	{
		//Create the URI
		$uri =& parent::_createURI($url);
 
		// Set URI defaults
		$menu =& JSite::getMenu();
 
		// Get the itemid form the URI
		$itemid = $uri->getVar('Itemid');
 
		if(is_null($itemid))
		{
			if($option = $uri->getVar('option'))
			{
				$item  = $menu->getItem($this->getVar('Itemid'));
				if(isset($item) && $item->component == $option) {
					$uri->setVar('Itemid', $item->id);
				}
			}
			else
			{
				if($option = $this->getVar('option')) {
					$uri->setVar('option', $option);
				}
 
				if($itemid = $this->getVar('Itemid')) {
					$uri->setVar('Itemid', $itemid);
				}
			}
		}
		else
		{
			if(!$uri->getVar('option'))
			{
				$item  = $menu->getItem($itemid);
				$uri->setVar('option', $item->component);
			}
		}
 
		return $uri;
	}
}
                                              
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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:

Select allOpen in new window

 

by: RQuadlingPosted on 2009-07-28 at 03:24:12ID: 24959246

Now go back and read my comment #24935588 please. Specifically the last few lines dealing with running the debug code to make sure we have the right types.

The error you are seeing implies that + is NOT the appropriate way to join the values.

Saying "I think they are arrays  [ ]" is where we started really.

Or, in other words, please follow our suggestions. They are normally little steps to avoid the wrong-path-rewind problems of big changes.

 

by: snowball77Posted on 2009-07-28 at 14:42:00ID: 24965488

Ok,
I added in the lines of code you said just after the line of code in questions in router.php

//Only an Itemid ? Get the full information from the itemid
            if(count($this->getVars()) == 1)
            {
                  $item = $menu->getItem($this->getVar('Itemid'));
                  $vars = $vars + $item->query;
            }
var_dump($vars, $item->query);
die();

And when I tried to run the application I got:


array(0) { } NULL

 

by: RQuadlingPosted on 2009-07-28 at 14:57:29ID: 24965592

Right. So, $item->query is null. You cannot add null to an array.

<?php
$array = array();
$null = null;
$array = $array + $null;

results in ...

PHP Fatal error:  Unsupported operand types ...


So it is now the case of going backwards from this point and see where the failure is.

Each of these needs to be run one at a time as the results may be long and complex.

var_dump($this->getVar('Itemid'));
var_dump($menu->getItem($this->getVar('Itemid')));

Make sure that 'Itemid' is correct and not say 'ItemID' or something different.

 

by: snowball77Posted on 2009-07-28 at 20:13:21ID: 24966913

Ok, sorry to be so ignorant with this, but can you explain  the steps.

You say each of these need to be run one at a time.....what do you mean exactly?

 

by: RQuadlingPosted on 2009-07-29 at 04:33:23ID: 24969088

Put the first var_dump() in your code (replacing the one you've already got) and then run it. What is the result. Then replace that with the next, run it, record result.

Step by step.

We know that the point of failure is currently at line 141 and that the value of $item->query is null and I think you think it should be something different.

The problem I see though is that Joomla is a significant project.

I see (http://www.joomla.org/announcements/release-news/5243-joomla-1513-security-release-now-available.html) that there is a security release available.

Are you able to upgrade and re-test? Make a note of anything you changed and see if it is still appropriate.



As for finding the issue, you need to track back from line 141 and see what values are not being processed correctly.

What customisations have you performed?

 

by: snowball77Posted on 2009-07-29 at 16:39:16ID: 24975661

I am going to do an upgrade and retest

 

by: snowball77Posted on 2009-08-11 at 01:25:48ID: 25067001

I upgraded and it worked

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...