本文整理汇总了PHP中RGFormsModel::get_upload_root方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_upload_root方法的具体用法?PHP RGFormsModel::get_upload_root怎么用?PHP RGFormsModel::get_upload_root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_upload_root方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gfuea_clean_zips
function gfuea_clean_zips($confirmation, $form, $entry, $ajax)
{
$upload_root = RGFormsModel::get_upload_root();
$filename = $upload_root . "/uploaded_files" . $entry['id'] . ".zip";
if (is_file($filename)) {
unlink($filename);
}
return $confirmation;
}
示例2: check_upload_folder
public static function check_upload_folder()
{
//check if upload folder is writable
$folder = RGFormsModel::get_upload_root();
if (empty($folder)) {
echo "<div class='error'>Upload folder is not writable. Export and file upload features will not be functional.</div>";
}
}
示例3: delete_old_log_files
/**
* Deletes any log files that are older than one month.
*
* @since 2.0.0
* @access public
* @static
*/
public static function delete_old_log_files()
{
GFCommon::log_debug(__METHOD__ . '(): Starting.');
$uploads_folder = RGFormsModel::get_upload_root();
if (!is_dir($uploads_folder) || is_link($uploads_folder)) {
GFCommon::log_debug(__METHOD__ . '(): No upload root - bailing.');
return;
}
$logs_folder = $uploads_folder . 'logs';
if (!is_dir($logs_folder) || is_link($logs_folder)) {
GFCommon::log_debug(__METHOD__ . '(): No logs folder - bailing.');
return;
}
GFCommon::log_debug(__METHOD__ . '(): Start deleting old log files');
foreach (glob($logs_folder . DIRECTORY_SEPARATOR . '*.txt', GLOB_BRACE) as $filename) {
$timestamp = filemtime($filename);
if ($timestamp < time() - MONTH_IN_SECONDS) {
// Delete files over one month old
GFCommon::log_debug(__METHOD__ . '(): Proceeding to delete ' . $filename);
$success = unlink($filename);
GFCommon::log_debug(__METHOD__ . '(): Delete successful: ' . ($success ? 'yes' : 'no'));
}
}
}
示例4: delete_signature_file
public function delete_signature_file($filename)
{
$folder = RGFormsModel::get_upload_root() . '/signatures/';
$file_path = $folder . $filename;
if (file_exists($file_path)) {
unlink($file_path);
}
}
示例5: settings_uninstall_page
public static function settings_uninstall_page()
{
self::page_header(__("Uninstall Gravity Forms", "gravityforms"), "");
if (isset($_POST["uninstall"])) {
if (!GFCommon::current_user_can_any("gravityforms_uninstall") || function_exists("is_multisite") && is_multisite() && !is_super_admin()) {
die(__("You don't have adequate permission to uninstall Gravity Forms.", "gravityforms"));
}
//dropping all tables
RGFormsModel::drop_tables();
//removing options
delete_option("rg_form_version");
delete_option("rg_gforms_key");
delete_option("rg_gforms_disable_css");
delete_option("rg_gforms_enable_html5");
delete_option("rg_gforms_captcha_public_key");
delete_option("rg_gforms_captcha_private_key");
delete_option("rg_gforms_message");
delete_option("gf_dismissed_upgrades");
delete_option("rg_gforms_currency");
delete_option("gform_api_count");
delete_option("gform_email_count");
//removing gravity forms upload folder
GFCommon::delete_directory(RGFormsModel::get_upload_root());
//Deactivating plugin
$plugin = "gravityforms/gravityforms.php";
deactivate_plugins($plugin);
update_option('recently_activated', array($plugin => time()) + (array) get_option('recently_activated'));
?>
<div class="updated fade" style="padding:20px;"><?php
echo sprintf(__("Gravity Forms have been successfully uninstalled. It can be re-activated from the %splugins page%s.", "gravityforms"), "<a href='plugins.php'>", "</a>");
?>
</div>
<?php
return;
}
?>
<form action="" method="post">
<?php
if (GFCommon::current_user_can_any("gravityforms_uninstall") && (!function_exists("is_multisite") || !is_multisite() || is_super_admin())) {
?>
<h3><span><i class="fa fa-times"></i> <?php
_e("Uninstall Gravity Forms", "gravityforms");
?>
</span></h3>
<div class="delete-alert alert_red">
<h3><i class="fa fa-exclamation-triangle gf_invalid"></i> <?php
_e("Warning", "gravityforms");
?>
</h3>
<div class="gf_delete_notice""><strong><?php
_e("This operation deletes ALL Gravity Forms data.", "gravityforms");
?>
</strong> <?php
_e("If you continue, You will not be able to retrieve or restore your forms or entries.", "gravityforms");
?>
</div>
<?php
$uninstall_button = '<input type="submit" name="uninstall" value="' . __("Uninstall Gravity Forms", "gravityforms") . '" class="button" onclick="return confirm(\'' . __("Warning! ALL Gravity Forms data, including form entries will be deleted. This cannot be undone. \\'OK\\' to delete, \\'Cancel\\' to stop", "gravityforms") . '\');"/>';
echo apply_filters("gform_uninstall_button", $uninstall_button);
?>
</div>
<?php
}
?>
</form>
<?php
self::page_footer();
}
示例6: settings_uninstall_page
public static function settings_uninstall_page()
{
self::page_header(__('Uninstall Gravity Forms', 'gravityforms'), '');
if (isset($_POST['uninstall'])) {
if (!GFCommon::current_user_can_any('gravityforms_uninstall') || function_exists('is_multisite') && is_multisite() && !is_super_admin()) {
die(esc_html__("You don't have adequate permission to uninstall Gravity Forms.", 'gravityforms'));
}
//dropping all tables
RGFormsModel::drop_tables();
//removing options
delete_option('rg_form_version');
delete_option('rg_gforms_key');
delete_option('rg_gforms_disable_css');
delete_option('rg_gforms_enable_html5');
delete_option('rg_gforms_captcha_public_key');
delete_option('rg_gforms_captcha_private_key');
delete_option('rg_gforms_message');
delete_option('gform_enable_noconflict');
delete_option('gform_enable_background_updates');
delete_option('gf_dismissed_upgrades');
delete_option('rg_gforms_currency');
delete_option('gform_api_count');
delete_option('gform_email_count');
//removing gravity forms upload folder
GFCommon::delete_directory(RGFormsModel::get_upload_root());
//Deactivating plugin
$plugin = 'gravityforms/gravityforms.php';
deactivate_plugins($plugin);
update_option('recently_activated', array($plugin => time()) + (array) get_option('recently_activated'));
?>
<div class="updated fade" style="padding:20px;"><?php
echo sprintf(esc_html__('Gravity Forms has been successfully uninstalled. It can be re-activated from the %splugins page%s.', 'gravityforms'), "<a href='plugins.php'>", '</a>');
?>
</div>
<?php
return;
}
?>
<form action="" method="post">
<?php
if (GFCommon::current_user_can_any('gravityforms_uninstall') && (!function_exists('is_multisite') || !is_multisite() || is_super_admin())) {
?>
<h3><span><i class="fa fa-times"></i> <?php
esc_html_e('Uninstall Gravity Forms', 'gravityforms');
?>
</span>
</h3>
<div class="delete-alert alert_red">
<h3>
<i class="fa fa-exclamation-triangle gf_invalid"></i> <?php
esc_html_e('Warning', 'gravityforms');
?>
</h3>
<div class="gf_delete_notice"><strong><?php
esc_html_e('This operation deletes ALL Gravity Forms data.', 'gravityforms');
?>
</strong> <?php
esc_html_e('If you continue, You will not be able to retrieve or restore your forms or entries.', 'gravityforms');
?>
</div>
<?php
$uninstall_button = '<input type="submit" name="uninstall" value="' . esc_attr__('Uninstall Gravity Forms', 'gravityforms') . '" class="button" onclick="return confirm(\'' . esc_js(__("Warning! ALL Gravity Forms data, including form entries will be deleted. This cannot be undone. 'OK' to delete, 'Cancel' to stop", 'gravityforms')) . '\');"/>';
/**
* Allows for the modification of the Gravity Forms uninstall button
*
* @param string $uninstall_button The HTML of the uninstall button
*/
echo apply_filters('gform_uninstall_button', $uninstall_button);
?>
</div>
<?php
}
?>
</form>
<?php
self::page_footer();
}
示例7: gravityforms_settings_page
public static function gravityforms_settings_page()
{
global $wpdb;
if (!GFCommon::ensure_wp_version()) {
return;
}
if (isset($_GET["setup"])) {
//forcing setup
RGForms::setup(true);
}
if (isset($_POST["submit"])) {
check_admin_referer('gforms_update_settings', 'gforms_update_settings');
if (!GFCommon::current_user_can_any("gravityforms_edit_settings")) {
die(__("You don't have adequate permission to edit settings.", "gravityforms"));
}
RGFormsModel::save_key($_POST["gforms_key"]);
update_option("rg_gforms_disable_css", $_POST["gforms_disable_css"]);
update_option("rg_gforms_enable_html5", $_POST["gforms_enable_html5"]);
update_option("rg_gforms_captcha_public_key", $_POST["gforms_captcha_public_key"]);
update_option("rg_gforms_captcha_private_key", $_POST["gforms_captcha_private_key"]);
if (!rgempty("gforms_currency")) {
update_option("rg_gforms_currency", rgpost("gforms_currency"));
}
//Updating message because key could have been changed
GFCommon::cache_remote_message();
//Re-caching version info
$version_info = GFCommon::get_version_info(false);
?>
<div class="updated fade" style="padding:6px;">
<?php
_e("Settings Updated", "gravityforms");
?>
.
</div>
<?php
} else {
if (isset($_POST["uninstall"])) {
if (!GFCommon::current_user_can_any("gravityforms_uninstall") || function_exists("is_multisite") && is_multisite() && !is_super_admin()) {
die(__("You don't have adequate permission to uninstall Gravity Forms.", "gravityforms"));
}
//droping all tables
RGFormsModel::drop_tables();
//removing options
delete_option("rg_form_version");
delete_option("rg_gforms_key");
delete_option("rg_gforms_disable_css");
delete_option("rg_gforms_enable_html5");
delete_option("rg_gforms_captcha_public_key");
delete_option("rg_gforms_captcha_private_key");
delete_option("rg_gforms_message");
delete_option("gf_dismissed_upgrades");
delete_option("rg_gforms_currency");
//removing gravity forms upload folder
GFCommon::delete_directory(RGFormsModel::get_upload_root());
//Deactivating plugin
$plugin = "gravityforms/gravityforms.php";
deactivate_plugins($plugin);
update_option('recently_activated', array($plugin => time()) + (array) get_option('recently_activated'));
?>
<div class="updated fade" style="padding:20px;"><?php
echo sprintf(__("Gravity Forms have been successfully uninstalled. It can be re-activated from the %splugins page%s.", "gravityforms"), "<a href='plugins.php'>", "</a>");
?>
</div>
<?php
return;
}
}
if (!isset($version_info)) {
$version_info = GFCommon::get_version_info();
}
?>
<form method="post">
<?php
wp_nonce_field('gforms_update_settings', 'gforms_update_settings');
?>
<h3><?php
_e("General Settings", "gravityforms");
?>
</h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="gforms_key"><?php
_e("Support License Key", "gravityforms");
?>
</label> <?php
gform_tooltip("settings_license_key");
?>
</th>
<td>
<?php
$key = GFCommon::get_key();
$key_field = '<input type="password" name="gforms_key" id="gforms_key" style="width:350px;" value="' . $key . '" />';
if ($version_info["is_valid_key"]) {
$key_field .= " <img src='" . GFCommon::get_base_url() . "/images/tick.png' class='gf_keystatus_valid' alt='valid key' title='valid key'/>";
} else {
if (!empty($key)) {
$key_field .= " <img src='" . GFCommon::get_base_url() . "/images/cross.png' class='gf_keystatus_invalid' alt='invalid key' title='invalid key'/>";
}
}
echo apply_filters('gform_settings_key_field', $key_field);
//.........这里部分代码省略.........
示例8: ajax_download_export
/**
* Handles the download request from the export entries page.
*
* @since 2.0.0
*/
public static function ajax_download_export()
{
check_admin_referer('gform_download_export');
if (!GFCommon::current_user_can_any('gravityforms_export_entries')) {
die;
}
$form_id = absint(rgget('form-id'));
if (empty($form_id)) {
die;
}
$form = GFAPI::get_form($form_id);
if (empty($form)) {
die;
}
$filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv';
$charset = get_option('blog_charset');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/csv; charset=' . $charset, true);
$buffer_length = ob_get_length();
//length or false if no buffer
if ($buffer_length > 1) {
ob_clean();
}
$export_id = rgget('export-id');
$export_id = sanitize_key($export_id);
$export_folder = RGFormsModel::get_upload_root() . 'export/';
$file = $export_folder . 'export-' . $export_id . '.csv';
readfile($file);
@unlink($file);
exit;
}
示例9: get_log_dir
private static function get_log_dir()
{
$upload_dir = RGFormsModel::get_upload_root();
$log_dir = $upload_dir . "logs/";
return $log_dir;
}
示例10: get_signature
private static function get_signature($form, $lead, $field, $form_array)
{
$value = RGFormsModel::get_lead_field_value($lead, $field);
$http_folder = RGFormsModel::get_upload_url_root() . 'signatures/';
$server_folder = RGFormsModel::get_upload_root() . 'signatures/';
$file = $server_folder . $value;
$sig_html = '';
/*
* Set defaults is we cannot find the images
*/
$width = 75;
$height = 45;
/*
* Only get sane defaults specific to the image if we can find it.
*/
if (file_exists($file) !== false && is_dir($file) !== true) {
$image_size = getimagesize($file);
$width = $image_size[0] / 4;
$height = $image_size[1] / 4;
$sig_html = '<img src="' . $server_folder . $value . '" alt="Signature" width="' . $width . '" height="' . $height . '" />';
}
/*
* Include the image details
*/
$form_array['signature'][] = $sig_html;
$form_array['signature_details'][] = array('img' => $sig_html, 'path' => $file, 'url' => $http_folder . $value, 'width' => $width, 'height' => $height);
$form_array['signature_details_id'][$field['id']] = array('img' => $sig_html, 'path' => $file, 'url' => $http_folder . $value, 'width' => $width, 'height' => $height);
return $form_array;
}
示例11: ajax_download_export
/**
* Handles the download request from the export entries page.
*
* @since 2.0.0
*/
public static function ajax_download_export()
{
check_admin_referer('gform_download_export');
if (!GFCommon::current_user_can_any('gravityforms_export_entries')) {
die;
}
$form_id = absint(rgget('form-id'));
if (empty($form_id)) {
die;
}
$form = GFAPI::get_form($form_id);
if (empty($form)) {
die;
}
$filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv';
GFCommon::log_debug(__METHOD__ . '(): Starting download of file: ' . $filename);
$charset = get_option('blog_charset');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename={$filename}");
header('Content-Type: text/csv; charset=' . $charset, true);
$buffer_length = ob_get_length();
//length or false if no buffer
if ($buffer_length > 1) {
ob_clean();
}
$export_folder = RGFormsModel::get_upload_root() . 'export/';
$export_id = rgget('export-id');
$file = $export_folder . sanitize_file_name('export-' . $export_id . '.csv');
$result = readfile($file);
if ($result === false) {
GFCommon::log_error(__METHOD__ . '(): An issue occurred whilst reading the file.');
} else {
@unlink($file);
GFCommon::log_debug(__METHOD__ . '(): Number of bytes read from the file: ' . print_r($result, 1));
}
exit;
}