PHP Web Host - Quality Web Hosting For All PHP Applications Sign up for PayPal and start accepting credit card payments instantly
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
autonami
Hangin' Around


Joined: Jul 25, 2009
Posts: 26

PostPosted: Thu Dec 10, 2009 4:12 pm Reply with quote Back to top

i was wondering if there was any way to redirect to a certain theme.

i have a piece of code that, when put in the top if index.php it detects a mobile browser, and redirects to a specific URL. i have a somewhat mobile friendly theme on my site, and was wondering if this or a similar script could be used to change the theme automatically upon mobile browser detection.

heres the code that i have that redirects on mobile browser detection.

Code:
 if(eregi("text/vnd.wap.wml",$_SERVER['HTTP_ACCEPT'])){ header('Location: ./mobile/');}


hope my question is easy to understand, and feel free to shoot me down if this has already been discussed. i couldnt find anything about it.
View user's profile Send private message
wHiTeHaT
Involved
Involved


Joined: Jul 18, 2004
Posts: 431
Location: Netherlands

PostPosted: Fri Dec 11, 2009 5:19 pm Reply with quote Back to top

in your header.php around line 33:

Code:
function head() {
   global $slogan, $sitename, $banners, $nukeurl, $Version_Num, $artpage, $topic, $hlpfile, $user, $hr, $theme, $cookie, $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $textcolor1, $textcolor2, $forumpage, $adminpage, $userpage, $pagetitle, $name, $db, $prefix, $nukeNAV;


Add below:

Code:

 if(eregi("text/vnd.wap.wml",$_SERVER['HTTP_ACCEPT'])){
$ThemeSel = 'YOUR MOBILE THEME NAME';
}else{
$ThemeSel = $ThemeSel;
}
 
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
montego
Former Admin in Good Standing


Joined: Aug 29, 2004
Posts: 9071
Location: Arizona

PostPosted: Sat Dec 12, 2009 9:32 am Reply with quote Back to top

Nice one wHiTeHaT.

Just one thing that I am going to start "evangelizing" as much as possible is moving away from
Only registered users can see links on this board!
Get registered or login to the forums!
. The POSIX API is deprecated as of PHP5.3 and is discouraged against. Instead, we should be moving towards the PCRE family of functions, in this case,
Only registered users can see links on this board!
Get registered or login to the forums!
.

We have our work cut our for us in RavenNuke(tm) to replace these functions. Wink
View user's profile Send private message Visit poster's website
autonami
Hangin' Around


Joined: Jul 25, 2009
Posts: 26

PostPosted: Mon Dec 14, 2009 3:50 am Reply with quote Back to top

thanks a lot for you help whitehat. but im not sure if its working... i have yet to test it on a device that has yet to visit my site.
but i cleared history and cache on both my mobile browsers, and it just shows the default theme.

if you guys care to check it out :
Only registered users can see links on this board!
Get registered or login to the forums!


should i leave the $ThemeSel = get_theme(); under the code you gave me?

im going to assume that the preg_match function wouldnt work with the current version of RN. ?
View user's profile Send private message
wHiTeHaT
Involved
Involved


Joined: Jul 18, 2004
Posts: 431
Location: Netherlands

PostPosted: Mon Dec 14, 2009 1:16 pm Reply with quote Back to top

I checked to see if your site worked with the tweak , and it seems it doesnt.
So i tryed over and found the solution ( i think).

make a backup of your mainfile.php
Then open it in your text editor and replace the complete function

function get_theme()
I assume your themename is "boxlike_mobile_beta"

Code:
function get_theme() {
   global $user, $db, $prefix, $user_prefix, $Default_Theme;
   static $theme = false;
   if ($theme) return $theme;
   $theme = (isset($_COOKIE['theme'])) ? base64_decode($_COOKIE['theme']) : false;
   if(eregi('text/vnd.wap.wml',$_SERVER['HTTP_ACCEPT'])){
$theme = 'boxlike_mobile_beta';
return $theme;
}else{
   if (isset($_POST['themeprev']) && $theme != $_POST['themeprev'] && file_exists('themes/'.$_POST['themeprev'].'/theme.php')) {
      $theme = $_POST['themeprev'];
      setcookie('theme',base64_encode($theme), 0);
      if (is_user($user)) {
         $user2 = explode(':', base64_decode(addslashes($user)));
         $user_id = intval($user2[0]);
         $info = base64_encode("$user2[0]:$user2[1]:$user2[2]:$user2[3]:$user2[4]:$user2[5]:$user2[6]:$user2[7]:$user2[8]:$theme:$user2[10]");
         setcookie('user', $info, time()+2592000);
         $db->sql_query('UPDATE '.$user_prefix.'_users SET theme=\''.$theme.'\' WHERE user_id=\''.$user_id.'\'');
      }
      return $theme;
   } elseif ($theme && file_exists('themes/'.$theme.'/theme.php')) {
      return $theme;
   }
   if (!is_user($user)) {
      $theme = $Default_Theme;
      return $theme;
   }
   
   
   $user = addslashes($user);
   $user2 = base64_decode($user);
   $user2 = explode(':', $user2);
   if($user2[9]) {
      if(!file_exists('themes/'.$user2[9].'/theme.php')) {
         $theme = $Default_Theme;
      } else $theme = $user2[9];
   } else $theme = $Default_Theme;
   
   return $theme;
   }
}

i have tested it on one of my own site's and it worked.
However keep in mind the current wap devices use the common browser functions , so not all portable devices sending the mobile identification.


Goodluck


Last edited by wHiTeHaT on Mon Dec 14, 2009 3:54 pm; edited 2 times in total
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
wHiTeHaT
Involved
Involved


Joined: Jul 18, 2004
Posts: 431
Location: Netherlands

PostPosted: Mon Dec 14, 2009 1:21 pm Reply with quote Back to top

There is also an addon for Firefox, so you can use WAP from within your browser, quite handy.

Only registered users can see links on this board!
Get registered or login to the forums!


Make sure you set in the add-on options to enable "Tell websites that the browser understands WML content"
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
wHiTeHaT
Involved
Involved


Joined: Jul 18, 2004
Posts: 431
Location: Netherlands

PostPosted: Mon Dec 14, 2009 4:16 pm Reply with quote Back to top

i have edited the code above couse i left some test variables in it Embarassed
just remove the $mytest1 instances and you are good.
There's 1 in the global line and one in the middle of the function.

But i wanted to tell you there excist a module called wap2go , it seems like the dev is starting to make it rn compatible.

you can check it here:
Only registered users can see links on this board!
Get registered or login to the forums!
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
autonami
Hangin' Around


Joined: Jul 25, 2009
Posts: 26

PostPosted: Mon Dec 14, 2009 8:30 pm Reply with quote Back to top

well, i believe that did the trick sir. thats awesome, thanks a lot for the help and the prompt feedback. this was very helpful to my site.

i actually have the wap2go installed on my site. but it doesnt work. apparently some things in the 2.3 RN config file didnt match up with the latest release of wap2go which was released in dec 2007. and he is a very busy guy and doesnt give much feedback either. ive tried all kinds of stuff and all i get is this error, "Unable to locate the RavenNuke(tm) configuration file - INCLUDE_PATHrnconfig.php " when trying to access the module.

thanks again bro.
View user's profile Send private message
nuken
RavenNuke(tm) Development Team


Joined: Mar 11, 2007
Posts: 1435
Location: North Carolina

PostPosted: Tue Dec 15, 2009 12:30 pm Reply with quote Back to top

I posted the fix for that on the wap2go forums.
View user's profile Send private message Send e-mail Visit poster's website
autonami
Hangin' Around


Joined: Jul 25, 2009
Posts: 26

PostPosted: Tue Dec 15, 2009 9:35 pm Reply with quote Back to top

nuken wrote:
I posted the fix for that on the wap2go forums.

To define the rnconfig.php file, open mobile/includes/w2g_mainfile.php and paste
Code:
if(!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../');

under
Code:
@include("settings.php");

so it will look like this
Code:
<?php
/******************************************************************************/
/* Wap-2-Go Mobile Phone Nuke-Addon */
/* bringing the Advanced Content Management System to Mobile Format */
/* ==========================================================================*/
/* powered by Nuke Database */
/* */
/* Copyright (c) 2007 by Philip Marsh -
Only registered users can see links on this board!
Get registered or login to the forums!
*/
/* */
/* FILE DETAILS and EXPLANATION: */
/* w2g_mainfile.php - Specific Functions for Mobile Site */
/******************************************************************************/
@include("settings.php");
if(!defined('INCLUDE_PATH')) define('INCLUDE_PATH', '../../');


This way if the CMS is not RavenNuke(tm), it will still work.


i put this in like you said. and it gave me another error

Unable to locate the RavenNuke(tm) configuration file - ../../rnconfig.php

**edit** i changed ('INCLUDE_PATH', '../../') to ('INCLUDE_PATH', '../') ( only one '../' and it works. outstanding. thanks a lot nuken. now i get to start moding this mod with a fancy theme and layout and such.
View user's profile Send private message
nuken
RavenNuke(tm) Development Team


Joined: Mar 11, 2007
Posts: 1435
Location: North Carolina

PostPosted: Tue Dec 15, 2009 9:54 pm Reply with quote Back to top

Oh yes, I had it on a sub domain and needed the extra ../ I'm glad you got it working.
View user's profile Send private message Send e-mail Visit poster's website
helidoc
Hangin' Around


Joined: Jul 09, 2006
Posts: 43

PostPosted: Wed Feb 10, 2010 8:00 am Reply with quote Back to top

Anyone have Wap2Go working on a 2.40 site was thinking of adding this for some of my Mobile users.
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum