本文整理汇总了PHP中api_get_path函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_path函数的具体用法?PHP api_get_path怎么用?PHP api_get_path使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_db_info
/**
* Update the file or directory path in the document db document table
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @param - action (string) - action type require : 'delete' or 'update'
* @param - old_path (string) - old path info stored to change
* @param - new_path (string) - new path info to substitute
* @desc Update the file or directory path in the document db document table
*
*/
static function update_db_info($action, $old_path, $new_path = '')
{
$dbTable = Database::get_course_table(TABLE_DOCUMENT);
$course_id = api_get_course_int_id();
/* DELETE */
if ($action == 'delete') {
$old_path = Database::escape_string($old_path);
$to_delete = "WHERE c_id = {$course_id} AND path LIKE BINARY '" . $old_path . "' OR path LIKE BINARY '" . $old_path . "/%'";
$query = "DELETE FROM {$dbTable} " . $to_delete;
$result = Database::query("SELECT id FROM {$dbTable} " . $to_delete);
if (Database::num_rows($result)) {
require_once api_get_path(INCLUDE_PATH) . '../metadata/md_funcs.php';
$mdStore = new mdstore(true);
// create if needed
$md_type = substr($dbTable, -13) == 'scormdocument' ? 'Scorm' : 'Document';
while ($row = Database::fetch_array($result)) {
$eid = $md_type . '.' . $row['id'];
$mdStore->mds_delete($eid);
$mdStore->mds_delete_offspring($eid);
}
}
}
/* UPDATE */
if ($action == 'update') {
if ($new_path[0] == '.') {
$new_path = substr($new_path, 1);
}
$new_path = str_replace('//', '/', $new_path);
// Attempt to update - tested & working for root dir
$new_path = Database::escape_string($new_path);
$query = "UPDATE {$dbTable}\n SET path = CONCAT('" . $new_path . "', SUBSTRING(path, LENGTH('" . $old_path . "')+1) )\n WHERE c_id = {$course_id} AND path LIKE BINARY '" . $old_path . "' OR path LIKE BINARY '" . $old_path . "/%'";
}
Database::query($query);
}
示例2: create_backup_is_admin
function create_backup_is_admin($_cid)
{
$this_section = SECTION_COURSES;
if (isset($_GET['session']) && $_GET['session']) {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
$_cid = true;
$is_courseAdmin = true;
} else {
$archive_path = api_get_path(SYS_ARCHIVE_PATH);
}
$archive_file = $_GET['archive'];
$archive_file = str_replace(array('..', '/', '\\'), '', $archive_file);
list($extension) = getextension($archive_file);
if (empty($extension) || !file_exists($archive_path . $archive_file)) {
return false;
}
$extension = strtolower($extension);
$content_type = '';
if (in_array($extension, array('xml', 'csv')) && (api_is_platform_admin(true) || api_is_drh())) {
$content_type = 'application/force-download';
// TODO: The following unclear condition is commented ant is to be checked. A replacement has been proposed.
//} elseif (strtolower($extension) == 'zip' || ('html' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin))) {
} elseif ($extension == 'zip' && $_cid && (api_is_platform_admin(true) || $is_courseAdmin)) {
//
$content_type = 'application/force-download';
}
if (empty($content_type)) {
return false;
}
return true;
}
示例3: onLogoutSuccess
/**
* @param Request $request
* @return null|RedirectResponse
*/
public function onLogoutSuccess(Request $request)
{
// Chamilo logout
$request->getSession()->remove('_locale');
$request->getSession()->remove('_locale_user');
if (api_is_global_chat_enabled()) {
$chat = new \Chat();
$chat->setUserStatus(0);
}
$userId = $this->storage->getToken()->getUser()->getId();
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT login_id, login_date\n FROM {$tbl_track_login}\n WHERE login_user_id = {$userId}\n ORDER BY login_date DESC\n LIMIT 0,1";
$row = Database::query($sql);
$loginId = null;
if (Database::num_rows($row) > 0) {
$loginId = Database::result($row, 0, "login_id");
}
$loginAs = $this->checker->isGranted('ROLE_PREVIOUS_ADMIN');
if (!$loginAs) {
$current_date = api_get_utc_datetime();
$sql = "UPDATE {$tbl_track_login}\n SET logout_date='" . $current_date . "'\n \t\t WHERE login_id='{$loginId}'";
Database::query($sql);
}
$online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE);
$query = "DELETE FROM " . $online_table . " WHERE login_user_id = {$userId}";
Database::query($query);
require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
exit_of_chat($userId);
$login = $this->router->generate('home');
$response = new RedirectResponse($login);
return $response;
}
示例4: WSCourseListOfUser
/**
* Get a list of courses (code, url, title, teacher, language) for a specific
* user and return to caller
* Function registered as service. Returns strings in UTF-8.
* @param string User name in Chamilo
* @param string Signature (composed of the sha1(username+apikey)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function WSCourseListOfUser($username, $signature)
{
if (empty($username) or empty($signature)) {
return -1;
}
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
foreach ($list as $key) {
break;
}
$local_key = $username . $key;
if (!api_is_valid_secret_key($signature, $local_key)) {
return -1;
// The secret key is incorrect.
}
$courses_list = array();
$courses_list_tmp = CourseManager::get_courses_list_by_user_id($user_id);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
return $courses_list;
}
示例5: HotPotGC
/**
* Garbage collector caller function
*/
function HotPotGC($root_sys, $flag, $userID)
{
// flag[0,1] - print or delete the HotPotatoes temp files (.t.html)
$documentPath = $root_sys . "courses";
require_once api_get_path(LIBRARY_PATH) . "fileManage.lib.php";
HotPotGCt($documentPath, $flag, $userID);
}
示例6: connectDb
/**
* Connect to the database, and create it if it doesn't exist
*/
function connectDb($path = null, $dbMode = null, $lang = 'english')
{
if ($this->db != null) {
return $this->db;
}
if ($dbMode == null) {
$dbMode = Xapian::DB_CREATE_OR_OPEN;
}
if ($path == null) {
$path = api_get_path(SYS_DATA_PATH) . 'searchdb/';
}
try {
$this->db = new XapianWritableDatabase($path, $dbMode);
$this->indexer = new XapianTermGenerator();
if (!in_array($lang, $this->xapian_languages())) {
$lang = 'english';
}
$this->stemmer = new XapianStem($lang);
$this->indexer->set_stemmer($this->stemmer);
return $this->db;
} catch (Exception $e) {
Display::display_error_message($e->getMessage());
return 1;
}
}
示例7: courses_list
/**
* Get a list of courses (code, url, title, teacher, language) and return to caller
* Function registered as service. Returns strings in UTF-8.
* @param string Security key (the Dokeos install's API key)
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function courses_list($security_key, $visibilities = 'public')
{
global $_configuration;
// Check if this script is launch by server and if security key is ok.
if ($security_key != $_configuration['security_key']) {
return array('error_msg' => 'Security check failed');
}
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
$courses_list = array();
if (!is_array($visibilities)) {
$tmp = $visibilities;
$visibilities = array($tmp);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[$course['code']] = array('title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH) . $course_info['directory'] . '/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
return $courses_list;
}
示例8: __construct
/**
*
* Constructor (generates a connection to the API and the Chamilo settings
* required for the connection to the video conference server)
* @param string $host
* @param string $salt
*/
public function __construct($host = null, $salt = null)
{
// Initialize video server settings from global settings
$plugin = BBBPlugin::create();
$bbb_plugin = $plugin->get('tool_enable');
if (empty($host)) {
$bbb_host = $plugin->get('host');
} else {
$bbb_host = $host;
}
if (empty($salt)) {
$bbb_salt = $plugin->get('salt');
} else {
$bbb_salt = $salt;
}
$this->logout_url = api_get_path(WEB_PLUGIN_PATH) . 'bbb/listing.php?' . api_get_cidreq();
$this->table = Database::get_main_table('plugin_bbb_meeting');
if ($bbb_plugin == true) {
$userInfo = api_get_user_info();
$this->user_complete_name = $userInfo['complete_name'];
$this->salt = $bbb_salt;
$info = parse_url($bbb_host);
$this->url = $bbb_host . '/bigbluebutton/';
if (isset($info['scheme'])) {
$this->protocol = $info['scheme'] . '://';
$this->url = str_replace($this->protocol, '', $this->url);
}
// Setting BBB api
define('CONFIG_SECURITY_SALT', $this->salt);
define('CONFIG_SERVER_BASE_URL', $this->url);
$this->api = new BigBlueButtonBN();
$this->plugin_enabled = true;
}
}
示例9: get_all_php_files
function get_all_php_files($base_path)
{
$list = scandir($base_path);
$files = array();
foreach ($list as $item) {
if (substr($item, 0, 1) == '.') {
continue;
}
$special_dirs = array(api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH));
if (in_array($base_path . $item . '/', $special_dirs)) {
continue;
}
if (is_dir($base_path . $item)) {
$files = array_merge($files, get_all_php_files($base_path . $item . '/'));
} else {
//only analyse php files
$sub = substr($item, -4);
if ($sub == '.php' or $sub == '.tpl') {
$files[] = $base_path . $item;
}
}
}
$list = null;
return $files;
}
示例10: login
/**
* Create a Shibboleth session for the user ID
*
* @param string $uid - The user ID
* @return $_user (array) - The user infos array created when the user logs in
*/
function login($uid)
{
/* This must be set for local.inc.php to register correctly the global variables in session
* This is BAD. Logic should be migrated into a function and stop relying on global variables.
*/
global $_uid, $is_allowedCreateCourse, $_real_cid, $_courseUser;
global $is_courseMember, $is_courseTutor, $is_allowed_in_course, $_gid;
$_uid = $uid;
//is_allowedCreateCourse
$user = User::store()->get_by_user_id($uid);
if (empty($user)) {
return;
}
$this->logout();
Chamilo::session()->start();
Session::write('_uid', $_uid);
global $_user;
$_user = (array) $user;
$_SESSION['_user'] = $_user;
$_SESSION['_user']['user_id'] = $_uid;
$_SESSION['noredirection'] = true;
//must be called before 'init_local.inc.php'
event_login();
//used in 'init_local.inc.php' this is BAD but and should be changed
$loginFailed = false;
$uidReset = true;
$gidReset = true;
$cidReset = false;
//FALSE !!
$mainDbName = Database::get_main_database();
$includePath = api_get_path(INCLUDE_PATH);
$no_redirection = true;
require "{$includePath}/local.inc.php";
return $_user;
}
示例11: create_dummy_course
/**
* Create the dummy course
*/
function create_dummy_course($course_code)
{
$this->default_property['insert_user_id'] = '1';
$this->default_property['insert_date'] = date('Y-m-d H:i:s');
$this->default_property['lastedit_date'] = date('Y-m-d H:i:s');
$this->default_property['lastedit_user_id'] = '1';
$this->default_property['to_group_id'] = '0';
$this->default_property['to_user_id'] = null;
$this->default_property['visibility'] = '1';
$this->default_property['start_visible'] = '0000-00-00 00:00:00';
$this->default_property['end_visible'] = '0000-00-00 00:00:00';
$course = Database::get_course_info($course_code);
$this->course = new Course();
$tmp_path = api_get_path(SYS_COURSE_PATH) . $course['directory'] . '/document/tmp_' . uniqid('');
@mkdir($tmp_path, api_get_permissions_for_new_directories(), true);
$this->course->backup_path = $tmp_path;
$this->create_dummy_links();
$this->create_dummy_events();
$this->create_dummy_forums();
$this->create_dummy_announcements();
$this->create_dummy_documents();
$this->create_dummy_learnpaths();
$cr = new CourseRestorer($this->course);
$cr->set_file_option(FILE_OVERWRITE);
$cr->restore($course_code);
rmdirr($tmp_path);
}
示例12: mdobject
function mdobject($_course, $eid)
{
if (!($dotpos = strpos($eid, '.'))) {
return;
}
$this->mdo_course = $_course;
$this->mdo_eid = $eid;
$this->mdo_type = $type = substr($eid, 0, $dotpos);
$this->mdo_id = $id = substr($eid, $dotpos + 1);
if ($type == 'Document' || $type == 'Scorm') {
$table = $type == 'Scorm' ? Database::get_course_table(TABLE_SCORMDOC) : Database::get_course_table(TABLE_DOCUMENT);
if ($dotpos = strpos($id, '.')) {
$urlp = '?sid=' . urlencode(substr($id, $dotpos + 1));
$id = substr($id, 0, $dotpos);
}
if ($docinfo = @mysql_fetch_array(Database::query("SELECT path,comment,filetype FROM\n {$table} WHERE id='" . addslashes($id) . "'"))) {
$this->mdo_path = $docinfo['path'];
$this->mdo_comment = $docinfo['comment'];
$this->mdo_filetype = $docinfo['filetype'];
if ($type == 'Scorm') {
$this->mdo_base_url = get_course_web() . $this->mdo_course['path'] . '/scorm' . $this->mdo_path;
$this->mdo_url = $this->mdo_base_url . '/index.php' . $urlp;
} else {
$this->mdo_url = api_get_path(WEB_PATH) . 'main/document/' . ($this->mdo_filetype == 'file' ? 'download' : 'document') . '.php?' . ($this->mdo_filetype == 'file' ? 'doc_url=' : 'curdirpath=') . urlencode($this->mdo_path);
}
}
} elseif ($type == 'Link') {
$link_table = Database::get_course_table(TABLE_LINK);
if ($linkinfo = @mysql_fetch_array(Database::query("SELECT url,title,description,category_id FROM\n {$link_table} WHERE id='" . addslashes($id) . "'"))) {
$this->mdo_url = $linkinfo['url'];
}
}
}
示例13: getConfiguration
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
if ($this->connector->security->isGranted('ROLE_ADMIN')) {
$home = api_get_path(SYS_DATA_PATH) . 'home';
return array('driver' => 'HomeDriver', 'alias' => $this->connector->translator->trans('Portal'), 'path' => $home, 'URL' => api_get_path(WEB_DATA_PATH) . 'home', 'accessControl' => array($this, 'access'));
}
}
示例14: www
/**
* Application web root
*/
public static function www()
{
static $result = false;
if (empty($result)) {
$result = api_get_path(WEB_PATH);
}
return $result;
}
示例15: getConfiguration
/**
* {@inheritdoc}
*/
public function getConfiguration()
{
if ($this->allow()) {
$home = api_get_path(SYS_APP_PATH) . 'home';
return array('driver' => 'HomeDriver', 'alias' => get_lang('Portal'), 'path' => $home, 'URL' => api_get_path(WEB_PATH) . 'home', 'accessControl' => array($this, 'access'));
}
return array();
}