Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('OPTSQZ_PLATFORM', 'WORDPRESS');
- if (!class_exists('ubam_optimum_sqz_items')) {
- class ubam_optimum_sqz_items
- {
- var $options = array();
- function ubam_optimum_sqz_items()
- {
- }
- }
- }
- if (!class_exists('ubam_optimum_sqz')) {
- class ubam_optimum_sqz
- {
- var $optionsName = 'ubam_optimum_sqz_options';
- var $localizationDomain = "ubam_optimum_sqz";
- var $thispluginurl = '';
- var $thispluginpath = '';
- var $options = array();
- var $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
- var $popup_page_ids = array();
- var $popup_info = '';
- function ubam_optimum_sqz()
- {
- $locale = get_locale();
- $mo = dirname(__FILE__) . "/languages/" . $this->localizationDomain . "-" . $locale . ".mo";
- load_textdomain($this->localizationDomain, $mo);
- $this->thispluginurl = OPTSQZ_PLUGIN_URL;
- $this->thispluginpath = OPTSQZ_PLUGIN_DIR;
- $this->getOptions();
- add_action("admin_menu", array(
- &$this,
- "admin_menu_link"
- ));
- if (isset($_REQUEST['page']) && strpos($_REQUEST['page'], "ubam_optimum_squeeze") !== false) {
- add_action('admin_print_styles', array(
- &$this,
- 'ubam_optimum_sqz_load_css'
- ));
- add_action('admin_print_scripts', array(
- &$this,
- 'ubam_optimum_sqz_load_js'
- ));
- }
- add_action('send_headers', array(
- &$this,
- "ubam_optimum_sqz_popup_check"
- ), 5);
- add_action('init', array(
- &$this,
- "ubam_optimum_sqz_init"
- ));
- add_filter('the_content', array(
- &$this,
- 'ubam_optimum_sqz_show_squeeze'
- ));
- }
- function ubam_optimum_sqz_init()
- {
- if (strpos($_SERVER['REQUEST_URI'], 'sprsqz_preview') !== false) {
- $output = $this->create_popup_html('', true);
- echo $output;
- exit;
- }
- if (strpos($_SERVER['REQUEST_URI'], 'sprsqz_reset_options') !== false) {
- $output = $this->get_page_style_settings();
- echo $output;
- exit;
- }
- }
- function ubam_optimum_sqz_add_popup_styles()
- {
- wp_enqueue_style('sprsqz_cb_style', OPTSQZ_PLUGIN_URL . 'js/colorbox.css', array(), mt_rand(), 'all');
- }
- function ubam_optimum_sqz_add_popup_js()
- {
- wp_enqueue_script('jquery');
- wp_enqueue_script('colorbox', OPTSQZ_PLUGIN_URL . 'js/jquery.colorbox-min.js', array(
- 'jquery'
- ), mt_rand());
- }
- function ubam_optimum_sqz_load_css()
- {
- wp_enqueue_style('sprsqz_cb_style', OPTSQZ_PLUGIN_URL . 'js/colorbox.css', array(), mt_rand(), 'all');
- wp_enqueue_style('sprsqz_style', OPTSQZ_PLUGIN_URL . 'style.css', array(), mt_rand(), 'all');
- }
- function ubam_optimum_sqz_load_js()
- {
- wp_enqueue_script('jquery');
- wp_enqueue_script('colorbox', OPTSQZ_PLUGIN_URL . 'js/jquery.colorbox-min.js', array(
- 'jquery'
- ), mt_rand());
- wp_enqueue_script('jscolor', OPTSQZ_PLUGIN_URL . 'js/jscolor/jscolor.js');
- }
- function ubam_optimum_sqz_show_squeeze($text)
- {
- global $wpdb;
- $optimum_sqz_tag_pattern = '/(\[optimum_squeeze\](.*?)\[\/optimum_squeeze\])/is';
- preg_match_all($optimum_sqz_tag_pattern, $text, $optimum_sqz_matches);
- if (is_array($optimum_sqz_matches)) {
- foreach ($optimum_sqz_matches[1] as $sqzkey => $sqzvalue) {
- $squeeze_pg_id = $optimum_sqz_matches[2][$sqzkey];
- $the_html = $this->create_popup_html($squeeze_pg_id);
- $text = str_replace($sqzvalue, $the_html, $text);
- }
- }
- return $text;
- }
- function create_popup_html($squeeze_pg_id, $preview = false)
- {
- global $wpdb;
- $the_html = '';
- if ($preview) {
- $_POST['template'] = $_POST['page_template'];
- $squeeze_pg = $this->array_to_object($_POST);
- } else {
- $squeeze_pg = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE item_id = '$squeeze_pg_id'");
- }
- if ($squeeze_pg) {
- $optimum_sqz_options = array();
- if ($preview) {
- $saved_style_info = $this->set_page_style_array();
- } else {
- $saved_style_info = get_option("ubam_optimum_sqz_item_style_{$squeeze_pg->id}", array());
- }
- if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
- $base_style = get_option("ubam_optimum_sqz_style_{$saved_style_info['style']}");
- $the_page_style = $this->ubam_array_replace_recursive($base_style, $saved_style_info);
- $optimum_sqz_options = $this->ubam_remove_magic_quotes($the_page_style);
- }
- ob_start();
- include(OPTSQZ_SQZ_TEMPLATE_DIR . 'css.php');
- if (empty($squeeze_pg->sub_headline))
- echo "div#optimum-sqz-sub-headline { display: none; }\n";
- $the_css = ob_get_contents();
- ob_end_clean();
- $the_css = $this->compress_css($the_css);
- if ($squeeze_pg->video_show != 0)
- $videojs = $this->ubam_optimum_sqz_video_js($squeeze_pg);
- $optin_out = $this->create_optin_html($squeeze_pg);
- $the_html = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . strtolower($squeeze_pg->template) . '_tpl.htm');
- $the_html = str_replace('[[-main_headline-]]', $squeeze_pg->main_headline, $the_html);
- $the_html = str_replace('[[-sub_headline-]]', $squeeze_pg->sub_headline, $the_html);
- $the_html = str_replace('[[-main_body-]]', $squeeze_pg->main_body, $the_html);
- $the_html = str_replace('[[-main_footer-]]', $squeeze_pg->main_footer, $the_html);
- $the_html = str_replace('[[-optin_headline-]]', $squeeze_pg->optin_headline, $the_html);
- $the_html = str_replace('[[-optin_code-]]', $optin_out, $the_html);
- $the_html = str_replace('[[-optin_footer-]]', $squeeze_pg->optin_footer, $the_html);
- $the_html = str_replace('[[-pre_video-]]', ($squeeze_pg->video_show == 1 ? $videojs : ''), $the_html);
- $the_html = str_replace('[[-post_video-]]', ($squeeze_pg->video_show == 2 ? $videojs : ''), $the_html);
- $the_html = '<style type="text/css">' . $the_css . '</style>' . $the_html;
- }
- return $the_html;
- }
- function write_optimum_sqz_file($squeeze_pg_id, $delete = false)
- {
- if ($delete) {
- @unlink(OPTSQZ_SQZ_POPUP_DIR . "/$squeeze_pg_id.html");
- } else {
- $squeeze_html = $this->create_popup_html($squeeze_pg_id);
- if (empty($squeeze_html))
- print "Empty Squeeze Html. <br />";
- if (!empty($squeeze_html)) {
- $handle = fopen(OPTSQZ_SQZ_POPUP_DIR . "/$squeeze_pg_id.html", "w");
- if (!$handle)
- print "Can't open the file<br />";
- fwrite($handle, $squeeze_html);
- fclose($handle);
- }
- }
- }
- function ubam_optimum_sqz_popup_check()
- {
- if (is_admin())
- return;
- $found_popup_page = false;
- $this->popup_info = '';
- $parsed_url = parse_url($_SERVER['REQUEST_URI']);
- $the_path = $parsed_url['path'];
- $popup_pages = get_option('ubam_optimum_sqz_popup_pages', array());
- if (!empty($popup_pages['front']) && $popup_pages['front']['path'] == rtrim($the_path, '/') && !isset($_COOKIE["u4bg43_{$popup_pages['front']['item_id']}"])) {
- $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_pages['front']['item_id']}");
- if (!empty($popup_info)) {
- if ($popup_info['enable_popup'] == 1 && (empty($popup_info['use_start_date']) || ($popup_info['use_start_date'] == 'yes' && strtotime($popup_info['start_date']) < strtotime(current_time('mysql'))))) {
- $this->popup_info = $popup_info;
- $date_today = date("Y-m-d");
- if ($popup_info['delay_days'] > 0)
- setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
- add_action('wp_print_styles', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_styles'
- ));
- add_action('wp_print_scripts', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_js'
- ));
- add_action('wp_head', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_head_code'
- ));
- return;
- }
- }
- }
- if (is_array($popup_pages)) {
- foreach ($popup_pages as $popup_page_id => $popup_page) {
- if ($popup_page_id == 'front' || $popup_page_id == 'every')
- continue;
- if ($popup_page['path'] == $the_path && !isset($_COOKIE["u4bg43_{$popup_page['item_id']}"])) {
- $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_page['item_id']}");
- if (!empty($popup_info)) {
- if ($popup_info['enable_popup'] == 1 && (empty($popup_info['use_start_date']) || ($popup_info['use_start_date'] == 'yes' && strtotime($popup_info['start_date']) < strtotime(current_time('mysql'))))) {
- $found_popup_page = true;
- $this->popup_info = $popup_info;
- $date_today = date("Y-m-d");
- if ($popup_info['delay_days'] > 0)
- setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
- add_action('wp_print_styles', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_styles'
- ));
- add_action('wp_print_scripts', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_js'
- ));
- add_action('wp_head', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_head_code'
- ));
- break;
- }
- }
- }
- }
- if ($found_popup_page)
- return;
- }
- $popup_cats = get_option('ubam_optimum_sqz_popup_cats', array());
- $popup_cat_path = '';
- if (is_array($popup_cats)) {
- foreach ($popup_cats as $popup_cat_id => $popup_page) {
- if (strpos($the_path, $popup_page['path']) !== false) {
- if (strlen($popup_page['path']) > strlen($popup_cat_path)) {
- $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_page['item_id']}");
- if (!empty($popup_info)) {
- if ($popup_info['enable_popup'] == 1 && (empty($popup_info['use_start_date']) || ($popup_info['use_start_date'] == 'yes' && strtotime($popup_info['start_date']) < strtotime(current_time('mysql'))))) {
- $found_popup_page = true;
- $popup_cat_path = $popup_page['path'];
- $this->popup_info = $popup_info;
- }
- }
- }
- }
- }
- if ($found_popup_page && !isset($_COOKIE["u4bg43_{$this->popup_info['item_id']}"])) {
- $date_today = date("Y-m-d");
- if ($this->popup_info['delay_days'] > 0)
- setcookie("u4bg43_{$this->popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $this->popup_info['delay_days']), $the_path);
- add_action('wp_print_styles', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_styles'
- ));
- add_action('wp_print_scripts', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_js'
- ));
- add_action('wp_head', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_head_code'
- ));
- return;
- }
- }
- if (!empty($popup_pages['every']) && !isset($_COOKIE["u4bg43_{$popup_pages['every']['item_id']}"])) {
- $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_pages['every']['item_id']}");
- if (!empty($popup_info)) {
- if ($popup_info['enable_popup'] == 1 && (empty($popup_info['use_start_date']) || ($popup_info['use_start_date'] == 'yes' && strtotime($popup_info['start_date']) < strtotime(current_time('mysql'))))) {
- $this->popup_info = $popup_info;
- $date_today = date("Y-m-d");
- if ($popup_info['delay_days'] > 0)
- setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
- add_action('wp_print_styles', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_styles'
- ));
- add_action('wp_print_scripts', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_js'
- ));
- add_action('wp_head', array(
- &$this,
- 'ubam_optimum_sqz_add_popup_head_code'
- ));
- }
- }
- }
- }
- function ubam_optimum_sqz_add_popup_head_code()
- {
- global $wpdb;
- $the_page = $this->popup_info;
- if (!empty($the_page)) {
- $optimum_sqz_options = array();
- $saved_style_info = get_option("ubam_optimum_sqz_item_style_{$the_page['id']}", array());
- if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
- $base_style = get_option("ubam_optimum_sqz_style_{$saved_style_info['style']}");
- $the_page_style = $this->ubam_array_replace_recursive($base_style, $saved_style_info);
- $optimum_sqz_options = $this->ubam_remove_magic_quotes($the_page_style);
- }
- ?>
- <script type="text/javascript">
- jQuery.noConflict();
- jQuery(document).ready(function($) {
- $(document).ready(function(){
- setTimeout(function() { $.fn.colorbox({
- innerWidth:<?php
- echo $optimum_sqz_options['sheet']['width'] + 40;
- ?>,
- opacity:.5,
- speed:500,
- overlayClose:true,
- scrolling: false,
- href:'<?php
- echo OPTSQZ_SQZ_POPUP_URL . "/{$the_page['item_id']}.html";
- ?>'});
- },
- <?php
- echo $the_page['delay_secs'] * 1000;
- ?>);
- });
- });
- </script>
- <?php
- }
- }
- function getOptions()
- {
- if (!$theOptions = get_option($this->optionsName)) {
- $theOptions = array(
- 'default' => 'options'
- );
- update_option($this->optionsName, $theOptions);
- }
- $this->options = $theOptions;
- }
- function saveAdminOptions()
- {
- return update_option($this->optionsName, $this->options);
- }
- function admin_menu_link()
- {
- add_menu_page(__(OPTSQZ_MENU_TITLE, "ubam_optimum_sqz"), __(OPTSQZ_MENU_TITLE, "ubam_optimum_sqz"), 'manage_options', 'ubam_optimum_squeeze', array(
- &$this,
- 'ubam_optimum_sqz_load_menu_page'
- ));
- if (function_exists('add_submenu_page')) {
- add_submenu_page('ubam_optimum_squeeze', __(OPTSQZ_MENU_TITLE . ' Popup Pages', 'ubam_optimum_sqz'), __('Popup Pages'), 'manage_options', 'ubam_optimum_squeeze-pop-pages.php', array(
- &$this,
- 'ubam_optimum_sqz_load_menu_page'
- ));
- add_submenu_page('ubam_optimum_squeeze', __(OPTSQZ_MENU_TITLE . ' Popup Cats', 'ubam_optimum_sqz'), __('Popup Cats'), 'manage_options', 'ubam_optimum_squeeze-pop-cats.php', array(
- &$this,
- 'ubam_optimum_sqz_load_menu_page'
- ));
- }
- }
- function ubam_optimum_sqz_load_menu_page()
- {
- if (!empty($_REQUEST['page']) && file_exists(OPTSQZ_PLUGIN_DIR . $_REQUEST['page'])) {
- include_once(OPTSQZ_PLUGIN_DIR . $_REQUEST['page']);
- } else {
- $this->admin_options_page();
- }
- }
- function filter_plugin_actions($links, $file)
- {
- $settings_link = '<a href="options-general.php?page=' . basename(__FILE__) . '">' . __('Settings') . '</a>';
- array_unshift($links, $settings_link);
- return $links;
- }
- function admin_options_page()
- {
- global $wpdb;
- global $ubam_optimum_sqz_upload_dir, $ubam_optimum_sqz_popup_dir;
- if ($_POST['ubam_optimum_sqz_save']) {
- if (!wp_verify_nonce($_POST['_wpnonce'], 'ubam_optimum_sqz-update-options'))
- die('Whoops! There was a problem with the data you posted. Please go back and try again.');
- $this->saveAdminOptions();
- echo '<div class="updated"><p>Success! Your changes were sucessfully saved!</p></div>';
- }
- if ($_POST['action'] == 'edit' || $_POST['action'] == 'copy') {
- $the_id = $_POST['iid'];
- if ($_POST['action'] == 'copy') {
- $wpdb->show_errors();
- $source_item = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE id=$the_id", ARRAY_A);
- $columns = '';
- $values = '';
- foreach ($source_item as $key => $value) {
- if ($key == 'id')
- continue;
- if ($key == 'item_id') {
- $value .= '_copy';
- $the_item_id = $value;
- }
- $columns .= (!empty($columns) ? ', ' : '') . $key;
- $values .= (!empty($values) ? ', ' : '') . "'" . addslashes($value) . "'";
- }
- if (!empty($columns)) {
- $DUPSQL = "INSERT INTO {$wpdb->prefix}ubam_optimum_sqz_items ($columns) VALUES ($values)";
- $the_row = $wpdb->query($DUPSQL);
- if ($the_row) {
- $the_id = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}ubam_optimum_sqz_items where item_id = '$the_item_id'");
- $source_style_info = get_option("ubam_optimum_sqz_item_style_{$_POST['iid']}", array());
- update_option("ubam_optimum_sqz_item_style_$the_id", $source_style_info);
- }
- }
- $wpdb->hide_errors();
- }
- $editmode = true;
- $SQL = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'ubam_optimum_sqz_style_%' ";
- $style_options = $wpdb->get_results($SQL);
- if ($style_options) {
- $styles = array();
- foreach ($style_options as $style) {
- $the_style = substr($style->option_name, strlen('ubam_optimum_sqz_style_'));
- $styles[$the_style] = get_option($style->option_name);
- }
- }
- $eitem = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE id=$the_id");
- $begin_month = date("n", strtotime($eitem->start_date));
- $begin_day = date("j", strtotime($eitem->start_date));
- $begin_year = date("Y", strtotime($eitem->start_date));
- $page_style = array();
- $saved_style_info = get_option("ubam_optimum_sqz_item_style_{$eitem->id}", array());
- if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
- $the_page_style = $this->ubam_array_replace_recursive($styles[$saved_style_info['style']], $saved_style_info);
- $page_style = $this->ubam_remove_magic_quotes($the_page_style);
- }
- ?><div class="wrap">
- <h2><?php
- echo OPTSQZ_OPTION_PAGE_TITLE;
- ?></h2> <?php
- require_once(OPTSQZ_TEMPLATE_DIR . "item-entry-form.htm");
- } else {
- if ($_POST['action'] == 'delete') {
- $wpdb->show_errors();
- $wpdb->query("DELETE FROM {$wpdb->prefix}ubam_optimum_sqz_items WHERE id={$_POST['iid']}");
- $wpdb->hide_errors();
- $this->write_optimum_sqz_file($_POST['itemId'], true);
- delete_option("ubam_optimum_sqz_item_style_{$_POST['iid']}");
- delete_option("ubam_optimum_sqz_popup_{$_POST['item_id']}");
- echo '<div class="updated"><p>Success! Item has been deleted from the database.</p></div>';
- }
- $start_date = ($_POST['use_start_date'] == 'yes' ? date("Y-m-d 00:00:00", strtotime(sprintf("%d-%02d-%02d", $_POST['begin_year'], $_POST['begin_month'], $_POST['begin_day']))) : "0000-00-00 00:00:00");
- if ($_POST['ubam_optimum_sqz_add_item']) {
- $page_style = $this->set_page_style_array();
- $insert_query = "INSERT INTO {$wpdb->prefix}ubam_optimum_sqz_items " . " (item_id, item_name, " . " main_headline, sub_headline, " . " main_body, main_footer, " . " optin_provider, optin_code," . " optin_headline, optin_footer, optin_button_text, " . " optin_form_name_field, optin_form_email_field, optin_form_fname_field, optin_form_lname_field, " . " video_show, " . " video_url, video_description, " . " video_width, video_height, video_ctrlcolor, video_embed_code, " . " video_autoload, " . " video_autoplay, " . " video_loop, " . " video_autorewind, " . " video_showstop, " . " video_showvol, " . " video_showctrl, " . " video_ctrltrans, " . " video_showfull, " . " video_showseek, " . " template, display_mode, " . " enable_popup, display_page, " . " delay_secs, delay_days, " . " use_start_date, start_date) " . "VALUES ('{$_POST['item_id']}', '{$_POST['item_name']}', " . " '{$_POST['main_headline']}', '{$_POST['sub_headline']}', " . " '{$_POST['main_body']}', '{$_POST['main_footer']}', " . " '{$_POST['optin_provider']}', '{$_POST['optin_code']}', " . " '{$_POST['optin_headline']}', '{$_POST['optin_footer']}', '{$_POST['optin_button_text']}', " . " '{$_POST['optin_form_name_field']}', '{$_POST['optin_form_email_field']}', '{$_POST['optin_form_fname_field']}', '{$_POST['optin_form_lname_field']}', " . " " . (empty($_POST['video_show']) ? '0' : $_POST['video_show']) . ", " . " '{$_POST['video_url']}', '{$_POST['video_description']}', " . " '{$_POST['video_width']}', '{$_POST['video_height']}', '{$_POST['video_ctrlcolor']}', '{$_POST['video_embed_code']}', " . " " . (empty($_POST['video_autoload']) ? '0' : $_POST['video_autoload']) . ", " . " " . (empty($_POST['video_autoplay']) ? '0' : $_POST['video_autoplay']) . ", " . " " . (empty($_POST['video_loop']) ? '0' : $_POST['video_loop']) . ", " . " " . (empty($_POST['video_autorewind']) ? '0' : $_POST['video_autorewind']) . ", " . " " . (empty($_POST['video_showstop']) ? '0' : $_POST['video_showstop']) . ", " . " " . (empty($_POST['video_showvol']) ? '0' : $_POST['video_showvol']) . ", " . " " . (empty($_POST['video_showctrl']) ? '0' : $_POST['video_showctrl']) . ", " . " " . (empty($_POST['video_ctrltrans']) ? '0' : $_POST['video_ctrltrans']) . ", " . " " . (empty($_POST['video_showfull']) ? '0' : $_POST['video_showfull']) . ", " . " " . (empty($_POST['video_showseek']) ? '0' : $_POST['video_showseek']) . ", " . " '{$_POST['page_template']}', '{$_POST['display_mode']}', " . " " . (empty($_POST['enable_popup']) ? '0' : $_POST['enable_popup']) . ", " . " '{$_POST['display_page']}', " . " " . (empty($_POST['delay_secs']) ? '0' : $_POST['delay_secs']) . ", " . " " . (empty($_POST['delay_days']) ? '0' : $_POST['delay_days']) . ", " . " '{$_POST['use_start_date']}', '$start_date') ";
- $wpdb->show_errors();
- $qresult = $wpdb->query($insert_query);
- $wpdb->hide_errors();
- if ($qresult === false) {
- echo '<div class="updated"><p><font color="red"><strong>Warning!</strong></font> Unable to add the item.</p></div>';
- } else {
- $the_id = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}ubam_optimum_sqz_items where item_id = '{$_POST['item_id']}'");
- update_option("ubam_optimum_sqz_item_$the_id", $page_style);
- update_option("ubam_optimum_sqz_popup_{$_POST['item_id']}", array(
- 'id' => $the_id,
- 'item_id' => $_POST['item_id'],
- 'enable_popup' => $_POST['enable_popup'],
- 'use_start_date' => $_POST['use_start_date'],
- 'start_date' => $start_date,
- 'delay_secs' => $_POST['delay_secs'],
- 'delay_days' => $_POST['delay_days']
- ));
- $this->write_optimum_sqz_file($_POST['item_id']);
- echo '<div class="updated"><p>Success! Item has been added to the database.</p></div>';
- }
- }
- if ($_POST['ubam_optimum_sqz_update_item']) {
- $page_style = $this->set_page_style_array();
- $update_query = "UPDATE {$wpdb->prefix}ubam_optimum_sqz_items " . " SET item_id = '{$_POST['item_id']}' " . " , item_name = '{$_POST['item_name']}' " . " , main_headline = '{$_POST['main_headline']}' " . " , sub_headline = '{$_POST['sub_headline']}' " . " , main_body = '{$_POST['main_body']}' " . " , main_footer = '{$_POST['main_footer']}' " . " , optin_provider = '{$_POST['optin_provider']}' " . " , optin_code = '{$_POST['optin_code']}' " . " , optin_headline = '{$_POST['optin_headline']}' " . " , optin_footer = '{$_POST['optin_footer']}' " . " , optin_button_text = '{$_POST['optin_button_text']}' " . " , optin_form_name_field = '{$_POST['optin_form_name_field']}' " . " , optin_form_email_field = '{$_POST['optin_form_email_field']}' " . " , optin_form_fname_field = '{$_POST['optin_form_fname_field']}' " . " , optin_form_lname_field = '{$_POST['optin_form_lname_field']}' " . " , video_show = " . (empty($_POST['video_show']) ? '0' : $_POST['video_show']) . " " . " , video_url = '{$_POST['video_url']}' " . " , video_embed_code = '{$_POST['video_embed_code']}' " . " , video_description = '{$_POST['video_description']}' " . " , video_width = '{$_POST['video_width']}' " . " , video_height = '{$_POST['video_height']}' " . " , video_autoload = " . (empty($_POST['video_autoload']) ? '0' : $_POST['video_autoload']) . " " . " , video_autoplay = " . (empty($_POST['video_autoplay']) ? '0' : $_POST['video_autoplay']) . " " . " , video_loop = " . (empty($_POST['video_loop']) ? '0' : $_POST['video_loop']) . " " . " , video_autorewind = " . (empty($_POST['video_autorewind']) ? '0' : $_POST['video_autorewind']) . " " . " , video_showstop = " . (empty($_POST['video_showstop']) ? '0' : $_POST['video_showstop']) . " " . " , video_showvol = " . (empty($_POST['video_showvol']) ? '0' : $_POST['video_showvol']) . " " . " , video_showctrl = " . (empty($_POST['video_showctrl']) ? '0' : $_POST['video_showctrl']) . " " . " , video_ctrlcolor = '{$_POST['video_ctrlcolor']}' " . " , video_ctrltrans = " . (empty($_POST['video_ctrltrans']) ? '0' : $_POST['video_ctrltrans']) . " " . " , video_showfull = " . (empty($_POST['video_showfull']) ? '0' : $_POST['video_showfull']) . " " . " , video_showseek = " . (empty($_POST['video_showseek']) ? '0' : $_POST['video_showseek']) . " " . " , template = '{$_POST['page_template']}' " . " , display_mode = '{$_POST['display_mode']}' " . " , enable_popup = " . (empty($_POST['enable_popup']) ? '0' : $_POST['enable_popup']) . " " . " , use_start_date = '{$_POST['use_start_date']}' " . " , start_date = '$start_date' " . " , delay_secs = " . (empty($_POST['delay_secs']) ? '0' : $_POST['delay_secs']) . " " . " , delay_days = " . (empty($_POST['delay_days']) ? '0' : $_POST['delay_days']) . " " . " , display_page = '{$_POST['display_page']}' " . " WHERE id = {$_POST['id']} ";
- $wpdb->show_errors();
- $qresult = $wpdb->query($update_query);
- $wpdb->hide_errors();
- if ($qresult === false) {
- echo '<div class="updated"><p><font color="red"><strong>Warning!</strong></font> Unable to update the item.</p></div>';
- } else {
- update_option("ubam_optimum_sqz_item_style_{$_POST['id']}", $page_style);
- update_option("ubam_optimum_sqz_popup_{$_POST['item_id']}", array(
- 'id' => $_POST['id'],
- 'item_id' => $_POST['item_id'],
- 'enable_popup' => $_POST['enable_popup'],
- 'use_start_date' => $_POST['use_start_date'],
- 'start_date' => $start_date,
- 'delay_secs' => $_POST['delay_secs'],
- 'delay_days' => $_POST['delay_days']
- ));
- $this->write_optimum_sqz_file($_POST['item_id']);
- echo '<div class="updated"><p>Success! Item has been successfully changed.</p></div>';
- }
- }
- $coreSQL = " FROM {$wpdb->prefix}ubam_optimum_sqz_items ORDER BY item_id";
- $SQL = "SELECT * $coreSQL";
- $countSQL = "SELECT count(*) $coreSQL";
- $wpdb->show_errors();
- $item_count = $wpdb->get_var($countSQL);
- $wpdb->hide_errors();
- $list_number = 20;
- if ($item_count == 0) {
- $itemlist = array();
- } else {
- require_once dirname(__FILE__) . "/includes/wp_paginate.php";
- $pager = new ubam_wp_paginate($SQL, $list_number, 5, $item_count, $js_function = "processPaginate");
- $the_page = (empty($_POST['wpppage']) ? 1 : $_POST['wpppage']);
- $itemlist = $pager->paginate($the_page);
- $pager_nav = $pager->renderFullNav();
- }
- $SQL = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'ubam_optimum_sqz_style_%' ";
- $style_options = $wpdb->get_results($SQL);
- if ($style_options) {
- $styles = array();
- foreach ($style_options as $style) {
- $the_style = substr($style->option_name, strlen('ubam_optimum_sqz_style_'));
- $styles[$the_style] = get_option($style->option_name);
- }
- }
- $admin_link_prefix = 'admin.php?page=';
- $popup = new ubam_optimum_sqz_items();
- if (!file_exists(OPTSQZ_SQZ_POPUP_DIR) || !is_dir(OPTSQZ_SQZ_POPUP_DIR)) {
- echo '<div class="updated"><p style="color: red;"><strong>WARNING!</strong> Unable to create temp popup directory \'' . basename(OPTSQZ_SQZ_POPUP_DIR) . '\' in the WordPress upload directory \'' . basename($ubam_optimum_sqz_upload_dir['basedir']) . '\'.</p></div>';
- }
- include_once(OPTSQZ_TEMPLATE_DIR . "header.htm");
- include_once(OPTSQZ_TEMPLATE_DIR . "item-list.htm");
- include_once(OPTSQZ_TEMPLATE_DIR . "footer.htm");
- }
- }
- function ubam_optimum_sqz_video_js($squeeze_pg)
- {
- if (empty($squeeze_pg->video_url) && empty($squeeze_pg->video_embed_code))
- return '';
- $description = '';
- if (!empty($squeeze_pg->video_description))
- $description = "*Video:" . htmlspecialchars($squeeze_pg->video_description);
- if (preg_match('/youtube.com/i', $squeeze_pg->video_url)) {
- $sep = "&";
- $parsed_url = parse_url($squeeze_pg->video_url);
- parse_str($parsed_url['query']);
- $borderColor = '#b1b1b1';
- if (!empty($squeeze_pg->video_ctrlcolor)) {
- $controls .= "{$sep}color1=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor) . "{$sep}color2=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor);
- $borderColor = $squeeze_pg->video_ctrlcolor;
- }
- if ($squeeze_pg->video_autoplay == 1)
- $controls .= "{$sep}autoplay=1";
- if ($squeeze_pg->video_loop == 1)
- $controls .= "{$sep}loop=1";
- $params = '';
- $embedParams = '';
- if ($squeeze_pg->video_showfull == 1) {
- $controls .= "{$sep}fs=1";
- $params .= '<param name="allowFullScreen" value="true"></param>';
- $embedParams .= 'allowfullscreen="true" ';
- }
- $videojs = "<div><div id='optimum-sqz-video-div' style='display:block;width:" . ($squeeze_pg->video_width) . "px;background-color:$borderColor;padding:2px;margin-right:auto;margin-left:auto;' title=\"$description\">";
- $videojs .= '<object width="' . $squeeze_pg->video_width . '" height="' . (intval($squeeze_pg->video_height) + 25) . '">';
- $videojs .= '<param name="movie" value="http://www.youtube.com/v/' . $v . '?showinfo=0' . $controls . '"';
- $videojs .= '<param name="allowScriptAccess" value="always"></param>';
- $videojs .= $params;
- $videojs .= '<embed src="http://www.youtube.com/v/' . $v . '?showinfo=0' . $controls . '" type="application/x-shockwave-flash" ';
- $videojs .= 'allowscriptaccess="always" ';
- $videojs .= 'width="' . $squeeze_pg->video_width . '" height="' . (intval($squeeze_pg->video_height) + 25) . '" ';
- $videojs .= $embedParams . '</embed></object></div></div>';
- } elseif (!empty($squeeze_pg->video_url)) {
- $splashImage = '';
- $player = OPTSQZ_PLUGIN_URL . "js/flowplayer3/flowplayer-3.2.3.swf";
- if (!empty($squeeze_pg->video_splashimage)) {
- $alt = '';
- if (!empty($description))
- $alt = "alt='$description'";
- $splashImage = '<img src="' . $squeeze_pg->video_splashimage . '" style="width:' . $squeeze_pg->video_width . 'px; height:' . $squeeze_pg->video_height . 'px;border:0;margin:0;padding:0" $alt />';
- }
- $loop = '';
- $autorewind = '';
- if ($squeeze_pg->video_loop == 1) {
- $loop = ', onBeforeFinish : function() { this.play(0); return false; } ';
- } else if ($squeeze_pg->video_autorewind == 1) {
- $autorewind = ', onFinish : function () { this.seek(0); } ';
- }
- $sep = ", ";
- $controls = "";
- $borderColor = '#999999';
- if ($squeeze_pg->video_showctrl == 2) {
- $controls = "plugins: { controls: null } ";
- } else {
- if ($squeeze_pg->video_showstop == 1)
- $controls .= "stop:true";
- if ($squeeze_pg->video_showvol == 0)
- $controls .= (empty($controls) ? '' : $sep) . "volume:false, mute:false";
- if ($squeeze_pg->video_showtime == 1)
- $controls .= (empty($controls) ? '' : $sep) . "time:false";
- if ($squeeze_pg->video_showctrl == 0)
- $controls .= (empty($controls) ? '' : $sep) . "autoHide: 'never'";
- if ($squeeze_pg->video_showctrl == 1)
- $controls .= (empty($controls) ? '' : $sep) . "autoHide: 'always'";
- if ($squeeze_pg->video_ctrltrans == 1) {
- $controls .= (empty($controls) ? '' : $sep) . "backgroundColor: 'transparent', backgroundGradient: 'none'";
- } else {
- if (!empty($squeeze_pg->video_ctrlcolor)) {
- $controls .= (empty($controls) ? '' : $sep) . "backgroundColor:'{$squeeze_pg->video_ctrlcolor}'";
- $borderColor = $squeeze_pg->video_ctrlcolor;
- }
- }
- if ($squeeze_pg->video_showfull == 0)
- $controls .= (empty($controls) ? '' : $sep) . "fullscreen:false";
- if ($squeeze_pg->video_showseek == 0)
- $controls .= (empty($controls) ? '' : $sep) . "scrubber: false";
- $controls = "plugins: { controls: { " . $controls . " } }";
- }
- if (!empty($controls)) {
- $controls_text = "
- ,
- $controls
- ";
- }
- $videojs = "<script type='text/javascript' src='" . OPTSQZ_PLUGIN_URL . "js/flowplayer3/example/flowplayer-3.2.3.min.js'></script>";
- $videojs .= "<div><div id='optimum-sqz-video-div' style='display:block;width:" . $squeeze_pg->video_width . "px;height:" . $squeeze_pg->video_height . "px;background-color:$borderColor;padding:2px;margin-right:auto;margin-left:auto;' title=\"$description\">$splashImage</div></div>";
- $videojs .= "<script type='text/javascript'>\n";
- $videojs .= "flowplayer('optimum-sqz-video-div', { src: '$player', wmode: 'transparent' }, { \n";
- $videojs .= " clip: { \n";
- $videojs .= " url: '" . $squeeze_pg->video_url . "', \n";
- $videojs .= " scaling: 'scale', autoPlay: " . ($squeeze_pg->video_autoplay == 1 ? 'true' : 'false') . ", autoBuffering: " . ($squeeze_pg->video_autoload == 1 ? 'true' : 'false') . " \n";
- $videojs .= " $loop $autorewind \n";
- $videojs .= " } \n";
- $videojs .= " $controls_text \n";
- $videojs .= "}); \n";
- $videojs .= "</script> ";
- } else {
- $borderColor = '#b1b1b1';
- if (!empty($squeeze_pg->video_ctrlcolor)) {
- $controls .= "{$sep}color1=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor) . "{$sep}color2=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor);
- $borderColor = $squeeze_pg->video_ctrlcolor;
- }
- $videojs = "<div><div id='optimum-sqz-video-div' style='display:block;width:" . ($squeeze_pg->video_width) . "px;height:" . $squeeze_pg->video_height . "px;background-color:$borderColor;padding:2px;margin-right:auto;margin-left:auto;' title=\"$description\">";
- $videojs .= $squeeze_pg->video_embed_code . '</div></div>';
- }
- return $videojs;
- }
- function parse_attributes($attrib_string)
- {
- $search_arr = array(
- "\n",
- "<br />",
- "\t"
- );
- $replace_arr = array(
- " ",
- " ",
- " "
- );
- $attrib_string = str_replace($search_arr, $replace_arr, $attrib_string);
- $regex = '@([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*"|\S*)@';
- preg_match_all($regex, $attrib_string, $matches);
- $attr = array();
- for ($i = 0; $i < count($matches[0]); $i++) {
- if (!empty($matches[0][$i]) && !empty($matches[1][$i])) {
- if (preg_match("/^'(.*)'$/", $matches[2][$i], $vmatch)) {
- $value = $vmatch[1];
- } else if (preg_match('/^"(.*)"$/', $matches[2][$i], $vmatch)) {
- $value = $vmatch[1];
- } else {
- $value = $matches[2][$i];
- }
- $key = strtolower($matches[1][$i]);
- $attr[$key] = $value;
- }
- }
- return $attr;
- }
- function create_optin_html($squeeze_pg)
- {
- $optin_code = $squeeze_pg->optin_code;
- $optin_provider = $squeeze_pg->optin_provider;
- $optin_button_text = $squeeze_pg->optin_button_text;
- if (empty($optin_code) || empty($optin_provider))
- return '';
- $optin_base = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . 'optin_base_tpl.htm');
- $optin_base_name_row = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . 'optin_base_name_row_tpl.htm');
- $htmlArray = $this->parseHtml($optin_code);
- $optin_out = '<form method="post" name="optimumsqzoptinform" action=' . $htmlArray['FORM'][0]['ACTION'] . ' onSubmit="javascript: return osOptInValidate();">';
- $name = $squeeze_pg->optin_form_name_field;
- $fname = $squeeze_pg->optin_form_fname_field;
- $lname = $squeeze_pg->optin_form_lname_field;
- $email = $squeeze_pg->optin_form_email_field;
- $optin_name_rows = '';
- $div = '<div style="width: 200px; margin: 0 auto;">';
- if (!is_array($htmlArray['INPUT']))
- return '';
- foreach ($htmlArray['INPUT'] as $input) {
- if (strpos(strtolower($input['TYPE']), 'hidden') !== false) {
- $optin_out .= '<input type="hidden" name=' . $input['NAME'] . ' value=' . $input['VALUE'] . '>';
- }
- if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($name)) && (strpos(strtolower($input['NAME']), $name) !== false)) {
- $optin_prompt = '<span class="optimum-sqz-input-prompt" id="optimum-sqz-input-prompt-name" onclick="javascript: promptHidePrompt(this, \'optimum-sqz-input-text-name\');">Enter your name...</span>' . "\n";
- $optin_name = $div . $optin_prompt . '<input type="text" name=' . $input['NAME'] . ' value="" class="optimum-sqz-input-text" prompt="optimum-sqz-input-prompt-name" id="optimum-sqz-input-text-name" onFocus="javascript: hidePrompt(this);" onBlur="javascript: showPrompt(this);" tabindex="400"></div>';
- $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
- $optin_name_rows .= $toptin_name_rows;
- }
- if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($fname)) && (strpos(strtolower($input['NAME']), $fname) !== false)) {
- $optin_prompt = '<span class="optimum-sqz-input-prompt" id="optimum-sqz-input-prompt-fname" onclick="javascript: promptHidePrompt(this, \'optimum-sqz-input-text-fname\');">Enter your first name...</span>' . "\n";
- $optin_name = $div . $optin_prompt . '<input type="text" name=' . $input['NAME'] . ' value="" class="optimum-sqz-input-text" prompt="optimum-sqz-input-prompt-fname" id="optimum-sqz-input-text-fname" onFocus="javascript: hidePrompt(this);" onBlur="javascript: showPrompt(this);" tabindex="400"></div>';
- $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
- $optin_name_rows .= $toptin_name_rows;
- }
- if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($lname)) && (strpos(strtolower($input['NAME']), $lname) !== false)) {
- $optin_prompt = '<span class="optimum-sqz-input-prompt" id="optimum-sqz-input-prompt-lname" onclick="javascript: promptHidePrompt(this, \'optimum-sqz-input-text-lname\');">Enter your last name...</span>' . "\n";
- $optin_name = $div . $optin_prompt . '<input type="text" name=' . $input['NAME'] . ' value="" class="optimum-sqz-input-text" prompt="optimum-sqz-input-prompt-lname" id="optimum-sqz-input-text-lname" onFocus="javascript: hidePrompt(this);" onBlur="javascript: showPrompt(this);" tabindex="450"></div>';
- $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
- $optin_name_rows .= $toptin_name_rows;
- }
- if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (strpos(strtolower($input['NAME']), $email) !== false)) {
- $optin_prompt = '<span class="optimum-sqz-input-prompt" id="optimum-sqz-input-prompt-email" onclick="javascript: promptHidePrompt(this, \'optimum-sqz-input-text-email\');">Enter your email address...</span>' . "\n";
- $optin_email = $div . $optin_prompt . '<input type="text" name=' . $input['NAME'] . ' value="" class="optimum-sqz-input-text" prompt="optimum-sqz-input-prompt-email" id="optimum-sqz-input-text-email" onFocus="javascript: hidePrompt(this);" onBlur="javascript: showPrompt(this);" tabindex="500"></div>';
- }
- }
- $format_out = $optin_base;
- $format_out = str_replace('[[-optin_name_rows-]]', $optin_name_rows, $format_out);
- $format_out = str_replace('[[-optin_email-]]', $optin_email, $format_out);
- $format_out = str_replace('[[-optin_button_text-]]', $optin_button_text, $format_out);
- $optin_out .= $format_out . '</form>';
- return $optin_out;
- }
- function ubam_array_replace_recursive()
- {
- $arrays = func_get_args();
- $original = array_shift($arrays);
- foreach ($arrays as $array) {
- foreach ($array as $key => $value) {
- if (is_array($value)) {
- $original[$key] = $this->ubam_array_replace_recursive($original[$key], $array[$key]);
- } else {
- $original[$key] = $value;
- }
- }
- }
- return $original;
- }
- function ubam_add_magic_quotes($array)
- {
- foreach ((array) $array as $k => $v) {
- if (is_array($v)) {
- $array[$k] = $this->ubam_add_magic_quotes($v);
- } else {
- $array[$k] = addslashes($v);
- }
- }
- return $array;
- }
- function ubam_remove_magic_quotes($array)
- {
- foreach ((array) $array as $k => $v) {
- if (is_array($v)) {
- $array[$k] = $this->ubam_remove_magic_quotes($v);
- } else {
- $array[$k] = stripslashes($v);
- }
- }
- return $array;
- }
- function compress_css($buffer)
- {
- $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
- $buffer = str_replace(array(
- "\r\n",
- "\r",
- "\n",
- "\t",
- ' ',
- ' ',
- ' '
- ), '', $buffer);
- return $buffer;
- }
- function parseHtml($s_str)
- {
- $i_indicatorL = 0;
- $i_indicatorR = 0;
- $s_tagOption = "";
- $i_arrayCounter = 0;
- $a_html = array();
- while (is_int(($i_indicatorL = strpos($s_str, "<", $i_indicatorR)))) {
- $i_indicatorL++;
- $i_indicatorR = strpos($s_str, ">", $i_indicatorL);
- $s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR - $i_indicatorL));
- $a_tag = explode(' ', $s_temp);
- list(, $s_tagName, , ) = each($a_tag);
- $s_tagName = strtoupper($s_tagName);
- $b_boolOptions = is_array(($s_tagOption = each($a_tag))) && $s_tagOption[1];
- if ($b_boolOptions) {
- $i_arrayCounter = (int) count($a_html[$s_tagName]);
- do {
- $eqPos = strpos($s_tagOption[1], '=');
- if ($eqPos != false) {
- $s_tagTokOption = strtoupper(substr($s_tagOption[1], 0, $eqPos));
- $s_tagTokValue = trim(substr($s_tagOption[1], ($eqPos + 1)));
- $a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] = $s_tagTokValue;
- }
- $b_boolOptions = is_array(($s_tagOption = each($a_tag))) && $s_tagOption[1];
- } while ($b_boolOptions);
- }
- }
- return $a_html;
- }
- function array_to_object($array = array())
- {
- if (!empty($array)) {
- $data = false;
- foreach ($array as $akey => $aval) {
- if ($akey == 'main_headline' || $akey == 'sub_headline' || $akey == 'main_body' || $akey == 'optin_headline' || $akey == 'optin_footer' || $akey == 'main_footer' || $akey == 'optin_button_text' || $akey == 'video_embed_code')
- $aval = stripslashes($aval);
- $data->{$akey} = $aval;
- }
- return $data;
- }
- return false;
- }
- function ieversion()
- {
- $match = preg_match('/MSIE ([0-9]\.[0-9])/', $_SERVER['HTTP_USER_AGENT'], $reg);
- if ($match == 0)
- return -1;
- else
- return floatval($reg[1]);
- }
- function set_page_style_array()
- {
- if (!empty($_POST['ubam_optimum_sqz_page_style']))
- $page_style['style'] = $_POST['ubam_optimum_sqz_page_style'];
- if (!empty($_POST['ubam_optimum_sqz_page_width']))
- $page_style['sheet']['width'] = $_POST['ubam_optimum_sqz_page_width'];
- if (!empty($_POST['ubam_optimum_sqz_top_margin']))
- $page_style['sheet']['margin-top'] = $_POST['ubam_optimum_sqz_top_margin'];
- if (!empty($_POST['ubam_optimum_sqz_body_bg_color']))
- $page_style['body']['background-color'] = $_POST['ubam_optimum_sqz_body_bg_color'];
- if (!empty($_POST['ubam_optimum_sqz_show_gradient']))
- $page_style['body']['gradient'] = $_POST['ubam_optimum_sqz_show_gradient'];
- if (!empty($_POST['ubam_optimum_sqz_show_borders']))
- $page_style['sheet-border']['show'] = $_POST['ubam_optimum_sqz_show_borders'];
- if (!empty($_POST['ubam_optimum_sqz_bgimg_url']))
- $page_style['body']['bgimg']['background-image'] = $_POST['ubam_optimum_sqz_bgimg_url'];
- if (!empty($_POST['ubam_optimum_sqz_bgimg_repeat']))
- $page_style['body']['bgimg']['background-repeat'] = $_POST['ubam_optimum_sqz_bgimg_repeat'];
- if (!empty($_POST['ubam_optimum_sqz_bgimg_position']))
- $page_style['body']['bgimg']['background-position'] = $_POST['ubam_optimum_sqz_bgimg_position'];
- if (!empty($_POST['ubam_optimum_sqz_bgimg_attachment']))
- $page_style['body']['bgimg']['background-attachment'] = $_POST['ubam_optimum_sqz_bgimg_attachment'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_size']))
- $page_style['post-content']['font-size'] = $_POST['ubam_optimum_sqz_postcontent_size'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_color']))
- $page_style['post-content']['color'] = $_POST['ubam_optimum_sqz_postcontent_color'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_weight']))
- $page_style['post-content']['font-weight'] = $_POST['ubam_optimum_sqz_postcontent_weight'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_style']))
- $page_style['post-content']['font-style'] = $_POST['ubam_optimum_sqz_postcontent_style'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_align']))
- $page_style['post-content']['text-align'] = $_POST['ubam_optimum_sqz_postcontent_align'];
- if (!empty($_POST['ubam_optimum_sqz_postcontent_font']))
- $page_style['post-content']['font-family'] = $_POST['ubam_optimum_sqz_postcontent_font'];
- if (!empty($_POST['ubam_optimum_sqz_olul_size']))
- $page_style['ol-ul']['font-size'] = $_POST['ubam_optimum_sqz_olul_size'];
- if (!empty($_POST['ubam_optimum_sqz_olul_color']))
- $page_style['ol-ul']['color'] = $_POST['ubam_optimum_sqz_olul_color'];
- if (!empty($_POST['ubam_optimum_sqz_olul_font']))
- $page_style['ol-ul']['font-family'] = $_POST['ubam_optimum_sqz_olul_font'];
- if (!empty($_POST['ubam_optimum_sqz_h1_size']))
- $page_style['h1']['font-size'] = $_POST['ubam_optimum_sqz_h1_size'];
- if (!empty($_POST['ubam_optimum_sqz_h1_color']))
- $page_style['h1']['color'] = $_POST['ubam_optimum_sqz_h1_color'];
- if (!empty($_POST['ubam_optimum_sqz_h1_weight']))
- $page_style['h1']['font-weight'] = $_POST['ubam_optimum_sqz_h1_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h1_style']))
- $page_style['h1']['font-style'] = $_POST['ubam_optimum_sqz_h1_style'];
- if (!empty($_POST['ubam_optimum_sqz_h1_align']))
- $page_style['h1']['text-align'] = $_POST['ubam_optimum_sqz_h1_align'];
- if (!empty($_POST['ubam_optimum_sqz_h1_font']))
- $page_style['h1']['font-family'] = $_POST['ubam_optimum_sqz_h1_font'];
- if (!empty($_POST['ubam_optimum_sqz_h2_size']))
- $page_style['h2']['font-size'] = $_POST['ubam_optimum_sqz_h2_size'];
- if (!empty($_POST['ubam_optimum_sqz_h2_color']))
- $page_style['h2']['color'] = $_POST['ubam_optimum_sqz_h2_color'];
- if (!empty($_POST['ubam_optimum_sqz_h2_weight']))
- $page_style['h2']['font-weight'] = $_POST['ubam_optimum_sqz_h2_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h2_style']))
- $page_style['h2']['font-style'] = $_POST['ubam_optimum_sqz_h2_style'];
- if (!empty($_POST['ubam_optimum_sqz_h2_align']))
- $page_style['h2']['text-align'] = $_POST['ubam_optimum_sqz_h2_align'];
- if (!empty($_POST['ubam_optimum_sqz_h2_font']))
- $page_style['h2']['font-family'] = $_POST['ubam_optimum_sqz_h2_font'];
- if (!empty($_POST['ubam_optimum_sqz_h3_size']))
- $page_style['h3']['font-size'] = $_POST['ubam_optimum_sqz_h3_size'];
- if (!empty($_POST['ubam_optimum_sqz_h3_color']))
- $page_style['h3']['color'] = $_POST['ubam_optimum_sqz_h3_color'];
- if (!empty($_POST['ubam_optimum_sqz_h3_weight']))
- $page_style['h3']['font-weight'] = $_POST['ubam_optimum_sqz_h3_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h3_style']))
- $page_style['h3']['font-style'] = $_POST['ubam_optimum_sqz_h3_style'];
- if (!empty($_POST['ubam_optimum_sqz_h3_align']))
- $page_style['h3']['text-align'] = $_POST['ubam_optimum_sqz_h3_align'];
- if (!empty($_POST['ubam_optimum_sqz_h3_font']))
- $page_style['h3']['font-family'] = $_POST['ubam_optimum_sqz_h3_font'];
- if (!empty($_POST['ubam_optimum_sqz_h4_size']))
- $page_style['h4']['font-size'] = $_POST['ubam_optimum_sqz_h4_size'];
- if (!empty($_POST['ubam_optimum_sqz_h4_color']))
- $page_style['h4']['color'] = $_POST['ubam_optimum_sqz_h4_color'];
- if (!empty($_POST['ubam_optimum_sqz_h4_weight']))
- $page_style['h4']['font-weight'] = $_POST['ubam_optimum_sqz_h4_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h4_style']))
- $page_style['h4']['font-style'] = $_POST['ubam_optimum_sqz_h4_style'];
- if (!empty($_POST['ubam_optimum_sqz_h4_align']))
- $page_style['h4']['text-align'] = $_POST['ubam_optimum_sqz_h4_align'];
- if (!empty($_POST['ubam_optimum_sqz_h4_font']))
- $page_style['h4']['font-family'] = $_POST['ubam_optimum_sqz_h4_font'];
- if (!empty($_POST['ubam_optimum_sqz_h5_size']))
- $page_style['h5']['font-size'] = $_POST['ubam_optimum_sqz_h5_size'];
- if (!empty($_POST['ubam_optimum_sqz_h5_color']))
- $page_style['h5']['color'] = $_POST['ubam_optimum_sqz_h5_color'];
- if (!empty($_POST['ubam_optimum_sqz_h5_weight']))
- $page_style['h5']['font-weight'] = $_POST['ubam_optimum_sqz_h5_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h5_style']))
- $page_style['h5']['font-style'] = $_POST['ubam_optimum_sqz_h5_style'];
- if (!empty($_POST['ubam_optimum_sqz_h5_align']))
- $page_style['h5']['text-align'] = $_POST['ubam_optimum_sqz_h5_align'];
- if (!empty($_POST['ubam_optimum_sqz_h5_font']))
- $page_style['h5']['font-family'] = $_POST['ubam_optimum_sqz_h5_font'];
- if (!empty($_POST['ubam_optimum_sqz_h6_size']))
- $page_style['h6']['font-size'] = $_POST['ubam_optimum_sqz_h6_size'];
- if (!empty($_POST['ubam_optimum_sqz_h6_color']))
- $page_style['h6']['color'] = $_POST['ubam_optimum_sqz_h6_color'];
- if (!empty($_POST['ubam_optimum_sqz_h6_weight']))
- $page_style['h6']['font-weight'] = $_POST['ubam_optimum_sqz_h6_weight'];
- if (!empty($_POST['ubam_optimum_sqz_h6_style']))
- $page_style['h6']['font-style'] = $_POST['ubam_optimum_sqz_h6_style'];
- if (!empty($_POST['ubam_optimum_sqz_h6_align']))
- $page_style['h6']['text-align'] = $_POST['ubam_optimum_sqz_h6_align'];
- if (!empty($_POST['ubam_optimum_sqz_h6_font']))
- $page_style['h6']['font-family'] = $_POST['ubam_optimum_sqz_h6_font'];
- if (!empty($_POST['ubam_optimum_sqz_a_color']))
- $page_style['a']['color'] = $_POST['ubam_optimum_sqz_a_color'];
- if (!empty($_POST['ubam_optimum_sqz_a_decoration']))
- $page_style['a']['text-decoration'] = $_POST['ubam_optimum_sqz_a_decoration'];
- if (!empty($_POST['ubam_optimum_sqz_a_font']))
- $page_style['a']['font-family'] = $_POST['ubam_optimum_sqz_a_font'];
- if (!empty($_POST['ubam_optimum_sqz_alink_color']))
- $page_style['a-link']['color'] = $_POST['ubam_optimum_sqz_alink_color'];
- if (!empty($_POST['ubam_optimum_sqz_alink_decoration']))
- $page_style['a-link']['text-decoration'] = $_POST['ubam_optimum_sqz_alink_decoration'];
- if (!empty($_POST['ubam_optimum_sqz_alink_font']))
- $page_style['a-link']['font-family'] = $_POST['ubam_optimum_sqz_alink_font'];
- if (!empty($_POST['ubam_optimum_sqz_ahover_color']))
- $page_style['a-hover']['color'] = $_POST['ubam_optimum_sqz_ahover_color'];
- if (!empty($_POST['ubam_optimum_sqz_ahover_decoration']))
- $page_style['a-hover']['text-decoration'] = $_POST['ubam_optimum_sqz_ahover_decoration'];
- if (!empty($_POST['ubam_optimum_sqz_ahover_font']))
- $page_style['a-hover']['font-family'] = $_POST['ubam_optimum_sqz_ahover_font'];
- if (!empty($_POST['ubam_optimum_sqz_avisited_color']))
- $page_style['a-visited']['color'] = $_POST['ubam_optimum_sqz_avisited_color'];
- if (!empty($_POST['ubam_optimum_sqz_avisited_decoration']))
- $page_style['a-visited']['text-decoration'] = $_POST['ubam_optimum_sqz_avisited_decoration'];
- if (!empty($_POST['ubam_optimum_sqz_avisited_font']))
- $page_style['a-visited']['font-family'] = $_POST['ubam_optimum_sqz_avisited_font'];
- return $page_style;
- }
- function get_page_style_settings()
- {
- $the_style = htmlspecialchars(trim($_POST['style']));
- if (empty($the_style))
- return '';
- $base_style = get_option("ubam_optimum_sqz_style_$the_style");
- $page_style = $this->ubam_remove_magic_quotes($base_style);
- $output['ubam_optimum_sqz_page_style'] = $the_style;
- $output['ubam_optimum_sqz_top_margin'] = $page_style['sheet']['margin-top'];
- $output['ubam_optimum_sqz_body_bg_color'] = $page_style['body']['background-color'];
- $output['ubam_optimum_sqz_show_gradient'] = $page_style['body']['gradient'];
- $output['ubam_optimum_sqz_show_borders'] = $page_style['sheet-border']['show'];
- $output['ubam_optimum_sqz_bgimg_url'] = $page_style['body']['bgimg']['background-image'];
- $output['ubam_optimum_sqz_bgimg_repeat'] = $page_style['body']['bgimg']['background-repeat'];
- $output['ubam_optimum_sqz_bgimg_position'] = $page_style['body']['bgimg']['background-position'];
- $output['ubam_optimum_sqz_bgimg_attachment'] = $page_style['body']['bgimg']['background-attachment'];
- $output['ubam_optimum_sqz_postcontent_size'] = $page_style['post-content']['font-size'];
- $output['ubam_optimum_sqz_postcontent_color'] = $page_style['post-content']['color'];
- $output['ubam_optimum_sqz_postcontent_weight'] = $page_style['post-content']['font-weight'];
- $output['ubam_optimum_sqz_postcontent_style'] = $page_style['post-content']['font-style'];
- $output['ubam_optimum_sqz_postcontent_align'] = $page_style['post-content']['text-align'];
- $output['ubam_optimum_sqz_postcontent_font'] = $page_style['post-content']['font-family'];
- $output['ubam_optimum_sqz_olul_size'] = $page_style['ol-ul']['font-size'];
- $output['ubam_optimum_sqz_olul_color'] = $page_style['ol-ul']['color'];
- $output['ubam_optimum_sqz_olul_font'] = $page_style['ol-ul']['font-family'];
- $output['ubam_optimum_sqz_h1_size'] = $page_style['h1']['font-size'];
- $output['ubam_optimum_sqz_h1_color'] = $page_style['h1']['color'];
- $output['ubam_optimum_sqz_h1_weight'] = $page_style['h1']['font-weight'];
- $output['ubam_optimum_sqz_h1_style'] = $page_style['h1']['font-style'];
- $output['ubam_optimum_sqz_h1_align'] = $page_style['h1']['text-align'];
- $output['ubam_optimum_sqz_h1_font'] = $page_style['h1']['font-family'];
- $output['ubam_optimum_sqz_h2_size'] = $page_style['h2']['font-size'];
- $output['ubam_optimum_sqz_h2_color'] = $page_style['h2']['color'];
- $output['ubam_optimum_sqz_h2_weight'] = $page_style['h2']['font-weight'];
- $output['ubam_optimum_sqz_h2_style'] = $page_style['h2']['font-style'];
- $output['ubam_optimum_sqz_h2_align'] = $page_style['h2']['text-align'];
- $output['ubam_optimum_sqz_h2_font'] = $page_style['h2']['font-family'];
- $output['ubam_optimum_sqz_h3_size'] = $page_style['h3']['font-size'];
- $output['ubam_optimum_sqz_h3_color'] = $page_style['h3']['color'];
- $output['ubam_optimum_sqz_h3_weight'] = $page_style['h3']['font-weight'];
- $output['ubam_optimum_sqz_h3_style'] = $page_style['h3']['font-style'];
- $output['ubam_optimum_sqz_h3_align'] = $page_style['h3']['text-align'];
- $output['ubam_optimum_sqz_h3_font'] = $page_style['h3']['font-family'];
- $output['ubam_optimum_sqz_h4_size'] = $page_style['h4']['font-size'];
- $output['ubam_optimum_sqz_h4_color'] = $page_style['h4']['color'];
- $output['ubam_optimum_sqz_h4_weight'] = $page_style['h4']['font-weight'];
- $output['ubam_optimum_sqz_h4_style'] = $page_style['h4']['font-style'];
- $output['ubam_optimum_sqz_h4_align'] = $page_style['h4']['text-align'];
- $output['ubam_optimum_sqz_h4_font'] = $page_style['h4']['font-family'];
- $output['ubam_optimum_sqz_h5_size'] = $page_style['h5']['font-size'];
- $output['ubam_optimum_sqz_h5_color'] = $page_style['h5']['color'];
- $output['ubam_optimum_sqz_h5_weight'] = $page_style['h5']['font-weight'];
- $output['ubam_optimum_sqz_h5_style'] = $page_style['h5']['font-style'];
- $output['ubam_optimum_sqz_h5_align'] = $page_style['h5']['text-align'];
- $output['ubam_optimum_sqz_h5_font'] = $page_style['h5']['font-family'];
- $output['ubam_optimum_sqz_h6_size'] = $page_style['h6']['font-size'];
- $output['ubam_optimum_sqz_h6_color'] = $page_style['h6']['color'];
- $output['ubam_optimum_sqz_h6_weight'] = $page_style['h6']['font-weight'];
- $output['ubam_optimum_sqz_h6_style'] = $page_style['h6']['font-style'];
- $output['ubam_optimum_sqz_h6_align'] = $page_style['h6']['text-align'];
- $output['ubam_optimum_sqz_h6_font'] = $page_style['h6']['font-family'];
- $output['ubam_optimum_sqz_a_color'] = $page_style['a']['color'];
- $output['ubam_optimum_sqz_a_decoration'] = $page_style['a']['text-decoration'];
- $output['ubam_optimum_sqz_a_font'] = $page_style['a']['font-family'];
- $output['ubam_optimum_sqz_alink_color'] = $page_style['a-link']['color'];
- $output['ubam_optimum_sqz_alink_decoration'] = $page_style['a-link']['text-decoration'];
- $output['ubam_optimum_sqz_alink_font'] = $page_style['a-link']['font-family'];
- $output['ubam_optimum_sqz_ahover_color'] = $page_style['a-hover']['color'];
- $output['ubam_optimum_sqz_ahover_decoration'] = $page_style['a-hover']['text-decoration'];
- $output['ubam_optimum_sqz_ahover_font'] = $page_style['a-hover']['font-family'];
- $output['ubam_optimum_sqz_avisited_color'] = $page_style['a-visited']['color'];
- $output['ubam_optimum_sqz_avisited_decoration'] = $page_style['a-visited']['text-decoration'];
- $output['ubam_optimum_sqz_avisited_font'] = $page_style['a-visited']['font-family'];
- $json_out = $this->json_encode($output);
- return $json_out;
- }
- function json_encode($a = false)
- {
- if (is_null($a))
- return 'null';
- if ($a === false)
- return 'false';
- if ($a === true)
- return 'true';
- if (is_scalar($a)) {
- if (is_float($a)) {
- $a = str_replace(",", ".", strval($a));
- }
- static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
- return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
- }
- $isList = true;
- for ($i = 0, reset($a); $i < count($a); $i++, next($a)) {
- if (key($a) !== $i) {
- $isList = false;
- break;
- }
- }
- $result = array();
- if ($isList) {
- foreach ($a as $v)
- $result[] = $this->json_encode($v);
- return '[ ' . join(', ', $result) . ' ]';
- } else {
- foreach ($a as $k => $v)
- $result[] = $this->json_encode($k) . ': ' . $this->json_encode($v);
- return '{ ' . join(', ', $result) . ' }';
- }
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement