Exemple #1
0
 function is_password_valid($user, $pass)
 {
     $storage =& get_storage();
     $md5_pass = md5($pass);
     $res = $storage->get_resource(MW_DS_USERS, $user, MW_REVISION_HEAD, false);
     return $md5_pass == $res->get(MW_RESOURCE_KEY_PASSWORD);
 }
Exemple #2
0
 function get_description()
 {
     $version = '???';
     $storage =& get_storage();
     if ($storage !== null && is_a($storage, 'MW_MySQLStorage')) {
         $version = $storage->get_server_info();
     }
     return "[http://www.mysql.com MySQL]: {$version}";
 }
Exemple #3
0
function register_dataspace($dataspace_def)
{
    $storage =& get_storage();
    if ($storage !== null) {
        $storage->register_dataspace($dataspace_def);
    } else {
        global $registry;
        $registry->register($dataspace_def, MW_COMPONENT_ROLE_DELAYED_DATASPACE_REGISTRATION);
    }
}
Exemple #4
0
function import_with_check($file, $ds_name = null, $res_name = null)
{
    if ($ds_name !== null) {
        $storage =& get_storage();
        if ($storage->exists($ds_name, $res_name)) {
            show_install_message('NOT importing data from ' . $file . ', because ' . $res_name . ' exists');
            return;
        }
    }
    show_install_message('Importing data from ' . $file);
    $status = import($file);
    global $import_with_errors;
    if ($status === null) {
        trigger_error("Unable to import {$file} - is required extension missing?", E_USER_ERROR);
        $import_with_errors = true;
    } else {
        if ($status !== true) {
            trigger_error("Error occurred while importing {$file}: {$status}", E_USER_ERROR);
            $import_with_errors = true;
        }
    }
}
 function rename($new_name, $with_redirect = true)
 {
     if (empty($new_name) || $this->upload_name === $new_name) {
         return false;
     }
     $storage =& get_storage();
     return $storage->rename_resource(MW_DS_UPLOADS, $this->upload_name, $new_name);
 }
Exemple #6
0
{
    if (MW_DEBUG) {
        echo '<div class="debug">' . htmlspecialchars('DEBUG: ' . $msg, ENT_NOQUOTES), "</div>\n";
    }
}
ini_set('include_path', ini_get('include_path') . ':.');
include 'miniwiki.php';
miniwiki_boot();
$req =& get_request("MW_PageRequest");
$page = $req->get_page();
set_current_page($page);
$auth =& get_auth();
if ($auth->is_invalid()) {
    add_info_text(_t('Invalid login.'));
}
$storage =& get_storage();
if (!$auth->is_logged && $storage->requires_login()) {
    $action = get_action(MW_ACTION_LOGIN);
    $action->handle();
}
$req =& get_request("MW_ActionRequest");
$action = $req->get_action();
if ($action === null) {
    trigger_error(_t("Unknown action."), E_USER_ERROR);
}
while ($action !== null) {
    if (!$action->is_valid()) {
        trigger_error(_t("Unknown action."), E_USER_ERROR);
        break;
    } elseif (!$action->is_permitted()) {
        add_info_text(_t('Insufficient user rights. Access denied to action: %0%', _t($action->get_name())));
Exemple #7
0
 function wiki_fn_list_upload_namespaces($args, $renderer_state)
 {
     $namespace = array_shift($args);
     $storage =& get_storage();
     return $storage->get_namespaces(MW_DS_UPLOADS, $namespace);
 }
Exemple #8
0
 function export($file, $with_history = true, $dataspaces = array())
 {
     $storage =& get_storage();
     $enc = config('encoding');
     $conv_enc_from = null;
     # convert to UTF-8 if possible
     if (strcasecmp($enc, "utf-8") != 0) {
         if (function_exists("iconv")) {
             $conv_enc_from = $enc;
             $enc = "utf-8";
         }
     }
     $out = fopen($file, "wb");
     fwrite($out, '<?xml version="1.0" encoding="' . $enc . '"?>' . "\n");
     fwrite($out, '<resources>' . "\n");
     if (sizeof($dataspaces) == 0) {
         $dataspaces = $storage->get_dataspace_names();
     }
     foreach ($dataspaces as $ds) {
         explode_dataspace_name($ds, $ds, $wanted_res);
         $ds_def = $storage->get_dataspace_definition($ds);
         $types_map = array();
         /** @todo custom keys may have (currently) only text type */
         if ($ds_def->get_content_type() == MW_RESOURCE_CONTENT_TYPE_BINARY) {
             $types_map[MW_RESOURCE_KEY_CONTENT] = MW_XML_TYPE_BINARY;
         }
         $types_map[MW_RESOURCE_KEY_LAST_MODIFIED] = MW_XML_TYPE_DATETIME;
         $res_names = $storage->get_resource_names($ds);
         foreach ($res_names as $res_name) {
             if ($wanted_res !== null && strpos($res_name, $wanted_res) !== 0) {
                 continue;
             }
             if ($with_history) {
                 # we need it ordered from oldest to newest
                 $resources = array_reverse($storage->get_resource_history($ds, $res_name, true));
             } else {
                 $resources = array($storage->get_resource($ds, $res_name, null, true));
             }
             foreach ($resources as $res) {
                 show_exporting_message('Exporting ' . $res->get(MW_RESOURCE_KEY_NAME) . ' revision ' . $res->get(MW_RESOURCE_KEY_REVISION));
                 fwrite($out, '<resource dataspace="' . $ds . '" name="' . $this->convert_for_xml($conv_enc_from, $enc, $res_name) . '">' . "\n");
                 foreach ($res->data as $key => $value) {
                     $type = MW_XML_TYPE_TEXT;
                     if (isset($types_map[$key])) {
                         $type = $types_map[$key];
                     }
                     fwrite($out, '<key name="' . $this->convert_for_xml($conv_enc_from, $enc, $key) . '">');
                     switch ($type) {
                         case MW_XML_TYPE_BINARY:
                             $value = base64_encode($value);
                             break;
                         case MW_XML_TYPE_DATETIME:
                             $value = $value->format_strftime("%Y%m%dT%H%M%SZ", true);
                             break;
                     }
                     fwrite($out, $this->convert_for_xml($conv_enc_from, $enc, $value, false));
                     fwrite($out, '</key>' . "\n");
                 }
                 fwrite($out, '</resource>' . "\n");
             }
         }
     }
     fwrite($out, '</resources>' . "\n");
     fclose($out);
     return true;
 }
Exemple #9
0
 function is_password_valid($user, $pass)
 {
     $storage =& get_storage();
     $client =& $storage->get_webdav_client($user, $pass);
     return $client->check_webdav($storage->root_path);
 }
Exemple #10
0
 function _rename($new_name)
 {
     $storage =& get_storage();
     return $storage->rename_resource(MW_DS_PAGES, $this->name, $new_name);
 }