本文整理汇总了PHP中file_delete_local函数的典型用法代码示例。如果您正苦于以下问题:PHP file_delete_local函数的具体用法?PHP file_delete_local怎么用?PHP file_delete_local使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了file_delete_local函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: plugins_releasemgt_file_delete
function plugins_releasemgt_file_delete($p_file_id)
{
$t_upload_method = plugin_config_get('upload_method', UPLOAD_METHOD_DEFAULT);
$c_file_id = db_prepare_int($p_file_id);
$t_filename = plugins_releasemgt_file_get_field($p_file_id, 'filename');
$t_diskfile = plugins_releasemgt_file_get_field($p_file_id, 'diskfile');
if (DISK == $t_upload_method || FTP == $t_upload_method) {
if (FTP == $t_upload_method) {
$ftp = plugins_releasemgt_file_ftp_connect();
file_ftp_delete($ftp, $t_diskfile);
file_ftp_disconnect($ftp);
}
if (file_exists($t_diskfile)) {
file_delete_local($t_diskfile);
}
}
$t_file_table = plugin_table('file');
$query = "DELETE FROM {$t_file_table}\n\t\t\t\tWHERE id='{$c_file_id}'";
db_query($query);
return true;
}
开发者ID:jhron,项目名称:mantis-releasemgt,代码行数:21,代码来源:releasemgt_api.php
示例2: mci_file_add
function mci_file_add($p_id, $p_name, $p_content, $p_file_type, $p_table, $p_title = '', $p_desc = '', $p_user_id = null)
{
if (!file_type_check($p_name)) {
return new soap_fault('Client', '', 'File type not allowed.');
}
if (!file_is_name_unique($p_name, $p_id)) {
return new soap_fault('Client', '', 'Duplicate filename.');
}
$t_file_size = strlen($p_content);
$t_max_file_size = (int) min(ini_get_number('upload_max_filesize'), ini_get_number('post_max_size'), config_get('max_file_size'));
if ($t_file_size > $t_max_file_size) {
return new soap_fault('Client', '', 'File is too big.');
}
if ('bug' == $p_table) {
$t_project_id = bug_get_field($p_id, 'project_id');
$t_issue_id = bug_format_id($p_id);
} else {
$t_project_id = $p_id;
$t_issue_id = 0;
}
# prepare variables for insertion
$c_issue_id = db_prepare_int($t_issue_id);
$c_project_id = db_prepare_int($t_project_id);
$c_file_type = db_prepare_string($p_file_type);
$c_title = db_prepare_string($p_title);
$c_desc = db_prepare_string($p_desc);
if ($p_user_id === null) {
$c_user_id = auth_get_current_user_id();
} else {
$c_user_id = (int) $p_user_id;
}
if ($t_project_id == ALL_PROJECTS) {
$t_file_path = config_get('absolute_path_default_upload_folder');
} else {
$t_file_path = project_get_field($t_project_id, 'file_path');
if ($t_file_path == '') {
$t_file_path = config_get('absolute_path_default_upload_folder');
}
}
$c_file_path = db_prepare_string($t_file_path);
$c_new_file_name = db_prepare_string($p_name);
$t_file_hash = $t_issue_id;
$t_disk_file_name = $t_file_path . file_generate_unique_name($t_file_hash . '-' . $p_name, $t_file_path);
$c_disk_file_name = db_prepare_string($t_disk_file_name);
$t_file_size = strlen($p_content);
$c_file_size = db_prepare_int($t_file_size);
$t_method = config_get('file_upload_method');
switch ($t_method) {
case FTP:
case DISK:
if (!file_exists($t_file_path) || !is_dir($t_file_path) || !is_writable($t_file_path) || !is_readable($t_file_path)) {
return new soap_fault('Server', '', "Upload folder '{$t_file_path}' doesn't exist.");
}
file_ensure_valid_upload_path($t_file_path);
if (!file_exists($t_disk_file_name)) {
mci_file_write_local($t_disk_file_name, $p_content);
if (FTP == $t_method) {
$conn_id = file_ftp_connect();
file_ftp_put($conn_id, $t_disk_file_name, $t_disk_file_name);
file_ftp_disconnect($conn_id);
file_delete_local($t_disk_file_name);
} else {
chmod($t_disk_file_name, config_get('attachments_file_permissions'));
}
$c_content = "''";
}
break;
case DATABASE:
$c_content = db_prepare_binary_string($p_content);
break;
}
$t_file_table = db_get_table($p_table . '_file');
$c_id = 'bug' == $p_table ? $c_issue_id : $c_project_id;
$query = "INSERT INTO {$t_file_table}\n\t\t\t(" . $p_table . "_id, title, description, diskfile, filename, folder, filesize, file_type, date_added, content, user_id)\n\t\tVALUES\n\t\t\t({$c_id}, '{$c_title}', '{$c_desc}', '{$c_disk_file_name}', '{$c_new_file_name}', '{$c_file_path}', {$c_file_size}, '{$c_file_type}', '" . db_now() . "', {$c_content}, {$c_user_id})";
db_query($query);
# get attachment id
$t_attachment_id = db_insert_id($t_file_table);
if ('bug' == $p_table) {
# updated the last_updated date
$result = bug_update_date($c_issue_id);
# log new bug
history_log_event_special($c_issue_id, FILE_ADDED, $c_new_file_name);
}
return $t_attachment_id;
}
开发者ID:nextgens,项目名称:mantisbt,代码行数:85,代码来源:mc_file_api.php
示例3: trigger_error
trigger_error(ERROR_FILE_TOO_BIG, ERROR);
}
$c_file_size = db_prepare_int($t_file_size);
$t_method = config_get('file_upload_method');
switch ($t_method) {
case FTP:
case DISK:
file_ensure_valid_upload_path($t_file_path);
if (FTP == $t_method) {
$conn_id = file_ftp_connect();
file_ftp_delete($conn_id, $t_disk_file_name);
file_ftp_put($conn_id, $t_disk_file_name, $v_tmp_name);
file_ftp_disconnect($conn_id);
}
if (file_exists($t_disk_file_name)) {
file_delete_local($t_disk_file_name);
}
if (!move_uploaded_file($v_tmp_name, $t_disk_file_name)) {
trigger_error(ERROR_FILE_MOVE_FAILED, ERROR);
}
chmod($t_disk_file_name, config_get('attachments_file_permissions'));
$c_content = '';
break;
case DATABASE:
$c_content = db_prepare_binary_string(fread(fopen($v_tmp_name, 'rb'), $v_size));
break;
default:
/** @todo Such errors should be checked in the admin checks */
trigger_error(ERROR_GENERIC, ERROR);
}
$query = "UPDATE {$t_project_file_table}\n\t\t\tSET title=" . db_param() . ", description=" . db_param() . ", date_added=" . db_param() . ",\n\t\t\t\tfilename=" . db_param() . ", filesize=" . db_param() . ", file_type=" . db_param() . ", content=" . db_param() . "\n\t\t\t\tWHERE id=" . db_param();
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:31,代码来源:proj_doc_update.php
示例4: file_move_bug_attachments
/**
* Move any attachments as needed when a bug is moved from project to project.
*
* @param integer $p_bug_id ID of bug containing attachments to be moved.
* @param integer $p_project_id_to Destination project ID for the bug.
* @return void
*
* @todo: this function can't cope with source or target storing attachments in DB
*/
function file_move_bug_attachments($p_bug_id, $p_project_id_to)
{
$t_project_id_from = bug_get_field($p_bug_id, 'project_id');
if ($t_project_id_from == $p_project_id_to) {
return;
}
$t_method = config_get('file_upload_method');
if ($t_method != DISK) {
return;
}
if (!file_bug_has_attachments($p_bug_id)) {
return;
}
$t_path_from = project_get_field($t_project_id_from, 'file_path');
if (is_blank($t_path_from)) {
$t_path_from = config_get('absolute_path_default_upload_folder', null, null, $t_project_id_from);
}
file_ensure_valid_upload_path($t_path_from);
$t_path_to = project_get_field($p_project_id_to, 'file_path');
if (is_blank($t_path_to)) {
$t_path_to = config_get('absolute_path_default_upload_folder', null, null, $p_project_id_to);
}
file_ensure_valid_upload_path($t_path_to);
if ($t_path_from == $t_path_to) {
return;
}
# Initialize the update query to update a single row
$c_bug_id = (int) $p_bug_id;
$t_query_disk_attachment_update = 'UPDATE {bug_file}
SET folder=' . db_param() . '
WHERE bug_id=' . db_param() . '
AND id =' . db_param();
$t_attachment_rows = bug_get_attachments($p_bug_id);
$t_attachments_count = count($t_attachment_rows);
for ($i = 0; $i < $t_attachments_count; $i++) {
$t_row = $t_attachment_rows[$i];
$t_basename = basename($t_row['diskfile']);
$t_disk_file_name_from = file_path_combine($t_path_from, $t_basename);
$t_disk_file_name_to = file_path_combine($t_path_to, $t_basename);
if (!file_exists($t_disk_file_name_to)) {
chmod($t_disk_file_name_from, 0775);
if (!rename($t_disk_file_name_from, $t_disk_file_name_to)) {
if (!copy($t_disk_file_name_from, $t_disk_file_name_to)) {
trigger_error(ERROR_FILE_MOVE_FAILED, ERROR);
}
file_delete_local($t_disk_file_name_from);
}
chmod($t_disk_file_name_to, config_get('attachments_file_permissions'));
db_query($t_query_disk_attachment_update, array(db_prepare_string($t_path_to), $c_bug_id, (int) $t_row['id']));
} else {
trigger_error(ERROR_FILE_DUPLICATE, ERROR);
}
}
}
开发者ID:martijnveen,项目名称:mantisbt,代码行数:63,代码来源:file_api.php
示例5: file_delete
function file_delete($p_file_id, $p_table = 'bug')
{
$t_upload_method = config_get('file_upload_method');
$c_file_id = db_prepare_int($p_file_id);
$t_filename = file_get_field($p_file_id, 'filename', $p_table);
$t_diskfile = file_get_field($p_file_id, 'diskfile', $p_table);
if ($p_table == 'bug') {
$t_bug_id = file_get_field($p_file_id, 'bug_id', $p_table);
$t_project_id = bug_get_field($t_bug_id, 'project_id');
} else {
$t_project_id = file_get_field($p_file_id, 'project_id', $p_table);
}
if (DISK == $t_upload_method || FTP == $t_upload_method) {
if (FTP == $t_upload_method) {
$ftp = file_ftp_connect();
file_ftp_delete($ftp, $t_diskfile);
file_ftp_disconnect($ftp);
}
$t_local_disk_file = file_normalize_attachment_path($t_diskfile, $t_project_id);
if (file_exists($t_local_disk_file)) {
file_delete_local($t_local_disk_file);
}
}
if ('bug' == $p_table) {
# log file deletion
history_log_event_special($t_bug_id, FILE_DELETED, file_get_display_name($t_filename));
}
$t_file_table = db_get_table('mantis_' . $p_table . '_file_table');
$query = "DELETE FROM {$t_file_table}\n\t\t\t\tWHERE id=" . db_param();
db_query_bound($query, array($c_file_id));
return true;
}
开发者ID:nourchene-benslimane,项目名称:mantisV0,代码行数:32,代码来源:file_api.php
示例6: file_delete
function file_delete($p_file_id, $p_table = 'bug')
{
$t_upload_method = config_get('file_upload_method');
$c_file_id = db_prepare_int($p_file_id);
$t_filename = file_get_field($p_file_id, 'filename', $p_table);
$t_diskfile = file_get_field($p_file_id, 'diskfile', $p_table);
if (DISK == $t_upload_method || FTP == $t_upload_method) {
if (FTP == $t_upload_method) {
$ftp = file_ftp_connect();
file_ftp_delete($ftp, $t_diskfile);
file_ftp_disconnect($ftp);
}
if (file_exists($t_diskfile)) {
file_delete_local($t_diskfile);
}
}
if ('bug' == $p_table) {
# log file deletion
$t_bug_id = file_get_field($p_file_id, 'bug_id', 'bug');
history_log_event_special($t_bug_id, FILE_DELETED, file_get_display_name($t_filename));
}
$t_file_table = config_get('mantis_' . $p_table . '_file_table');
$query = "DELETE FROM {$t_file_table}\n\t\t\t\tWHERE id='{$c_file_id}'";
db_query($query);
return true;
}
开发者ID:centaurustech,项目名称:BenFund,代码行数:26,代码来源:file_api.php
注:本文中的file_delete_local函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论