','',$wub_content);
$wub_content = str_replace('
','
',$wub_content);
fclose($fp);
}
else $wub_content = '';
$res = str_replace($ed_tag,$btn_tag.$wub_content,$src);
return $res;
}
// -----------------------------------------------------
function get_page_params($page_id) //GALIA
{
$max_line_chars = 25000;
$sitemap_fname = '../sitemap.php';
$temp = '';
if (file_exists($sitemap_fname))
{
$fp = fopen($sitemap_fname, 'r' );
$fsize = filesize($sitemap_fname);
if ($fsize > 0)
{
while ($data = fgetcsv($fp, $max_line_chars, '|'))
{
$data_str = implode('|', $data);
if(strpos($data_str, ''.$page_id)!==false)
{
$temp = $data;
break;
}
}
fclose($fp);
}
}
return $temp;
}
$page_info = get_page_params($page_id); //GALIA
function get_fs($src,$start,$stop) //GALIA
{
if ($start == '') $res = $src;
else if (strpos($src,$start) === false)
{
$res = '';
return $res;
}
else $res = substr($src,strpos($src,$start) + strlen($start));
if (($stop != '') && (strpos($res,$stop) !== false)) $res = substr($res,0,strpos($res,$stop));
return $res;
}
function format_users($users) //GALIA
{
$users_array = array();
$details_arr = array();
$i = 1;
while (strpos($users, '');
$basic = get_fs($all, '').' ';
$details = get_fs($all, ' ').' ';
$access = get_fs($all, '', '').' ';
list($username, $password) = explode (' ', $basic);
$details_str = explode (' ', $details);
foreach($details_str as $k=>$v)
{
if($v!='') { $details_arr [substr($v, 0, strpos($v, '='))] = get_fs($v, '="', '"'); }
}
$access_arr = array(); $j = 1;
while (strpos($access, '');
list($section, $type) = explode (' ', $access_str);
$access_arr [] = array(substr($section, 0, strpos($section, '=')) => get_fs($section, '="', '"'), substr($type, 0, strpos($type, '=')) => get_fs($type, '="', '"'));
$j++;
}
$users_array [] = array('id' => $i, 'username' => get_fs($username, '="', '"'), 'password' => get_fs($password, '="', '"'), 'access' => $access_arr, 'details' => $details_arr);
$i++;
}
return $users_array;
}
function get_user($username) //GALIA
{
$users = '';
$users_arr = array();
$specific_user = array();
$filename = "../documents/centraladmin.ezg.php";
clearstatcache();
if (file_exists($filename))
{
$fp = fopen($filename, 'r' );
$fsize = filesize($filename);
if ($fsize > 0)
{
$file_contents = fread( $fp,$fsize);
$users = get_fs($file_contents,'','');
}
fclose($fp);
}
if($users!='') { $users_arr = format_users($users); }
if(!empty($users_arr))
{
foreach($users_arr as $k=>$v)
{
if(array_search($username, $v)!==false)
{
$specific_user = $v;
break;
}
}
}
return $specific_user;
}
function has_write_access($pv_user,$pv_pawd) //GALIA
{
global $page_info;
$auth = false;
$section_flag = false;
$write_flag = false;
$user_account = array();
$user_account = get_user($pv_user);
if (isset($page_info [7]) && ($page_info[7]!='-1' && $page_info[7]!='' || $page_info [6]=='TRUE') && !empty($user_account))
{
if($user_account['access'][0]['section']!='ALL' && $user_account['username'] == $pv_user && $user_account['password']==crypt($pv_pawd,$user_account['password']) )
{
foreach($user_account['access'] as $k=>$v)
{
if( $page_info[7] == $v['section'])
{
if($v['type']=='1') { $auth = true; }
else { $auth = false; }
break;
}
}
}
else { $auth = false; }
}
return $auth;
}
// -----------------------------------------------------
function show_page($login,$pwd,$alertid,$actionid)
{
global $editor_pwd,$page_target,$page_id,$wrong_pwd,$show_dialog;
global $page_info; //GALIA
$session_id = GetSessionId();
if ($pwd == '') {
if($page_info[7]=='-1' || $page_info[7]=='') { //GALIA
$admin_access = (isset($_SESSION['cur_pwd'.$session_id]) && $editor_pwd == ($_SESSION['cur_pwd'.$session_id]));
}
else {
if($actionid=='doedit' && isset($_SESSION['cur_pwd']) && isset($_SESSION['cur_user']) && has_write_access($_SESSION['cur_user'],$_SESSION['cur_pwd'])==true) {
$_SESSION['cur_pwd'.$session_id] = $_SESSION['cur_user'];
}
elseif($actionid=='doedit' && isset($_SESSION['SID_ADMIN'])) {
if(!isset($_SESSION['HTTP_USER_AGENT']) || isset($_SESSION['HTTP_USER_AGENT']) && ($_SESSION['HTTP_USER_AGENT'] == md5($_SERVER['HTTP_USER_AGENT'])) ) {
$_SESSION['cur_pwd'.$session_id] = $_SESSION['SID_ADMIN'];
}
}
if(isset($_SESSION['cur_pwd'.$session_id]) && (isset($_SESSION['cur_user']) && $_SESSION['cur_user']==($_SESSION['cur_pwd'.$session_id]) || isset($_SESSION['SID_ADMIN']) && $_SESSION['SID_ADMIN'] == ($_SESSION['cur_pwd'.$session_id]))) {
$admin_access = true;
}
else { $admin_access = false; if($alertid!=3) {$alertid = 0;} } //GALIA
}
}
else
{
$admin_access = ($editor_pwd == $pwd);
if ($admin_access)
{
$_SESSION['cur_pwd'.$session_id]= $editor_pwd;
$alertid = 2;
}
else
{
$_SESSION["cur_pwd".$session_id] = NULL;
unset($_SESSION["cur_pwd".$session_id]);
$alertid = 1;
}
}
if ($actionid == 'edit')
{
if ($admin_access) { edit_page($_GET['tag']); exit(); }
}
if (($actionid == 'save') && ($admin_access)) {save_page(); }
$p_name = GetPageName();
$fp = fopen($p_name, "r");
$contents = fread($fp, filesize($p_name));
fclose($fp);
if (isset($_SESSION['SID_ADMIN']))
$contents = str_replace('','back to CENTRAL ADMIN',$contents);
while (substr_count($contents," 0):
$editable_tag = GetFromStringAbi($contents,"");
$subpage_id = GetFromString($editable_tag,"name=",">");
$btn_tag = "";
if ($admin_access) { $btn_tag = "
"; }
$contents = replace_editable_tags($contents,$editable_tag,$subpage_id,$btn_tag);
endwhile;
if($page_info[7]!='-1' && $page_info[7]!='')
{ $contents = str_replace('42_ezgedit.php?action=login','../documents/centraladmin.php?pageid=42&indexflag=index',$contents);}
else if ($admin_access)
$contents = str_replace('_ezgedit.php?action=login','_ezgedit.php?action=remcookie',$contents);
if ($login)
{
$java = '
';
$contents = str_replace('',$java.'