Member
Member
vikaskbh   2009-09-25, 10:12
#1
Mobile Hack for Zenphoto 1.2

[b]Index File Modification[/b]

`

<?php

// force UTF-8 Ø

$isMobile = CheckUserAgent();

if (!defined('ZENFOLDER')) { define('ZENFOLDER', 'zp-core'); }

if (!file_exists(dirname(__FILE__) . '/' . ZENFOLDER . "/zp-config.php")) {

$dir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));

if (substr($dir, -1) == '/') $dir = substr($dir, 0, -1);

$location = "http://". $_SERVER['HTTP_HOST']. $dir . "/" . ZENFOLDER . "/setup.php";

header("Location: $location" );

}

define('OFFSET_PATH', 0);

require_once(ZENFOLDER . "/template-functions.php");

if (getOption('zenphoto_release') != ZENPHOTO_RELEASE) {

header("Location: " . FULLWEBPATH . "/" . ZENFOLDER . "/setup.php");

exit();

}

if($isMobile == true){

setOption('zp_plugin_static_html_cache', 0, false);

}else{

header ('Content-Type: text/html; charset=' . getOption('charset'));

}

$obj = '';

// Display an arbitrary theme-included PHP page

if (isset($_GET['p'])) {

handleSearchParms('page', $_zp_current_album, $_zp_current_image);

$theme = setupTheme();

$page = str_replace(array('/','\\','.'), '', sanitize($_GET['p']));

if (strpos($page, '*')===0) {

$page = substr($page,1); // handle old zenfolder page urls

$_GET['z'] = true;

}

if (isset($_GET['z'])) { // system page

$_zp_gallery_page = basename($obj = ZENFOLDER."/".$page.".php");

} else {

$obj = THEMEFOLDER."/$theme/$page.php";

$_zp_gallery_page = basename($obj);

}

// Display an Image page.

} else if (in_context(ZP_IMAGE)) {

handleSearchParms('image', $_zp_current_album, $_zp_current_image);

if($isMobile != true){

$theme = setupTheme();

}else{

$theme = "mobile";

}

$_zp_gallery_page = basename($obj = THEMEFOLDER."/$theme/image.php");

//update hit counter

if (!isMyALbum($_zp_current_album->name, ALL_RIGHTS)) {

$hc = $_zp_current_image->get('hitcounter')+1;

$_zp_current_image->set('hitcounter', $hc);

$_zp_current_image->save();

}

// Display an Album page.

} else if (in_context(ZP_ALBUM)) {

if ($_zp_current_album->isDynamic()) {

$search = $_zp_current_album->getSearchEngine();

$cookiepath = WEBPATH;

if (WEBPATH == '') { $cookiepath = '/'; }

zp_setcookie("zenphoto_image_search_params", $search->getSearchParams(), 0, $cookiepath);

set_context(ZP_INDEX | ZP_ALBUM);

} else {

handleSearchParms('album', $_zp_current_album);

}

if($isMobile != true){

$theme = setupTheme();

}else{

$theme = "mobile";

}

$_zp_gallery_page = basename($obj = THEMEFOLDER."/$theme/album.php");

// update hit counter

if (!isMyALbum($_zp_current_album->name, ALL_RIGHTS) && getCurrentPage() == 1) {

$hc = $_zp_current_album->get('hitcounter')+1;

$_zp_current_album->set('hitcounter', $hc);

$_zp_current_album->save();

}

// Display the Index page.

} else if (in_context(ZP_INDEX)) {

handleSearchParms('index');

if($isMobile != true){

$theme = setupTheme();

}else{

$theme = "mobile";

}

$_zp_gallery_page = basename($obj = THEMEFOLDER."/$theme/index.php");

}

// Load plugins, then load the requested $obj (page, image, album, or index; defined above).

if (file_exists(SERVERPATH . "/" . internalToFilesystem($obj)) && $zp_request) {

foreach (getEnabledPlugins() as $extension=>$loadtype) {

$_zp_loaded_plugins[] = $extension;

require_once(SERVERPATH . "/" . ZENFOLDER . PLUGIN_FOLDER . $extension);

}

// Zenpage automatic hitcounter update support

if(function_exists("is_NewsArticle") AND !$_zp_loggedin) {

if(is_NewsArticle()) {

$hc = $_zp_current_zenpage_news->get('hitcounter')+1;

$_zp_current_zenpage_news->set('hitcounter', $hc);

$_zp_current_zenpage_news->save();

}

if(is_NewsCategory()) {

$catname = sanitize($_GET['category']);

query("UPDATE ".prefix('zenpage_news_categories')." SET ``hitcounter` = `hitcounter`+1 WHERE `cat_link` = '".$catname."'",true);
}
if(is_Pages()) {
$hc = $_zp_current_zenpage_page->get('hitcounter')+1;
$_zp_current_zenpage_page->set('hitcounter', $hc);
$_zp_current_zenpage_page->save();
}
}

// re-initialize video dimensions if needed
if (isImageVideo() & !is_null($_zp_flash_player)) $_zp_current_image->updateDimensions();

// zp_plugin_static_html_cache

// Display the page itself

if(!is_null($_zp_HTML_cache)) { $_zp_HTML_cache->startHTMLCache(); }
// Include the appropriate page for the requested object, and a 200 OK header.
header("HTTP/1.0 200 OK");
header("Status: 200 OK");
include($obj);

} else {
// If the requested object does not exist, issue a 404 and redirect to the theme's
// 404.php page, or a 404.php in the zp-core folder.

list($album, $image) = rewrite_get_album_image('album','image');
$_zp_gallery_page = '404.php';
if (!isset($theme)) {
$theme = setupTheme();
}
$errpage = THEMEFOLDER.'/'.internalToFilesystem($theme).'/404.php';
header("HTTP/1.0 404 Not Found");
header("Status: 404 Not Found");
if (file_exists(SERVERPATH . "/" . $errpage)) {
include($errpage);
} else {
include(ZENFOLDER. '/404.php');
}

}

exposeZenPhotoInformations( $obj, $_zp_loaded_plugins, $theme, $_zp_filters );

if(!is_null($_zp_HTML_cache)) { $_zp_HTML_cache->endHTMLCache(); }

function CheckUserAgent() {

$pdas=array(
'acer', 'alcatel', 'audiovox', 'avantgo', 'blackberry',
'blazer', 'cdm', 'digital paths','elaine', 'epoc',
'ericsson', 'handspring', 'iemobile', 'kyocera', 'lg',
'midp', 'mmp', 'mobile', 'motorola', 'nokia', 'o2', 'openwave', 'opera mini', 'operamini',
'opwv', 'palm', 'panasonic', 'pda', 'phone',
'playstation portable','pocket','psp', 'qci', 'sagem',
'sanyo', 'samsung', 'sec', 'sendo', 'sharp',
'smartphone', 'sonyericsson', 'symbian', 'telit', 'tsm',
'up-browser', 'up.browser', 'up.link', 'vodafone', 'wap',
'windows ce','cldc', 'xiino'
);
$accept=isset($_SERVER['HTTP_ACCEPT'])?strtolower($_SERVER['HTTP_ACCEPT']):'';
if(((strpos($accept,'text/vnd.wap.wml')>0)||
(strpos($accept,'application/vnd.wap.xhtml+xml')>0))||
isset($_SERVER['HTTP_X_WAP_PROFILE'])||
isset($_SERVER['HTTP_PROFILE'])||
isset($_SERVER['X-OperaMini-Features'])||
isset($_SERVER['UA-pixels']) )
return true;
if(isset($_SERVER['HTTP_USER_AGENT']))

$agent=strtolower($_SERVER['HTTP_USER_AGENT']);
if(isset($agent)){
foreach($pdas as $browser)
if(false!==strpos($agent,$browser))
return true;
}

return false;
}

?>

Rest of the things you need to do in theme files...

e.g.

`

setOption('albums_per_page', 4, false);

setOption('images_per_page', 4, false);

setOption('image_size', 150, false);

setOption('image_quality', 65, false);

setOption('thumb_quality', 70, false);

`

... blah.. blah..
Member
Member
vikaskbh   2009-09-25, 10:18
#2
Mobile site modification in previous version (1.0.8) of zenphoto was damn easy.

This new database driven options, (static-html-cache) plug-ins driven Zen-Photo wasted my more hours to recode mobile hacks.
Member
Member
sbillard   2009-09-25, 23:59
#3
well, that is one reason we recommend not changing core files.
Administrator
Administrator
acrylian   2009-09-26, 08:38
#4
The iPhone theme recently developed by a user seems to be the more elegant way actually.
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.