Пример #1
0
/**
* Validate the data in passed in the configuration page
* @param $config - the information from the form mod.html
*/
function voicepresentation_process_options($config)
{
    global $CFG;
    /*******
        we do the following verfication before submitting the configuration
      	-The parameters sent can not be empty
      	-The url of the server can not finish with a /
      	-The url must start with http:// or https://
      	-The api account has to valid
      ********/
    $config->module = "voicetools";
    if (empty($config->servername)) {
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_string('wrongconfigurationURLunavailable', 'voicepresentation'));
        error(get_string('wrongconfigurationURLunavailable', 'voicepresentation'), $_SERVER["HTTP_REFERER"]);
    }
    if (empty($config->adminusername)) {
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_string('emptyAdminUsername', 'voicepresentation'));
        error(get_string('emptyAdminUsername', 'voicepresentation'), $_SERVER["HTTP_REFERER"]);
    }
    if (empty($config->adminpassword)) {
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_string('emptyAdminPassword', 'voicepresentation'));
        error(get_string('emptyAdminPassword', 'voicepresentation'), $_SERVER["HTTP_REFERER"]);
    }
    if ($config->servername[strlen($config->servername) - 1] == '/') {
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_String('trailingSlash', 'voicepresentation'));
        error(get_String('trailingSlash', 'voicepresentation'), $_SERVER["HTTP_REFERER"]);
    }
    if (!preg_match('/^http:\\/\\//', $config->servername) && !preg_match('/^https:\\/\\//', $config->servername)) {
        wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_String('trailingHttp', 'voicepresentation'));
        error(get_String('trailingHttp', 'voicepresentation'), $_SERVER["HTTP_REFERER"]);
    }
    //check if the api account filled is correct and allowed
    $result = voicetools_api_check_documentbase($config->servername, $config->adminusername, $config->adminpassword, $CFG->wwwroot);
    if ($result != "ok") {
        if (get_string($result, 'voicepresentation') == "[[]]") {
            //the error description is not in the bundle
            wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, $result);
            error($result, 'javascript:history.back();');
        } else {
            wimba_add_log(WIMBA_ERROR, voicepresentation_LOGS, get_String($result, 'voicepresentation'));
            error(get_string($result, 'voicepresentation'), 'javascript:history.back();');
        }
    }
    //to make sure that all the necessary module are installed
    wimba_add_log(WIMBA_INFO, voicepresentation_LOGS, "php info :\n" . print_r(get_loaded_extensions(), true));
    wimba_add_log(WIMBA_INFO, voicepresentation_LOGS, "The module is well configured");
}
Пример #2
0
<?php

global $CFG;
require_once "../../config.php";
require_once 'lib/php/common/WimbaLib.php';
require_once 'lib/php/vt/WimbaVoicetoolsAPI.php';
$user = optional_param("user", PARAM_ALPHANUM);
$pass = optional_param("pass", PARAM_ALPHANUM);
$server = optional_param("server", PARAM_TEXT);
$result = voicetools_api_check_documentbase($server, $user, $pass, $CFG->wwwroot);
if ($result != "ok") {
    if (get_string($result, 'voicetools') == "[[" . $result . "]]") {
        //the error description is not in the bundle
        wimba_add_log(WIMBA_ERROR, "wimbaConfiguration", $result);
        echo get_string("generic_error", 'voicetools');
    } else {
        wimba_add_log(WIMBA_ERROR, "wimbaConfiguration", get_String($result, 'voicetools'));
        echo get_string($result, 'voicetools');
    }
} else {
    $php_extension = get_loaded_extensions();
    for ($i = 0; $i < count($php_extension); $i++) {
        if ($php_extension[$i] == "libxml" || $php_extension[$i] == "domxml") {
            wimba_add_log(WIMBA_INFO, 'wimbaConfiguration', "The module is well configured");
            echo $result;
            exit;
        }
    }
    wimba_add_log(WIMBA_INFO, 'wimbaConfiguration', "domxml is not installed");
    echo get_string("domxml", 'voicetools');
}