本文整理汇总了PHP中WPFB_Core::UploadDir方法的典型用法代码示例。如果您正苦于以下问题:PHP WPFB_Core::UploadDir方法的具体用法?PHP WPFB_Core::UploadDir怎么用?PHP WPFB_Core::UploadDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPFB_Core
的用法示例。
在下文中一共展示了WPFB_Core::UploadDir方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetEngine
static function GetEngine()
{
if (!self::$engine) {
if (!class_exists('getID3')) {
$tmp_dir = WPFB_Core::UploadDir() . '/.tmp';
if (!is_dir($tmp_dir)) {
@mkdir($tmp_dir);
}
define('GETID3_TEMP_DIR', $tmp_dir . '/');
unset($tmp_dir);
require_once WPFB_PLUGIN_ROOT . 'extras/getid3/getid3.php';
}
self::$engine = new getID3();
}
return self::$engine;
}
示例2: __construct
function __construct()
{
wpfb_loadclass('Download', 'Admin');
$dir = WPFB_Core::UploadDir() . '/.tmp/';
WPFB_Admin::Mkdir($dir);
$test_files = array('banner.png' => 'https://wpfilebase.com/wp-content/blogs.dir/2/files/2015/03/banner_023.png', 'small.txt' => 'https://wpfilebase.com/robots.txt');
$this->local_files = array();
foreach ($test_files as $f => $u) {
$fn = $dir . $f;
$this->local_files[$f] = $fn;
if (file_exists($fn)) {
continue;
}
echo "Downloading test file {$u}\n";
WPFB_Download::SideloadFile($u, $fn);
}
}
示例3: OnDeactivate
static function OnDeactivate()
{
wp_clear_scheduled_hook(WPFB . '_cron');
self::UnProtectUploadPath();
$sync_data_file = WPFB_Core::UploadDir() . '/._sync.data';
is_file($sync_data_file) && unlink($sync_data_file);
//delete_option('wpfilebase_dismiss_support_ending');
delete_option('wpfb_license_nag');
if (get_option('wpfb_uninstall')) {
self::RemoveOptions();
self::DropDBTables();
self::RemoveTpls();
delete_option('wpfilebase_cron_sync_time');
delete_option('wpfilebase_cron_sync_stats');
delete_option('wpfb_license_key');
delete_option('wpfilebase_last_check');
delete_option('wpfilebase_forms');
delete_option('wpfilebase_ftags');
delete_option('wpfilebase_rsyncs');
delete_option('wpfb_uninstall');
delete_option('wpfilebase_dismiss_support_ending');
}
}
示例4: GetThumbPath
function GetThumbPath($refresh = false)
{
static $base_dir = '';
if (empty($base_dir) || $refresh) {
$base_dir = (empty(WPFB_Core::$settings->thumbnail_path) ? WPFB_Core::UploadDir() : path_join(ABSPATH, WPFB_Core::$settings->thumbnail_path)) . '/';
}
if ($this->is_file) {
if (empty($this->file_thumbnail)) {
return null;
}
return dirname($base_dir . $this->GetLocalPathRel()) . '/' . $this->file_thumbnail;
} else {
if (empty($this->cat_icon)) {
return null;
}
return $base_dir . $this->GetLocalPathRel() . '/' . $this->cat_icon;
}
}
示例5: Chmod
static function Chmod($base_dir, $files)
{
$result = array();
$upload_dir = self::cleanPath(WPFB_Core::UploadDir());
$upload_dir_len = strlen($upload_dir);
// chmod
if (is_writable($upload_dir)) {
@chmod($upload_dir, octdec(WPFB_PERM_DIR));
}
for ($i = 0; $i < count($files); $i++) {
$f = "{$base_dir}/" . $files[$i];
if (file_exists($f)) {
@chmod($f, octdec(WPFB_PERM_FILE));
if (!is_writable($f) && !is_writable(dirname($f))) {
$result[] = sprintf(__('File <b>%s</b> is not writable!', WPFB), substr($f, $upload_dir_len));
}
}
}
return $result;
}
示例6: UploadDirIsLocked
static function UploadDirIsLocked()
{
$f = WPFB_Core::UploadDir() . '/.lock';
return file_exists($f) && time() - filemtime($f) < 120;
// max lock for 120 seconds without update!
}
示例7: ProtectUploadPath
static function ProtectUploadPath()
{
$htaccess = self::UnProtectUploadPath();
if (WPFB_Core::$settings->protect_upload_path && is_writable(WPFB_Core::UploadDir()) && ($fp = @fopen($htaccess, 'w'))) {
@fwrite($fp, "Order deny,allow\n");
@fwrite($fp, "Deny from all\n");
@fclose($fp);
return @chmod($htaccess, octdec(WPFB_PERM_FILE));
}
return false;
}
示例8: Display
static function Display()
{
global $wpdb, $user_ID;
//register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
wpfb_loadclass('File', 'Category', 'Admin', 'Output');
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
$clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync', 'doit', 'ids', 'files', 'cats', 'batch_sync'));
// keep search keyword
// switch simple/extended form
if (isset($_GET['exform'])) {
$exform = !empty($_GET['exform']) && $_GET['exform'] == 1;
update_user_option($user_ID, WPFB_OPT_NAME . '_exform', $exform, true);
} else {
$exform = (bool) get_user_option(WPFB_OPT_NAME . '_exform');
}
if (!empty($_GET['wpfb-hide-how-start'])) {
update_user_option($user_ID, WPFB_OPT_NAME . '_hide_how_start', 1);
}
$show_how_start = !(bool) get_user_option(WPFB_OPT_NAME . '_hide_how_start');
WPFB_Admin::PrintFlattrHead();
?>
<script type="text/javascript">
/* Liking/Donate Bar */
if(typeof(jQuery) != 'undefined') {
jQuery(document).ready(function(){
if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
jQuery('#wpfb-liking').hide();
jQuery('#wpfb-liking-toggle').addClass('closed');
}
jQuery('#wpfb-liking-toggle').click(function(){
jQuery('#wpfb-liking').slideToggle();
jQuery(this).toggleClass('closed');
setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
});
});
}
</script>
<div class="wrap">
<div id="icon-wpfilebase" class="icon32"><br /></div>
<h2><?php
echo WPFB_PLUGIN_NAME;
?>
</h2>
<?php
if ($show_how_start) {
wpfb_call('AdminHowToStart', 'Display');
}
if (!empty($_GET['action'])) {
echo '<p><a href="' . $clean_uri . '" class="button">' . __('Go back') . '</a></p>';
}
switch ($action) {
default:
$clean_uri = remove_query_arg('pagenum', $clean_uri);
$upload_dir = WPFB_Core::UploadDir();
$upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
$chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
if (!is_dir($upload_dir)) {
$result = WPFB_Admin::Mkdir($upload_dir);
if ($result['error']) {
$error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', WPFB), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
} else {
wpfb_call('Setup', 'ProtectUploadPath');
}
} elseif (!is_writable($upload_dir)) {
$error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', WPFB), $upload_dir_rel, $chmod_cmd);
}
if (!empty($error_msg)) {
echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
}
if (!empty(WPFB_Core::$settings->tag_conv_req)) {
echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
_e('WP-Filebase content tags must be converted', WPFB);
echo '</a></p></div><div style="clear:both;"></div>';
}
if (!get_post(WPFB_Core::$settings->file_browser_post_id)) {
echo '<div class="updated"><p>';
printf(__('File Browser post or page not set! Some features like search will not work. <a href="%s">Click here to set the File Browser Post ID.</a>', WPFB), esc_attr(admin_url('admin.php?page=wpfilebase_sets#' . sanitize_title(__('File Browser', WPFB)))));
echo '</p></div><div style="clear:both;"></div>';
}
/*
wpfb_loadclass('Config');
if(!WPFB_Config::IsWritable()) {
echo '<div class="updated"><p>';
printf(__('The config file %s is not writable or could not be created. Please create the file and make it writable for the webserver.',WPFB), WPFB_Config::$file);
echo '</p></div><div style="clear:both;"></div>';
}
*/
?>
<?php
if (self::PluginHasBeenUsedAWhile(true)) {
self::ProUpgradeNag();
}
if (self::PluginHasBeenUsedAWhile()) {
?>
//.........这里部分代码省略.........
示例9: Display
static function Display()
{
global $wpdb, $user_ID;
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
wpfb_loadclass('AdminDashboard');
add_thickbox();
wp_enqueue_script('dashboard');
if (wp_is_mobile()) {
wp_enqueue_script('jquery-touch-punch');
}
//register_shutdown_function( create_function('','$error = error_get_last(); if( $error && $error[\'type\'] != E_STRICT ){print_r( $error );}else{return true;}') );
wpfb_loadclass('File', 'Category', 'Admin', 'Output');
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$action = !empty($_POST['action']) ? $_POST['action'] : (!empty($_GET['action']) ? $_GET['action'] : '');
$clean_uri = remove_query_arg(array('message', 'action', 'file_id', 'cat_id', 'deltpl', 'hash_sync', 'doit', 'ids', 'files', 'cats', 'batch_sync'));
// keep search keyword
WPFB_Admin::PrintFlattrHead();
?>
<script type="text/javascript">
/* Liking/Donate Bar */
if(typeof(jQuery) != 'undefined') {
jQuery(document).ready(function(){
if(getUserSetting("wpfilebase_hidesuprow",false) == 1) {
jQuery('#wpfb-liking').hide();
jQuery('#wpfb-liking-toggle').addClass('closed');
}
jQuery('#wpfb-liking-toggle').click(function(){
jQuery('#wpfb-liking').slideToggle();
jQuery(this).toggleClass('closed');
setUserSetting("wpfilebase_hidesuprow", 1-getUserSetting("wpfilebase_hidesuprow",false), 0);
});
});
}
</script>
<div class="wrap">
<div id="icon-wpfilebase" class="icon32"><br /></div>
<h2><?php
echo WPFB_PLUGIN_NAME;
?>
</h2>
<?php
switch ($action) {
default:
$clean_uri = remove_query_arg('pagenum', $clean_uri);
$upload_dir = WPFB_Core::UploadDir();
$upload_dir_rel = str_replace(ABSPATH, '', $upload_dir);
$chmod_cmd = "CHMOD " . WPFB_PERM_DIR . " " . $upload_dir_rel;
if (!is_dir($upload_dir)) {
$result = WPFB_Admin::Mkdir($upload_dir);
if ($result['error']) {
$error_msg = sprintf(__('The upload directory <code>%s</code> does not exists. It could not be created automatically because the directory <code>%s</code> is not writable. Please create <code>%s</code> and make it writable for the webserver by executing the following FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, str_replace(ABSPATH, '', $result['parent']), $upload_dir_rel, $chmod_cmd);
} else {
wpfb_call('Setup', 'ProtectUploadPath');
}
} elseif (!is_writable($upload_dir)) {
$error_msg = sprintf(__('The upload directory <code>%s</code> is not writable. Please make it writable for PHP by executing the follwing FTP command: <code>%s</code>', 'wp-filebase'), $upload_dir_rel, $chmod_cmd);
}
if (!empty($error_msg)) {
echo '<div class="error default-password-nag"><p>' . $error_msg . '</p></div>';
}
if (!empty(WPFB_Core::$settings->tag_conv_req)) {
echo '<div class="updated"><p><a href="' . add_query_arg('action', 'convert-tags') . '">';
_e('WP-Filebase content tags must be converted', 'wp-filebase');
echo '</a></p></div><div style="clear:both;"></div>';
}
?>
<?php
if (self::PluginHasBeenUsedAWhile(true)) {
self::ProUpgradeNag();
}
if (self::PluginHasBeenUsedAWhile()) {
?>
<div id="wpfb-support-col">
<div id="wpfb-liking-toggle"></div>
<h3><?php
_e('Like WP-Filebase?', 'wp-filebase');
?>
</h3>
<div id="wpfb-liking">
<!-- <div style="text-align: center;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwordpress.org%2Fextend%2Fplugins%2Fwp-filebase%2F&send=false&layout=button_count&width=150&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:140px; height:21px; display:inline-block; text-align:center;" <?php
echo ' allowTransparency="true"';
?>
></iframe></div> -->
<div style="text-align: center;" ><a href="https://twitter.com/wpfilebase" class="twitter-follow-button" data-show-count="false">Follow @wpfilebase</a>
<script type="text/javascript">!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
<p>Please <a href="http://wordpress.org/support/view/plugin-reviews/wp-filebase">give it a good rating</a>.</p>
<p>For Cloud support and lots of other advanced features consider an</p>
<p style="text-align: center;"><a href="https://wpfilebase.com/?ref=dblike" class="button-primary">Upgrade to Pro</a></p>
<p style="text-align: center;"><a href="http://demo.wpfilebase.com/?ref=dblike" class="button">Live Pro Demo</a></p>
<p style="text-align:right;float:right;font-style:italic;">Thanks, Fabian</p>
<!-- <div style="text-align: center;">
<?php
//WPFB_Admin::PrintPayPalButton()
//.........这里部分代码省略.........
示例10: list_files
require_once ABSPATH . 'wp-admin/includes/file.php';
$tmp_files = list_files(WPFB_Core::UploadDir() . '/.tmp');
foreach ($tmp_files as $tmp) {
if (time() - filemtime($tmp) >= TMP_FILE_MAX_AGE) {
@unlink($tmp);
}
}
exit;
}
if (empty($_FILES['async-upload'])) {
wp_die(__('No file was uploaded.', WPFB) . ' (ASYNC)');
}
if (!@is_uploaded_file($_FILES['async-upload']['tmp_name']) || !($tmp = WPFB_Admin::GetTmpFile($_FILES['async-upload']['name'])) || !@move_uploaded_file($_FILES['async-upload']['tmp_name'], $tmp)) {
wpfb_ajax_die(sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name'])));
}
$_FILES['async-upload']['tmp_name'] = trim(substr($tmp, strlen(WPFB_Core::UploadDir())), '/');
$json = json_encode($_FILES['async-upload']);
if ($file_add_now) {
$file_data = array('file_flash_upload' => $json, 'file_category' => 0);
if (!empty($_REQUEST['presets'])) {
$presets = array();
parse_str(stripslashes($_REQUEST['presets']), $presets);
WPFB_Admin::AdaptPresets($presets);
$file_data = array_merge($file_data, $presets);
}
$result = WPFB_Admin::InsertFile($file_data, false);
if (empty($result['error'])) {
$resp = array_merge((array) $result['file'], array('file_thumbnail_url' => $result['file']->GetIconUrl(), 'file_edit_url' => $result['file']->GetEditUrl(), 'file_cur_user_can_edit' => $result['file']->CurUserCanEdit(), 'file_download_url' => $result['file']->GetUrl(), 'nonce' => wp_create_nonce(WPFB . '-updatefile' . $result['file_id'])));
if (isset($_REQUEST['tpl_tag'])) {
$tpl_tag = $_REQUEST['tpl_tag'];
if ($tpl_tag === 'false') {
示例11: upload
private static function upload($args)
{
define('TMP_FILE_MAX_AGE', 3600 * 3);
$frontend_upload = !empty($args['frontend_upload']) && $args['frontend_upload'] !== "false";
$file_add_now = !empty($args['file_add_now']) && $args['file_add_now'] !== "false";
// TODO: need to check if frontend_upload and user logged in state
// Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead
if (!is_user_logged_in()) {
if (is_ssl() && empty($_COOKIE[SECURE_AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[SECURE_AUTH_COOKIE] = $_REQUEST['auth_cookie'];
} elseif (empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie'])) {
$_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie'];
}
if (empty($_COOKIE[LOGGED_IN_COOKIE]) && !empty($_REQUEST['logged_in_cookie'])) {
$_COOKIE[LOGGED_IN_COOKIE] = $_REQUEST['logged_in_cookie'];
}
if (!empty($_REQUEST['auth_cookie']) || !empty($_REQUEST['logged_in_cookie'])) {
wp_set_current_user(wp_validate_auth_cookie());
}
}
wpfb_loadclass('Category', 'File');
$parent_cat = empty($args['cat_id']) ? null : WPFB_Category::GetCat($args['cat_id']);
if ($frontend_upload) {
if ($file_add_now) {
wpfb_ajax_die('Unsupported upload!');
} else {
if (!WPFB_Core::$settings->frontend_upload && !current_user_can('upload_files')) {
wpfb_ajax_die(__('You do not have permission to upload files.'));
}
}
} else {
if (!WPFB_Core::CurUserCanUpload() && !$parent_cat && !$parent_cat->CurUserCanAddFiles()) {
wpfb_ajax_die(__('You do not have permission to upload files.'));
}
check_admin_referer(WPFB . '-async-upload');
}
wpfb_loadclass('Admin');
if (!empty($args['delupload'])) {
$del_upload = @json_decode($args['delupload']);
if ($del_upload && is_file($tmp = WPFB_Core::UploadDir() . '/.tmp/' . str_replace(array('../', '.tmp/'), '', $del_upload->tmp_name))) {
echo (int) @unlink($tmp);
}
// delete other old temp files
require_once ABSPATH . 'wp-admin/includes/file.php';
$tmp_files = list_files(WPFB_Core::UploadDir() . '/.tmp');
foreach ($tmp_files as $tmp) {
if (time() - filemtime($tmp) >= TMP_FILE_MAX_AGE) {
@unlink($tmp);
}
}
exit;
}
if (empty($_FILES['async-upload'])) {
wpfb_ajax_die(__('No file was uploaded.', 'wp-filebase') . ' (ASYNC)');
}
if (!is_uploaded_file($_FILES['async-upload']['tmp_name']) || !($tmp = WPFB_Admin::GetTmpFile($_FILES['async-upload']['name'])) || !move_uploaded_file($_FILES['async-upload']['tmp_name'], $tmp)) {
wpfb_ajax_die(sprintf(__('“%s” has failed to upload due to an error'), esc_html($_FILES['async-upload']['name'])));
}
$_FILES['async-upload']['tmp_name'] = trim(substr($tmp, strlen(WPFB_Core::UploadDir())), '/');
$json = json_encode($_FILES['async-upload']);
if ($file_add_now) {
$file_data = array('file_flash_upload' => $json, 'file_category' => 0);
if (!empty($args['presets'])) {
$presets = array();
parse_str($args['presets'], $presets);
WPFB_Admin::AdaptPresets($presets);
$file_data = array_merge($file_data, $presets);
}
$result = WPFB_Admin::InsertFile($file_data, false);
if (empty($result['error'])) {
$resp = array_merge((array) $result['file'], array('file_thumbnail_url' => $result['file']->GetIconUrl(), 'file_edit_url' => $result['file']->GetEditUrl(), 'file_cur_user_can_edit' => $result['file']->CurUserCanEdit(), 'file_download_url' => $result['file']->GetUrl(), 'nonce' => wp_create_nonce(WPFB . '-updatefile' . $result['file_id'])));
if (isset($args['tpl_tag'])) {
$tpl_tag = $args['tpl_tag'];
if ($tpl_tag === 'false') {
$tpl_tag = null;
}
$resp['tpl'] = $result['file']->GenTpl2($tpl_tag);
}
} else {
wpfb_ajax_die($result['error']);
}
$json = json_encode($resp);
}
header('Content-Type: application/json; charset=' . get_option('blog_charset'));
//header('Content-Length: ' . strlen($json));
echo $json;
}
示例12: GetLogFile
static function GetLogFile($for)
{
static $cache = array();
if (isset($cache[$for])) {
return $cache[$for];
}
$u = WPFB_Core::UploadDir();
$fn = $u . '/._log-' . $for . '-' . md5($u . (defined('NONCE_KEY') ? NONCE_KEY : '') . $for) . '.txt';
if (is_file($fn) && filesize($fn) > self::LOG_MAX_FILE_SIZE) {
rename($fn, "{$fn}.old");
file_put_contents($fn, strstr(file_get_contents("{$fn}.old", false, null, self::LOG_MAX_FILE_SIZE / 2), "\n"));
touch($fn, date('U', filemtime("{$fn}.old")), time());
}
return $cache[$for] = $fn;
}