Cleaning code

skala
Julio Montoya 15 years ago
parent ecf96f6bff
commit 055ff171ab
  1. 59
      main/blog/blog.php
  2. 54
      main/blog/blog_admin.php
  3. 8
      main/blog/calendar.php
  4. 40
      main/blog/download.php

@ -1,22 +1,15 @@
<?php //$Id: announcements.php 16702 2008-11-10 13:02:30Z elixir_inter $
/*
/* For licensing terms, see /chamilo_license.txt */
<?php
/* For licensing terms, see /license.txt */
/**
==============================================================================
BLOG HOMEPAGE
This file takes care of all blog navigation and displaying.
@package dokeos.blogs
==============================================================================
@package chamilo.blogs
*/
/*
==============================================================================
INIT
==============================================================================
*/
// name of the language file that needs to be included
$language_file = "blog";
@ -26,36 +19,33 @@ include ('../inc/global.inc.php');
$this_section=SECTION_COURSES;
/* ------------ ACCESS RIGHTS ------------ */
/* ACCESS RIGHTS */
// notice for unauthorized people.
api_protect_course_script(true);
//session
if(isset($_GET['id_session']))
{
$_SESSION['id_session'] = $_GET['id_session'];
if(isset($_GET['id_session'])) {
$_SESSION['id_session'] = intval($_GET['id_session']);
}
$lib_path = api_get_path(LIBRARY_PATH);
require_once ($lib_path.'/display.lib.php');
require_once ($lib_path.'/text.lib.php');
require_once ($lib_path.'/blog.lib.php');
require_once ($lib_path.'/fckeditor/fckeditor.php');
require_once $lib_path.'/display.lib.php';
require_once $lib_path.'/text.lib.php';
require_once $lib_path.'/blog.lib.php';
require_once $lib_path.'/fckeditor/fckeditor.php';
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs');
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$nameTools = get_lang('Blogs');
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
$MonthsLong = api_get_months_long();
$current_page = $_GET['action'];
/*
==============================================================================
PROCESSING
==============================================================================
*/
$safe_post_title = Security::remove_XSS($_POST['post_title']);
@ -208,9 +198,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post')
}
}
/*
==============================================================================
DISPLAY
==============================================================================
*/
$htmlHeadXtra[] = '<script src="tbl_change.js" type="text/javascript" language="javascript"></script>';
@ -369,21 +357,18 @@ if ($flag == '1')
$user_task = false;
if (isset ($_GET['task_id']) && is_numeric($_GET['task_id']))
if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) {
$task_id = (int)$_GET['task_id'];
else
{
} else {
$task_id = 0;
$tbl_blogs_tasks_rel_user = Database :: get_course_table(TABLE_BLOGS_TASKS_REL_USER);
$sql = "
SELECT COUNT(*) as number
FROM ".$tbl_blogs_tasks_rel_user."
WHERE
blog_id = ".$blog_id." AND
user_id = ".api_get_user_id()." AND
task_id = ".$task_id;
$sql = "SELECT COUNT(*) as number
FROM ".$tbl_blogs_tasks_rel_user."
WHERE
blog_id = ".$blog_id." AND
user_id = ".api_get_user_id()." AND
task_id = ".$task_id;
$result = Database::query($sql);
$row = Database::fetch_array($result);
@ -535,4 +520,4 @@ switch ($current_page)
<?php
// Display the footer
Display::display_footer();
?>
?>

@ -1,16 +1,13 @@
<?php //$Id: announcements.php 16702 2008-11-10 13:02:30Z elixir_inter $
/*
/* For licensing terms, see /chamilo_license.txt */
<?php
/* For licensing terms, see /license.txt */
/**
==============================================================================
BLOG HOMEPAGE
This file takes care of all blog navigation and displaying.
@package dokeos.blogs
==============================================================================
@package chamilo.blogs
*/
// name of the language file that needs to be included
$language_file = "blog";
$language_file = 'blog';
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
@ -19,17 +16,17 @@ $this_section=SECTION_COURSES;
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
/* ------------ ACCESS RIGHTS ------------ */
/* ACCESS RIGHTS */
// notice for unauthorized people.
api_protect_course_script(true);
//------------ ONLY USERS REGISTERED IN THE COURSE----------------------
// ONLY USERS REGISTERED IN THE COURSE
if((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit())
{
api_not_allowed(true);//print headers/footers
}
if (api_is_allowed_to_edit()) {
if (api_is_allowed_to_edit()) {
require_once(api_get_path(LIBRARY_PATH) . "blog.lib.php");
$nameTools = get_lang("blog_management");
@ -37,10 +34,7 @@ if (api_is_allowed_to_edit()) {
// the learning path, we do not include the banner so we have to explicitly
// include the stylesheet, which is normally done in the header
if ($_GET['origin'] != 'learnpath') {
$interbreadcrumb[]= array (
'url' => 'blog_admin.php?',
'name' => $nameTools
);
$interbreadcrumb[]= array ('url' => 'blog_admin.php?','name' => $nameTools);
$my_url='';
if (isset($_GET['action']) && $_GET['action']=='add') {
$current_section=get_lang('AddBlog');
@ -54,18 +48,15 @@ if (api_is_allowed_to_edit()) {
'name' => $current_section
);
Display::display_header('');
} else {
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$clarolineRepositoryWeb."css/default.css\"/>";
}
} else {
//echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$clarolineRepositoryWeb."css/default.css\"/>"; //@todo this line should be deprecated
}
echo '<div class="actions">';
echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>",Display::return_icon('blog_new.gif',get_lang('AddBlog')),get_lang('AddBlog')."</a>";
echo '</div>';
/*
==============================================================================
PROCESSING..
==============================================================================
PROCESSING..
*/
$get_blog_name = Security::remove_XSS($_POST['blog_name']);
$get_blog_subtitle = Security::remove_XSS($_POST['blog_subtitle']);
@ -76,7 +67,6 @@ if (api_is_allowed_to_edit()) {
Blog::create_blog($get_blog_name,$get_blog_subtitle);
Display::display_confirmation_message(get_lang('BlogStored'));
}
}
if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) {
if (strlen(trim($_POST['blog_name']))>0) {
@ -93,15 +83,11 @@ if (api_is_allowed_to_edit()) {
Display::display_confirmation_message(get_lang('BlogDeleted'));
}
/*
==============================================================================
/*
DISPLAY
==============================================================================
*/
//api_display_tool_title($nameTools);
//api_introductionsection(TOOL_BLOG);
if (isset($_GET['action']) && $_GET['action'] == 'add') {
// we show the form if
// 1. no post data
@ -112,22 +98,19 @@ if (api_is_allowed_to_edit()) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}*/
if (strlen($_POST['blog_name'])==0) {
if (count($_POST)>0) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
if (count($_POST)>0) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
}
}
Blog::display_new_blog_form();
}
Blog::display_new_blog_form();
}
}
if (isset($_GET['action']) && $_GET['action'] == 'edit') {
// we show the form if
// 1. no post data
// 2. there is post data and one of the three form elements is empty
if (!$_POST OR (!empty($_POST) AND (empty($_POST['edit_blog_submit']) OR empty($_POST['blog_name']) )))
{
if (!$_POST OR (!empty($_POST) AND (empty($_POST['edit_blog_submit']) OR empty($_POST['blog_name']) ))) {
// if there is post data there is certainly an error in the form
if ($_POST) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
@ -136,7 +119,6 @@ if (api_is_allowed_to_edit()) {
}
}
Blog::display_blog_list();
} else {
api_not_allowed(true);
}

@ -1,9 +1,10 @@
<?php
/* For licensing terms, see /license.txt */
// name of the language file that needs to be included
$language_file = 'agenda';
// including the global
include('../inc/global.inc.php');
require_once '../inc/global.inc.php';
// the variables for the days and the months
// Defining the shorts for the days
@ -107,8 +108,7 @@ table.calendar .monthyear a:hover
<!--
var month_names = new Array(
<?php
foreach($MonthsLong as $index => $month)
{
foreach($MonthsLong as $index => $month){
echo '"'.$month.'",';
}
?>
@ -128,4 +128,4 @@ foreach($DaysShort as $index => $day)
<div id="calendar_data"></div>
<div id="clock_data"></div>
</body>
</html>
</html>

@ -1,47 +1,24 @@
<?php // $Id: download.php 12218 2007-05-01 18:27:14Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2008 Dokeos SPRL
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 address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
info@dokeos.com
==============================================================================
*/
/* For licensing terms, see /license.txt */
/**
==============================================================================
* This file is responsible for passing requested documents to the browser.
* Html files are parsed to fix a few problems with URLs,
* but this code will hopefully be replaced soon by an Apache URL
* rewrite mechanism.
*
* @package dokeos.document
==============================================================================
* @package chamilo.blogs
*/
/*
==============================================================================
MAIN CODE
==============================================================================
*/
session_cache_limiter('public');
include('../inc/global.inc.php');
require_once '../inc/global.inc.php';
$this_section=SECTION_COURSES;
include(api_get_path(LIBRARY_PATH).'document.lib.php');
require_once api_get_path(LIBRARY_PATH).'document.lib.php';
// IMPORTANT to avoid caching of documents
header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
@ -58,8 +35,7 @@ $doc_url = str_replace('///', '&', $doc_url);
$doc_url = str_replace(' ', '+', $doc_url);
$doc_url = str_replace('/..', '', $doc_url); //echo $doc_url;
if (! isset($_course))
{
if (! isset($_course)) {
api_not_allowed(true);
}
$full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/'.$doc_url;
@ -80,10 +56,10 @@ $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
// launch event
event_download($doc_url);
$sql = 'SELECT filename FROM '.$tbl_blogs_attachment.' WHERE path LIKE BINARY "'.$doc_url.'"';
$sql = 'SELECT filename FROM '.$tbl_blogs_attachment.' WHERE path LIKE BINARY "'.Database::escape_string($doc_url).'"';
$result= Database::query($sql);
$row= Database::fetch_array($result);
$result = Database::query($sql);
$row = Database::fetch_array($result);
DocumentManager::file_send_for_download($full_file_name,TRUE, $row['filename']);
exit;
?>
Loading…
Cancel
Save