Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-11-2010, 03:46 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
Php coding.. um not really sure sorry!

As some of you know for some time I have been trying to figure out how to redirect mobile users from my main site to my phpbb forum without the joomla/jfusion intergration shizzle.

Anyhow I figured it out! But have a hit a problem..

Ok lets start from the beginning I have found a script and have been testing it here -

www.themidwiferysanctuary.com/mobiletest.php

If you click on the above link on a desktop browser it should take you to my normal site but if you access it through a mobile device e.g. iphone it should take you too a blue looking mobile version.

1st off can you try it please.

As far as I can tell it works so obviously the code is no use to me in mobiletest.php as well thats not even a page. so I want the code to be in my main index page of my website.

So this is the code -

PHP Code:
function is_mobile(){
    
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
    
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
    
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";    
    
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
    
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
    
$regex_match.=")/i";        
    return isset(
$_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_matchstrtolower($_SERVER['HTTP_USER_AGENT']));
}
if(
is_mobile()) { 
//it's a mobile browser, do something
header("Location: http://www.themidwiferysanctuary.com/phpBB");
} else {
//it's not a mobile browser, do something else
header("Location: http://www.themidwiferysanctuary.com");

So I stuck that in my main index page, pretty much anywhere I don't know if it matters where.

Then I tried accessing my main url www.themidwiferysanctuary.com from my iphone (it should redirect me to the mobile site) which it did! YAY!

But if I tried to access the main site via a desktop browser, firefox said that it was redirecting in a way that was never going to complete (or something along those lines) and the page just timed out...


So now I don't know what to do!
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #2 (permalink)  
Old 07-11-2010, 04:07 AM
ScriptMan's Avatar
Super Moderator
Latest Blog:
None

 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 2,756
iTrader: 3 / 100%
ScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest order
I think it is creating an infinite loop. You might try changing this line:
PHP Code:
header("Location: http://www.themidwiferysanctuary.com"); 
to this:
PHP Code:
header("Location: http://www.themidwiferysanctuary.com/index.php"); 
If that should happen to work then all your incoming links to the main site main should point to themidwiferysanctuary.com/ and index.php should never be mentioned.


This is just a guess on my part.

There is most likely a better way by rewriting the script to use not issett but that is another challenge,
__________________
These forums are as good as the posts that you contribute to them.~~
ScriptMan
Webmaster Help Articles
Share |
Reply With Quote
  #3 (permalink)  
Old 07-11-2010, 04:11 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
Ah na that didnt work either thanks for trying.

This is what firefox says

Quote:
The page isn't redirecting properly













Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

* This problem can sometimes be caused by disabling or refusing to accept
cookies.
It is really frustrating trying to find an easy to use script! Aghhh"!!!
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #4 (permalink)  
Old 07-11-2010, 04:31 AM
Costin Trifan's Avatar
Coding Tiger
 
Join Date: 04-13-07
Location: Romania
Posts: 3,371
iTrader: 0 / 0%
Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
Send a message via Yahoo to Costin Trifan
if that code above is inserted in the index.php page then this is why your browser is getting into that infinite loop. see that else there? it will always be hit and the page will always be redirecting to the index.php page. so, you should add another if statement inside that else statement to check if you're already viewing the index.php page, otherwise, redirect. btw, always use exit(); after header statements

PHP Code:
if(is_mobile()) { 
    
//it's a mobile browser, do something
    
header("Location: http://www.themidwiferysanctuary.com/phpBB");
    exit();
}
else {
    
//it's not a mobile browser, do something else
//    header("Location: http://www.themidwiferysanctuary.com");

    
$base_url "http://www.themidwiferysanctuary.com";
    
$url $_SERVER['REQUEST_URI'];
    if (
strcasecmp($base_url$url) == 0) {
        
//home page;
    
}
    else {
        
// redirect
        
header("location: http://www.themidwiferysanctuary.com");
        exit();
    }

__________________
my private spice

...IrisMVC
Share |
Reply With Quote
  #5 (permalink)  
Old 07-11-2010, 04:57 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
It still says its not redirecting properly and just gives me the firefox time out page.
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #6 (permalink)  
Old 07-11-2010, 05:52 AM
ScriptMan's Avatar
Super Moderator
Latest Blog:
None

 
Join Date: 02-10-07
Location: Central Kentucky
Posts: 2,756
iTrader: 3 / 100%
ScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest orderScriptMan is a web professional of the highest order
Silly question, are you forcing FF to reload the page? It does not do that by default. Right click and select reload.
__________________
These forums are as good as the posts that you contribute to them.~~
ScriptMan
Webmaster Help Articles
Share |
Reply With Quote
  #7 (permalink)  
Old 07-11-2010, 06:01 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
yep done that Script man and it still says cant redirecft or what not.

This is what my index.php file looks like.

Like I said I don't know where to put my snippet of code so I have just put it right at the top.

PHP Code:
<?php
function is_mobile(){
    
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
    
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
    
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";    
    
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
    
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
    
$regex_match.=")/i";        
    return isset(
$_SERVER['HTTP_X_WAP_PROFILE']) or isset($_SERVER['HTTP_PROFILE']) or preg_match($regex_matchstrtolower($_SERVER['HTTP_USER_AGENT']));
}
if(
is_mobile()) { 
    
//it's a mobile browser, do something
    
header("Location: http://www.themidwiferysanctuary.com/phpBB");
    exit();
}
else {
    
//it's not a mobile browser, do something else
//    header("Location: http://www.themidwiferysanctuary.com");

    
$base_url "http://www.themidwiferysanctuary.com";
    
$url $_SERVER['REQUEST_URI'];
    if (
strcasecmp($base_url$url) == 0) {
        
//home page;
    
}
    else {
        
// redirect
        
header("location: http://www.themidwiferysanctuary.com");
        exit();
    }
}
/**
* @version        $Id: index.php 11407 2009-01-09 17:23:42Z willebil $
* @package        Joomla
* @copyright    Copyright (C) 2005 - 2009 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.
*/
// Set flag that this is a parent file
define'_JEXEC');

define('JPATH_BASE'dirname(__FILE__) );

define'DS'DIRECTORY_SEPARATOR );

require_once ( 
JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( 
JPATH_BASE .DS.'includes'.DS.'framework.php' );

JDEBUG $_PROFILER->mark'afterLoad' ) : null;

/**
 * CREATE THE APPLICATION
 *
 * NOTE :
 */
$mainframe =& JFactory::getApplication('site');

/**
 * INITIALISE THE APPLICATION
 *
 * NOTE :
 */
// set the language
$mainframe->initialise();

JPluginHelper::importPlugin('system');

// trigger the onAfterInitialise events
JDEBUG $_PROFILER->mark('afterInitialise') : null;
$mainframe->triggerEvent('onAfterInitialise');

/**
 * ROUTE THE APPLICATION
 *
 * NOTE :
 */
$mainframe->route();

// authorization
$Itemid JRequest::getInt'Itemid');
$mainframe->authorize($Itemid);

// trigger the onAfterRoute events
JDEBUG $_PROFILER->mark('afterRoute') : null;
$mainframe->triggerEvent('onAfterRoute');

/**
 * DISPATCH THE APPLICATION
 *
 * NOTE :
 */
$option JRequest::getCmd('option');
$mainframe->dispatch($option);

// trigger the onAfterDispatch events
JDEBUG $_PROFILER->mark('afterDispatch') : null;
$mainframe->triggerEvent('onAfterDispatch');

/**
 * RENDER  THE APPLICATION
 *
 * NOTE :
 */
$mainframe->render();

// trigger the onAfterRender events
JDEBUG $_PROFILER->mark('afterRender') : null;
$mainframe->triggerEvent('onAfterRender');

/**
 * RETURN THE RESPONSE
 */
echo JResponse::toString($mainframe->getCfg('gzip'));
Thansk for your help guys really appreciate it, this has been doing my head in for ages!!
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #8 (permalink)  
Old 07-11-2010, 09:21 PM
Contributing Member
Latest Blog:
None

 
Join Date: 06-28-10
Posts: 94
iTrader: 0 / 0%
homeschooled is an unknown quantity at this point
If PHP does not do it, go JS.

Quote:
if(is_mobile()) {
echo '<SCRIPT language="JavaScript">
window.location="http://www.themidwiferysanctuary.com/phpBB"
</SCRIPT>';
}
__________________
Lake Forest Web Design
Share |
Reply With Quote
  #9 (permalink)  
Old 07-12-2010, 03:05 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
Homeschooled that works but it brings this error up on my forum -

[phpBB Debug] PHP Notice: in file /index.php on line 114: Cannot modify header information - headers already sent by (output started at /index.php:8
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #10 (permalink)  
Old 07-12-2010, 01:30 PM
Costin Trifan's Avatar
Coding Tiger
 
Join Date: 04-13-07
Location: Romania
Posts: 3,371
iTrader: 0 / 0%
Costin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest orderCostin Trifan is a web professional of the highest order
Send a message via Yahoo to Costin Trifan
does this code exists on http://www.themidwiferysanctuary.com ? 'cause i can access that page without problems...
__________________
my private spice

...IrisMVC
Share |
Reply With Quote
  #11 (permalink)  
Old 07-14-2010, 01:11 AM
Midwifery Sanctuary's Avatar
v7n Mentor
Latest Blog:
None

 
Join Date: 10-12-09
Location: UK
Posts: 356
iTrader: 7 / 100%
Midwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really niceMidwifery Sanctuary is just really nice
If you reread my previous post.

Quote:
Homeschooled that works but it brings this error up on my forum -

[phpBB Debug] PHP Notice: in file /index.php on line 114: Cannot modify header information - headers already sent by (output started at /index.php:8
__________________
The Midwifery Sanctuary
Share |
Reply With Quote
  #12 (permalink)  
Old 07-14-2010, 09:05 PM
Contributing Member
Latest Blog:
None

 
Join Date: 06-28-10
Posts: 94
iTrader: 0 / 0%
homeschooled is an unknown quantity at this point
Quote:
Originally Posted by Midwifery Sanctuary View Post
If you reread my previous post.
I think it wouldn't error in PHP because it's JS madam. Try to check on whitespace before and after your <? ?>.
__________________
Lake Forest Web Design
Share |
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ad coding thumbtak Coding Forum 8 07-28-2008 05:38 AM
Need help re-coding something devilzfan300 Coding Forum 3 08-20-2007 12:00 PM
need help with this coding..... daraptor Coding Forum 1 02-05-2007 03:33 PM
Coding in D/M OMG docquesting Coding Forum 59 03-03-2005 10:21 AM
php coding, java coding, webdesign, windows coding... SVB SEO Forum 5 02-24-2004 10:25 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 11:52 AM.
© Copyright 2010 V7 Inc
Powered by vBulletin
Copyright © 2000-2010 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.