Feature #272 - Installation scripts: Replacement of all mysql_*() function calls with Database::*() equivalents.

skala
Ivan Tcholakov 15 years ago
parent fb1432145a
commit 0c1280587b
  1. 2
      main/exercice/mark_free_answer.php
  2. 2
      main/inc/lib/document.lib.php
  3. 11
      main/install/install_functions.inc.php
  4. 162
      main/install/update-db-1.6.x-1.8.0.inc.php
  5. 50
      main/install/update-db-1.8.0-1.8.2.inc.php
  6. 50
      main/install/update-db-1.8.2-1.8.3.inc.php
  7. 70
      main/install/update-db-1.8.3-1.8.4.inc.php
  8. 66
      main/install/update-db-1.8.4-1.8.5.inc.php
  9. 113
      main/install/update-db-1.8.5-1.8.6.inc.php
  10. 66
      main/install/update-db-1.8.6-1.8.6.1.inc.php
  11. 96
      main/install/update-db-1.8.6.1-1.8.6.2.inc.php
  12. 64
      main/install/update-db-1.8.6.2-1.8.7.inc.php
  13. 34
      main/install/update-db-scorm-1.6.x-1.8.0.inc.php
  14. 6
      main/install/update-files-1.6.x-1.8.0.inc.php
  15. 8
      main/install/update-files-1.8.5-1.8.6.inc.php
  16. 8
      main/install/update-files-1.8.6.1-1.8.6.2.inc.php
  17. 201
      main/install/update_db.inc.php
  18. 42
      main/install/update_files.inc.php
  19. 8
      main/install/upgrade.php
  20. 36
      main/install/upgrade_lib.php
  21. 4
      main/messages/download.php
  22. 4
      main/messages/send_message.php

@ -182,7 +182,7 @@ if($action == 'mark'){
$res = Database::query($sql);
$my_msg = get_lang('MarkInserted');
}
//$Database::query($sql);
//Database::query($sql);
//return 0;
}
}else{

@ -540,7 +540,7 @@ class DocumentManager {
if ($result && Database::num_rows($result) != 0)
{
while ($row = Database::fetch_array($result,'ASSOC'))
//while ($row = Database::fetch_array($result,MYSQL_NUM))
//while ($row = Database::fetch_array($result, 'NUM'))
{
if($row['filetype']=='file' && pathinfo($row['path'],PATHINFO_EXTENSION)=='html'){

@ -1106,18 +1106,17 @@ function display_after_install_message($installType, $nbr_courses) {
function test_db_connect($dbHostForm, $dbUsernameForm, $dbPassForm, $singleDbForm, $dbPrefixForm) {
$dbConnect = -1;
if ($singleDbForm == 1) {
if(@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm) !== false) {
if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
$dbConnect = 1;
} else {
$dbConnect = -1;
}
} elseif ($singleDbForm == 0) {
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
if ($res !== false) {
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$multipleDbCheck = @mysql_query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
if (@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm)) !== false) {
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$multipleDbCheck = @Database::query("CREATE DATABASE ".$dbPrefixForm."test_chamilo_connection");
if ($multipleDbCheck !== false) {
$multipleDbCheck = @mysql_query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
$multipleDbCheck = @Database::query("DROP DATABASE IF EXISTS ".$dbPrefixForm."test_chamilo_connection");
if ($multipleDbCheck !== false) {
$dbConnect = 1;
} else {

@ -85,12 +85,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />
@ -105,13 +106,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -153,12 +151,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -175,17 +173,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
if (strlen($dbStatsForm) > 40){
if (strlen($dbStatsForm) > 40) {
error_log('Database name '.$dbStatsForm.' is too long, skipping', 0);
} elseif (!in_array($dbStatsForm,$dblist)){
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -204,16 +202,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
*/
if (strlen($dbUserForm) > 40) {
error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
} elseif (!in_array($dbUserForm, $dblist)){
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
foreach ($u_q_list as $query){
if ($only_test){
error_log("mysql_query($dbUserForm,$query)", 0);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -249,14 +247,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -267,7 +265,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -276,9 +274,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -292,8 +290,8 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
" FROM $dbNameForm.user u, $dbNameForm.course_rel_user cu " .
" WHERE cu.course_code = '".$row_course['code']."' " .
" AND u.user_id = cu.user_id";
$res_uc = mysql_query($sql_uc);
while($user_row = mysql_fetch_array($res_uc)) {
$res_uc = Database::query($sql_uc);
while($user_row = Database::fetch_array($res_uc)) {
$users_list[$user_row['fn'].' '.$user_row['ln']] = $user_row['ui'];
}
@ -310,54 +308,54 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_categories";
$res_orig = mysql_query($sql_orig);
$res_orig = Database::query($sql_orig);
$order = 1;
while ($row = mysql_fetch_array($res_orig)) {
while ($row = Database::fetch_array($res_orig)) {
$myorder = (empty($row['cat_order']) ? $order : $row['cat_order']);
$sql = "INSERT INTO ".$prefix_course."forum_category " .
"(cat_id,cat_title,cat_comment,cat_order,locked) VALUES " .
"('".$row['cat_id']."','".mysql_real_escape_string($row['cat_title'])."','','".$myorder."',0)";
$res = mysql_query($sql);
$lastcatid = mysql_insert_id();
"('".$row['cat_id']."','".Database::escape_string($row['cat_title'])."','','".$myorder."',0)";
$res = Database::query($sql);
$lastcatid = Database::insert_id();
//error_log($sql,0);
$order ++;
//add item_property - forum categories were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_category','1','$lastcatid','ForumCategoryAdded','1','1')";
$res = mysql_query($sql);
$res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_forums ORDER BY forum_last_post_id desc";
$res_orig = mysql_query($sql_orig);
$res_orig = Database::query($sql_orig);
$order = 1;
while ($row = mysql_fetch_array($res_orig)) {
while ($row = Database::fetch_array($res_orig)) {
$sql = "INSERT INTO ".$prefix_course."forum_forum " .
"(forum_id,forum_category,allow_edit,forum_comment," .
"forum_title," .
"forum_last_post, forum_threads," .
"locked, forum_posts, " .
"allow_new_threads, forum_order) VALUES " .
"('".$row['forum_id']."','".$row['cat_id']."',1,'".mysql_real_escape_string($row['forum_desc'])."'," .
"'".mysql_real_escape_string($row['forum_name'])."'," .
"('".$row['forum_id']."','".$row['cat_id']."',1,'".Database::escape_string($row['forum_desc'])."'," .
"'".Database::escape_string($row['forum_name'])."'," .
"'".$row['forum_last_post_id']."','".$row['forum_topics']."'," .
"0,'".$row['forum_posts']."'," .
"1,$order)";
//error_log($sql,0);
$res = mysql_query($sql);
$lastforumid = mysql_insert_id();
$res = Database::query($sql);
$lastforumid = Database::insert_id();
$order++;
//add item_property - forums were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum','1','$lastforumid','ForumAdded','1','1')";
$res = mysql_query($sql);
$res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_topics";
$res_orig = mysql_query($sql_orig);
while ($row = mysql_fetch_array($res_orig)) {
$res_orig = Database::query($sql_orig);
while ($row = Database::fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable
if ($row['topic_poster'] <= 1) {
@ -369,30 +367,30 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
//convert time from varchar to datetime
$time = $row['topic_time'];
$name = mysql_real_escape_string($name);
$name = Database::escape_string($name);
$sql = "INSERT INTO ".$prefix_course."forum_thread " .
"(thread_id,forum_id,thread_poster_id," .
"locked,thread_replies,thread_sticky,thread_title," .
"thread_poster_name, thread_date, thread_last_post," .
"thread_views) VALUES " .
"('".$row['topic_id']."','".$row['forum_id']."','".$poster_id."'," .
"0,'".$row['topic_replies']."',0,'".mysql_real_escape_string($row['topic_title'])."'," .
"0,'".$row['topic_replies']."',0,'".Database::escape_string($row['topic_title'])."'," .
"'$name','$time','".$row['topic_last_post_id']."'," .
"'".$row['topic_views']."')";
//error_log($sql,0);
$res = mysql_query($sql);
$lastthreadid = mysql_insert_id();
$res = Database::query($sql);
$lastthreadid = Database::insert_id();
//add item_property - forum threads were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property (tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_thread','1','$lastthreadid','ForumThreadAdded','1','1')";
$res = mysql_query($sql);
$res = Database::query($sql);
//error_log($sql,0);
}
$sql_orig = "SELECT * FROM ".$prefix_course."bb_posts bp, ".$prefix_course."bb_posts_text bpt WHERE bp.post_id = bpt.post_id";
$res_orig = mysql_query($sql_orig);
while ($row = mysql_fetch_array($res_orig)) {
$res_orig = Database::query($sql_orig);
while ($row = Database::fetch_array($res_orig)) {
$name = $row['prenom'].' '.$row['nom'];
//check if user id is reusable
if ($row['poster_id'] <= 0 ) {
@ -404,7 +402,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
//convert time from varchar to datetime
$time = $row['post_time'];
$name = mysql_real_escape_string($name);
$name = Database::escape_string($name);
$sql = "INSERT INTO ".$prefix_course."forum_post " .
"(post_id,forum_id,thread_id," .
"poster_id,post_parent_id,visible, " .
@ -412,28 +410,28 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
"post_date, post_notification) VALUES " .
"('".$row['post_id']."','".$row['forum_id']."','".$row['topic_id']."'," .
"'".$poster_id."','".$row['parent_id']."',1," .
"'".mysql_real_escape_string($row['post_title'])."','$name', '".mysql_real_escape_string($row['post_text'])."'," .
"'".Database::escape_string($row['post_title'])."','$name', '".Database::escape_string($row['post_text'])."'," .
"'$time',0)";
//error_log($sql,0);
$res = mysql_query($sql);
$lastpostid = mysql_insert_id();
$res = Database::query($sql);
$lastpostid = Database::insert_id();
//add item_property - forum threads were not put into item_properties before
$sql = "INSERT INTO ".$prefix_course."item_property(tool,insert_user_id,ref,lastedit_type,lastedit_user_id,visibility) " .
"VALUES ('forum_post','1','$lastpostid','ForumPostAdded','1','1')";
$res = mysql_query($sql);
$res = Database::query($sql);
//error_log($sql,0);
}
unset($users_list);
$sql_orig = "SELECT id, tutor_id FROM ".$prefix_course."group_info";
$res_orig = mysql_query($sql_orig);
$res_orig = Database::query($sql_orig);
$order = 1;
while ($row = mysql_fetch_array($res_orig)) {
while ($row = Database::fetch_array($res_orig)) {
$sql = "INSERT INTO ".$prefix_course."group_rel_tutor " .
"(user_id,group_id) VALUES " .
"('".$row['tutor_id']."','".$row['id']."')";
$res = mysql_query($sql);
$res = Database::query($sql);
}
}
}
@ -465,12 +463,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test){
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -492,12 +490,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)){
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -516,15 +514,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
*/
if (strlen($dbUserForm) > 40) {
error_log('Database name '.$dbUserForm.' is too long, skipping', 0);
} elseif (!in_array($dbUserForm,$dblist)) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbUserForm, executed: $query", 0);
}
@ -541,16 +539,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//get the courses list
if (strlen($dbNameForm) > 40) {
error_log('Database name '.$dbNameForm.' is too long, skipping', 0);
} elseif (!in_array($dbNameForm,$dblist)) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.6.x-1.8.0.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while ($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -564,7 +562,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if ($singleDbForm) {
$prefix_course = $prefix.$row['db_name']."_";
} else {
mysql_select_db($row['db_name']);
Database::select_db($row['db_name']);
}
foreach($c_q_list as $query) {
@ -572,9 +570,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/',"$1 $prefix$2$3",$query);
}
if ($only_test) {
error_log("mysql_query(".$row['db_name'].",$query)", 0);
error_log("Database::query(".$row['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row['db_name'].", executed: $query", 0);
}

@ -84,12 +84,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />
@ -104,13 +105,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -150,12 +148,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -178,12 +176,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -204,13 +202,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm,$dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -244,14 +242,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.0-1.8.2.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -262,7 +260,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -271,9 +269,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}

@ -84,12 +84,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -103,13 +104,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -150,12 +148,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -178,12 +176,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -204,13 +202,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm, $query)", 0);
error_log("Database::query($dbUserForm, $query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -244,14 +242,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.2-1.8.3.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while ($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -262,7 +260,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@ -271,9 +269,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}

@ -83,12 +83,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -102,13 +103,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -149,12 +147,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm, $query)", 0);
error_log("Database::query($dbNameForm, $query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -177,12 +175,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -203,13 +201,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)){
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -243,14 +241,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.3-1.8.4.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while ($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while ($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -261,7 +259,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@ -270,9 +268,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -285,15 +283,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$sql_ip = "SELECT * FROM ".$prefix_course."item_property WHERE tool='learnpath'";
$res_ip = mysql_query($sql_ip);
$res_ip = Database::query($sql_ip);
$paths = array();
while ($row_ip = mysql_fetch_array($res_ip)) {
while ($row_ip = Database::fetch_array($res_ip)) {
$paths[] = $row_ip['ref'];
}
$sql_lp = "SELECT * FROM ".$prefix_course."lp";
$res_lp = mysql_query($sql_lp);
$res_lp = Database::query($sql_lp);
$tbl_tool = $prefix_course."tool";
while ($row_lp = mysql_fetch_array($res_lp)) {
while ($row_lp = Database::fetch_array($res_lp)) {
$time = date("Y-m-d H:i:s", time());
$vis = 'v';
$input = stripslashes($row_lp['name']);
@ -306,20 +304,20 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//the path is already in item_property, check the visibility is the
//same as the homepage tool's
$res2 = Database::query($sql2);
if (mysql_num_rows($res2) > 0) {
$row2 = mysql_fetch_array($res2);
if (Database::num_rows($res2) > 0) {
$row2 = Database::fetch_array($res2);
$vis = $row2['visibility'];
}
$visi = array('v' => 1, 'i' => 0);
if ($visi[$vis] != $row_ip['visibility']) {
$sql_upd = "UPDATE ".$prefix_course."item_propery SET visibility=".$visi[$vis]." WHERE tool='learnpath' AND ref='".$row_lp['id']."'";
$res_upd = mysql_query($sql_upd);
$res_upd = Database::query($sql_upd);
}
} else {
//the path is not in item_property, insert it
$res2 = Database::query($sql2);
if (mysql_num_rows($res2) > 0) {
$row2 = mysql_fetch_array($res2);
if (Database::num_rows($res2) > 0) {
$row2 = Database::fetch_array($res2);
$vis = $row2['visibility'];
}
$visi = array('v' => 1, 'i' => 0);
@ -328,7 +326,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
"(tool,ref,insert_date,last_edit_date,insert_user_id,lastedit_type,lastedit_user_id,visibility)" .
"VALUES" .
"('learnpath',".$row_lp['id'].",'$time','$time',1,'learnpathAdded',1,".$visi[$vis].")";
$res_ins = mysql_query($sql_ins);
$res_ins = Database::query($sql_ins);
}
}
}

@ -65,12 +65,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -84,13 +85,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -131,12 +129,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -159,12 +157,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -185,13 +183,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach($u_q_list as $query){
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -227,16 +225,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.4-1.8.5.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -247,7 +245,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach ($c_q_list as $query) {
@ -256,9 +254,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -272,17 +270,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
$mysql = "SELECT * FROM $mytable WHERE min_score != 0 AND prerequisite != ''";
$myres = mysql_query($query);
$myres = Database::query($query);
if ($myres!==false && mysql_num_rows($myres) > 0) {
while ($myrow = mysql_fetch_array($myres)) {
if ($myres!==false && Database::num_rows($myres) > 0) {
while ($myrow = Database::fetch_array($myres)) {
if (is_numeric($myrow['prerequisite'])) {
$mysql2 = "UPDATE $mytable SET mastery_score = '".$myrow['min_score']."' WHERE id = '".$myrow['prerequisite']."'";
$myres2 = mysql_query($mysql2);
$myres2 = Database::query($mysql2);
//echo $mysql2."<br />";
if ($myres2 !== false) {
$mysql3 = "UPDATE $mytable SET min_score = 0 WHERE id = '".$myrow['id']."'";
$myres3 = mysql_query($mysql3);
$myres3 = Database::query($mysql3);
//echo $mysql3."<br />";
}
}
@ -305,8 +303,8 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$only_dir = array();
$sql_select = "SELECT filetype FROM " . $my_course_table . " WHERE filetype = 'folder'";
$result = mysql_query($sql_select);
$num_row = mysql_num_rows($result);
$result = Database::query($sql_select);
$num_row = Database::num_rows($result);
// check if there are already folder registered
if ($num_row == 0) {
@ -324,7 +322,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
filetype = 'folder',
post_group_id = '0',
sent_date = '0000-00-00 00:00:00' ";
mysql_query($sql_insert_all);
Database::query($sql_insert_all);
}
}

@ -66,12 +66,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -85,13 +86,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
$dblist = Database::get_databases();
$perm = api_get_permissions_for_new_directories();
@ -135,12 +132,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif(!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -152,15 +149,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
// Filling the access_url_rel_user table with access_url_id by default = 1
$query = "SELECT user_id FROM $dbNameForm.user";
$result_users = mysql_query($query);
while ($row= mysql_fetch_array($result_users, MYSQL_NUM)) {
$result_users = Database::query($query);
while ($row = Database::fetch_array($result_users, 'NUM')) {
$user_id = $row[0];
$sql = "INSERT INTO $dbNameForm.access_url_rel_user SET user_id=$user_id, access_url_id=1";
$res = mysql_query($sql);
$res = Database::query($sql);
//Updating user image
$query = "SELECT picture_uri FROM $dbNameForm.user WHERE user_id=$user_id";
$res = mysql_query($query);
$picture_uri = mysql_fetch_array($res, MYSQL_NUM);
$res = Database::query($query);
$picture_uri = Database::fetch_array($res, 'NUM');
$file = $picture_uri[0];
$dir = api_get_path(SYS_CODE_PATH).'upload/users/';
$image_repository = file_exists($dir.$file) ? $dir.$file : $dir.$user_id.'/'.$file;
@ -212,10 +209,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
// Filling the access_url_rel_session table with access_url_id by default = 1
$query = "SELECT id FROM $dbNameForm.session";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
$result = Database::query($query);
while ($row = Database::fetch_array($result, 'NUM')) {
$sql = "INSERT INTO $dbNameForm.access_url_rel_session SET session_id=".$row[0].", access_url_id=1";
$res = mysql_query($sql);
$res = Database::query($sql);
}
//Since the parser of the migration DB does not work for this kind of inserts (HTML) we move it here
@ -254,7 +251,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
/*
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -304,7 +301,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
*/
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -344,7 +341,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');
';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleLeftList\', \'TemplateTitleListLeftListDescription\', \'leftlist.gif\', \'
@ -382,7 +379,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleLeftRightList\', \'TemplateTitleLeftRightListDescription\', \'leftrightlist.gif\', \'
@ -434,7 +431,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleRightList\', \'TemplateTitleRightListDescription\', \'rightlist.gif\', \'
@ -473,7 +470,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
/*
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -500,7 +497,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</tr>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
*/
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -536,7 +533,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');
';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleDesc\', \'TemplateTitleCheckListDescription\', \'description.gif\', \'
@ -565,7 +562,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');
';
$res = mysql_query($sql);
$res = Database::query($sql);
/*
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -606,7 +603,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
*/
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -672,7 +669,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
/*
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -715,7 +712,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');
';
$res = mysql_query($sql);
$res = Database::query($sql);
*/
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -782,7 +779,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</body>
\');
';
$res = mysql_query($sql);
$res = Database::query($sql);
/*
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -816,7 +813,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
*/
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
@ -883,7 +880,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
<br />
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleAudio\', \'TemplateTitleAudioDescription\', \'audiocomment.gif\', \'
@ -918,7 +915,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</p>
</body>
\');';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleVideo\', \'TemplateTitleVideoDescription\', \'video.gif\', \'
@ -980,7 +977,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
<style type="text/css">body{}</style><!-- to fix a strange bug appearing with firefox when editing this template -->
</body>
\'); ';
$res = mysql_query($sql);
$res = Database::query($sql);
$sql = 'INSERT INTO '.$dbNameForm.'.system_template (title, comment, image, content) VALUES
(\'TemplateTitleFlash\', \'TemplateTitleFlashDescription\', \'flash.gif\', \'
@ -1004,11 +1001,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
</center>
</body>
\'); ';
$res = mysql_query($sql);
$res = Database::query($sql);
// Check if course_module exists, as it was not installed in Dokeos 1.8.5 because of a broken query, and $sql = 'INSERT it if necessary
$query = "SELECT * FROM $dbNameForm.course_module";
$result = mysql_query($query);
$result = Database::query($query);
if ($result === false) {
//the course_module table doesn't exist, create it
$sql = "CREATE TABLE $dbNameForm.course_module (
@ -1022,7 +1019,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
PRIMARY KEY (id)
)
";
$result = mysql_query($sql);
$result = Database::query($sql);
if ($result !== false) {
$sql = "INSERT INTO $dbNameForm.course_module (name, link, image, `row`,`column`, position) VALUES
('calendar_event','calendar/agenda.php','agenda.gif',1,1,'basic'),
@ -1053,7 +1050,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
('gradebook','gradebook/index.php','gradebook.gif',2,2,'basic'),
('glossary','glossary/index.php','glossary.gif',2,1,'basic'),
('notebook','notebook/index.php','notebook.gif',2,1,'basic')";
$res = mysql_query($sql);
$res = Database::query($sql);
}
}
@ -1072,12 +1069,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm,$dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -1098,13 +1095,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm,$dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -1141,16 +1138,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif(!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.5-1.8.6.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -1161,7 +1158,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -1170,9 +1167,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -1188,11 +1185,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
// shared documents folder
$query = "INSERT INTO $t_d (path,title,filetype,size) VALUES ('/shared_folder','".get_lang('SharedDocumentsDirectory')."','folder','0')";
$myres = mysql_query($query);
$myres = Database::query($query);
if ($myres !== false) {
$doc_id = mysql_insert_id();
$doc_id = Database::insert_id();
$query = "INSERT INTO $t_ip (tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ('document',1,NOW(),NOW(),$doc_id,'FolderAdded',1,0,NULL,1)";
$myres = mysql_query($query);
$myres = Database::query($query);
}
}
}

@ -66,12 +66,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -85,13 +86,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -132,12 +130,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach($m_q_list as $query) {
if ($only_test){
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -161,12 +159,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm,$dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -187,13 +185,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm, $dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -229,16 +227,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.6-1.8.6.1.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -249,7 +247,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -258,9 +256,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -277,11 +275,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//update correct page_id to wiki table, actually only store 0
$query = "SELECT id, reflink FROM $t_wiki";
$res_page = mysql_query($query);
$res_page = Database::query($query);
$wiki_id = $reflink = array();
if (mysql_num_rows($res_page) > 0 ) {
while ($row_page = mysql_fetch_row($res_page)) {
if (Database::num_rows($res_page) > 0 ) {
while ($row_page = Database::fetch_row($res_page)) {
$wiki_id[] = $row_page[0];
$reflink[] = $row_page[1];
}
@ -294,19 +292,19 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
foreach ($wiki_id as $key => $wiki_page) {
$pag_id = $reflink_flip[$reflink[$key]];
$sql= "UPDATE $t_wiki SET page_id='".($pag_id + 1)."' WHERE id = '$wiki_page'";
$res_update = mysql_query($sql);
$res_update = Database::query($sql);
}
}
//insert page_id into wiki_conf table, actually this table is empty
$query = "SELECT DISTINCT page_id FROM $t_wiki ORDER BY page_id";
$myres_wiki = mysql_query($query);
$myres_wiki = Database::query($query);
if (mysql_num_rows($myres_wiki) > 0) {
while ($row_wiki = mysql_fetch_row($myres_wiki)) {
if (Database::num_rows($myres_wiki) > 0) {
while ($row_wiki = Database::fetch_row($myres_wiki)) {
$page_id = $row_wiki[0];
$query = "INSERT INTO ".$t_wiki_conf." (page_id, task, feedback1, feedback2, feedback3, fprogress1, fprogress2, fprogress3) VALUES ('".$page_id."','','','','','','','')";
$myres_wiki_conf = mysql_query($query);
$myres_wiki_conf = Database::query($query);
}
}

@ -66,12 +66,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -85,13 +86,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -132,12 +130,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -155,21 +153,21 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
FROM session_rel_course
ORDER BY id_session, course_code";
$res = mysql_query($sql);
$res = Database::query($sql);
if ($res === false) {
error_log('Could not query session course coaches table: '.mysql_error());
error_log('Could not query session course coaches table: '.Database::error());
} else {
// For each coach found, add him as a course coach in the
// session_rel_course_rel_user table
while ($row = mysql_fetch_array($res)) {
while ($row = Database::fetch_array($res)) {
// chech if coach is a student
$sql = "SELECT 1 FROM session_rel_course_rel_user
WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'";
$rs = mysql_query($sql);
$rs = Database::query($sql);
if (mysql_num_rows($rs) > 0) {
if (Database::num_rows($rs) > 0) {
$sql_upd = "UPDATE session_rel_course_rel_user SET status=2
WHERE id_session='{$row[id_session]}' AND course_code='{$row[course_code]}' AND id_user='{$row[id_coach]}'";
} else {
@ -177,10 +175,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
VALUES ('{$row[id_session]}','{$row[course_code]}','{$row[id_coach]}',2)";
}
$rs_coachs = mysql_query($sql_ins);
$rs_coachs = Database::query($sql_ins);
if ($rs_coachs === false) {
error_log('Could not move course coach to new table: '.mysql_error());
error_log('Could not move course coach to new table: '.Database::error());
}
}
@ -189,34 +187,34 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
// Remove duplicated rows for 'show_tutor_data' AND 'show_teacher_data' into settings_current table
$sql = "SELECT id FROM settings_current WHERE variable='show_tutor_data' ORDER BY id";
$rs_chk_id1 = mysql_query($sql);
$rs_chk_id1 = Database::query($sql);
if ($rs_chk_id1 === false) {
error_log('Could not query settings_current ids table: '.mysql_error());
error_log('Could not query settings_current ids table: '.Database::error());
} else {
$i = 1;
while ($row_id1 = mysql_fetch_array($rs_chk_id1)) {
while ($row_id1 = Database::fetch_array($rs_chk_id1)) {
$id = $row_id1['id'];
if ($i > 1) {
$sql_del = "DELETE FROM settings_current WHERE id = '$id'";
mysql_query($sql_del);
Database::query($sql_del);
}
$i++;
}
}
$sql = "SELECT id FROM settings_current WHERE variable='show_teacher_data' ORDER BY id";
$rs_chk_id2 = mysql_query($sql);
$rs_chk_id2 = Database::query($sql);
if ($rs_chk_id2 === false) {
error_log('Could not query settings_current ids table: '.mysql_error());
error_log('Could not query settings_current ids table: '.Database::error());
} else {
$i = 1;
while ($row_id2 = mysql_fetch_array($rs_chk_id2)) {
while ($row_id2 = Database::fetch_array($rs_chk_id2)) {
$id = $row_id2['id'];
if ($i > 1) {
$sql_del = "DELETE FROM settings_current WHERE id = '$id'";
mysql_query($sql_del);
Database::query($sql_del);
}
$i++;
}
@ -238,12 +236,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm,$dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
@ -266,12 +264,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)) {
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
@ -292,13 +290,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm,$dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test){
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -335,16 +333,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif(!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.6.1-1.8.6.2.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -355,7 +353,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -364,9 +362,9 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
@ -383,16 +381,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
// get all ids and update description_type field with them from course_description table
$sql_sel = "SELECT id FROM $t_course_description";
$rs_sel = mysql_query($sql_sel);
$rs_sel = Database::query($sql_sel);
if ($rs_sel === false) {
error_log('Could not query course_description ids table: '.mysql_error());
error_log('Could not query course_description ids table: '.Database::error());
} else {
if (mysql_num_rows($rs_sel) > 0) {
while ($row_ids = mysql_fetch_array($rs_sel)) {
if (Database::num_rows($rs_sel) > 0) {
while ($row_ids = Database::fetch_array($rs_sel)) {
$description_id = $row_ids['id'];
$sql_upd = "UPDATE $t_course_description SET description_type='$description_id' WHERE id='$description_id'";
mysql_query($sql_upd);
Database::query($sql_upd);
}
}
}

@ -66,12 +66,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if (empty ($dbScormForm) || $dbScormForm == 'mysql' || $dbScormForm == $dbPrefixForm) {
$dbScormForm = $dbPrefixForm.'scorm';
}
$res = @mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if ($res === false) {
//$no = mysql_errno();
//$msg = mysql_error();
//$no = Database::errno();
//$msg = Database::error();
//echo '<hr />['.$no.'] - '.$msg.'<hr />';
echo get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />' .
@ -85,13 +86,10 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
$dblist = Database::get_databases();
$dblistres = mysql_list_dbs();
$dblist = array();
while ($row = mysql_fetch_object($dblistres)) {
$dblist[] = $row->Database;
}
/*
-----------------------------------------------------------
Normal upgrade procedure:
@ -132,17 +130,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach ($m_q_list as $query){
if ($only_test) {
error_log("mysql_query($dbNameForm,$query)", 0);
error_log("Database::query($dbNameForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbNameForm, executed: $query", 0);
}
if ($res === false) {
error_log('Error in '.$query.': '.mysql_error());
error_log('Error in '.$query.': '.Database::error());
}
}
}
@ -165,12 +163,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}elseif(!in_array($dbNameForm,$dblist)){
error_log('Database '.$dbNameForm.' was not found, skipping',0);
}else{
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach($m_q_list as $query){
if($only_test){
error_log("mysql_query($dbNameForm,$query)",0);
error_log("Database::query($dbNameForm,$query)",0);
}else{
$res = mysql_query($query);
$res = Database::query($query);
if($log)
{
error_log("In $dbNameForm, executed: $query",0);
@ -195,17 +193,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbStatsForm, $dblist)){
error_log('Database '.$dbStatsForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach ($s_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbStatsForm,$query)", 0);
error_log("Database::query($dbStatsForm,$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In $dbStatsForm, executed: $query", 0);
}
if ($res === false) {
error_log('Error in '.$query.': '.mysql_error());
error_log('Error in '.$query.': '.Database::error());
}
}
}
@ -224,15 +222,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif (!in_array($dbUserForm,$dblist)) {
error_log('Database '.$dbUserForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach ($u_q_list as $query) {
if ($only_test) {
error_log("mysql_query($dbUserForm,$query)", 0);
error_log("Database::query($dbUserForm,$query)", 0);
error_log("In $dbUserForm, executed: $query", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($res === false) {
error_log('Error in '.$query.': '.mysql_error());
error_log('Error in '.$query.': '.Database::error());
}
}
}
@ -270,16 +268,16 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
} elseif(!in_array($dbNameForm, $dblist)) {
error_log('Database '.$dbNameForm.' was not found, skipping', 0);
} else {
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL ORDER BY code");
if ($res === false) { die('Error while querying the courses list in update_db-1.8.6.2-1.8.7.inc.php'); }
if (mysql_num_rows($res) > 0) {
if (Database::num_rows($res) > 0) {
$i = 0;
$list = array();
//while( ($i < MAX_COURSE_TRANSFER) && ($row = mysql_fetch_array($res)))
while($row = mysql_fetch_array($res)) {
//while( ($i < MAX_COURSE_TRANSFER) && ($row = Database::fetch_array($res)))
while($row = Database::fetch_array($res)) {
$list[] = $row;
$i++;
}
@ -290,7 +288,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
* without a database name
*/
if (!$singleDbForm) { //otherwise just use the main one
mysql_select_db($row_course['db_name']);
Database::select_db($row_course['db_name']);
}
foreach($c_q_list as $query) {
@ -299,14 +297,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
}
if ($only_test) {
error_log("mysql_query(".$row_course['db_name'].",$query)", 0);
error_log("Database::query(".$row_course['db_name'].",$query)", 0);
} else {
$res = mysql_query($query);
$res = Database::query($query);
if ($log) {
error_log("In ".$row_course['db_name'].", executed: $query", 0);
}
if ($res === false) {
error_log('Error in '.$query.': '.mysql_error());
error_log('Error in '.$query.': '.Database::error());
}
}
}

@ -64,7 +64,7 @@ $courses_id_list = array();
$courses_id_full_table_prefix_list = array();
$courses_dir_list = array();
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
$sql = "SELECT * FROM course";
$res = Database::query($sql);
@ -118,13 +118,13 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
//migrate learnpaths
$sql_test = "SELECT * FROM $my_new_lp";
$res_test = mysql_query($sql_test);
$res_test = Database::query($sql_test);
$sql_lp = "SELECT * FROM $lp_main";
if ($loglevel > 1) { error_log("$sql_lp", 0); }
$res_lp = mysql_query($sql_lp);
$res_lp = Database::query($sql_lp);
if (!$res_lp or !$res_test) {
if ($loglevel > 1) {
error_log("+++Problem querying DB $lp_main+++ skipping (".mysql_error().")", 0);
error_log("+++Problem querying DB $lp_main+++ skipping (".Database::error().")", 0);
if (!$res_test) {
error_log("This might be due to no existing table in the destination course", 0);
}
@ -136,8 +136,8 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
//echo "Treating lp id : ".$row['learnpath_id']."<br />\n";
$ins_lp_sql = "INSERT INTO $my_new_lp (lp_type,name,description,display_order,content_maker) " .
"VALUES (1," .
"'".mysql_real_escape_string($row['learnpath_name'])."'," .
"'".mysql_real_escape_string($row['learnpath_description'])."',$dsp_ord,'Dokeos')";
"'".Database::escape_string($row['learnpath_name'])."'," .
"'".Database::escape_string($row['learnpath_description'])."',$dsp_ord,'Dokeos')";
$ins_lp_res = Database::query($ins_lp_sql);
$in_id = Database::insert_id();
if (empty($in_id) or $in_id == false) die('Could not insert lp: '.$ins_lp_sql);
@ -162,8 +162,8 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
//TODO build path for this chapter (although there is no real path for any chapter)
//TODO find out how to calculate the "next_item_id" with the "ordre" field
$my_lp_item = $my_new_lp_item;
$myname = mysql_real_escape_string($row['chapter_name']);
$mydesc = mysql_real_escape_string($row['chapter_description']);
$myname = Database::escape_string($row['chapter_name']);
$mydesc = Database::escape_string($row['chapter_description']);
$ins_lp_sql = "INSERT INTO $my_new_lp_item (" .
"lp_id," .
"item_type," .
@ -324,8 +324,8 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
"'".$lp_ids[$parent_lps[$row['chapter_id']]]."'," . //insert new learnpath ID
"'$type'," .
"'$ref', " .
"'".mysql_real_escape_string($row['title'])."'," .
"'".mysql_real_escape_string($row['description'])."'," .
"'".Database::escape_string($row['title'])."'," .
"'".Database::escape_string($row['description'])."'," .
"'$ref'," .
"".$my_parent_id."," .
"'$prereq_id'," .
@ -572,7 +572,7 @@ foreach ($courses_id_full_table_prefix_list as $course_code => $db) {
}
if ($intrp != $row_i['intro_text']) {
//echo "<pre>Replacing ".$row_i['intro_text']."\n by \n ".$intro."</pre><br />\n";
$sql_upd = "update $tbl_intro set intro_text = '".mysql_real_escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".mysql_real_escape_string($row_i['intro_text'])."'";
$sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'";
//echo $sql_upd."<br />\n";
fwrite($fh,"$sql_upd\n");
fwrite($fh_revert,"UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n");
@ -618,7 +618,7 @@ $lp_course_code = array();
$scorm_lp_paths = array();
//avoid empty dokeosCourse fields as they potentially break the rest
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
$course_main = TABLE_MAIN_COURSE;
$sql_crs = "SELECT * FROM $course_main WHERE target_course_code IS NULL";
if ($loglevel > 0) { error_log("$sql_crs", 0); }
@ -883,7 +883,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
while ($scormItem = Database::fetch_array($res_items)) {
$my_sco_id = $scormItem['scoId']; //the index for display??? (check that)
$my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name
$my_title = mysql_real_escape_string($scormItem['scoTitle']);
$my_title = Database::escape_string($scormItem['scoTitle']);
$my_status = $scormItem['status'];
$my_student = $scormItem['studentId'];
$my_score = $scormItem['score'];
@ -1028,7 +1028,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
while ($scormItem = Database::fetch_array($res_items)) {
$my_sco_id = $scormItem['scoId']; //the index for display??? (check that)
$my_identifier = $scormItem['scoIdentifier']; //the scorm item path/name
$my_title = mysql_real_escape_string($scormItem['scoTitle']);
$my_title = Database::escape_string($scormItem['scoTitle']);
$my_status = $scormItem['status'];
$my_student = $scormItem['studentId'];
$my_score = $scormItem['score'];
@ -1138,9 +1138,9 @@ foreach ($scorms as $my_course_code => $paths_list) {
//$my_new_lp_view = $db_name.$new_lp_view;
//$my_new_lp_item_view = $db_name.$new_lp_item_view;
//$sel_sql = "SELECT * FROM $my_new_lp WHERE id = $in_id";
//$res = @mysql_query($sel_sql);
//$res = @Database::query($sel_sql);
//if (!$res) {
// echo "Error selecting lp: $sel_sql - ".mysql_error()."<br />\n";
// echo "Error selecting lp: $sel_sql - ".Database::error()."<br />\n";
//}
$lp_details = array();
//while($row = Database::fetch_array($res)) {
@ -1268,7 +1268,7 @@ foreach ($scorms as $my_course_code => $paths_list) {
}
if ($intro != $row_i['intro_text']) {
//echo "<pre>Replacing ".$row_i['intro_text']."\n by \n ".$intro."</pre><br />\n";
$sql_upd = "update $tbl_intro set intro_text = '".mysql_real_escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".mysql_real_escape_string($row_i['intro_text'])."'";
$sql_upd = "update $tbl_intro set intro_text = '".Database::escape_string($intro)."' WHERE id = 'course_homepage' AND intro_text = '".Database::escape_string($row_i['intro_text'])."'";
//echo $sql_upd."<br />\n";
fwrite($fh, $sql_upd."\n");
fwrite($fh_revert, "UPDATE $tbl_intro set intro_text = '".$row_i['intro_text']."' WHERE id = 'course_homepage' AND intro_text = '$intro';\n");

@ -71,17 +71,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$sys_course_path = $pathForm.'courses/';
//$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
$db_name = $dbNameForm;
$sql = "SELECT * FROM course";
error_log('Getting courses for files updates: '.$sql, 0);
$result = mysql_query($sql);
$result = Database::query($sql);
$perm = api_get_permissions_for_new_directories();
//$old_umask = umask(0); // This function is not thread-safe.
while ($courses_directories = mysql_fetch_array($result)) {
while ($courses_directories = Database::fetch_array($result)) {
$currentCourseRepositorySys = $sys_course_path.$courses_directories["directory"]."/";
$db_name = $courses_directories["db_name"];

@ -57,18 +57,18 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
//linking
$link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
mysql_select_db($dbNameForm, $link);
$res = @Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
Database::select_db($dbNameForm, $link);
$db_name = $dbNameForm;
$sql = "SELECT * FROM $db_name.course";
error_log('Getting courses for files updates: '.$sql, 0);
$result = mysql_query($sql);
$result = Database::query($sql);
$perm = api_get_permissions_for_new_directories();
//$old_umask = umask(0); // This function is not thread-safe.
while($courses_directories = mysql_fetch_array($result)) {
while($courses_directories = Database::fetch_array($result)) {
$currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';

@ -52,14 +52,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
//$old_umask = umask(0); // This function is not thread-safe.
$link = mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
mysql_select_db($dbNameForm, $link);
$link = Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
Database::select_db($dbNameForm, $link);
$db_name = $dbNameForm;
$sql = "SELECT * FROM $db_name.course";
error_log('Getting courses for files updates: '.$sql, 0);
$result = mysql_query($sql);
$result = Database::query($sql);
while ($courses_directories = mysql_fetch_array($result)) {
while ($courses_directories = Database::fetch_array($result)) {
$currentCourseRepositorySys = $sys_course_path.$courses_directories['directory'].'/';
//upload > announcements
if (!is_dir($currentCourseRepositorySys."upload/announcements")){

@ -81,13 +81,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
{
$dbScormForm = $dbPrefixForm.'scorm';
}
@mysql_connect($dbHostForm, $dbUsernameForm, $dbPassForm);
@Database::connect(array('server' => $dbHostForm, 'username' => $dbUsernameForm, 'password' => $dbPassForm));
//if error on connection to the database, show error and exit
if (mysql_errno() > 0)
if (Database::errno() > 0)
{
$no = mysql_errno();
$msg = mysql_error();
$no = Database::errno();
$msg = Database::error();
echo '<hr />['.$no.'] - '.$msg.'<hr />
'.get_lang('DBServerDoesntWorkOrLoginPassIsWrong').'.<br /><br />
@ -102,7 +103,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
exit ();
}
@mysql_query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
@Database::query("set session sql_mode='';"); // Disabling special SQL modes (MySQL 5)
/*
-----------------------------------------------------------
@ -136,19 +137,19 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
mysql_select_db($dbNameForm);
Database::select_db($dbNameForm);
foreach($m_q_list as $query){
if($only_test){
echo "mysql_query($dbNameForm,$query)<br />";
echo "Database::query($dbNameForm,$query)<br />";
}else{
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
//manual updates in here
//update all registration_date, expiration_date and active fields
//$sql_upd = "UPDATE user SET registration_date=NOW()";
//$res_upd = mysql_query($sql_upd);
//$res_upd = Database::query($sql_upd);
//end of manual updates
//get the stats queries list (s_q_list)
@ -160,12 +161,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
mysql_select_db($dbStatsForm);
Database::select_db($dbStatsForm);
foreach($s_q_list as $query){
if($only_test){
echo "mysql_query($dbStatsForm,$query)<br />";
echo "Database::query($dbStatsForm,$query)<br />";
}else{
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -178,12 +179,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
mysql_select_db($dbUserForm);
Database::select_db($dbUserForm);
foreach($u_q_list as $query){
if($only_test){
echo "mysql_query($dbUserForm,$query)<br />";
echo "Database::query($dbUserForm,$query)<br />";
}else{
$res = mysql_query($query);
$res = Database::query($query);
}
}
}
@ -205,13 +206,13 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
$installation_settings['allow_teacher_self_registration'] = $allowSelfRegProf;
$installation_settings['admin_phone_form'] = $adminPhoneForm;
//mysql_query("INSERT INTO `$dbNameForm`.`course_module` (`name`,`link`,`image`,`row`,`column`,`position`) VALUES
//Database::query("INSERT INTO `$dbNameForm`.`course_module` (`name`,`link`,`image`,`row`,`column`,`position`) VALUES
// ('AddedLearnpath', NULL, 'scormbuilder.gif', 0, 0, 'external'),
// ('".TOOL_BACKUP."', 'coursecopy/backup.php' , 'backup.gif', 2, 1, 'courseadmin'),
// ('".TOOL_COPY_COURSE_CONTENT."', 'coursecopy/copy_course.php' , 'copy.gif', 2, 2, 'courseadmin'),
// ('".TOOL_RECYCLE_COURSE."', 'coursecopy/recycle_course.php' , 'recycle.gif', 2, 3, 'courseadmin')");
//...
//mysql_query("UPDATE `$dbNameForm`.`course_module` SET name='".TOOL_LEARNPATH."' WHERE link LIKE 'scorm/%'");
//Database::query("UPDATE `$dbNameForm`.`course_module` SET name='".TOOL_LEARNPATH."' WHERE link LIKE 'scorm/%'");
*/
}
@ -233,12 +234,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
if(count($c_q_list)>0)
{
//get the courses list
mysql_select_db($dbNameForm);
$res = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
Database::select_db($dbNameForm);
$res = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if($res===false){die('Error while querying the courses list in update_db.inc.php');}
if(mysql_num_rows($res)>0)
if(Database::num_rows($res)>0)
{
while($row = mysql_fetch_array($res))
while($row = Database::fetch_array($res))
{
$list[] = $row;
}
@ -249,14 +250,14 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
* We connect to the right DB first to make sure we can use the queries
* without a database name
*/
mysql_select_db($row['db_name']);
Database::select_db($row['db_name']);
foreach($c_q_list as $query)
{
if($only_test)
{
echo "mysql_query(".$row['db_name'].",$query)<br />";
echo "Database::query(".$row['db_name'].",$query)<br />";
}else{
$res = mysql_query($query);
$res = Database::query($query);
}
}
//update course manually
@ -267,17 +268,17 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
//update forum tables (migrate from bb_ tables to forum_ tables)
//migrate categories
$sql_orig = "SELECT * FROM bb_categories";
$res_orig = mysql_query($sql_orig);
while($row = mysql_fetch_array($res_orig)){
$res_orig = Database::query($sql_orig);
while($row = Database::fetch_array($res_orig)){
$sql = "INSERT INTO forum_category " .
"(cat_id,cat_title,cat_comment,cat_order,locked) VALUES " .
"('".$row['cat_id']."','".$row['cat_title']."','','".$row['cat_order']."',0)";
$res = mysql_query($sql);
$res = Database::query($sql);
}
$sql_orig = "SELECT * FROM bb_forums ORDER BY forum_last_post_id desc";
$res_orig = mysql_query($sql_orig);
$res_orig = Database::query($sql_orig);
$order = 1;
while($row = mysql_fetch_array($res_orig)){
while($row = Database::fetch_array($res_orig)){
$sql = "INSERT INTO forum_forum " .
"(forum_id,forum_category,allow_edit,forum_comment," .
"forum_title," .
@ -289,12 +290,12 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
"'".$row['forum_last_post_id']."','".$row['forum_topics']."'," .
"0,'".$row['forum_posts']."'," .
"1,$order)";
$res = mysql_query($sql);
$res = Database::query($sql);
$order++;
}
$sql_orig = "SELECT * FROM bb_topics";
$res_orig = mysql_query($sql_orig);
while($row = mysql_fetch_array($res_orig)){
$res_orig = Database::query($sql_orig);
while($row = Database::fetch_array($res_orig)){
//convert time from varchar to datetime
$time = $row['topic_time'];
$name = $row['prenom']." ".$row['nom'];
@ -307,11 +308,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
"0,'".$row['topic_replies']."',0,'".$row['topic_title']."'," .
"'$name','$time','".$row['topic_last_post_id']."'," .
"'".$row['topic_views']."')";
$res = mysql_query($sql);
$res = Database::query($sql);
}
$sql_orig = "SELECT * FROM bb_posts, bb_posts_text WHERE bb_posts.post_id = bb_posts_text.post_id";
$res_orig = mysql_query($sql_orig);
while($row = mysql_fetch_array($res_orig)){
$res_orig = Database::query($sql_orig);
while($row = Database::fetch_array($res_orig)){
//convert time from varchar to datetime
$time = $row['post_time'];
$name = $row['prenom']." ".$row['nom'];
@ -324,7 +325,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
"'".$row['poster_id']."','".$row['parent_id']."',1," .
"'".$row['post_title']."','$name', '".$row['post_text']."'," .
"'$time',0)";
$res = mysql_query($sql);
$res = Database::query($sql);
}
}
}
@ -336,21 +337,21 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
$courseDB = array ();
$nbr_courses = 0;
if ($result = mysql_query("SELECT code,db_name,directory,course_language FROM `$dbNameForm`.`course` WHERE target_course_code IS NULL"))
if ($result = Database::query("SELECT code,db_name,directory,course_language FROM `$dbNameForm`.`course` WHERE target_course_code IS NULL"))
{
$i = 0;
$nbr_courses = mysql_num_rows($result);
$nbr_courses = Database::num_rows($result);
while ($i < MAX_COURSE_TRANSFER && (list ($course_code, $mysql_base_course, $directory, $languageCourse) = mysql_fetch_row($result)))
while ($i < MAX_COURSE_TRANSFER && (list ($course_code, $db_base_course, $directory, $languageCourse) = Database::fetch_row($result)))
{
if (!file_exists($newPath.'courses/'.$directory))
{
if ($singleDbForm)
{
$prefix = $_configuration['table_prefix'].$mysql_base_course.$_configuration['db_glue'];
$prefix = $_configuration['table_prefix'].$db_base_course.$_configuration['db_glue'];
$mysql_base_course = $dbNameForm.'`.`'.$_configuration['table_prefix'].$mysql_base_course;
$db_base_course = $dbNameForm.'`.`'.$_configuration['table_prefix'].$db_base_course;
}
else
{
@ -358,7 +359,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
}
$coursePath[$course_code] = $directory;
$courseDB[$course_code] = $mysql_base_course;
$courseDB[$course_code] = $db_base_course;
include ("../lang/english/create_course.inc.php");
@ -372,11 +373,11 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
// Set item-properties of dropbox files
/*
$sql = "SELECT * FROM `$mysql_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id";
$res = mysql_query($sql);
while ($obj = mysql_fetch_object($res))
$sql = "SELECT * FROM `$db_base_course".$_configuration['db_glue']."dropbox_file` f, `".$_configuration['db_glue']."_base_course".$_configuration['db_glue']."dropbox_post` p WHERE f.id = p.file_id";
$res = Database::query($sql);
while ($obj = Database::fetch_object($res))
{
$sql = "INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property` SET ";
$sql = "INSERT INTO `$db_base_course".$_configuration['db_glue']."item_property` SET ";
$sql .= " tool = '".TOOL_DROPBOX."', ";
$sql .= " insert_date = '".$obj->upload_date."', ";
$sql .= " lastedit_date = '".$obj->last_upload_date."', ";
@ -385,7 +386,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE'))
$sql .= " to_group_id = '0', ";
$sql .= " to_user_id = '".$obj->dest_user_id."', ";
$sql .= " insert_user_id = '".$obj->uploader_id."'";
mysql_query($sql);
Database::query($sql);
}
*/
@ -422,14 +423,14 @@ function store_forumcategory($values)
global $_user;
// find the max cat_order. The new forum category is added at the end => max cat_order + &
$sql="SELECT MAX(cat_order) as sort_max FROM ".mysql_real_escape_string($table_categories);
$sql="SELECT MAX(cat_order) as sort_max FROM ".Database::escape_string($table_categories);
$result=Database::query($sql);
$row=mysql_fetch_array($result);
$row=Database::fetch_array($result);
$new_max=$row['sort_max']+1;
$sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".mysql_real_escape_string($values['forum_category_title'])."','".mysql_real_escape_string($values['forum_category_comment'])."','".mysql_real_escape_string($new_max)."')";
$sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".Database::real_escape_string($values['forum_category_title'])."','".Database::escape_string($values['forum_category_comment'])."','".Database::escape_string($new_max)."')";
Database::query($sql);
$last_id=mysql_insert_id();
$last_id=Database::insert_id();
api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']);
return array('id'=>$last_id,'title'=>$values['forum_category_title']) ;
}
@ -446,28 +447,28 @@ function store_forum($values)
global $_user;
// find the max forum_order for the given category. The new forum is added at the end => max cat_order + &
$sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']);
$sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".Database::escape_string($values['forum_category']);
$result=Database::query($sql);
$row=mysql_fetch_array($result);
$row=Database::fetch_array($result);
$new_max=$row['sort_max']+1;
$sql="INSERT INTO ".$table_forums."
(forum_title, forum_comment, forum_category, allow_anonymous, allow_edit, approval_direct_post, allow_attachments, allow_new_threads, default_view, forum_of_group, forum_group_public_private, forum_order)
VALUES ('".mysql_real_escape_string($values['forum_title'])."',
'".mysql_real_escape_string($values['forum_comment'])."',
'".mysql_real_escape_string($values['forum_category'])."',
'".mysql_real_escape_string($values['allow_anonymous_group']['allow_anonymous'])."',
'".mysql_real_escape_string($values['students_can_edit_group']['students_can_edit'])."',
'".mysql_real_escape_string($values['approval_direct_group']['approval_direct'])."',
'".mysql_real_escape_string($values['allow_attachments_group']['allow_attachments'])."',
'".mysql_real_escape_string($values['allow_new_threads_group']['allow_new_threads'])."',
'".mysql_real_escape_string($values['default_view_type_group']['default_view_type'])."',
'".mysql_real_escape_string($values['group_forum'])."',
'".mysql_real_escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."',
'".mysql_real_escape_string($new_max)."')";
VALUES ('".Database::escape_string($values['forum_title'])."',
'".Database::escape_string($values['forum_comment'])."',
'".Database::escape_string($values['forum_category'])."',
'".Database::escape_string($values['allow_anonymous_group']['allow_anonymous'])."',
'".Database::escape_string($values['students_can_edit_group']['students_can_edit'])."',
'".Database::escape_string($values['approval_direct_group']['approval_direct'])."',
'".Database::escape_string($values['allow_attachments_group']['allow_attachments'])."',
'".Database::escape_string($values['allow_new_threads_group']['allow_new_threads'])."',
'".Database::escape_string($values['default_view_type_group']['default_view_type'])."',
'".Database::escape_string($values['group_forum'])."',
'".Database::escape_string($values['public_private_group_forum_group']['public_private_group_forum'])."',
'".Database::escape_string($new_max)."')";
Database::query($sql);
$last_id=mysql_insert_id();
$last_id=Database::insert_id();
api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']);
return array('id'=>$last_id, 'title'=>$values['forum_title']);
}
@ -488,15 +489,15 @@ function store_thread($values)
// We first store an entry in the forum_thread table because the thread_id is used in the forum_post table
$sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_views, thread_date, thread_sticky)
VALUES ('".mysql_real_escape_string($values['post_title'])."',
'".mysql_real_escape_string($values['forum_id'])."',
'".mysql_real_escape_string($values['user_id'])."',
'".mysql_real_escape_string($values['poster_name'])."',
'".mysql_real_escape_string($values['topic_views'])."',
'".mysql_real_escape_string($values['post_date'])."',
'".mysql_real_escape_string($values['thread_sticky'])."')";
VALUES ('".Database::escape_string($values['post_title'])."',
'".Database::escape_string($values['forum_id'])."',
'".Database::escape_string($values['user_id'])."',
'".Database::escape_string($values['poster_name'])."',
'".Database::escape_string($values['topic_views'])."',
'".Database::escape_string($values['post_date'])."',
'".Database::escape_string($values['thread_sticky'])."')";
$result=Database::query($sql);
$last_thread_id=mysql_insert_id();
$last_thread_id=Database::insert_id();
api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']);
// if the forum properties tell that the posts have to be approved we have to put the whole thread invisible
// because otherwise the students will see the thread and not the post in the thread.
@ -527,12 +528,12 @@ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
$sql_phpbb_threads="SELECT forum.*, users.user_id
FROM $phpbb_threads forum, $table_users users
WHERE forum_id='".mysql_real_escape_string($phpbb_forum_id)."'
WHERE forum_id='".Database::escape_string($phpbb_forum_id)."'
AND forum.nom=users.lastname AND forum.prenom=users.firstname
";
$result_phpbb_threads=Database::query($sql_phpbb_threads);
$threads_counter=0;
while ($row_phpbb_threads=mysql_fetch_array($result_phpbb_threads))
while ($row_phpbb_threads=Database::fetch_array($result_phpbb_threads))
{
$values['post_title']=$row_phpbb_threads['topic_title'];
$values['forum_id']=$new_forum_id;
@ -553,9 +554,9 @@ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id)
// Now we update the forum_forum table with the total number of posts for the given forum.
$sql="UPDATE $table_forums
SET forum_posts='".mysql_real_escape_string($posts_counter)."',
forum_threads='".mysql_real_escape_string($threads_counter)."'
WHERE forum_id='".mysql_real_escape_string($new_forum_id)."'";
SET forum_posts='".Database::escape_string($posts_counter)."',
forum_threads='".Database::escape_string($threads_counter)."'
WHERE forum_id='".Database::escape_string($new_forum_id)."'";
//echo $sql;
$result=Database::query($sql);
return array("threads"=>$threads_counter, "posts"=>$posts_counter);
@ -586,10 +587,10 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
WHERE posts.post_id=posts_text.post_id
AND posts.nom=users.lastname
AND posts.prenom=users.firstname
AND posts.topic_id='".mysql_real_escape_string($phpbb_thread_id)."'
AND posts.topic_id='".Database::escape_string($phpbb_thread_id)."'
";
$result_phpbb_posts=Database::query($sql_phpbb_posts);
while($row_phpbb_posts=mysql_fetch_array($result_phpbb_posts))
while($row_phpbb_posts=Database::fetch_array($result_phpbb_posts))
{
$values=array();
$values['post_title']=$row_phpbb_posts['post_title'];
@ -604,26 +605,26 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
// We first store an entry in the forum_post table
$sql="INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible)
VALUES ('".mysql_real_escape_string($values['post_title'])."',
'".mysql_real_escape_string($values['post_text'])."',
'".mysql_real_escape_string($values['thread_id'])."',
'".mysql_real_escape_string($values['forum_id'])."',
'".mysql_real_escape_string($values['user_id'])."',
'".mysql_real_escape_string($values['post_date'])."',
'".mysql_real_escape_string($values['post_notification'])."',
'".mysql_real_escape_string($values['post_parent_id'])."',
'".mysql_real_escape_string($values['visible'])."')";
VALUES ('".Database::escape_string($values['post_title'])."',
'".Database::escape_string($values['post_text'])."',
'".Database::escape_string($values['thread_id'])."',
'".Database::escape_string($values['forum_id'])."',
'".Database::escape_string($values['user_id'])."',
'".Database::escape_string($values['post_date'])."',
'".Database::escape_string($values['post_notification'])."',
'".Database::escape_string($values['post_parent_id'])."',
'".Database::escape_string($values['visible'])."')";
$result=Database::query($sql);
$post_counter++;
$last_post_id=mysql_insert_id();
$last_post_id=Database::insert_id();
// We check if there added resources and if so we update them
if (in_array($row_phpbb_posts['post_id'],$added_resources))
{
$sql_update_added_resource="UPDATE $table_added_resources
SET source_type='forum_post', source_id='".mysql_real_escape_string($last_post_id)."'
WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."' AND source_id='".mysql_real_escape_string($row_phpbb_posts['post_id'])."'";
SET source_type='forum_post', source_id='".Database::escape_string($last_post_id)."'
WHERE source_type='".Database::escape_string(TOOL_BB_POST)."' AND source_id='".Database::escape_string($row_phpbb_posts['post_id'])."'";
echo $sql_update_added_resource;
$result=Database::query($sql_update_added_resource);
}
@ -632,9 +633,9 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo
}
// update the thread_last_post of the post table AND the
$sql="UPDATE $table_threads SET thread_last_post='".mysql_real_escape_string($last_post_id)."',
thread_replies='".mysql_real_escape_string($post_counter-1)."'
WHERE thread_id='".mysql_real_escape_string($new_forum_thread_id)."'";
$sql="UPDATE $table_threads SET thread_last_post='".Database::escape_string($last_post_id)."',
thread_replies='".Database::escape_string($post_counter-1)."'
WHERE thread_id='".Database::escape_string($new_forum_thread_id)."'";
//echo $sql;
$result=Database::query($sql);
//echo $sql;
@ -652,9 +653,9 @@ function get_added_resources()
$return_array=array();
// TODO: now we also migrate the added resources.
$sql_added_resources="SELECT * FROM $table_added_resources WHERE source_type='".mysql_real_escape_string(TOOL_BB_POST)."'";
$sql_added_resources="SELECT * FROM $table_added_resources WHERE source_type='".Database::escape_string(TOOL_BB_POST)."'";
$result=Database::query($sql_added_resources);
while ($row=mysql_fetch_array($result))
while ($row=Database::fetch_array($result))
{
$return_array[]=$row['source_id'];
}
@ -670,10 +671,10 @@ function get_forumcategory_id_by_name($forum_category_name)
{
global $table_categories;
$sql="SELECT cat_id FROM $table_categories WHERE cat_title='".mysql_real_escape_string($forum_category_name)."'";
$sql="SELECT cat_id FROM $table_categories WHERE cat_title='".Database::escape_string($forum_category_name)."'";
//echo $sql;
$result=Database::query($sql);
$row=mysql_fetch_array($result);
$row=Database::fetch_array($result);
//echo $row['cat_id'];
return $row['cat_id'];
}

@ -75,7 +75,7 @@
*/
function fill_document_table($dir)
{
global $newPath, $course, $mysql_base_course, $_configuration;
global $newPath, $course, $db_base_course, $_configuration;
$documentPath = $newPath.'courses/'.$course.'/document';
@ -94,31 +94,31 @@ function fill_document_table($dir)
$file_size = filesize($dir.'/'.$readdir);
$result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
$result = Database::query("SELECT id,visibility FROM `$db_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
if (list ($id, $visibility) = mysql_fetch_row($result)) {
mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='file',title='".addslashes($readdir)."',size='$file_size' WHERE id='$id' AND path='".addslashes($path)."'");
if (list ($id, $visibility) = Database::fetch_row($result)) {
Database::query("UPDATE `$db_base_course".$_configuration['db_glue']."document` SET filetype='file',title='".addslashes($readdir)."',size='$file_size' WHERE id='$id' AND path='".addslashes($path)."'");
} else {
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title,size) VALUES('".addslashes($path)."','file','".addslashes($readdir)."','$file_size')");
$id = mysql_insert_id();
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."document`(path,filetype,title,size) VALUES('".addslashes($path)."','file','".addslashes($readdir)."','$file_size')");
$id =Database::insert_id();
}
$visibility = ($visibility == 'v') ? 1 : 0;
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility,lastedit_type,to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','DocumentAdded','0','".$file_date."','".$file_date."')");
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility,lastedit_type,to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','DocumentAdded','0','".$file_date."','".$file_date."')");
} elseif (is_dir($dir.'/'.$readdir)) {
$result = mysql_query("SELECT id,visibility FROM `$mysql_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
$result = Database::query("SELECT id,visibility FROM `$db_base_course".$_configuration['db_glue']."document` WHERE path='".addslashes($path)."' LIMIT 0,1");
if (list ($id, $visibility) = mysql_fetch_row($result)) {
mysql_query("UPDATE `$mysql_base_course".$_configuration['db_glue']."document` SET filetype='folder',title='".addslashes($readdir)."' WHERE id='$id' AND path='".addslashes($path)."'");
if (list ($id, $visibility) = Database::fetch_row($result)) {
Database::query("UPDATE `$db_base_course".$_configuration['db_glue']."document` SET filetype='folder',title='".addslashes($readdir)."' WHERE id='$id' AND path='".addslashes($path)."'");
} else {
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')");
$id = mysql_insert_id();
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."document`(path,filetype,title) VALUES('".addslashes($path)."','folder','".addslashes($readdir)."')");
$id = Database::insert_id();
}
$visibility = ($visibility == 'v') ? 1 : 0;
mysql_query("INSERT INTO `$mysql_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility, lastedit_type, to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','FolderCreated','0','".$file_date."','".$file_date."')");
Database::query("INSERT INTO `$db_base_course".$_configuration['db_glue']."item_property`(tool,ref,visibility, lastedit_type, to_group_id,insert_date,lastedit_date) VALUES('document','$id','$visibility','FolderCreated','0','".$file_date."','".$file_date."')");
if (!fill_document_table($dir.'/'.$readdir)) {
return false;
@ -146,7 +146,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
$perm = api_get_permissions_for_new_directories();
foreach ($coursePath as $key => $course) {
$mysql_base_course = $courseDB[$key];
$db_base_course = $courseDB[$key];
@ unlink($oldPath.$course.'/document/.htaccess');
@ unlink($oldPath.$course.'/group/index.php');
@ -159,7 +159,7 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
if ($fp = @ fopen($oldPath.$course.'/index.php', 'w')) {
fputs($fp, '<?php
$cidReq = "'.$key.'";
$dbname = "'.str_replace($dbPrefixForm, '', $mysql_base_course).'";
$dbname = "'.str_replace($dbPrefixForm, '', $db_base_course).'";
include("../../main/course_home/course_home.php");
?>');
@ -187,15 +187,15 @@ if (defined('SYSTEM_INSTALLATION') || defined('DOKEOS_COURSE_UPDATE')) {
fill_document_table($newPath.'courses/'.$course.'/document');
mysql_query("ALTER TABLE `$mysql_base_course".$_configuration['db_glue']."document` DROP `visibility`");
Database::query("ALTER TABLE `$db_base_course".$_configuration['db_glue']."document` DROP `visibility`");
// Update item_properties of group documents
$sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$mysql_base_course".$_configuration['db_glue']."group_info` g,`$mysql_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')";
$res = mysql_query($sql);
$sql = "SELECT d.id AS doc_id, g.id AS group_id FROM `$db_base_course".$_configuration['db_glue']."group_info` g,`$db_base_course".$_configuration['db_glue']."document` d WHERE path LIKE CONCAT(g.secret_directory,'%')";
$res = Database::query($sql);
while ($group_doc = mysql_fetch_object($res)) {
$sql = "UPDATE `$mysql_base_course".$_configuration['db_glue']."item_property` SET to_group_id = '".$group_doc->group_id."', visibility = '1' WHERE ref = '".$group_doc->doc_id."' AND tool = '".TOOL_DOCUMENT."'";
mysql_query($sql);
while ($group_doc = Database::fetch_object($res)) {
$sql = "UPDATE `$db_base_course".$_configuration['db_glue']."item_property` SET to_group_id = '".$group_doc->group_id."', visibility = '1' WHERE ref = '".$group_doc->doc_id."' AND tool = '".TOOL_DOCUMENT."'";
Database::query($sql);
}
}

@ -317,13 +317,7 @@ class Page_DatabaseSettings extends HTML_QuickForm_Page {
class ValidateDatabaseConnection extends HTML_QuickForm_Rule {
public function validate($parameters) {
$db_host = $parameters[0];
$db_user = $parameters[1];
$db_password = $parameters[2];
if (mysql_connect($db_host, $db_user, $db_password)) {
return true;
}
return false;
return Database::connect(array('server' => $parameters[0], 'username' => $parameters[1], 'password' => $parameters[2])) !== false;
}
}

@ -60,9 +60,9 @@ function upgrade_16x_to_180($values) {
//Get the list of queries to upgrade the main database
$main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'main');
if (count($main_query_list) > 0) {
mysql_select_db($main_database);
Database::select_db($main_database);
foreach ($main_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
@ -70,9 +70,9 @@ function upgrade_16x_to_180($values) {
//Get the list of queries to upgrade the statistics/tracking database
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats');
if (count($tracking_query_list) > 0) {
mysql_select_db($tracking_database);
Database::select_db($tracking_database);
foreach ($tracking_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
@ -80,9 +80,9 @@ function upgrade_16x_to_180($values) {
//Get the list of queries to upgrade the user database
$user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'user');
if (count($user_query_list) > 0) {
mysql_select_db($user_database);
Database::select_db($user_database);
foreach ($user_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
@ -113,26 +113,26 @@ function upgrade_16x_to_180($values) {
*/
$main_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'main');
if (count($main_query_list) > 0) {
mysql_select_db($main_database);
Database::select_db($main_database);
foreach ($main_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'stats');
$tracking_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'stats');
if (count($tracking_query_list) > 0) {
mysql_select_db($tracking_database);
Database::select_db($tracking_database);
foreach ($tracking_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
$user_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-post.sql', 'user');
if (count($user_query_list) > 0) {
mysql_select_db($user_database);
Database::select_db($user_database);
foreach ($user_query_list as $this_query) {
mysql_query($this_query);
Database::query($this_query);
}
}
@ -144,21 +144,21 @@ function upgrade_16x_to_180($values) {
$course_query_list = get_sql_file_contents('migrate-db-1.6.x-1.8.0-pre.sql', 'course');
if (count($course_query_list) > 0) {
//upgrade course databases
mysql_select_db($main_database);
$sql_result = mysql_query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if (mysql_num_rows($sql_result) > 0) {
while ($row = mysql_fetch_array($sql_result)) {
Database::select_db($main_database);
$sql_result = Database::query("SELECT code,db_name,directory,course_language FROM course WHERE target_course_code IS NULL");
if (Database::num_rows($sql_result) > 0) {
while ($row = Database::fetch_array($sql_result)) {
$course_list[] = $row;
}
//for each course in the course list...
foreach ($course_list as $this_course) {
mysql_select_db($this_course['db_name']);
Database::select_db($this_course['db_name']);
//... execute the list of course update queries
foreach ($course_query_list as $this_query) {
if ($is_single_database) { //otherwise just use the main one
$query = preg_replace('/^(UPDATE|ALTER TABLE|CREATE TABLE|DROP TABLE|INSERT INTO|DELETE FROM)\s+(\w*)(.*)$/', "$1 $prefix$2$3", $query);
}
mysql_query($this_query);
Database::query($this_query);
}
}
}

@ -42,14 +42,14 @@ $tbl_messsage_attachment = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT);
$sql= "SELECT filename,message_id FROM $tbl_messsage_attachment WHERE path LIKE BINARY '$file_url'";
$result= Database::query($sql);
$row= Database::fetch_array($result,MYSQL_ASSOC);
$row= Database::fetch_array($result, 'ASSOC');
$title = str_replace(' ','_', $row['filename']);
$message_id = $row['message_id'];
// allow download only for user sender and user receiver
$sql = "SELECT user_sender_id, user_receiver_id, group_id FROM $tbl_messsage WHERE id = '$message_id'";
$rs= Database::query($sql);
$row_users= Database::fetch_array($rs,MYSQL_ASSOC);
$row_users= Database::fetch_array($rs, 'ASSOC');
$current_uid = api_get_user_id();
// get message user id for inbox/outbox

@ -64,8 +64,8 @@ if ($panel_id == 2 || $panel_id == 4 ) {
<?php
}
//here we decode to utf8 because this page is called from an ajax popup
$subject_message = utf8_decode($subject_message);
$content_message = utf8_decode($content_message);
$subject_message = api_utf8_decode($subject_message);
$content_message = api_utf8_decode($content_message);
if ($panel_id==4 && !empty($content_message)) {
if ($subject_message=='clear') {

Loading…
Cancel
Save