本文整理汇总了PHP中AIOWPSecurity_Utility_File::get_attachment_id_from_url方法的典型用法代码示例。如果您正苦于以下问题:PHP AIOWPSecurity_Utility_File::get_attachment_id_from_url方法的具体用法?PHP AIOWPSecurity_Utility_File::get_attachment_id_from_url怎么用?PHP AIOWPSecurity_Utility_File::get_attachment_id_from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AIOWPSecurity_Utility_File
的用法示例。
在下文中一共展示了AIOWPSecurity_Utility_File::get_attachment_id_from_url方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_tab5
function render_tab5()
{
global $aio_wp_security;
global $wpdb;
$events_table_name = AIOWPSEC_TBL_EVENTS;
AIOWPSecurity_Utility::cleanup_table($events_table_name, 500);
if (isset($_POST['aiowps_import_settings'])) {
$nonce = $_REQUEST['_wpnonce'];
if (!wp_verify_nonce($nonce, 'aiowpsec-import-settings-nonce')) {
$aio_wp_security->debug_logger->log_debug("Nonce check failed on import AIOWPS settings!", 4);
die("Nonce check failed on import AIOWPS settings!");
}
if (empty($_POST['aiowps_import_settings_file']) && empty($_POST['aiowps_import_settings_text'])) {
$this->show_msg_error(__('Please choose a file to import your settings from.', 'aiowpsecurity'));
} else {
if (empty($_POST['aiowps_import_settings_file'])) {
$import_from = "text";
} else {
$import_from = "file";
}
if ($import_from == "file") {
//Let's get the uploaded import file path
$submitted_import_file_path = trim($_POST['aiowps_import_settings_file']);
$attachment_id = AIOWPSecurity_Utility_File::get_attachment_id_from_url($submitted_import_file_path);
//we'll need this later for deleting
//Verify that file chosen has valid AIOWPS settings contents
$aiowps_settings_file_contents = $this->check_if_valid_aiowps_settings_file($submitted_import_file_path);
} else {
//Get the string right from the textarea. Still confirm it's in the expected format.
$aiowps_settings_file_contents = $this->check_if_valid_aiowps_settings_text($_POST['aiowps_import_settings_text']);
}
if ($aiowps_settings_file_contents != -1) {
//Apply the settings and delete the file (if applicable)
$settings_array = json_decode($aiowps_settings_file_contents, true);
$aiowps_settings_applied = update_option('aio_wp_security_configs', $settings_array);
if (!$aiowps_settings_applied) {
//Failed to import settings
$aio_wp_security->debug_logger->log_debug("Import AIOWPS settings from " . $import_from . " operation failed!", 4);
$this->show_msg_error(__('Import AIOWPS settings from ' . $import_from . ' operation failed!', 'aiowpsecurity'));
if ($import_from == "file") {
//Delete the uploaded settings file for security purposes
wp_delete_attachment($attachment_id, true);
if (false === wp_delete_attachment($attachment_id, true)) {
$this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes.', 'aiowpsecurity'));
} else {
$this->show_msg_updated(__('The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
}
}
} else {
$aio_wp_security->configs->configs = $settings_array;
//Refresh the configs global variable
//Just in case user submits partial config settings
//Run add_option_values to make sure any missing config items are at least set to default
AIOWPSecurity_Configure_Settings::add_option_values();
if ($import_from == "file") {
//Delete the uploaded settings file for security purposes
wp_delete_attachment($attachment_id, true);
if (false === wp_delete_attachment($attachment_id, true)) {
$this->show_msg_updated(__('Your AIOWPS settings were successfully imported via file input.', 'aiowpsecurity'));
$this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes because it contains security settings details.', 'aiowpsecurity'));
} else {
$this->show_msg_updated(__('Your AIOWPS settings were successfully imported. The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
}
} else {
$this->show_msg_updated(__('Your AIOWPS settings were successfully imported via text entry.', 'aiowpsecurity'));
}
//Now let's refresh the .htaccess file with any modified rules if applicable
$res = AIOWPSecurity_Utility_Htaccess::write_to_htaccess();
if ($res == -1) {
$this->show_msg_error(__('Could not write to the .htaccess file. Please check the file permissions.', 'aiowpsecurity'));
}
}
} else {
//Invalid settings file
$aio_wp_security->debug_logger->log_debug("The contents of your settings file appear invalid!", 4);
$this->show_msg_error(__('The contents of your settings file appear invalid. Please check the contents of the file you are trying to import settings from.', 'aiowpsecurity'));
if ($import_from == "file") {
//Let's also delete the uploaded settings file for security purposes
wp_delete_attachment($attachment_id, true);
if (false === wp_delete_attachment($attachment_id, true)) {
$this->show_msg_error(__('The deletion of the import file failed. Please delete this file manually via the media menu for security purposes.', 'aiowpsecurity'));
} else {
$this->show_msg_updated(__('The file you uploaded was also deleted for security purposes because it contains security settings details.', 'aiowpsecurity'));
}
}
}
}
}
?>
<h2><?php
_e('Export or Import Your AIOWPS Settings', 'aiowpsecurity');
?>
</h2>
<div class="aio_blue_box">
<?php
echo '<p>' . __('This section allows you to export or import your All In One WP Security & Firewall settings.', 'aiowpsecurity');
echo '<br />' . __('This can be handy if you wanted to save time by applying the settings from one site to another site.', 'aiowpsecurity') . '
<br />' . __('NOTE: Before importing, it is your responsibility to know what settings you are trying to import. Importing settings blindly can cause you to be locked out of your site.', 'aiowpsecurity') . '
<br />' . __('For Example: If a settings item relies on the domain URL then it may not work correctly when imported into a site with a different domain.', 'aiowpsecurity') . '
</p>';
//.........这里部分代码省略.........