<?php
/*
OpenDataBag - Data Web Interface
Copyright (C) 2004 Nawara
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if(!defined('cfg_clean_detail'))
define('cfg_clean_detail',0);
define('cfg_use_cache',1);
ignore_user_abort(true);
define('cfg_base_path', getcwd());
define('ODBMENU',cfg_data_path.'/script/inc_menu.txt');
if(!defined('cfg_sso_path'))
define('cfg_sso_path',cfg_data_path);
if(!defined('cfg_cron'))
define('cfg_cron',0);
// URL to help pages
$browser_lang=getenv('HTTP_ACCEPT_LANGUAGE');
if(strpos($browser_lang,','))
$cfg_lang=substr($browser_lang,0,strpos($browser_lang,','));
elseif(strlen($browser_lang)>0)
$cfg_lang=$browser_lang;
else
$cfg_lang='en';
//------------------------------------------------------------------
if (!empty($_SERVER['HTTP_USER_AGENT']))
{
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
}
else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']))
{
$HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
}
else if (!isset($HTTP_USER_AGENT))
{
$HTTP_USER_AGENT = '';
}
if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[2];
$browser_agent = 'opera';
$browser_type = 'full';
}
else if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'ie';
$browser_type = 'full';
}
else if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'omniweb';
$browser_type = 'full';
}
else if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'netscape';
$browser_type = 'full';
}
else if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'mozilla';
$browser_type = 'full';
}
else if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'konqueror';
$browser_type = 'full';
}
else if (ereg('Nokia([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version))
{
$browser_version = $log_version[1];
$browser_agent = 'nokia';
$browser_type = 'mobile';
}
else
{
$browser_version = 0;
$browser_agent = 'other';
$browser_type = 'full';
}
//------------------------------------------------------------------
define('cfg_help_url', 'http://opendatabag.net/help/doku.php?id='.urlencode(cfg_skin_name.' '.$cfg_lang));
define('cfg_faq_url', 'http://opendatabag.net/help/doku.php?id='.urlencode('About ODB ('.$cfg_lang.')'));
global $bagaccess_array;
global $context_inputs;
global $context_params;
$context_inputs='';
$context_params='';
$_odb_import_username='';
$message='';
require_once(cfg_data_path.'/script/inc_functions.txt');
require_once(cfg_data_path.'/script/inc_data.txt');
if(!cfg_cron)
{
// fixing structure start -------------------------------------------------------------------
if(!file_exists(cfg_data_path.'/../logo.jpg'))
copy(cfg_data_path.'/../images/logo.jpg',cfg_data_path.'/../logo.jpg');
if(!file_exists(cfg_data_path.'/../style.css'))
fclose(fopen(cfg_data_path.'/../style.css','a'));
if(!file_exists(cfg_sso_path.'/data/dat_articles.txt'))
copy(cfg_sso_path.'/data/dist-dat_articles.txt',cfg_sso_path.'/data/dat_articles.txt');
if(!file_exists(cfg_sso_path.'/data/dat_menu.txt'))
copy(cfg_sso_path.'/data/dist-dat_menu.txt',cfg_sso_path.'/data/dat_menu.txt');
if(!file_exists(cfg_sso_path.'/data/.passwd.txt'))
{
if(file_exists(cfg_sso_path.'/data/.passwd'))
{
$fp=fopen(cfg_sso_path.'/data/.passwd.txt','w');
fwrite($fp,base64_encode(serialize(unserialize(gzuncompress(base64_decode(file_get_contents(cfg_sso_path.'/data/.passwd')))))));
fclose($fp);
}
elseif(file_exists(cfg_data_path.'/data/.passwd.txt'))
{
addpath(cfg_sso_path.'/data');
copy(cfg_data_path.'/data/.passwd.txt',cfg_sso_path.'/data/.passwd.txt');
}
elseif(file_exists(cfg_data_path.'/data/.passwd'))
{
$fp=fopen(cfg_sso_path.'/data/.passwd.txt','w');
fwrite($fp,base64_encode(serialize(unserialize(gzuncompress(base64_decode(file_get_contents(cfg_data_path.'/data/.passwd')))))));
fclose($fp);
}
else
{
addpath(cfg_data_path.'/data');
copy(cfg_data_path.'/data/.passwd.txt-dist',cfg_sso_path.'/data/.passwd.txt');
}
}
if(!file_exists(cfg_data_path.'/data/dat_access.txt'))
copy(cfg_data_path.'/data/dist-dat_access.txt',cfg_data_path.'/data/dat_access.txt');
// fixing structure end -------------------------------------------------------------------
}
$bagaccess_array['deleted']=0;
$bagaccess_array['logs']=0;
$bagaccess_array['articles']=1;
require_once(cfg_data_path.'/script/sec_basic.txt');
if(cfg_cron==1)
{
set_time_limit(0);
//USEREXIT OnCron
$userexit='oncron';
if(file_exists(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt'))
{
include(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt');
}
else
{
include(cfg_data_path.'/script/userexit/exit_'.$userexit.'.txt');
}
echo 'odb_cron.php (odb'.INFO.') '.date('Y-m-d H:i:s').CRLF;
exit;
}
$search=get('search');
if(get('mobile'))
define('mobile',1);
elseif($browser_type=='mobile')
define('mobile',1);
else
define('mobile',0);
$bag=get('bag');
$lastbag=get('lastbag');
$choosebag=get('choosebag');
$id=get('id');
$run=basename(get('run'));
$sys=basename(get('sys'));
$mask=basename(get('mask'));
$script=basename(get('script'));
$skin=basename(get('skin'));
$popup=0+get('popup');
$sys_comment=get('sys_comment');
$title=get('title');
$mm1=get('mm1');
$mm2=get('mm2');
$mark=get('mark');
$compare=get('compare');
$showcms=get('showcms');
if(!defined('cfg_showcms') or cfg_showcms!='ON')
$showcms=0;
elseif($showcms=='no')
$showcms=0;
else
$showcms=1;
$cnt_mark='';
if(get('tree0'))
define('cfg_load_tree',1);
else
define('cfg_load_tree',0);
$tree_filter=get('tree_filter');
//clear bag problem
if(get('upgrade_me')) //upgrade condition //------------------------------------------------------------------------------------------------
{
$odb_zip=file_get_contents('http://nawara.home.pl/opendatabag.net/odb.zip');
if(strlen($odb_zip)>1000000)
{
$tmp_dir2=rand(10000,99999);
addpath(cfg_data_path.'/temp/upgrade/'.$tmp_dir2);
$fp=fopen(cfg_data_path.'/temp/upgrade/'.$tmp_dir2.'/odb.zip','w+');
fwrite($fp,$odb_zip);
fclose($fp);
$tmp_dir=getcwd();
chdir(cfg_data_path.'/temp/upgrade/'.$tmp_dir2);
system('unzip odb.zip 2>&1 >> upgrade.log ');
chdir($tmp_dir);
$upgrade_name='';
$res=opendir(cfg_data_path.'/temp/upgrade/'.$tmp_dir2);
while($fl = readdir($res))
if($fl!='.' and $fl!='..' and $fl!='upgrade.log' and $fl!='odb.zip' and $fl!='backup' )
$upgrade_name=$fl;
closedir($res);
if($upgrade_name)
{
dircopy(cfg_data_path.'/temp/upgrade/'.$tmp_dir2.'/'.$upgrade_name,cfg_base_path,cfg_data_path.'/temp/upgrade/'.$tmp_dir2.'/backup',1);
remove_directory(cfg_data_path.'/temp/upgrade/'.$tmp_dir2.'/'.$upgrade_name);
echo '<br />';
myecho('Upgrade successful');
echo '<br /><a href="index.php">';
myecho('Continue...');
echo '</a>';
}
else
myecho('Cannot upgrade');
}
else
{
myecho('Cannot load upgrade file');
}
exit;
}
if(strlen($run))
{
if(file_exists(cfg_data_path.'/config/script/run_'.$run.'.txt'))
{
include(cfg_data_path.'/config/script/run_'.$run.'.txt');
}
else
{
include(cfg_data_path.'/script/run_'.$run.'.txt');
}
$fp=fopen(cfg_data_path.'/data/.lastmod','wb');
fwrite($fp,date('Ymd H:i:s'));
fclose($fp);
}
//USEREXIT OnShowMenu
$userexit='onshowmenu';
if(file_exists(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt'))
{
include(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt');
}
else
{
include(cfg_data_path.'/script/userexit/exit_'.$userexit.'.txt');
}
clearstatcache();
$LastMod = 0;
$LastMod1 = 0;
$LastMod2 = 0;
if(file_exists(cfg_data_path.'/data/.lastmod'))
$LastMod1 = filemtime(cfg_data_path.'/data/.lastmod');
if(file_exists(cfg_myecho_path.'/lang/.lastmod'))
$LastMod2 = filemtime(cfg_myecho_path.'/lang/.lastmod');
if($LastMod1>$LastMod)
$LastMod=$LastMod1;
if($LastMod2>$LastMod)
{
$LastMod=$LastMod2;
//echo date('d.m.Y H:i:s',$LastMod2); exit;
}
define('LASTMOD',$LastMod);
if(cfg_use_cache and !$login and !$message and !$invitation_valid and $script!='translateall' and $sys!='import' and $sys!='export')
{
// Cache steering
$last_mod=gmdate('D, d M Y H:i:s',LASTMOD). ' GMT';
header("Pragma: "); // session_start daje "no-cache" wiÄc trzeba wyczyÅciÄ.
header("Cache-Control: max-age=1, must-revalidate");
header('Last-Modified: ' . $last_mod);
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 1) . ' GMT');
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) and strtotime(trim($_SERVER['HTTP_IF_MODIFIED_SINCE']))>=LASTMOD)
{
//echo '304'; exit;
header('HTTP/1.0 304 Not Modified');
header('Content-Length: 0');
// header('Status: 304 Not Modified');
exit();
}
/*
$if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]);
$gmdate_mod = date('D, d M Y H:i:s', LASTMOD) . ' GMT';
//echo $gmdate_mod;
if($if_modified_since)
{
$if_modified_since_time=strtotime($if_modified_since);
if ($if_modified_since_time >= LASTMOD and time()-LASTMOD<3*60*60)
{
header("HTTP/1.0 304 Not Modified");
exit;
}
}
header("Last-Modified: $gmdate_mod");
header("Expires: $gmdate_mod");
*/
}
//showing menu from database
if(!$login)
{
$tmp_result_array=search('sysGroupBy=menu Active MyBag=menu');
$tmp_sorted_result_array=array();
reset($tmp_result_array);
foreach($tmp_result_array as $tmp_line)
if(read($tmp_line,'User Group')=='' or strtoupper(read($tmp_line,'User Group'))==strtoupper(USERGROUP))
$tmp_sorted_result_array[$tmp_line]=read($tmp_line,'Menu Order');
asort($tmp_sorted_result_array);
reset($tmp_sorted_result_array);
foreach($tmp_sorted_result_array as $tmp_line => $tmp)
{
$Menu_Name=read($tmp_line,'Menu Name');
if($Menu_Name!='Help' and $Menu_Name!='Administration')
{
$Submenu_Name=read($tmp_line,'Submenu Name');
//if(check_access($Submenu_Name,1) and check_access($Menu_Name,1))
{
$Menu_Search=read($tmp_line,'Menu Search');
$Menu_Link=read($tmp_line,'Menu Link');
if($Menu_Search)
$Menu_Link.='&odb_search='.rawurlencode($Menu_Search);
if(use_homepage and !defined('cfg_start_menu1') and !defined('cfg_start_menu2'))
{
define('cfg_start_menu1',$Menu_Name);
define('cfg_start_menu2',$Submenu_Name);
}
if($Submenu_Name)
$menu_array[$Menu_Name][$Submenu_Name]=$Menu_Link;
else
$menu_array[$Menu_Name]=$Menu_Link;
}
}
}
//smart switching off menu data if not directly requested by sysGroupBy=menu
if(strpos('_'.$search,'menu')==0 and strpos('_'.$search,'sysId=')==0)
$bagaccess_array['menu']=0;
reset($tmp_sorted_result_array);
foreach($tmp_sorted_result_array as $tmp_line => $tmp)
{
$Menu_Name=read($tmp_line,'Menu Name');
if($Menu_Name=='Administration')
{
$Submenu_Name=read($tmp_line,'Submenu Name');
if(check_access($Submenu_Name,1) and check_access($Menu_Name,1))
{
$Menu_Search=read($tmp_line,'Menu Search');
$Menu_Link=read($tmp_line,'Menu Link');
$Menu_Link.='&odb_search='.rawurlencode($Menu_Search);
if($Submenu_Name)
$menu_array[$Menu_Name][$Submenu_Name]=$Menu_Link;
else
$menu_array[$Menu_Name]=$Menu_Link;
}
}
}
if(USERGROUP=='ADMIN')
{
$menu_array['Administration']['Add New User']='odb_script=new&odb_group=user';
$menu_array['Administration']['Add New...']='odb_search=---&odb_sys=uninew';
//$menu_array['Administration']['My Calendar']='odb_search='.USERDESCRIPTION.'&odb_script=xcal';
$menu_array['Administration']['Reset Password']='odb_sys=reset';
//$menu_array['Administration']['Manage Users']='odb_script=report&odb_search=sysGroupBy%3Duser&k2=User+Group&n1=%5BMyBag%5D&n2=%5BUser+Group%5D&n3=&n4=&n5=&n6=&n7=&n8=&n9=&k3=User&e1=&e2=&e3=&e4=&e5=&e6=&e7=&e8=&e9=&k4=Registration+Date&v1=&v2=&v3=&v4=&v5=&v6=&v7=&v8=&v9=';
$menu_array['Administration']['Manage Articles']='odb_search=articles&odb_script=&odb_tree0=Language&odb_tree1=Menu+header&odb_tree2=Menu+item';
$menu_array['Administration']['Manage Users']='odb_search=sysGroupBy%3Duser&odb_tree0=%5BUser+Group%5D&odb_tree1=%5BUser%5D+%28%5BRegistration+Date%5D%29';
$menu_array['Administration']['Manage Translations']='odb_search=---&odb_script=translateall';
$menu_array['Administration']['Manage Menu']='odb_sort1=Menu+Order&odb_page=all&odb_tab=Menu&odb_search=sysGroupBy%3dmenu';
$menu_array['Administration']['Manage Structure']='odb_search=---&odb_sys=structure';
}
$menu_array['Help']['Topic List']=cfg_help_url;
$menu_array['Help']['About ODB']=cfg_faq_url;
reset($tmp_sorted_result_array);
foreach($tmp_sorted_result_array as $tmp_line => $tmp)
{
$Menu_Name=read($tmp_line,'Menu Name');
if($Menu_Name=='Help')
{
$Submenu_Name=read($tmp_line,'Submenu Name');
if(check_access($Submenu_Name,1) and check_access($Menu_Name,1))
{
$Menu_Search=read($tmp_line,'Menu Search');
$Menu_Link=read($tmp_line,'Menu Link');
$Menu_Link.='&odb_search='.rawurlencode($Menu_Search);
if($Submenu_Name)
$menu_array[$Menu_Name][$Submenu_Name]=$Menu_Link;
else
$menu_array[$Menu_Name]=$Menu_Link;
}
}
}
if(USERGROUP=='ADMIN')
$menu_array['Help']['System info']='odb_sys=logs&odb_search=---';
//----------------------------------
reset($menu_array);
while(list($menu_name,$submenu)=each($menu_array))
{
$menu_link='';
$submenu_array=array();
if(is_array($submenu))
{
$submenu_array=$submenu;
while(list($submenu_name,$submenu_link)=each($submenu_array))
{
if($submenu_link!='')
{
if(substr($submenu_link,0,4)!='http')
{
$tmp_link=str_replace('&','&',$submenu_link).'&odb_mm1='.$menu_name.'&odb_mm2='.$submenu_name;
$tmp_link=str_replace("'","",$tmp_link);
$link_content='';
$link_content.='<'.'?php'.CRLF;
$link_content.='$tmp_str=\''.$tmp_link.'\';'.CRLF;
$link_content.='parse_str($tmp_str,$inner_get_array);'.CRLF;
$link_content.='include(\'./odb_index.php\');'.CRLF;
$link_content.='?'.'>'.CRLF;
if(!file_exists(cfg_base_path.'/'.linkname($menu_name).'-'.linkname($submenu_name).'.php') or $link_content!=file_get_contents(cfg_base_path.'/'.linkname($menu_name).'-'.linkname($submenu_name).'.php'))
{
$fp=fopen(cfg_base_path.'/'.linkname($menu_name).'-'.linkname($submenu_name).'.php','wb');
fwrite($fp,$link_content);
fclose($fp);
mylog('MENU CHANGED '.linkname($menu_name).'-'.linkname($submenu_name));
}
}
}
}
}
else
{
$menu_link=$submenu;
if(substr($menu_link,0,4)!='http')
{
$link_content='';
$link_content.='<'.'?php'.CRLF;
$link_content.='$tmp_str=\''.str_replace('&','&',$menu_link).'&odb_mm1='.$menu_name.'&odb_mm2=\';'.CRLF;
$link_content.='parse_str($tmp_str,$inner_get_array);'.CRLF;
$link_content.='include(\'./odb_index.php\');'.CRLF;
$link_content.='?'.'>'.CRLF;
if(!file_exists(cfg_base_path.'/'.linkname($menu_name).'.php') or $link_content!=file_get_contents(cfg_base_path.'/'.linkname($menu_name).'.php'))
{
$fp=fopen(cfg_base_path.'/'.linkname($menu_name).'.php','wb');
fwrite($fp,$link_content);
fclose($fp);
}
}
}
}
}
//----------------------------------
if(defined('change_passwd') and change_passwd=='yes')
{
$script='chpasswd';
}
elseif(use_homepage=='yes' or (mobile and !$search))
{
//USEREXIT OnLogin
$userexit='onlogin';
if(file_exists(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt'))
{
include(cfg_data_path.'/config/userexit/exit_'.$userexit.'.txt');
}
else
{
include(cfg_data_path.'/script/userexit/exit_'.$userexit.'.txt');
}
if(cfg_start_menu2!='')
$tmp_start_point='&'.$menu_array[cfg_start_menu1][cfg_start_menu2];
else
$tmp_start_point='&'.$menu_array[cfg_start_menu1];
$tmp_start_point=str_replace('&','&',$tmp_start_point);
parse_str($tmp_start_point, $_GET);
parse_str(str_replace('&odb_','&',$tmp_start_point));
}
if($search=='' or $script=='new' or $script=='search')
$search='---';
$search=trim(replace_const($search));
define('ODBSCRIPT',cfg_data_path.'/script/sys_'.$sys.'.txt');
$report_link='';
$tmp_content='';
if($script!='new' and $script!='search')
$tmp_content.='<input name="odb_script" type="hidden" value="'.$script.'" />';
if(isset($group))
$tmp_content.='<input name="odb_group" type="hidden" value="'.$group.'" />';
if($popup)
$tmp_content.='<input name="odb_popup" type="hidden" value="'.$popup.'" />';
define('REPORT_COLUMN_COUNT',20);
if(cfg_load_tree)
{
$tmp_tree_filter='';
if($title) $tmp_content .= '<input name="odb_title" type="hidden" value="'.$title.'" />';
if($search) $report_link.='&odb_search='.urlencode($search);
if($tree_filter) $report_link.='&odb_tree_filter='.urlencode($tree_filter);
for($ii=0;$ii<10;$ii++)
{
//if(get('tree'.$ii)) $tmp_content .= '<input name="odb_tree'.$ii.'" type="hidden" value="'.get('tree'.$ii).'" />';
if(get('tree'.$ii)) $report_link.='&odb_tree'.$ii.'='.urlencode(get('tree'.$ii));
$tmp_content .= '<input name="odb_tree'.$ii.'" type="hidden" value="'.get('tree'.$ii).'" />';
$value=get('tree'.$ii);
if(strpos('_'.$value,'[')>0)
{
$tmp_filter='';
$pos=strpos('_'.$value,'[');
while($pos>0)
{
$variable=substr($value,$pos,strpos($value.']',']',$pos)-$pos);
$value=str_replace('['.$variable.']','',$value);
if(strpos('_'.$search.' '.$tmp_tree_filter,'['.$variable.']')==0)
$tmp_filter.='['.$variable.'] ';
$pos=strpos('_'.$value,'[');
}
if(trim($value)=='')
$tmp_tree_filter.=$tmp_filter;
}
elseif(trim($value) and strpos('_'.$search.' '.$tmp_tree_filter,'['.$value.']')==0)
$tmp_tree_filter.='['.$value.'] ';
}
$tmp_tree_filter=trim($tmp_tree_filter);
//$search=trim($search.' '.$tmp_tree_filter); off - search field too complicated
}
if($script=='chart' or $script=='cube')
{
$tmp_content .= '<input name="odb_title" type="hidden" value="'.$title.'" />';
$tmp_content .= '<input name="odb_type" type="hidden" value="'.get('type').'" />';
for($ii=0;$ii<10;$ii++)
{
$tmp_content .= '<input name="a'.$ii.'" type="hidden" value="'.get('a'.$ii).'" />';
$tmp_content .= '<input name="b'.$ii.'" type="hidden" value="'.get('b'.$ii).'" />';
$tmp_content .= '<input name="c'.$ii.'" type="hidden" value="'.get('c'.$ii).'" />';
$tmp_content .= '<input name="d'.$ii.'" type="hidden" value="'.get('d'.$ii).'" />';
}
}
elseif($script=='report' or $script=='action' or $script=='cal' or $script=='rcal' or $script=='xrcal')
{
if($title) $tmp_content .= '<input name="odb_title" type="hidden" value="'.$title.'" />';
if($search) $report_link.='&odb_search='.urlencode($search);
if($script) $report_link.='&odb_script='.urlencode($script);
if($title) $report_link.='&odb_title='.urlencode($title);
if(get('k2')) $tmp_content .= '<input name="k2" type="hidden" value="'.get('k2').'"/>';
if(get('k3')) $tmp_content .= '<input name="k3" type="hidden" value="'.get('k3').'"/>';
if(get('k4')) $tmp_content .= '<input name="k4" type="hidden" value="'.get('k4').'"/>';
if(get('k2')) $report_link.='&k2='.urlencode(get('k2'));
if(get('k3')) $report_link.='&k3='.urlencode(get('k3'));
if(get('k4')) $report_link.='&k4='.urlencode(get('k4'));
for($ii=1;$ii<4;$ii++)
{
if(get('a'.$ii)) $tmp_content .= '<input name="a'.$ii.'" type="hidden" value="'.get('a'.$ii).'" />';
if(get('f'.$ii)) $tmp_content .= '<input name="f'.$ii.'" type="hidden" value="'.get('f'.$ii).'" />';
if(get('s'.$ii)) $tmp_content .= '<input name="s'.$ii.'" type="hidden" value="'.get('s'.$ii).'" />';
if(get('a'.$ii)) $report_link.='&a'.$ii.'='.urlencode(get('a'.$ii));
if(get('f'.$ii)) $report_link.='&f'.$ii.'='.urlencode(get('f'.$ii));
if(get('s'.$ii)) $report_link.='&s'.$ii.'='.urlencode(get('s'.$ii));
}
for($ii=1;$ii<REPORT_COLUMN_COUNT;$ii++)
{
if(get('n'.$ii)) $tmp_content .= '<input name="n'.$ii.'" type="hidden" value="'.get('n'.$ii).'" />';
if(get('e'.$ii)) $tmp_content .= '<input name="e'.$ii.'" type="hidden" value="'.get('e'.$ii).'" />';
if(get('v'.$ii)) $tmp_content .= '<input name="v'.$ii.'" type="hidden" value="'.get('v'.$ii).'" />';
if(get('n'.$ii)) $report_link.='&n'.$ii.'='.urlencode(get('n'.$ii));
if(get('e'.$ii)) $report_link.='&e'.$ii.'='.urlencode(get('e'.$ii));
if(get('v'.$ii)) $report_link.='&v'.$ii.'='.urlencode(get('v'.$ii));
}
}
define('REPORTLINK',$report_link);
define('ODBSEARCH',$tmp_content);
$pos1=strpos('_'.strtolower($search),'mybag=');
if($pos1)
{
if(substr('_'.$search,$pos1-1,1)!='[')
{
$pos2=strpos('_'.$search.' ',' ',$pos1);
$bag=trim(substr($search,$pos1-1+6,$pos2-$pos1-6));
$search=trim(substr($search,0,$pos1-1).substr($search,$pos2));
$choosebag=$bag;
}
}
if(defined('cfg_bag'))
$bag=cfg_bag;
elseif($choosebag=='nobag')
$bag='';
elseif($choosebag=='')
$bag=$bag;
else
$bag=$choosebag;
setcookie('odb_mobile',mobile,time()+120*24*60*60,'/');
//$rev_search=myecho_reverse($search);
//$search=$rev_search;
if(!defined('cfg_skin'))
define('cfg_skin','odb');
define('cfg_images_path', 'images'); //uri
if($sys=='chart' or $sys=='suggest' or $sys=='export' or $sys=='download' or $sys=='invite' or $sys=='downloadcert' or $sys=='rss' or $sys=='antibot' or $sys=='image')
{
include(ODBSCRIPT);
}
else
{
if($skin)
$skin=$skin;
elseif($login and $showcms)
$skin='cms';
elseif($login)
$skin='login';
elseif($popup or $sys=='popup' or $sys=='upload')
$skin='popup';
if(mobile)
{
if(file_exists(cfg_data_path.'/config/script/skin_'.$skin.'_mobile.html'))
{
include(cfg_data_path.'/config/script/skin_'.$skin.'_mobile.html');
}
elseif(file_exists(cfg_data_path.'/script/skin_'.$skin.'_mobile.html'))
{
include(cfg_data_path.'/script/skin_'.$skin.'_mobile.html');
}
elseif(file_exists(cfg_data_path.'/config/script/skin_'.$skin.'.html'))
{
include(cfg_data_path.'/config/script/skin_'.$skin.'.html');
}
else
{
include(cfg_data_path.'/script/skin_'.$skin.'.html');
}
}
else
{
if(file_exists(cfg_data_path.'/config/script/skin_'.$skin.'.html'))
{
include(cfg_data_path.'/config/script/skin_'.$skin.'.html');
}
else
{
include(cfg_data_path.'/script/skin_'.$skin.'.html');
}
}
//Session array save
$session_array['bag']=$bag;
if($mm1) $session_array['mm1']=$mm1;
if($mm2) $session_array['mm2']=$mm2;
if($sys_comment and $sys_comment!='Your comment here...') $session_array['sys_comment']=$sys_comment;
save_session();
//~ echo '<pre>';
//~ print_r($session_array);
//~ echo '</pre>';
}
/*
if($message)
{
echo '<div class="message">';
myecho($message);
echo '</div>';
}
*/
?>