Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:fschuett
oss-moodle
oss-moodle-db_replace.php
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File oss-moodle-db_replace.php of Package oss-moodle
<?php // This file is part of Moodle - http://moodle.org/ // // Moodle is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Moodle is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Search and replace strings throughout all texts in the whole database * * @package admin/cli * @subpackage db_replace * @copyright 2012 Frank Schütte <fschuett@gymnasium-himmelsthuer.de> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ define('NO_OUTPUT_BUFFERING', true); define('CLI_SCRIPT', true); require($CFG->dirroot.'/config.php'); require_once($CFG->libdir.'/clilib.php'); // cli only functions require_once($CFG->libdir.'/adminlib.php'); require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/course/lib.php'); // now get cli options list($options, $unrecognized) = cli_get_params(array('search'=>'', 'replace'=>''), array('h'=>'help')); if ($unrecognized) { $unrecognized = implode("\n ", $unrecognized); cli_error(get_string('cliunknowoption', 'admin', $unrecognized)); } if ($options['help'] || $options['search']=='' || $options['replace']=='') { $help = "Replace absolute links in db. This script is designed to replace old url with new url and to be calle from the command line. Options: -h, --help Print out this help --search String to search for --replace String to replace it with Example: \$sudo -u www-data /usr/bin/php db_replace.php --search='http://linuxmuster.net/moodle' --replace='http://linuxmuster.new/moodle' "; echo $help; die; } if (moodle_needs_upgrading()) { echo "Moodle upgrade pending, replace execution suspended.\n"; exit(1); } $starttime = microtime(); /// emulate normal session /// cron_setup_user(); /// Start output log $timenow = time(); mtrace("Server Time: ".date('r',$timenow)."\n\n"); echo "Replacing " . $options['search'] . " with " . $options['replace'] . " in database ...\n"; db_replace($options['search'], $options['replace']); /// Rebuild course cache which might be incorrect now rebuild_course_cache(); exit(0);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor