コード例 #1
0
ファイル: web-invoice.php プロジェクト: dimps123/web-invoice
 function init()
 {
     global $wpdb, $wp_version;
     if (version_compare($wp_version, '2.6', '<')) {
         // Using old WordPress
         load_plugin_textdomain(WEB_INVOICE_TRANS_DOMAIN, PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)) . '/languages');
     } else {
         load_plugin_textdomain(WEB_INVOICE_TRANS_DOMAIN, PLUGINDIR . '/' . dirname(plugin_basename(__FILE__)) . '/languages', dirname(plugin_basename(__FILE__)) . '/languages');
     }
     if (is_admin()) {
         if (is_multisite() && !get_option('web_invoice_installed', false)) {
             $this->install();
         }
         if (get_option('web_invoice_installed', false) != WEB_INVOICE_VERSION_NUM) {
             $version = get_option('web_invoice_installed', false);
             if ($version == true) {
                 $version = '2.1.0';
             }
             $this->upgrade($version);
         }
         wp_enqueue_script('jquery');
         wp_enqueue_script('jquery-ui-core');
         wp_enqueue_script('jquery-ui-tabs');
         wp_enqueue_script('jquery-maskedinput', $this->uri . "/js/jquery.maskedinput.js", array('jquery'));
         wp_enqueue_script('jquery-cookie', $this->uri . "/js/jquery.cookie.js", array('jquery'));
         wp_enqueue_script('jquery-form', $this->uri . "/js/jquery.form.js", array('jquery'));
         wp_enqueue_script('jquery-impromptu', $this->uri . "/js/jquery-impromptu.1.7.js", array('jquery'), '1.8.0');
         wp_enqueue_script('jquery-field', $this->uri . "/js/jquery.field.min.js", array('jquery'), '1.8.0');
         wp_enqueue_script('jquery-delegate', $this->uri . "/js/jquery.delegate.js", array('jquery'), '1.8.0');
         wp_enqueue_script('jquery-calculation', $this->uri . "/js/jquery.calculation.min.js", array('jquery'), '1.8.0');
         wp_enqueue_script('jquery-tablesorter', $this->uri . "/js/jquery.tablesorter.min.js", array('jquery'), '1.8.0');
         wp_enqueue_script('jquery-autogrow-textarea', $this->uri . "/js/jquery.autogrow-textarea.js", array('jquery'), '1.8.0');
         wp_enqueue_script('web-invoice', $this->uri . "/js/web-invoice.js", array('jquery', 'jquery-ui-core', 'jquery-ui-tabs'), WEB_INVOICE_VERSION_NUM, true);
     } else {
         if (isset($_POST['web_invoice_id_hash'])) {
             $md5_invoice_id = $_POST['web_invoice_id_hash'];
             $invoice_id = web_invoice_md5_to_invoice($md5_invoice_id);
             //Check to see if this is a credit card transaction, if so process
             if (web_invoice_does_invoice_exist($invoice_id)) {
                 web_invoice_process_cc_transaction($_POST);
                 exit(0);
             }
         }
         if (isset($_GET['invoice_id'])) {
             $md5_invoice_id = $_GET['invoice_id'];
             // Convert MD5 hash into Actual Invoice ID
             $invoice_id = web_invoice_md5_to_invoice($md5_invoice_id);
             //Check if invoice exists, SSL enforcement is setup, and we are not currently browing HTTPS,  then reload page into HTTPS
             if (!function_exists('wp_https_redirect')) {
                 if (web_invoice_does_invoice_exist($invoice_id) && get_option('web_invoice_force_https') == 'true' && $_SERVER['HTTPS'] != "on" && preg_match('/^https/', get_option('siteurl')) == 0) {
                     $host_x = preg_split('/\\//', get_option('siteurl'));
                     $host = $host_x[2];
                     header("Location: https://" . $host . $_SERVER['REQUEST_URI']);
                     exit(0);
                 }
             }
         }
     }
     if (empty($_GET['invoice_id'])) {
         unset($_GET['invoice_id']);
     }
 }
コード例 #2
0
ファイル: Frontend.php プロジェクト: dimps123/web-invoice
function web_invoice_print_pdf()
{
    $ip = $_SERVER['REMOTE_ADDR'];
    // Check to see a proper invoice id is used, or show regular content
    if (!($invoice_id = web_invoice_md5_to_invoice($_GET['invoice_id']))) {
        return $content;
    }
    // Invoice viewed, update log
    web_invoice_update_log($invoice_id, 'visited', "PDF downloaded by {$ip}");
    $dompdf = web_invoice_pdf_get($invoice_id);
    $dompdf->stream("web-invoice-{$invoice_id}.pdf");
    exit(0);
}