123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708 |
- <?php // $Id: configure_homepage.php 9246 2006-09-25 13:24:53Z bmol $
- /*
- ==============================================================================
- Dokeos - elearning and course management software
- Copyright (c) 2004 Dokeos S.A.
- Copyright (c) 2003 Ghent University (UGent)
- Copyright (c) 2001 Universite catholique de Louvain (UCL)
- Copyright (c) Olivier Brouckaert
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
- 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.
- See the GNU General Public License for more details.
- Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
- ==============================================================================
- */
- $langFile='admin';
- $cidReset=true;
- include('../inc/global.inc.php');
- $this_section=SECTION_PLATFORM_ADMIN;
- api_protect_admin_script();
- include_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php');
- $action=$_GET['action'];
- $tbl_category=Database::get_main_table(MAIN_CATEGORY_TABLE);
- $tool_name=get_lang('ConfigureHomePage');
- //$interbreadcrumb[]=array("url" => "index.php","name" => get_lang('PlatformAdmin'));
- $menu_language=$_SESSION['user_language_choice'];
- if(!isset($menu_language))
- {
- $menu_language=$platformLanguage;
- }
- if(!file_exists('../../home/home_menu_'.$menu_language.'.html'))
- {
- copy('../../home/home_menu.html','../../home/home_menu_'.$menu_language.'.html');
- }
- $errorMsg='';
- if(!empty($action))
- {
- if($_POST['formSent'])
- {
- if($action == 'edit_top')
- {
- $home_top=trim(stripslashes($_POST['home_top']));
- if(!is_writable('../../home/home_top.html'))
- {
- $errorMsg=get_lang('HomePageFilesNotWritable');
- }
- elseif(!empty($home_top))
- {
- $fp=fopen('../../home/home_top.html','w');
- fputs($fp,$home_top);
- fclose($fp);
- }
- }
- elseif($action == 'edit_notice')
- {
- $notice_title=trim(strip_tags(stripslashes($_POST['notice_title'])));
- $notice_text=trim(str_replace(array("\r","\n"),array("","<br />"),strip_tags(stripslashes($_POST['notice_text']),'<a>')));
- if(empty($notice_title))
- {
- $errorMsg=get_lang('PleaseEnterNoticeTitle');
- }
- elseif(empty($notice_text))
- {
- $errorMsg=get_lang('PleaseEnterNoticeText');
- }
- elseif(!is_writable('../../home/home_notice.html'))
- {
- $errorMsg=get_lang('HomePageFilesNotWritable');
- }
- else
- {
- $fp=fopen('../../home/home_notice.html','w');
- fputs($fp,"<b>$notice_title</b><br />\n$notice_text");
- fclose($fp);
- }
- }
- elseif($action == 'edit_news')
- {
- $home_news=trim(stripslashes($_POST['home_news']));
- if(!is_writable('../../home/home_news.html'))
- {
- $errorMsg=get_lang('HomePageFilesNotWritable');
- }
- elseif(!empty($home_news))
- {
- $fp=fopen('../../home/home_news.html','w');
- fputs($fp,$home_news);
- fclose($fp);
- }
- }
- elseif($action == 'insert_link' || $action == 'edit_link')
- {
- $link_index=intval($_POST['link_index']);
- $insert_where=intval($_POST['insert_where']);
- $link_name=trim(stripslashes($_POST['link_name']));
- $link_url=trim(stripslashes($_POST['link_url']));
- $link_html=trim(stripslashes($_POST['link_html']));
- $filename=trim(stripslashes($_POST['filename']));
- $target_blank=$_POST['target_blank']?true:false;
- if($link_url == 'http://')
- {
- $link_url='';
- }
- elseif(!empty($link_url) && !strstr($link_url,'://'))
- {
- $link_url='http://'.$link_url;
- }
- if(!is_writable('../../home/home_menu_'.$menu_language.'.html'))
- {
- $errorMsg=get_lang('HomePageFilesNotWritable');
- }
- elseif(empty($link_name))
- {
- $errorMsg=get_lang('PleaseEnterLinkName');
- }
- else
- {
- if($action == 'insert_link' || empty($filename) || strstr($filename,'/') || !strstr($filename,'.html'))
- {
- $filename=replace_dangerous_char($link_name,'strict').'.html';
- }
- if(!empty($filename))
- {
- $filename=str_replace('home_','user_',$filename);
- }
- if(!strstr($filename,'_'.$menu_language.'.html'))
- {
- $filename=str_replace('.html','_'.$menu_language.'.html',$filename);
- }
- $home_menu=file('../../home/home_menu_'.$menu_language.'.html');
- if($insert_where < -1 || $insert_where > (sizeof($home_menu) - 1))
- {
- $insert_where=sizeof($home_menu) - 1;
- }
- foreach($home_menu as $key=>$enreg)
- {
- $home_menu[$key]=trim($enreg);
- }
- if(empty($link_url))
- {
- $link_url=$rootWeb.'index.php?include='.urlencode($filename);
- if(!file_exists($rootSys.'home/'.$filename))
- {
- $fp=@fopen($rootSys.'home/'.$filename,'w');
- if($fp)
- {
- fputs($fp,get_lang('MyTextHere'));
- fclose($fp);
- }
- }
- }
- if($action == 'edit_link' && !empty($link_html))
- {
- $fp=@fopen($rootSys.'home/'.$filename,'w');
- if($fp)
- {
- fputs($fp,$link_html);
- fclose($fp);
- }
- }
- if($action == 'insert_link')
- {
- for($i=sizeof($home_menu);$i;$i--)
- {
- if($i > $insert_where)
- {
- $home_menu[$i]=$home_menu[$i-1];
- }
- else
- {
- break;
- }
- }
- $home_menu[$insert_where+1]='<li><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'.$link_name.'</a></li>';
- }
- else
- {
- $home_menu[$link_index]='<li><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'">'.$link_name.'</a></li>';
- }
- $home_menu=implode("\n",$home_menu);
- $fp=fopen('../../home/home_menu_'.$menu_language.'.html','w');
- fputs($fp,$home_menu);
- fclose($fp);
- }
- }
- if(empty($errorMsg))
- {
- header('Location: '.$_SERVER['PHP_SELF']);
- exit();
- }
- }
- elseif($action == 'open_link')
- {
- $link=$_GET['link'];
- if(strstr($link,'/') || !strstr($link,'.html'))
- {
- $link='';
- $action='';
- }
- }
- elseif($action == 'delete_link')
- {
- $link_index=intval($_GET['link_index']);
- $home_menu=file('../../home/home_menu_'.$menu_language.'.html');
- foreach($home_menu as $key=>$enreg)
- {
- if($key == $link_index)
- {
- unset($home_menu[$key]);
- }
- else
- {
- $home_menu[$key]=trim($enreg);
- }
- }
- $home_menu=implode("\n",$home_menu);
- $fp=fopen('../../home/home_menu_'.$menu_language.'.html','w');
- fputs($fp,$home_menu);
- fclose($fp);
- header('Location: '.$_SERVER['PHP_SELF']);
- exit();
- }
- elseif($action == 'edit_top')
- {
- $home_top=file('../../home/home_top.html');
- $home_top=implode('',$home_top);
- }
- elseif($action == 'edit_notice')
- {
- $home_notice=file('../../home/home_notice.html');
- $notice_title=strip_tags($home_notice[0]);
- $notice_text=strip_tags(str_replace('<br />',"\n",$home_notice[1]),'<a>');
- }
- elseif($action == 'edit_news')
- {
- $home_news=file('../../home/home_news.html');
- $home_news=implode('',$home_news);
- }
- elseif($action == 'insert_link')
- {
- $home_menu=file('../../home/home_menu_'.$menu_language.'.html');
- }
- elseif($action == 'edit_link')
- {
- $link_index=intval($_GET['link_index']);
- $home_menu=file('../../home/home_menu_'.$menu_language.'.html');
- $target_blank=false;
- $link_name='';
- $link_url='';
- foreach($home_menu as $key=>$enreg)
- {
- if($key == $link_index)
- {
- if(strstr($enreg,'target="_blank"'))
- {
- $target_blank=true;
- }
- $link_name=strip_tags($enreg);
- $enreg=explode('href="',$enreg);
- list($link_url)=explode('"',$enreg[sizeof($enreg)-1]);
- if(strstr($link_url,$rootWeb) && strstr($link_url,'?include='))
- {
- $link_url=explode('?include=',$link_url);
- $filename=$link_url[sizeof($link_url)-1];
- if(!strstr($filename,'/') && strstr($filename,'.html'))
- {
- $link_html=file($rootWeb.'home/'.$filename);
- $link_html=implode('',$link_html);
- $link_url='';
- }
- else
- {
- $filename='';
- }
- }
- break;
- }
- }
- }
- }
- else
- {
- $result=api_sql_query("SELECT name FROM $tbl_category WHERE parent_id IS NULL ORDER BY tree_pos",__FILE__,__LINE__);
- $Categories=api_store_result($result);
- }
- Display::display_header($tool_name);
- //api_display_tool_title($tool_name);
- if($action == 'open_link')
- {
- ?>
- <div style="margin-bottom: 10px;">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>"><< <?php echo get_lang('Back'); ?></a>
- </div>
- <?php
- include('../../home/'.$link);
- }
- elseif($action == 'edit_notice')
- {
- ?>
- <div style="margin-bottom: 10px;">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>"><< <?php echo get_lang('Back'); ?></a>
- </div>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action; ?>" method="post" style="margin:0px;">
- <input type="hidden" name="formSent" value="1"/>
- <table border="0" cellpadding="5" cellspacing="0">
- <?php
- if(!empty($errorMsg))
- {
- ?>
- <tr>
- <td colspan="2">
- <?php
- Display::display_normal_message($errorMsg); //main API
- ?>
- </td>
- </tr>
- <?php
- }
- ?>
- <tr>
- <td nowrap="nowrap"><?php echo get_lang('NoticeTitle'); ?> :</td>
- <td><input type="text" name="notice_title" size="30" maxlength="50" value="<?php echo htmlentities($notice_title); ?>" style="width: 350px;"/></td>
- </tr>
- <tr>
- <td nowrap="nowrap" valign="top"><?php echo get_lang('NoticeText'); ?> :</td>
- <td><textarea name="notice_text" cols="30" rows="5" wrap="virtual" style="width: 350px;"><?php echo htmlentities($notice_text); ?></textarea></td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="submit" value="<?php echo get_lang('Ok'); ?>"/></td>
- </tr>
- </table>
- </form>
- <?php
- }
- elseif($action == 'insert_link' || $action == 'edit_link')
- {
- ?>
- <div style="margin-bottom: 10px;">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>"><< <?php echo get_lang('Back'); ?></a>
- </div>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action; ?>" method="post" style="margin:0px;">
- <input type="hidden" name="formSent" value="1"/>
- <input type="hidden" name="link_index" value="<?php if($action == 'edit_link') echo $link_index; else echo '0'; ?>"/>
- <input type="hidden" name="filename" value="<?php if($action == 'edit_link') echo $filename; else echo ''; ?>"/>
- <table border="0" cellpadding="5" cellspacing="0">
- <?php
- if(!empty($errorMsg))
- {
- ?>
- <tr>
- <td colspan="2">
- <?php
- Display::display_normal_message($errorMsg); //main API
- ?>
- </td>
- </tr>
- <?php
- }
- ?>
- <tr>
- <td nowrap="nowrap"><?php echo get_lang('LinkName'); ?> :</td>
- <td><input type="text" name="link_name" size="30" maxlength="50" value="<?php echo htmlentities($link_name); ?>" style="width: 350px;"/></td>
- </tr>
- <tr>
- <td nowrap="nowrap"><?php echo get_lang('LinkURL'); ?> (<?php echo get_lang('Optional'); ?>) :</td>
- <td><input type="text" name="link_url" size="30" maxlength="100" value="<?php if(empty($link_url)) echo 'http://'; else echo htmlentities($link_url); ?>" style="width: 350px;"/></td>
- </tr>
- <?php if($action == 'insert_link'): ?>
- <tr>
- <td nowrap="nowrap"><?php echo get_lang('InsertThisLink'); ?> :</td>
- <td><select name="insert_where">
- <option value="-1"><?php echo get_lang('FirstPlace'); ?></option>
- <?php
- foreach($home_menu as $key=>$enreg)
- {
- ?>
- <option value="<?php echo $key; ?>" <?php if($formSent && $insert_where == $key) echo 'selected="selected"'; ?> ><?php echo get_lang('After'); ?> "<?php echo trim(strip_tags($enreg)); ?>"</option>
- <?php
- }
- ?>
- </select></td>
- </tr>
- <?php endif; ?>
- <tr>
- <td nowrap="nowrap"><?php echo get_lang('OpenInNewWindow'); ?> ?</td>
- <td><input class="checkbox" type="checkbox" name="target_blank" value="1" <?php if($target_blank) echo 'checked="checked"'; ?> /> <?php echo get_lang('Yes'); ?></td>
- </tr>
- <?php if($action == 'edit_link' && empty($link_url)): ?>
- </table>
- <table border="0" cellpadding="5" cellspacing="0" width="100%">
- <tr>
- <td>
- <?php
- api_disp_html_area('link_html',isset($_POST['link_html'])?$_POST['link_html']:$link_html,'400px');
- ?>
- </td>
- </tr>
- <tr>
- <td><input type="submit" value="<?php echo get_lang('Ok'); ?>"/></td>
- </tr>
- <?php else: ?>
- <tr>
- <td> </td>
- <td><input type="submit" value="<?php echo get_lang('Ok'); ?>"/></td>
- </tr>
- <?php endif; ?>
- </table>
- </form>
- <?php
- }
- elseif($action == 'edit_top' || $action == 'edit_news')
- {
- if($action == 'edit_top')
- {
- $open='home_top';
- }
- else
- {
- $open='home_news';
- }
- ?>
- <div style="margin-bottom: 10px;">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>"><< <?php echo get_lang('Back'); ?></a>
- </div>
- <form action="<?php echo $_SERVER['PHP_SELF']; ?>?action=<?php echo $action; ?>" method="post" style="margin:0px;">
- <input type="hidden" name="formSent" value="1"/>
- <?php
- if(!empty($errorMsg))
- {
- Display::display_normal_message($errorMsg); //main API
- }
- ?>
- <table border="0" cellpadding="5" cellspacing="0" width="100%">
- <tr>
- <td>
- <?php
- api_disp_html_area($open,isset($_POST[$open])?trim(stripslashes($_POST[$open])):${$open},'400px');
- ?>
- </td>
- </tr>
- <tr>
- <td><input type="submit" value="<?php echo get_lang('Ok'); ?>"/></td>
- </tr>
- </table>
- </form>
- <?php
- }
- else
- {
- ?>
- <table border="0" cellpadding="5" cellspacing="0" width="100%">
- <tr>
- <td width="80%" colspan="2">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_top"><img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify')); ?>"/></a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_top"><?php echo get_lang('EditHomePage'); ?></a>
- </td>
- <td width="20%">
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=insert_link"><img src="../img/insert_row.png" border="0"/></a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=insert_link"/><?php echo get_lang('InsertLink'); ?></a>
- </td>
- </tr>
- <tr>
- <td width="80%" colspan="2" valign="top">
- <table border="0" cellpadding="5" cellspacing="0" width="100%">
- <tr>
- <td colspan="2">
- <?php
- include('../../home/home_top.html');
- ?>
- </td>
- </tr>
- <tr>
- <td width="50%">
- <br />
- <a href="course_category.php"><img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify')); ?>"/></a> <a href="course_category.php"><?php echo get_lang('EditCategories'); ?></a>
- </td>
- <td width="50%">
- <br />
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_news"><img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify')); ?>"/></a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_news"><?php echo get_lang('EditNews'); ?></a>
- </td>
- </tr>
- <tr>
- <td width="50%" valign="top">
- <table border="0" cellpadding="5" cellspacing="0" width="100%">
- <?php
- if(sizeof($Categories))
- {
- foreach($Categories as $enreg)
- {
- ?>
- <tr>
- <td><img src="../img/opendir.gif" border="0" alt=""/> <?php echo $enreg['name']; ?></td>
- </tr>
- <?php
- }
- unset($Categories);
- }
- else
- {
- echo get_lang('NoCategories');
- }
- ?>
- </table>
- </td>
- <td width="50%" valign="top">
- <?php
- include('../../home/home_news.html');
- ?>
- </td>
- </tr>
- </table>
- </td>
- <td width="20%" rowspan="3" valign="top">
- <div class="menu" style="width: 100%;">
- <?php
- api_display_language_form();
- ?>
- <form id="loginform">
- <label><?php echo get_lang('LoginName'); ?></label>
- <input type="text" id="login" size="15" value="" disabled="disabled" />
- <label><?php echo get_lang('UserPassword'); ?></label>
- <input type="password" id="password" size="15" disabled="disabled" />
- <input type="button" value="<?php echo get_lang('Ok'); ?>" disabled="disabled" />
- </form>
- <div class="menusection">
- <span class="menusectioncaption"><?php echo get_lang('User'); ?></span>
- <ul class="menulist">
- <li><span style="color: #9D9DA1; font-weight: bold;"><?php echo ucfirst(get_lang('Registration')); ?></span></li>
- <li><span style="color: #9D9DA1; font-weight: bold;"><?php echo ucfirst(get_lang('LostPassword')); ?></span></li>
- </ul>
- </div>
- <div class="menusection">
- <span class="menusectioncaption"><?php echo ucfirst(get_lang('General')); ?></span>
- <ul class="menulist">
- <?php
- $home_menu=file('../../home/home_menu_'.$menu_language.'.html');
- foreach($home_menu as $key=>$enreg)
- {
- $enreg=trim($enreg);
- if(!empty($enreg))
- {
- $edit_link='<a href="'.$_SERVER['PHP_SELF'].'?action=edit_link&link_index='.$key.'"><img src="../img/edit.gif" border="0" style="margin-top: 2px;" title="'.htmlentities(get_lang('Modify')).'"/></a>';
- $delete_link='<a href="'.$_SERVER['PHP_SELF'].'?action=delete_link&link_index='.$key.'" onclick="javascript:if(!confirm(\''.addslashes(htmlentities(get_lang('ConfirmYourChoice'))).'\')) return false;"><img src="../img/delete.gif" border="0" style="margin-top: 2px;" title="'.htmlentities(get_lang('Delete')).'"/></a>';
- echo str_replace(array('href="'.$rootWeb.'index.php?include=','</li>'),array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename($_SERVER['PHP_SELF']).'?action=open_link&link=','<br />'.$edit_link.' '.$delete_link.'</li>'),$enreg);
- }
- }
- ?>
- </ul>
- </div>
- <br />
- <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_notice"><img src="../img/edit.gif" border="0" title="<?php echo htmlentities(get_lang('Modify')); ?>"/></a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?action=edit_notice"><?php echo get_lang('EditNotice'); ?></a>
- <div class="note">
- <?php
- include('../../home/home_notice.html');
- ?>
- </div>
- </div>
- </td>
- </tr>
- </table>
- <?php
- }
- /*
- ==============================================================================
- FOOTER
- ==============================================================================
- */
- Display::display_footer();
- ?>
|