Internal: Update tests/scripts/ to ensure right path for global.inc.php and exit is always present. Scripts are not yet supported in C2.

pull/5461/head
Yannick Warnier 2 years ago
parent 326565fb1f
commit e21437d5a2
  1. 4
      tests/scripts/build_translation_request_file.php
  2. 2
      tests/scripts/check_extra_fields.php
  3. 2
      tests/scripts/check_users_in_csv_file.php
  4. 2
      tests/scripts/course2session.php
  5. 2
      tests/scripts/delete_deleted_exercises_with_questions.php
  6. 4
      tests/scripts/delete_items_from_csv.php
  7. 4
      tests/scripts/delete_old_courses.php
  8. 4
      tests/scripts/delete_old_courses_even_not_empty.php
  9. 8
      tests/scripts/delete_old_tasks.php
  10. 10
      tests/scripts/delete_orphan_questions.php
  11. 2
      tests/scripts/delete_users_from_csv.php
  12. 2
      tests/scripts/detect_deleted_visible_documents.php
  13. 1
      tests/scripts/disable_user_conditions.php
  14. 3
      tests/scripts/edit_course_html_files.php
  15. 1
      tests/scripts/fix_course_index.php
  16. 18
      tests/scripts/fix_course_spent_time.php
  17. 2
      tests/scripts/fix_documents_path.php
  18. 4
      tests/scripts/fix_duplicate_settings.php
  19. 2
      tests/scripts/fix_exercise_score_in_lp.php
  20. 7
      tests/scripts/fix_group_items_with_old_db.php
  21. 4
      tests/scripts/fix_lp_calendar.php
  22. 2
      tests/scripts/fix_lp_id_to_iid.php
  23. 2
      tests/scripts/fix_lp_id_to_iid_v2.php
  24. 2
      tests/scripts/fix_lp_items_not_found.php
  25. 2
      tests/scripts/fix_migrations_1.9.x_1.10.0.php
  26. 2
      tests/scripts/fix_mimetex.php
  27. 2
      tests/scripts/fix_restored_learnpaths.php
  28. 2
      tests/scripts/fix_student_publication_id.php
  29. 3
      tests/scripts/fix_user_id.php
  30. 4
      tests/scripts/insert_session_fields.php
  31. 3
      tests/scripts/insert_sessions_categories.php
  32. 2
      tests/scripts/kill_all_queries.php
  33. 2
      tests/scripts/login_as_admin.php
  34. 4
      tests/scripts/migrate_item_property.php
  35. 2
      tests/scripts/move_users.php
  36. 4
      tests/scripts/multi_url_conversion.php
  37. 2
      tests/scripts/restore_deleted_documents.php
  38. 2
      tests/scripts/settings2csv.php
  39. 6
      tests/scripts/switch_files_to_gettext.php
  40. 16
      tests/scripts/synchronize_user_base_from_ldap.php
  41. 2
      tests/scripts/update_user_extra_field.php
  42. 3
      tests/scripts/userfields_to_groups.php
  43. 2
      tests/scripts/users_no_course.php
  44. 2
      tests/scripts/video.php
  45. 4
      tests/scripts/wipe-out.php

@ -7,8 +7,8 @@
/**
* Includes and declarations
*/
die();
require_once '../../main/inc/global.inc.php';
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$path = api_get_path(SYS_LANG_PATH);
$referenceLanguage = 'english';
$language = 'german';

@ -9,7 +9,7 @@
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$em = Database::getManager();
$repo = $em->getRepository('ChamiloCoreBundle:ExtraField');

@ -3,7 +3,7 @@
exit;
require_once __DIR__.'/../inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();
$file = '';

@ -9,7 +9,7 @@
*/
// comment exit statement before executing
exit;
require __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$debug = 1;
// Who will be the general coach assigned to all sessions created?

@ -3,7 +3,7 @@
exit;
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$sql = 'SELECT iid, c_id, title
FROM c_quiz

@ -3,7 +3,7 @@
exit;
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$file = 'delete.csv';
if (!file_exists($file)) {
@ -58,4 +58,4 @@ foreach ($data as $row) {
}
$counter++;
}
}

@ -17,7 +17,7 @@ exit;
$creation = '2014-01-01';
$access = '2014-07-01';
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
if (PHP_SAPI !== 'cli') {
die('This script can only be executed from the command line');
@ -51,7 +51,7 @@ if (!empty($items)) {
echo('rm -rf '.__DIR__.'/../../archive/'.$item['directory'].'_*').PHP_EOL;
exec('rm -rf '.__DIR__.'/../../archive/'.$item['directory'].'_*');
// The normal procedure also created a database dump, but it is
// stored in the course folder, so no issue there...
// stored in the course folder, so no issue there...
if (substr($size, 0, 4) == '160K') {
$total += 160;
}

@ -7,7 +7,7 @@
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
if (PHP_SAPI !== 'cli') {
die('This script can only be executed from the command line');
@ -45,7 +45,7 @@ if (!empty($items)) {
echo('rm -rf '.__DIR__.'/../../archive/'.$item['directory'].'_*').PHP_EOL;
exec('rm -rf '.__DIR__.'/../../archive/'.$item['directory'].'_*');
// The normal procedure also created a database dump, but it is
// stored in the course folder, so no issue there...
// stored in the course folder, so no issue there...
if (substr($size, 3, 1) == 'K') {
$total += substr($size, 0, 3);
}

@ -11,12 +11,12 @@
* @author Percy Santiago <psantiago@icpna.edu.pe>
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
exit(); //remove this line to execute from the command line
exit; //remove this line to execute from the command line
if (PHP_SAPI !== 'cli') {
die('This script can only be executed from the command line');
}
require __DIR__.'/../../main/inc/conf/configuration.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
// Dates
$expiryDate = '2015-06-01'; //session start date must be < to be considered
@ -51,8 +51,8 @@ echo "[".time()."] Found $countSessions sessions between $fromDate and $expiryDa
while ($session = mysql_fetch_assoc($res)) {
$sql2 = "SELECT c.id AS cid, c.code as ccode, c.directory as cdir
FROM course c, session_rel_course s
WHERE s.id_session = ".$session['id']."
FROM course c, session_rel_course s
WHERE s.id_session = ".$session['id']."
AND s.course_code = c.code";
$res2 = mysql_query($sql2, $conexion); //Database::query($sql2);

@ -3,11 +3,11 @@
exit;
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$sql = 'SELECT iid, c_id, question
FROM c_quiz_question
WHERE iid not in (SELECT question_id from c_quiz_rel_question)
$sql = 'SELECT iid, c_id, question
FROM c_quiz_question
WHERE iid not in (SELECT question_id from c_quiz_rel_question)
ORDER BY iid';
$result = Database::query($sql);
@ -23,4 +23,4 @@ foreach ($data as $row) {
}
echo 'Deleting question '.$counter.'/'.$totalQuestions.' - #'.$row['iid'].PHP_EOL;
$counter++;
}
}

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
exit;
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();
// Define origin and destination courses' code

@ -5,7 +5,7 @@
*/
exit;
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();
// Define origin and destination courses' code

@ -16,6 +16,7 @@
* than 6 months then deactivate his account and send an email to the learner.
* */
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$senderId = api_get_setting('platform.disable_user_conditions_sender_id');

@ -11,7 +11,8 @@
* need to move it to an executable folder and change the first require.
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
require __DIR__.'/../../main/inc/global.inc.php';
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();
// Search string

@ -11,6 +11,7 @@
* - Check the results in one index.php file
* - Delete this file
*/
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be launched from the command line');
}

@ -8,7 +8,7 @@
*/
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$maxSeconds = 10 * 60 * 60; // Check records higher than X hours
$addSecondsToLogin = 2 * 60 * 60; // Update this abusive records with X hours
@ -17,14 +17,14 @@ $sendMessage = true;
$userId = 1; // User id that will receive a report
$update = false; // Update and fix the record
$sql = "SELECT
course_access_id,
counter,
UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date) diff,
login_course_date,
logout_course_date
FROM track_e_course_access
WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date)
$sql = "SELECT
course_access_id,
counter,
UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date) diff,
login_course_date,
logout_course_date
FROM track_e_course_access
WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date)
ORDER by diff DESC
LIMIT $limit
";

@ -19,7 +19,7 @@
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
/*$test = '
https://example.fr/../../../../../../../LOLOS/CHAMILO/document/Chamilo/Fonctionalite_de_groupe.html

@ -4,9 +4,9 @@
* Remove the current_settings duplicates from migration 1.9.x to 1.10.x
*/
//exit;
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
//api_protect_admin_script();

@ -9,7 +9,7 @@
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();

@ -21,10 +21,11 @@
/**
* Context initialization
*/
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be executed from the command line');
}
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
/**
* Old database configuration
@ -83,7 +84,7 @@ foreach ($oldDBH->query($sqlOld) as $oldRow) {
$sqlNew = "SELECT iid, to_group_id FROM c_item_property
WHERE c_id = ".$oldRow['c_id'].
$sessionSubSelect.
" AND tool = '".$oldRow['tool']."'
" AND tool = '".$oldRow['tool']."'
AND ref = ".$oldRow['ref'];
//echo trim(str_replace("\n", '', $sqlNew)).PHP_EOL;
@ -173,4 +174,4 @@ function getOldGroupsByCourse() {
}
}
return $courses;
}
}

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
require __DIR__ . '/../../main/inc/global.inc.php';
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$extraField = new ExtraField('lp_item');
$extraFieldInfo = $extraField->get_handler_field_info_by_field_variable('calendar');

@ -7,7 +7,7 @@
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
/** @var int $courseId */
$onlyCourseId = 0;

@ -7,7 +7,7 @@
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
/** @var int $courseId */
$onlyCourseId = 0;

@ -9,7 +9,7 @@
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
/** @var The course id $courseId */
$courseId = 0;

@ -6,7 +6,7 @@
*/
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();

@ -3,7 +3,7 @@
exit;
require_once __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$sql = 'SELECT iid, id, question, c_id
FROM c_quiz_question

@ -7,7 +7,7 @@ use Chamilo\CourseBundle\Entity\CLp;
use Doctrine\ORM\Query\Expr\Join;
use Chamilo\CourseBundle\Entity\CTool;
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$em = Database::getManager();

@ -6,7 +6,7 @@ if (PHP_SAPI != 'cli') {
die('This script can only be launched from the command line');
}
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH).'install/install.lib.php';

@ -3,10 +3,11 @@
/**
* Temporary fix to set user.user_id to the same as user.id
*/
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be executed from the command line');
}
require __DIR__.'/../../main/inc/conf/configuration.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$dbh = mysql_connect(
$_configuration['db_host'],

@ -3,9 +3,9 @@
* This script insert session extra fields
*/
//exit;
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();

@ -3,7 +3,8 @@
/**
* This script generates four session categories.
*/
require_once '../../main/inc/global.inc.php';
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();
$accessUrlId = api_get_current_access_url_id();

@ -10,7 +10,7 @@
* should be able to quickly restart your database.
*/
exit;
require_once '../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$result = Database::query("SHOW FULL PROCESSLIST");
while ($row=Database::fetch_array($result)) {
$process_id=$row["Id"];

@ -7,7 +7,7 @@ if (PHP_SAPI != 'cli') {
die('This script can only be executed from the command line');
}
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$userInfo = UserManager::logInAsFirstAdmin();

@ -19,11 +19,11 @@ use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
echo 'First check if table "classification__category" has a default category; if not then run: <br />';
echo 'bin/console sonata:media:fix-media-context';
echo 'change course id in the query';
//exit;
exit;
// For tests to clean all resource stuff:
//
require_once __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$sql = "SELECT
d.id,

@ -11,7 +11,7 @@
* Init
*/
die('Remove the "die()" line to execute this script'.PHP_EOL);
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
// Define origin and destination courses' code
$originCourse = 'XYZ2014';
$destinationCourse = 'XYZ2014C2';

@ -7,7 +7,7 @@
* referencing ID 1 to ID 2.
*/
die();
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$tableAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
$tableUserRelCourseVote = Database::get_main_table(TABLE_MAIN_USER_REL_COURSE_VOTE);
@ -120,4 +120,4 @@ $resU = Database::query($sqlU);
echo "Table $tableAccessUrlRelUserGroup updated".PHP_EOL;
echo "Database updated.".PHP_EOL;
echo "Please set \$_configuration['multiple_access_urls'] to true in the app/config/configuration.php file".PHP_EOL;
echo "Please set \$_configuration['multiple_access_urls'] to true in the app/config/configuration.php file".PHP_EOL;

@ -10,7 +10,7 @@ use Chamilo\CourseBundle\Entity\CItemProperty;
exit;
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();

@ -28,7 +28,7 @@ if (!empty($argv[1])) {
$language = $argv[1];
}
$_GET['language'] = $language;
@require __DIR__ . '/../../main/inc/global.inc.php';
@require_once __DIR__.'/../../public/main/inc/global.inc.php';
// Categories, in order of appearance in the Chamilo settings page
// Check the end of main/admin/settings.php for the initial list

@ -6,8 +6,8 @@
/**
* Includes and declarations.
*/
exit();
require_once __DIR__.'/../../inc/global.inc.php';
exit;
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$path = api_get_path(SYS_LANG_PATH).'english';
ini_set('memory_limit', '128M');
/**
@ -87,4 +87,4 @@ foreach ($files as $file) {
flush();
}
echo "Done analyzing $countFiles files, with $countReplaces replacements!\n";
echo "Done analyzing $countFiles files, with $countReplaces replacements!\n";

@ -7,7 +7,7 @@ User account synchronisation from LDAP
This script
creates new user accounts found in the LDAP directory (if multiURL is enable, it creates the user on the URL for which the LDAP has been configured)
disables user accounts not found in the LDAP directory (it disbales the user for all URLs)
disables user accounts not found in the LDAP directory (it disbales the user for all URLs)
or delete the user depending on the variable deleteUsersNotFoundInLDAP (only if the user has auth_source === extldap)
updates existing user accounts found in the LDAP directory, re-enabling them if disabled (it applies for all URLs) only if option reenableUsersFoundInLDAP is set to true.
anonymizes user accounts disabled for more than 3 years (applies for all URLs) only if the variable is set to true (by default).
@ -25,7 +25,7 @@ username field is used to identify and match LDAP and Chamilo accounts together.
*/
exit;
// Change this to the absolute path to chamilo root folder if you move the script out of tests/scripts
$chamiloRoot = __DIR__.'/../..';
$chamiloRoot = __DIR__.'/../../public';
// Set to true in order to get a trace of changes made by this script
$debug = false;
@ -43,7 +43,7 @@ $reenableUsersFoundInLDAP = false;
// Anonymize user accounts disabled for more than 3 years
$anonymizeUserAccountsDisbaledFor3Years = false;
// List of username of accounts that should not be disabled or deleted if not present in LDAP
// List of username of accounts that should not be disabled or deleted if not present in LDAP
// For exemple the first admin and the anonymous user that has no username ('')
//$usernameListNotToTouchEvenIfNotInLDAP = ['admin','','test'];
@ -101,7 +101,7 @@ if (api_is_multiple_url_enabled()) {
$multipleUrlLDAPConfig = true;
if (!empty($extldap_config) && array_key_exists('host', $extldap_config) && !empty($extldap_config['host'])) {
$multipleUrlLDAPConfig = false;
}
}
}
if (!$multipleUrlLDAPConfig) {
@ -201,7 +201,7 @@ foreach ($accessUrls as $accessUrl) {
LDAP_OPT_PROTOCOL_VERSION,
array_key_exists('protocol_version', $extldap_config[$accessUrlId]) ? $extldap_config[$accessUrlId]['protocol_version'] : 2
);
ldap_set_option(
$ldap,
LDAP_OPT_REFERRALS,
@ -284,7 +284,7 @@ foreach ($accessUrls as $accessUrl) {
}
$entry = ldap_next_entry($ldap, $entry);
}
ldap_close($ldap);
if ($debug) {
echo "ldapUsers = " . print_r($ldapUsers,1) . "\n";
@ -413,7 +413,7 @@ foreach (array_diff(array_keys($dbUsers), array_keys($allLdapUsers)) as $usernam
}
if ($debug) {
echo 'Deleted user ' . $usernameToDisable . "\n";
}
}
} else {
if (!$test) {
if ($user->isActive()) {
@ -435,7 +435,7 @@ foreach (array_diff(array_keys($dbUsers), array_keys($allLdapUsers)) as $usernam
if ($debug) {
echo 'Disabled ' . $user->getUsername() . "\n";
}
}
}
}
}
if (!$test) {

@ -17,7 +17,7 @@
exit;
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
// Define origin and destination courses' code
$extraFieldName = 'dni';

@ -3,10 +3,11 @@
* Move user fields "ruc" and "razon_social" to (social) groups (create groups)
* and assign the related users to those groups.
*/
exit;
if (PHP_SAPI != 'cli') {
die('This script can only be launched from the command line');
}
require __DIR__ . '/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
// We assume all these fields represent the same value, so they are on a 1-1
// relationship.

@ -7,7 +7,7 @@
*/
exit;
require __DIR__.'/../../main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
api_protect_admin_script();

@ -7,7 +7,7 @@
* @todo Add security filtering for filenames
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
exit();
exit;
ini_set('memory_limit',0);
ini_set('max_execution_time',0);
ini_set('upload_max_filesize',0);

@ -14,7 +14,7 @@
/**
* Security checks
*/
exit;
if (PHP_SAPI != 'cli') {
echo "For security reasons, this script can only be launched from the command line, sorry.";
exit;
@ -43,7 +43,7 @@ ini_set('track_errors',1);
$_SERVER['SERVER_NAME'] = '';
$_SERVER['HTTP_HOST'] = 'localhost';
$root = __DIR__.'/../';
require $root.'main/inc/global.inc.php';
require_once __DIR__.'/../../public/main/inc/global.inc.php';
$global_db = Database::get_main_database();
$webpath = api_get_path(WEB_PATH);

Loading…
Cancel
Save