本文整理汇总了PHP中fs类的典型用法代码示例。如果您正苦于以下问题:PHP fs类的具体用法?PHP fs怎么用?PHP fs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了fs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
function write($log_file_data, $string)
{
$log_dir = $log_file_data[0];
$log_name = $log_file_data[1];
$file_name = $log_dir . $log_name;
if (!is_dir($log_dir)) {
fs::mkdir($log_dir, 0775, true);
}
$oldumask = @umask(0);
$file_existed = @file_exists($file_name);
$log_file = @fopen($file_name, 'a');
if ($log_file) {
$time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
$notice = '[ ' . $time . " ]\n";
$user =& user::instance();
if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
$notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
}
$notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
@fwrite($log_file, $notice);
@fclose($log_file);
if (!$file_existed) {
@chmod($file_name, 0664);
}
@umask($oldumask);
$result = true;
} else {
@umask($oldumask);
$result = false;
debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
}
return $result;
}
示例2: set
public static function set($autoattendant)
{
$xml = FreeSwitch::setSection('autoattendant', $autoattendant['auto_attendant_id']);
media::generateConfig($autoattendant, $xml);
if (!empty($autoattendant['extension_context_id'])) {
$xml->setAttributeValue('', 'digit-len', $autoattendant['extension_digits']);
}
$xml->setAttributeValue('', 'timeout', $autoattendant['timeout'] * 1000);
$xml->setAttributeValue('', 'inter-digit-timeout', $autoattendant['digit_timeout'] * 1000);
if (!empty($autoattendant['registry']['max-failures'])) {
$xml->setAttributeValue('', 'max-failures', $autoattendant['registry']['max-failures']);
} else {
$xml->setAttributeValue('', 'max-failures', '3');
}
$xml->deleteChildren();
if (!empty($autoattendant['extension_context_id'])) {
$xml->update(sprintf('/entry[@action="menu-exec-app"][@name="catch_all"][@digits="\\/^([0-9]{%s})$\\/"][@param="execute_extension $1 XML context_%s"]', $autoattendant['extension_digits'], $autoattendant['extension_context_id']));
}
foreach ($autoattendant['keys'] as $key) {
if (!isset($key['digits'])) {
continue;
}
if (!($transferString = fs::getTransferToNumber($key['number_id']))) {
continue;
}
$xml->update(sprintf('/entry[@action="menu-exec-app"][@digits="%s"][@param="transfer %s"]', $key['digits'], $transferString));
}
}
示例3: _clean_up
function _clean_up()
{
parent::_clean_up();
fs::rm(MEDIA_DIR);
$this->db->sql_delete('file_object');
$this->db->sql_delete('media');
}
示例4: _add_project_controllers
function _add_project_controllers(&$result)
{
$items = fs::find_subitems(PROJECT_DIR . '/core/controllers/', 'f', '', false);
sort($items);
foreach ($items as $item) {
$class = $this->_clean_class_path($item);
$result[$class] = $class;
}
}
示例5: _get_ini_cache_size
function _get_ini_cache_size()
{
$size = 0;
$files = fs :: find_subitems(CACHE_DIR, 'f');
foreach($files as $file)
$size += filesize($file);
return $size;
}
示例6: _get_directory_file_size
function _get_directory_file_size($dir)
{
$size = 0;
$files = fs :: find($dir, 'f');
foreach($files as $file)
$size += filesize($file);
return $size;
}
示例7: actionOperation
public function actionOperation()
{
Yii::import('mod.core.components.fs');
if (isset($_GET['operation'])) {
//$fs = new fs(dirname(__FILE__) . DS . 'data' . DS . 'root' . DS);
$fs = new fs(Yii::getPathOfAlias('webroot.themes'));
try {
$rslt = null;
switch ($_GET['operation']) {
case 'get_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$rslt = $fs->lst($node, isset($_GET['id']) && $_GET['id'] === '#');
break;
case "get_content":
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$rslt = $fs->data($node);
break;
case 'create_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$rslt = $fs->create($node, isset($_GET['text']) ? $_GET['text'] : '', !isset($_GET['type']) || $_GET['type'] !== 'file');
break;
case 'rename_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$rslt = $fs->rename($node, isset($_GET['text']) ? $_GET['text'] : '');
break;
case 'delete_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$rslt = $fs->remove($node);
break;
case 'move_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
$rslt = $fs->move($node, $parn);
break;
case 'copy_node':
$node = isset($_GET['id']) && $_GET['id'] !== '#' ? $_GET['id'] : '/';
$parn = isset($_GET['parent']) && $_GET['parent'] !== '#' ? $_GET['parent'] : '/';
$rslt = $fs->copy($node, $parn);
break;
default:
throw new Exception('Unsupported operation: ' . $_GET['operation']);
break;
}
header('Content-Type: application/json; charset=utf-8');
echo json_encode($rslt);
} catch (Exception $e) {
header($_SERVER["SERVER_PROTOCOL"] . ' 500 Server Error');
header('Status: 500 Server Error');
echo $e->getMessage();
}
die;
}
}
示例8: write_template_file
/**
* Writes a compiled template file
*
* @param string $ filename
* @param string $ content to write to the file
* @return void
* @access protected
*/
function write_template_file($file, $data)
{
if (!is_dir(dirname($file))) {
fs::mkdir(dirname($file), 0777, true);
}
$fp = fopen($file, "wb");
if (fwrite($fp, $data, strlen($data))) {
fclose($fp);
}
}
示例9: _add_project_site_objects
function _add_project_site_objects(&$result)
{
$items = fs :: find_subitems(PROJECT_DIR . '/core/model/site_objects/', 'f', '', false);
foreach($items as $item)
{
$class = $this->_clean_class_path($item);
$result[$class] = $class;
}
}
示例10: perform
function perform(&$request, &$response)
{
$files = fs :: find(VAR_DIR . '/compiled', 'f');
foreach($files as $file)
unlink($file);
if($request->has_attribute('popup'))
$response->write(close_popup_response($request));
$request->set_status(REQUEST_STATUS_SUCCESS);
}
示例11: get_classes_list
function get_classes_list()
{
$contents = array_merge(fs::ls(LIMB_DIR . '/core/model/site_objects/'), fs::ls(PROJECT_DIR . '/core/model/site_objects/'));
$classes_list = array();
foreach ($contents as $file_name) {
if (substr($file_name, -10, 10) == '.class.php') {
$classes_list[] = substr($file_name, 0, strpos($file_name, '.'));
}
}
return $classes_list;
}
示例12: perform
function perform(&$request, &$response)
{
$files = fs::find_subitems(CACHE_DIR, 'f');
foreach ($files as $file) {
unlink($file);
}
if ($request->has_attribute('popup')) {
$response->write(close_popup_response($request));
}
$request->set_status(REQUEST_STATUS_SUCCESS);
}
示例13: register
/**
* Register module
* @throws modules_exception
* @return object|bool module
*/
public function register($module)
{
core::dprint('[mod_register] ' . $module);
$module_class = loader::CLASS_PREFIX . $module;
$module_path = loader::get_root() . loader::DIR_MODULES . $module . '/';
$module_file = $module_path . 'module' . loader::DOT_PHP;
if (!fs::file_exists($module_file)) {
throw new modules_exception('Failed to register module ' . $module . '. File does not exists');
}
require_once $module_file;
$this->set($module, new $module_class($module_path));
return $this->get($module);
}
示例14: set
public static function set($autoattendant)
{
$xml = FreeSwitch::setSection('autoattendant', $autoattendant['auto_attendant_id']);
if (empty($autoattendant['registry']['mediafile_id']) or !class_exists('Media')) {
$type = 'tty';
} else {
$type = $autoattendant['registry']['type'];
}
switch ($type) {
case 'audio':
$xml->setAttributeValue('', 'greet-long', Media::getMediaFile($autoattendant['registry']['mediafile_id']));
$xml->setAttributeValue('', 'greet-short', Media::getMediaFile($autoattendant['registry']['mediafile_id']));
break;
default:
if (empty($autoattendant['registry']['tts_string'])) {
$tts_string = 'Thank you for calling, your call is important to us.';
} else {
$tts_string = $autoattendant['registry']['tts_string'];
}
$tts_string = 'say:' . preg_replace('/[^A-Za-z0-9.,!? ]/', '', $tts_string);
$xml->setAttributeValue('', 'tts-engine', 'flite');
$xml->setAttributeValue('', 'tts-voice', 'kal');
$xml->setAttributeValue('', 'greet-long', $tts_string);
$xml->setAttributeValue('', 'greet-short', $tts_string);
}
if (!empty($autoattendant['extension_context_id'])) {
$xml->setAttributeValue('', 'digit-len', $autoattendant['extension_digits']);
}
$xml->setAttributeValue('', 'timeout', $autoattendant['timeout'] * 1000);
$xml->setAttributeValue('', 'inter-digit-timeout', $autoattendant['digit_timeout'] * 1000);
if (!empty($autoattendant['registry']['max-failures'])) {
$xml->setAttributeValue('', 'max-failures', $autoattendant['registry']['max-failures']);
} else {
$xml->setAttributeValue('', 'max-failures', '3');
}
$xml->deleteChildren();
if (!empty($autoattendant['extension_context_id'])) {
$xml->update(sprintf('/entry[@action="menu-exec-app"][@name="catch_all"][@digits="\\/^([0-9]{%s})$\\/"][@param="execute_extension $1 XML context_%s"]', $autoattendant['extension_digits'], $autoattendant['extension_context_id']));
}
foreach ($autoattendant['keys'] as $key) {
if (!isset($key['digits'])) {
continue;
}
if (!($transferString = fs::getTransferToNumber($key['number_id']))) {
continue;
}
$xml->update(sprintf('/entry[@action="menu-exec-app"][@digits="%s"][@param="transfer %s"]', $key['digits'], $transferString));
}
}
示例15: clear_static
function clear_static()
{
if (!$this->get_domain()) {
return false;
}
$root = core::module('sat')->get_static_root($this);
$data = array();
fs::build_tree($root, $data);
foreach ($data['files'] as $f) {
fs::unlink($f);
}
$data['dirs'] = array_reverse($data['dirs']);
foreach ($data['dirs'] as $f) {
fs::unlink($f, true);
}
}