コード例 #1
0
ファイル: users_mgr.ext.php プロジェクト: SnowyYANG/miniwiki
 function change_password($user, $pass)
 {
     $storage =& get_storage();
     $res = new MW_Resource(MW_DS_USERS);
     $res->set(MW_RESOURCE_KEY_NAME, $user);
     $md5_pass = md5($pass);
     $res->set(MW_RESOURCE_KEY_PASSWORD, $md5_pass);
     $storage->update_resource(MW_DS_USERS, $res);
 }
コード例 #2
0
 function update($content, $message)
 {
     $storage =& get_storage();
     $auth =& get_auth();
     $this->user = $auth->user;
     $this->revision = MW_REVISION_HEAD;
     $res = new MW_Resource(MW_DS_UPLOADS);
     $res->set(MW_RESOURCE_KEY_NAME, $this->upload_name);
     $res->set(MW_RESOURCE_KEY_CONTENT, $content);
     $res->set(MW_RESOURCE_KEY_MESSAGE, $message);
     $res->set(MW_RESOURCE_KEY_AUTHOR, $this->user);
     $storage->update_resource(MW_DS_UPLOADS, $res);
     $this->load();
     return true;
 }
コード例 #3
0
ファイル: filesystem.ext.php プロジェクト: SnowyYANG/miniwiki
 function get_resource($dataspace, $name, $revision, $with_data)
 {
     if ($this->is_forbidden_name($name)) {
         return null;
     }
     $path = $this->get_path_for_resource_name($dataspace, $name);
     if (!is_file($path)) {
         return null;
     }
     $ds_def = $this->dataspace_defs[$dataspace];
     $has_content = $ds_def->get_content_type() != MW_RESOURCE_CONTENT_TYPE_NONE;
     $is_versioned = $ds_def->is_versioned();
     $res = new MW_Resource($dataspace);
     $this->lock_read();
     # custom keys are only for non-content dataspaces
     if (!$has_content) {
         # format of custom keys file is:
         # # ignored...
         # NAME
         #  VALUE (starts with space)
         #  VALUE (dtto)
         # NAME
         # ...
         $handle = fopen($path, "r");
         if ($handle) {
             $curname = null;
             $curvalue = null;
             while (!feof($handle)) {
                 $line = rtrim(fgets($handle, 4096), "\n\r");
                 if (strpos($line, '#') === 0) {
                     continue;
                 }
                 if (strpos($line, ' ') === 0) {
                     if ($curvalue !== null) {
                         $curvalue .= "\n";
                     }
                     $curvalue .= substr($line, 1);
                 } else {
                     if ($curname !== null) {
                         $res->set($curname, $curvalue);
                     }
                     $curname = $line;
                 }
             }
             if ($curname !== null) {
                 $res->set($curname, $curvalue);
             }
             fclose($handle);
         }
     }
     if ($has_content) {
         if ($with_data) {
             $res->set(MW_RESOURCE_KEY_CONTENT, file_get_contents($path));
         }
         $res->set(MW_RESOURCE_KEY_CONTENT_LENGTH, filesize($path));
     }
     $res->set(MW_RESOURCE_KEY_LAST_MODIFIED, new MW_FilesystemDateTime(filemtime($path)));
     $res->set(MW_RESOURCE_KEY_NAME, $name);
     $this->unlock();
     return $res;
 }
コード例 #4
0
ファイル: mysql.ext.php プロジェクト: SnowyYANG/miniwiki
 /** @private */
 function &create_resource_object_from_result($dataspace, &$result)
 {
     $res = new MW_Resource($dataspace);
     foreach ($result as $key => $value) {
         if (!is_int($key)) {
             if ($key === MW_RESOURCE_KEY_LAST_MODIFIED) {
                 $value = new MW_MySQLDateTime($value);
             }
             $res->set($key, $value);
         }
     }
     return $res;
 }
コード例 #5
0
ファイル: webdav.ext.php プロジェクト: SnowyYANG/miniwiki
 function get_resource($dataspace, $name, $revision, $with_data)
 {
     if ($this->is_forbidden_name($name)) {
         return null;
     }
     $path = $this->get_path_for_resource_name($dataspace, $name);
     $client =& $this->get_current_webdav_client();
     $item = $client->gpi($path);
     if ($item === false) {
         return null;
     }
     if (isset($item['resourcetype']) && $item['resourcetype'] == 'collection') {
         return null;
     }
     $ds_def = $this->get_dataspace_definition($dataspace);
     if ($ds_def === null) {
         return null;
     }
     $is_versioned = $ds_def->is_versioned();
     $res = new MW_Resource($dataspace);
     if ($with_data) {
         $data = '';
         if (!$this->is_success($client->get($path, $data))) {
             return null;
         }
         $res->set(MW_RESOURCE_KEY_CONTENT, $data);
     }
     $res->set(MW_RESOURCE_KEY_CONTENT_LENGTH, $item['getcontentlength']);
     $res->set(MW_RESOURCE_KEY_LAST_MODIFIED, new MW_WebDAVDateTime($item['lastmodified']));
     $res->set(MW_RESOURCE_KEY_NAME, $name);
     return $res;
 }
コード例 #6
0
ファイル: page.ext.php プロジェクト: SnowyYANG/miniwiki
 function update($content, $message)
 {
     $this->load();
     if ($this->has_content && $this->raw_content == $content) {
         return false;
     }
     $storage =& get_storage();
     $auth =& get_auth();
     $this->user = $auth->user;
     $this->revision = MW_REVISION_HEAD;
     $res = new MW_Resource(MW_DS_PAGES);
     $res->set(MW_RESOURCE_KEY_NAME, $this->name);
     $res->set(MW_RESOURCE_KEY_CONTENT, $content);
     $res->set(MW_RESOURCE_KEY_MESSAGE, $message);
     $res->set(MW_RESOURCE_KEY_AUTHOR, $this->user);
     $storage->update_resource(MW_DS_PAGES, $res);
     $this->load();
     return true;
 }