Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
86
core/formats/helix.php
Normal file
86
core/formats/helix.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
define ('URL_CLIP', 0);
|
||||
define ('URL_DIRECTORY', 1);
|
||||
|
||||
class HAuthorize {
|
||||
public $password;
|
||||
public $uuid;
|
||||
public $uuid_writeable;
|
||||
|
||||
public function __construct () {
|
||||
$this->uuid = "*";
|
||||
$this->uuid_writeable = 1;
|
||||
}
|
||||
|
||||
public function getString () {
|
||||
return "{$this->password};{$this->uuid};{$this->uuid_writeable}";
|
||||
}
|
||||
|
||||
public function setPassword ($username, $realm, $password) {
|
||||
$this->password = md5 ("$username:$realm:$password");
|
||||
}
|
||||
}
|
||||
|
||||
class HPermission {
|
||||
public $url;
|
||||
public $url_type;
|
||||
public $permission_type;
|
||||
public $expires;
|
||||
public $debitted_time;
|
||||
|
||||
public function __construct ($url, $url_type) {
|
||||
$this->url = $url;
|
||||
$this->url_type = $url_type;
|
||||
$this->expires = "*"; // MM/DD/YYYY:HH:MM:SS
|
||||
$this->permission_type = 0;
|
||||
$this->debitted_time = 0;
|
||||
}
|
||||
|
||||
public function getString () {
|
||||
return "{$this->url};{$this->url_type};{$this->permission_type};{$this->expires};{$this->debitted_time}";
|
||||
}
|
||||
}
|
||||
|
||||
class HFile {
|
||||
public $authorize;
|
||||
public $permission = array ();
|
||||
|
||||
public function addAuthorize ($name, $realm, $password) {
|
||||
$this->authorize = new HAuthorize ();
|
||||
$this->authorize->setPassword ($name, $realm, $password);
|
||||
}
|
||||
|
||||
public function addPermission ($url, $url_type) {
|
||||
$this->permission[] = new HPermission ($url, $url_type);
|
||||
}
|
||||
|
||||
public function write ($name) {
|
||||
$file = fopen ($name, 'w');
|
||||
fwrite ($file, $this->getString ());
|
||||
fclose ($file);
|
||||
}
|
||||
|
||||
public function writeFTP ($ftp, $path) {
|
||||
$file = tmpfile ();
|
||||
fwrite ($file, $this->getString ());
|
||||
fseek ($file, 0);
|
||||
|
||||
ftp_fput ($ftp, $path, $file, FTP_BINARY);
|
||||
|
||||
fclose ($file);
|
||||
}
|
||||
|
||||
public function getString () {
|
||||
$result = array ();
|
||||
$result[] = $this->authorize->getString ();
|
||||
$result[] = "\n";
|
||||
foreach ($this->permission as $p) {
|
||||
$result[] = $p->getString ();
|
||||
$result[] = "\n";
|
||||
}
|
||||
return implode ("", $result);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue