diff --git a/main/admin/configure_homepage.php b/main/admin/configure_homepage.php
index 2f6bca8cee..cb5b61a3fa 100644
--- a/main/admin/configure_homepage.php
+++ b/main/admin/configure_homepage.php
@@ -1,4 +1,4 @@
- (sizeof($home_menu) - 1))
- {
+ if($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1)) {
$insert_where=sizeof($home_menu) - 1;
}
// For each line of the file, remove trailing spaces and special chars
- foreach($home_menu as $key=>$enreg)
- {
+ foreach($home_menu as $key=>$enreg) {
$home_menu[$key]=trim($enreg);
}
// If the given link url is empty, then replace the link url by a link to the link file created
- if(empty($link_url))
- {
+ if(empty($link_url)) {
$link_url=api_get_path(WEB_PATH).'index.php?include='.urlencode($filename);
// If the file doesn't exist, then create it and
// fill it with default text
- if(!file_exists(api_get_path(SYS_PATH).'home/'.$filename))
- {
+ if(!file_exists(api_get_path(SYS_PATH).'home/'.$filename)) {
$fp=@fopen(api_get_path(SYS_PATH).'home/'.$filename,'w');
- if($fp)
- {
+ if($fp) {
fputs($fp,get_lang('MyTextHere'));
fclose($fp);
@@ -377,12 +357,10 @@ if(!empty($action))
}
// If the requested action is to edit a link, open the file and
// write to it (if the file doesn't exist, create it)
- if($action == 'edit_link' && !empty($link_html))
- {
+ if($action == 'edit_link' && !empty($link_html)) {
$fp=@fopen(api_get_path(SYS_PATH).'home/'.$filename,'w');
- if($fp)
- {
+ if($fp) {
fputs($fp,$link_html);
fclose($fp);
}
@@ -390,16 +368,11 @@ if(!empty($action))
// If the requested action is to create a link, make some room
// for the new link in the home_menu array at the requested place
// and insert the new link there
- if($action == 'insert_link')
- {
- for($i=sizeof($home_menu);$i;$i--)
- {
- if($i > $insert_where)
- {
+ if($action == 'insert_link') {
+ for($i=sizeof($home_menu);$i;$i--) {
+ if($i > $insert_where) {
$home_menu[$i]=$home_menu[$i-1];
- }
- else
- {
+ } else {
break;
}
}
@@ -440,8 +413,7 @@ if(!empty($action))
break;
} //end of switch($action)
- if(empty($errorMsg))
- {
+ if(empty($errorMsg)) {
header('Location: '.api_get_self());
exit();
}
@@ -459,14 +431,10 @@ if(!empty($action))
$home_menu=file($homep.$menuf.'_'.$lang.$ext);
- foreach($home_menu as $key=>$enreg)
- {
- if($key == $link_index)
- {
+ foreach($home_menu as $key=>$enreg) {
+ if($key == $link_index) {
unset($home_menu[$key]);
- }
- else
- {
+ } else {
$home_menu[$key]=trim($enreg);
}
}
@@ -577,15 +545,12 @@ if(!empty($action))
$link_url='';
// For each line of the home_menu file
- foreach($home_menu as $key=>$enreg)
- {
+ foreach($home_menu as $key=>$enreg) {
// Check if the current item is the one we want to update
- if($key == $link_index)
- {
+ if($key == $link_index) {
// This is the link we want to update
// Check if the target should be "_blank"
- if(strstr($enreg,'target="_blank"'))
- {
+ if(strstr($enreg,'target="_blank"')) {
$target_blank=true;
}
// Remove dangerous HTML tags from the link itself (this is an
@@ -599,21 +564,17 @@ if(!empty($action))
// If the link contains the web root of this portal, then strip
// it off and keep only the name of the file that needs edition
- if(strstr($link_url,$_configuration['root_web']) && strstr($link_url,'?include='))
- {
+ if(strstr($link_url,$_configuration['root_web']) && strstr($link_url,'?include=')) {
$link_url=explode('?include=',$link_url);
$filename=$link_url[sizeof($link_url)-1];
- if(!strstr($filename,'/') && strstr($filename,'.html'))
- {
+ if(!strstr($filename,'/') && strstr($filename,'.html')) {
// Get oonly the contents of the link file
$link_html=file(api_get_path(SYS_PATH).'home/'.$filename);
$link_html=implode('',$link_html);
$link_url='';
- }
- else
- {
+ } else {
$filename='';
}
}
@@ -654,8 +615,7 @@ switch($action){