Advertisement
Guest User

UOSI

a guest
Oct 12th, 2012
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 71.63 KB | None | 0 0
  1. <?php
  2. define('OPTSQZ_PLATFORM', 'WORDPRESS');
  3. if (!class_exists('ubam_optimum_sqz_items')) {
  4.     class ubam_optimum_sqz_items
  5.     {
  6.         var $options = array();
  7.         function ubam_optimum_sqz_items()
  8.         {
  9.         }
  10.     }
  11. }
  12. if (!class_exists('ubam_optimum_sqz')) {
  13.     class ubam_optimum_sqz
  14.     {
  15.         var $optionsName = 'ubam_optimum_sqz_options';
  16.         var $localizationDomain = "ubam_optimum_sqz";
  17.         var $thispluginurl = '';
  18.         var $thispluginpath = '';
  19.         var $options = array();
  20.         var $months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
  21.         var $popup_page_ids = array();
  22.         var $popup_info = '';
  23.         function ubam_optimum_sqz()
  24.         {
  25.             $locale = get_locale();
  26.             $mo     = dirname(__FILE__) . "/languages/" . $this->localizationDomain . "-" . $locale . ".mo";
  27.             load_textdomain($this->localizationDomain, $mo);
  28.             $this->thispluginurl  = OPTSQZ_PLUGIN_URL;
  29.             $this->thispluginpath = OPTSQZ_PLUGIN_DIR;
  30.             $this->getOptions();
  31.             add_action("admin_menu", array(
  32.                 &$this,
  33.                 "admin_menu_link"
  34.             ));
  35.             if (isset($_REQUEST['page']) && strpos($_REQUEST['page'], "ubam_optimum_squeeze") !== false) {
  36.                 add_action('admin_print_styles', array(
  37.                     &$this,
  38.                     'ubam_optimum_sqz_load_css'
  39.                 ));
  40.                 add_action('admin_print_scripts', array(
  41.                     &$this,
  42.                     'ubam_optimum_sqz_load_js'
  43.                 ));
  44.             }
  45.             add_action('send_headers', array(
  46.                 &$this,
  47.                 "ubam_optimum_sqz_popup_check"
  48.             ), 5);
  49.             add_action('init', array(
  50.                 &$this,
  51.                 "ubam_optimum_sqz_init"
  52.             ));
  53.             add_filter('the_content', array(
  54.                 &$this,
  55.                 'ubam_optimum_sqz_show_squeeze'
  56.             ));
  57.         }
  58.         function ubam_optimum_sqz_init()
  59.         {
  60.             if (strpos($_SERVER['REQUEST_URI'], 'sprsqz_preview') !== false) {
  61.                 $output = $this->create_popup_html('', true);
  62.                 echo $output;
  63.                 exit;
  64.             }
  65.             if (strpos($_SERVER['REQUEST_URI'], 'sprsqz_reset_options') !== false) {
  66.                 $output = $this->get_page_style_settings();
  67.                 echo $output;
  68.                 exit;
  69.             }
  70.         }
  71.         function ubam_optimum_sqz_add_popup_styles()
  72.         {
  73.             wp_enqueue_style('sprsqz_cb_style', OPTSQZ_PLUGIN_URL . 'js/colorbox.css', array(), mt_rand(), 'all');
  74.         }
  75.         function ubam_optimum_sqz_add_popup_js()
  76.         {
  77.             wp_enqueue_script('jquery');
  78.             wp_enqueue_script('colorbox', OPTSQZ_PLUGIN_URL . 'js/jquery.colorbox-min.js', array(
  79.                 'jquery'
  80.             ), mt_rand());
  81.         }
  82.         function ubam_optimum_sqz_load_css()
  83.         {
  84.             wp_enqueue_style('sprsqz_cb_style', OPTSQZ_PLUGIN_URL . 'js/colorbox.css', array(), mt_rand(), 'all');
  85.             wp_enqueue_style('sprsqz_style', OPTSQZ_PLUGIN_URL . 'style.css', array(), mt_rand(), 'all');
  86.         }
  87.         function ubam_optimum_sqz_load_js()
  88.         {
  89.             wp_enqueue_script('jquery');
  90.             wp_enqueue_script('colorbox', OPTSQZ_PLUGIN_URL . 'js/jquery.colorbox-min.js', array(
  91.                 'jquery'
  92.             ), mt_rand());
  93.             wp_enqueue_script('jscolor', OPTSQZ_PLUGIN_URL . 'js/jscolor/jscolor.js');
  94.         }
  95.         function ubam_optimum_sqz_show_squeeze($text)
  96.         {
  97.             global $wpdb;
  98.             $optimum_sqz_tag_pattern = '/(\[optimum_squeeze\](.*?)\[\/optimum_squeeze\])/is';
  99.             preg_match_all($optimum_sqz_tag_pattern, $text, $optimum_sqz_matches);
  100.             if (is_array($optimum_sqz_matches)) {
  101.                 foreach ($optimum_sqz_matches[1] as $sqzkey => $sqzvalue) {
  102.                     $squeeze_pg_id = $optimum_sqz_matches[2][$sqzkey];
  103.                     $the_html      = $this->create_popup_html($squeeze_pg_id);
  104.                     $text          = str_replace($sqzvalue, $the_html, $text);
  105.                 }
  106.             }
  107.             return $text;
  108.         }
  109.         function create_popup_html($squeeze_pg_id, $preview = false)
  110.         {
  111.             global $wpdb;
  112.             $the_html = '';
  113.             if ($preview) {
  114.                 $_POST['template'] = $_POST['page_template'];
  115.                 $squeeze_pg        = $this->array_to_object($_POST);
  116.             } else {
  117.                 $squeeze_pg = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE item_id = '$squeeze_pg_id'");
  118.             }
  119.             if ($squeeze_pg) {
  120.                 $optimum_sqz_options = array();
  121.                 if ($preview) {
  122.                     $saved_style_info = $this->set_page_style_array();
  123.                 } else {
  124.                     $saved_style_info = get_option("ubam_optimum_sqz_item_style_{$squeeze_pg->id}", array());
  125.                 }
  126.                 if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
  127.                     $base_style          = get_option("ubam_optimum_sqz_style_{$saved_style_info['style']}");
  128.                     $the_page_style      = $this->ubam_array_replace_recursive($base_style, $saved_style_info);
  129.                     $optimum_sqz_options = $this->ubam_remove_magic_quotes($the_page_style);
  130.                 }
  131.                 ob_start();
  132.                 include(OPTSQZ_SQZ_TEMPLATE_DIR . 'css.php');
  133.                 if (empty($squeeze_pg->sub_headline))
  134.                     echo "div#optimum-sqz-sub-headline { display: none; }\n";
  135.                 $the_css = ob_get_contents();
  136.                 ob_end_clean();
  137.                 $the_css = $this->compress_css($the_css);
  138.                 if ($squeeze_pg->video_show != 0)
  139.                     $videojs = $this->ubam_optimum_sqz_video_js($squeeze_pg);
  140.                 $optin_out = $this->create_optin_html($squeeze_pg);
  141.                 $the_html  = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . strtolower($squeeze_pg->template) . '_tpl.htm');
  142.                 $the_html  = str_replace('[[-main_headline-]]', $squeeze_pg->main_headline, $the_html);
  143.                 $the_html  = str_replace('[[-sub_headline-]]', $squeeze_pg->sub_headline, $the_html);
  144.                 $the_html  = str_replace('[[-main_body-]]', $squeeze_pg->main_body, $the_html);
  145.                 $the_html  = str_replace('[[-main_footer-]]', $squeeze_pg->main_footer, $the_html);
  146.                 $the_html  = str_replace('[[-optin_headline-]]', $squeeze_pg->optin_headline, $the_html);
  147.                 $the_html  = str_replace('[[-optin_code-]]', $optin_out, $the_html);
  148.                 $the_html  = str_replace('[[-optin_footer-]]', $squeeze_pg->optin_footer, $the_html);
  149.                 $the_html  = str_replace('[[-pre_video-]]', ($squeeze_pg->video_show == 1 ? $videojs : ''), $the_html);
  150.                 $the_html  = str_replace('[[-post_video-]]', ($squeeze_pg->video_show == 2 ? $videojs : ''), $the_html);
  151.                 $the_html  = '<style type="text/css">' . $the_css . '</style>' . $the_html;
  152.             }
  153.             return $the_html;
  154.         }
  155.         function write_optimum_sqz_file($squeeze_pg_id, $delete = false)
  156.         {
  157.             if ($delete) {
  158.                 @unlink(OPTSQZ_SQZ_POPUP_DIR . "/$squeeze_pg_id.html");
  159.             } else {
  160.                 $squeeze_html = $this->create_popup_html($squeeze_pg_id);
  161.                 if (empty($squeeze_html))
  162.                     print "Empty Squeeze Html. <br />";
  163.                 if (!empty($squeeze_html)) {
  164.                     $handle = fopen(OPTSQZ_SQZ_POPUP_DIR . "/$squeeze_pg_id.html", "w");
  165.                     if (!$handle)
  166.                         print "Can't open the file<br />";
  167.                     fwrite($handle, $squeeze_html);
  168.                     fclose($handle);
  169.                 }
  170.             }
  171.         }
  172.         function ubam_optimum_sqz_popup_check()
  173.         {
  174.             if (is_admin())
  175.                 return;
  176.             $found_popup_page = false;
  177.             $this->popup_info = '';
  178.             $parsed_url       = parse_url($_SERVER['REQUEST_URI']);
  179.             $the_path         = $parsed_url['path'];
  180.             $popup_pages      = get_option('ubam_optimum_sqz_popup_pages', array());
  181.             if (!empty($popup_pages['front']) && $popup_pages['front']['path'] == rtrim($the_path, '/') && !isset($_COOKIE["u4bg43_{$popup_pages['front']['item_id']}"])) {
  182.                 $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_pages['front']['item_id']}");
  183.                 if (!empty($popup_info)) {
  184.                     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'))))) {
  185.                         $this->popup_info = $popup_info;
  186.                         $date_today       = date("Y-m-d");
  187.                         if ($popup_info['delay_days'] > 0)
  188.                             setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
  189.                         add_action('wp_print_styles', array(
  190.                             &$this,
  191.                             'ubam_optimum_sqz_add_popup_styles'
  192.                         ));
  193.                         add_action('wp_print_scripts', array(
  194.                             &$this,
  195.                             'ubam_optimum_sqz_add_popup_js'
  196.                         ));
  197.                         add_action('wp_head', array(
  198.                             &$this,
  199.                             'ubam_optimum_sqz_add_popup_head_code'
  200.                         ));
  201.                         return;
  202.                     }
  203.                 }
  204.             }
  205.             if (is_array($popup_pages)) {
  206.                 foreach ($popup_pages as $popup_page_id => $popup_page) {
  207.                     if ($popup_page_id == 'front' || $popup_page_id == 'every')
  208.                         continue;
  209.                     if ($popup_page['path'] == $the_path && !isset($_COOKIE["u4bg43_{$popup_page['item_id']}"])) {
  210.                         $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_page['item_id']}");
  211.                         if (!empty($popup_info)) {
  212.                             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'))))) {
  213.                                 $found_popup_page = true;
  214.                                 $this->popup_info = $popup_info;
  215.                                 $date_today       = date("Y-m-d");
  216.                                 if ($popup_info['delay_days'] > 0)
  217.                                     setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
  218.                                 add_action('wp_print_styles', array(
  219.                                     &$this,
  220.                                     'ubam_optimum_sqz_add_popup_styles'
  221.                                 ));
  222.                                 add_action('wp_print_scripts', array(
  223.                                     &$this,
  224.                                     'ubam_optimum_sqz_add_popup_js'
  225.                                 ));
  226.                                 add_action('wp_head', array(
  227.                                     &$this,
  228.                                     'ubam_optimum_sqz_add_popup_head_code'
  229.                                 ));
  230.                                 break;
  231.                             }
  232.                         }
  233.                     }
  234.                 }
  235.                 if ($found_popup_page)
  236.                     return;
  237.             }
  238.             $popup_cats     = get_option('ubam_optimum_sqz_popup_cats', array());
  239.             $popup_cat_path = '';
  240.             if (is_array($popup_cats)) {
  241.                 foreach ($popup_cats as $popup_cat_id => $popup_page) {
  242.                     if (strpos($the_path, $popup_page['path']) !== false) {
  243.                         if (strlen($popup_page['path']) > strlen($popup_cat_path)) {
  244.                             $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_page['item_id']}");
  245.                             if (!empty($popup_info)) {
  246.                                 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'))))) {
  247.                                     $found_popup_page = true;
  248.                                     $popup_cat_path   = $popup_page['path'];
  249.                                     $this->popup_info = $popup_info;
  250.                                 }
  251.                             }
  252.                         }
  253.                     }
  254.                 }
  255.                 if ($found_popup_page && !isset($_COOKIE["u4bg43_{$this->popup_info['item_id']}"])) {
  256.                     $date_today = date("Y-m-d");
  257.                     if ($this->popup_info['delay_days'] > 0)
  258.                         setcookie("u4bg43_{$this->popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $this->popup_info['delay_days']), $the_path);
  259.                     add_action('wp_print_styles', array(
  260.                         &$this,
  261.                         'ubam_optimum_sqz_add_popup_styles'
  262.                     ));
  263.                     add_action('wp_print_scripts', array(
  264.                         &$this,
  265.                         'ubam_optimum_sqz_add_popup_js'
  266.                     ));
  267.                     add_action('wp_head', array(
  268.                         &$this,
  269.                         'ubam_optimum_sqz_add_popup_head_code'
  270.                     ));
  271.                     return;
  272.                 }
  273.             }
  274.             if (!empty($popup_pages['every']) && !isset($_COOKIE["u4bg43_{$popup_pages['every']['item_id']}"])) {
  275.                 $popup_info = get_option("ubam_optimum_sqz_popup_{$popup_pages['every']['item_id']}");
  276.                 if (!empty($popup_info)) {
  277.                     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'))))) {
  278.                         $this->popup_info = $popup_info;
  279.                         $date_today       = date("Y-m-d");
  280.                         if ($popup_info['delay_days'] > 0)
  281.                             setcookie("u4bg43_{$popup_info['item_id']}", $date_today, time() + (60 * 60 * 24 * $popup_info['delay_days']), '/');
  282.                         add_action('wp_print_styles', array(
  283.                             &$this,
  284.                             'ubam_optimum_sqz_add_popup_styles'
  285.                         ));
  286.                         add_action('wp_print_scripts', array(
  287.                             &$this,
  288.                             'ubam_optimum_sqz_add_popup_js'
  289.                         ));
  290.                         add_action('wp_head', array(
  291.                             &$this,
  292.                             'ubam_optimum_sqz_add_popup_head_code'
  293.                         ));
  294.                     }
  295.                 }
  296.             }
  297.         }
  298.         function ubam_optimum_sqz_add_popup_head_code()
  299.         {
  300.             global $wpdb;
  301.             $the_page = $this->popup_info;
  302.             if (!empty($the_page)) {
  303.                 $optimum_sqz_options = array();
  304.                 $saved_style_info    = get_option("ubam_optimum_sqz_item_style_{$the_page['id']}", array());
  305.                 if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
  306.                     $base_style          = get_option("ubam_optimum_sqz_style_{$saved_style_info['style']}");
  307.                     $the_page_style      = $this->ubam_array_replace_recursive($base_style, $saved_style_info);
  308.                     $optimum_sqz_options = $this->ubam_remove_magic_quotes($the_page_style);
  309.                 }
  310. ?>
  311.                 <script type="text/javascript">
  312.                     jQuery.noConflict();
  313.                     jQuery(document).ready(function($) {
  314.                         $(document).ready(function(){
  315.                             setTimeout(function()     { $.fn.colorbox({
  316.                                                         innerWidth:<?php
  317.                 echo $optimum_sqz_options['sheet']['width'] + 40;
  318. ?>,
  319.                                                         opacity:.5,
  320.                                                         speed:500,
  321.                                                         overlayClose:true,
  322.                                                         scrolling: false,
  323.                                                         href:'<?php
  324.                 echo OPTSQZ_SQZ_POPUP_URL . "/{$the_page['item_id']}.html";
  325. ?>'});
  326.                                                     },
  327.                                         <?php
  328.                 echo $the_page['delay_secs'] * 1000;
  329. ?>);
  330.                         });
  331.                     });
  332.                 </script>
  333.                 <?php
  334.             }
  335.         }
  336.         function getOptions()
  337.         {
  338.             if (!$theOptions = get_option($this->optionsName)) {
  339.                 $theOptions = array(
  340.                     'default' => 'options'
  341.                 );
  342.                 update_option($this->optionsName, $theOptions);
  343.             }
  344.             $this->options = $theOptions;
  345.         }
  346.         function saveAdminOptions()
  347.         {
  348.             return update_option($this->optionsName, $this->options);
  349.         }
  350.         function admin_menu_link()
  351.         {
  352.             add_menu_page(__(OPTSQZ_MENU_TITLE, "ubam_optimum_sqz"), __(OPTSQZ_MENU_TITLE, "ubam_optimum_sqz"), 'manage_options', 'ubam_optimum_squeeze', array(
  353.                 &$this,
  354.                 'ubam_optimum_sqz_load_menu_page'
  355.             ));
  356.             if (function_exists('add_submenu_page')) {
  357.                 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(
  358.                     &$this,
  359.                     'ubam_optimum_sqz_load_menu_page'
  360.                 ));
  361.                 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(
  362.                     &$this,
  363.                     'ubam_optimum_sqz_load_menu_page'
  364.                 ));
  365.             }
  366.         }
  367.         function ubam_optimum_sqz_load_menu_page()
  368.         {
  369.             if (!empty($_REQUEST['page']) && file_exists(OPTSQZ_PLUGIN_DIR . $_REQUEST['page'])) {
  370.                 include_once(OPTSQZ_PLUGIN_DIR . $_REQUEST['page']);
  371.             } else {
  372.                 $this->admin_options_page();
  373.             }
  374.         }
  375.         function filter_plugin_actions($links, $file)
  376.         {
  377.             $settings_link = '<a href="options-general.php?page=' . basename(__FILE__) . '">' . __('Settings') . '</a>';
  378.             array_unshift($links, $settings_link);
  379.             return $links;
  380.         }
  381.         function admin_options_page()
  382.         {
  383.             global $wpdb;
  384.             global $ubam_optimum_sqz_upload_dir, $ubam_optimum_sqz_popup_dir;
  385.             if ($_POST['ubam_optimum_sqz_save']) {
  386.                 if (!wp_verify_nonce($_POST['_wpnonce'], 'ubam_optimum_sqz-update-options'))
  387.                     die('Whoops! There was a problem with the data you posted. Please go back and try again.');
  388.                 $this->saveAdminOptions();
  389.                 echo '<div class="updated"><p>Success! Your changes were sucessfully saved!</p></div>';
  390.             }
  391.             if ($_POST['action'] == 'edit' || $_POST['action'] == 'copy') {
  392.                 $the_id = $_POST['iid'];
  393.                 if ($_POST['action'] == 'copy') {
  394.                     $wpdb->show_errors();
  395.                     $source_item = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE id=$the_id", ARRAY_A);
  396.                     $columns     = '';
  397.                     $values      = '';
  398.                     foreach ($source_item as $key => $value) {
  399.                         if ($key == 'id')
  400.                             continue;
  401.                         if ($key == 'item_id') {
  402.                             $value .= '_copy';
  403.                             $the_item_id = $value;
  404.                         }
  405.                         $columns .= (!empty($columns) ? ', ' : '') . $key;
  406.                         $values .= (!empty($values) ? ', ' : '') . "'" . addslashes($value) . "'";
  407.                     }
  408.                     if (!empty($columns)) {
  409.                         $DUPSQL  = "INSERT INTO {$wpdb->prefix}ubam_optimum_sqz_items ($columns) VALUES ($values)";
  410.                         $the_row = $wpdb->query($DUPSQL);
  411.                         if ($the_row) {
  412.                             $the_id            = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}ubam_optimum_sqz_items where item_id = '$the_item_id'");
  413.                             $source_style_info = get_option("ubam_optimum_sqz_item_style_{$_POST['iid']}", array());
  414.                             update_option("ubam_optimum_sqz_item_style_$the_id", $source_style_info);
  415.                         }
  416.                     }
  417.                     $wpdb->hide_errors();
  418.                 }
  419.                 $editmode      = true;
  420.                 $SQL           = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'ubam_optimum_sqz_style_%' ";
  421.                 $style_options = $wpdb->get_results($SQL);
  422.                 if ($style_options) {
  423.                     $styles = array();
  424.                     foreach ($style_options as $style) {
  425.                         $the_style          = substr($style->option_name, strlen('ubam_optimum_sqz_style_'));
  426.                         $styles[$the_style] = get_option($style->option_name);
  427.                     }
  428.                 }
  429.                 $eitem            = $wpdb->get_row("SELECT * from {$wpdb->prefix}ubam_optimum_sqz_items WHERE id=$the_id");
  430.                 $begin_month      = date("n", strtotime($eitem->start_date));
  431.                 $begin_day        = date("j", strtotime($eitem->start_date));
  432.                 $begin_year       = date("Y", strtotime($eitem->start_date));
  433.                 $page_style       = array();
  434.                 $saved_style_info = get_option("ubam_optimum_sqz_item_style_{$eitem->id}", array());
  435.                 if (isset($saved_style_info['style']) && !empty($saved_style_info['style'])) {
  436.                     $the_page_style = $this->ubam_array_replace_recursive($styles[$saved_style_info['style']], $saved_style_info);
  437.                     $page_style     = $this->ubam_remove_magic_quotes($the_page_style);
  438.                 }
  439. ?><div class="wrap">
  440.                 <h2><?php
  441.                 echo OPTSQZ_OPTION_PAGE_TITLE;
  442. ?></h2> <?php
  443.                 require_once(OPTSQZ_TEMPLATE_DIR . "item-entry-form.htm");
  444.             } else {
  445.                 if ($_POST['action'] == 'delete') {
  446.                     $wpdb->show_errors();
  447.                     $wpdb->query("DELETE FROM {$wpdb->prefix}ubam_optimum_sqz_items WHERE id={$_POST['iid']}");
  448.                     $wpdb->hide_errors();
  449.                     $this->write_optimum_sqz_file($_POST['itemId'], true);
  450.                     delete_option("ubam_optimum_sqz_item_style_{$_POST['iid']}");
  451.                     delete_option("ubam_optimum_sqz_popup_{$_POST['item_id']}");
  452.                     echo '<div class="updated"><p>Success! Item has been deleted from the database.</p></div>';
  453.                 }
  454.                 $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");
  455.                 if ($_POST['ubam_optimum_sqz_add_item']) {
  456.                     $page_style   = $this->set_page_style_array();
  457.                     $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') ";
  458.                     $wpdb->show_errors();
  459.                     $qresult = $wpdb->query($insert_query);
  460.                     $wpdb->hide_errors();
  461.                     if ($qresult === false) {
  462.                         echo '<div class="updated"><p><font color="red"><strong>Warning!</strong></font> Unable to add the item.</p></div>';
  463.                     } else {
  464.                         $the_id = $wpdb->get_var("SELECT id FROM {$wpdb->prefix}ubam_optimum_sqz_items where item_id = '{$_POST['item_id']}'");
  465.                         update_option("ubam_optimum_sqz_item_$the_id", $page_style);
  466.                         update_option("ubam_optimum_sqz_popup_{$_POST['item_id']}", array(
  467.                             'id' => $the_id,
  468.                             'item_id' => $_POST['item_id'],
  469.                             'enable_popup' => $_POST['enable_popup'],
  470.                             'use_start_date' => $_POST['use_start_date'],
  471.                             'start_date' => $start_date,
  472.                             'delay_secs' => $_POST['delay_secs'],
  473.                             'delay_days' => $_POST['delay_days']
  474.                         ));
  475.                         $this->write_optimum_sqz_file($_POST['item_id']);
  476.                         echo '<div class="updated"><p>Success! Item has been added to the database.</p></div>';
  477.                     }
  478.                 }
  479.                 if ($_POST['ubam_optimum_sqz_update_item']) {
  480.                     $page_style   = $this->set_page_style_array();
  481.                     $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']} ";
  482.                     $wpdb->show_errors();
  483.                     $qresult = $wpdb->query($update_query);
  484.                     $wpdb->hide_errors();
  485.                     if ($qresult === false) {
  486.                         echo '<div class="updated"><p><font color="red"><strong>Warning!</strong></font> Unable to update the item.</p></div>';
  487.                     } else {
  488.                         update_option("ubam_optimum_sqz_item_style_{$_POST['id']}", $page_style);
  489.                         update_option("ubam_optimum_sqz_popup_{$_POST['item_id']}", array(
  490.                             'id' => $_POST['id'],
  491.                             'item_id' => $_POST['item_id'],
  492.                             'enable_popup' => $_POST['enable_popup'],
  493.                             'use_start_date' => $_POST['use_start_date'],
  494.                             'start_date' => $start_date,
  495.                             'delay_secs' => $_POST['delay_secs'],
  496.                             'delay_days' => $_POST['delay_days']
  497.                         ));
  498.                         $this->write_optimum_sqz_file($_POST['item_id']);
  499.                         echo '<div class="updated"><p>Success! Item has been successfully changed.</p></div>';
  500.                     }
  501.                 }
  502.                 $coreSQL  = "  FROM {$wpdb->prefix}ubam_optimum_sqz_items ORDER BY item_id";
  503.                 $SQL      = "SELECT * $coreSQL";
  504.                 $countSQL = "SELECT count(*) $coreSQL";
  505.                 $wpdb->show_errors();
  506.                 $item_count = $wpdb->get_var($countSQL);
  507.                 $wpdb->hide_errors();
  508.                 $list_number = 20;
  509.                 if ($item_count == 0) {
  510.                     $itemlist = array();
  511.                 } else {
  512.                     require_once dirname(__FILE__) . "/includes/wp_paginate.php";
  513.                     $pager     = new ubam_wp_paginate($SQL, $list_number, 5, $item_count, $js_function = "processPaginate");
  514.                     $the_page  = (empty($_POST['wpppage']) ? 1 : $_POST['wpppage']);
  515.                     $itemlist  = $pager->paginate($the_page);
  516.                     $pager_nav = $pager->renderFullNav();
  517.                 }
  518.                 $SQL           = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'ubam_optimum_sqz_style_%' ";
  519.                 $style_options = $wpdb->get_results($SQL);
  520.                 if ($style_options) {
  521.                     $styles = array();
  522.                     foreach ($style_options as $style) {
  523.                         $the_style          = substr($style->option_name, strlen('ubam_optimum_sqz_style_'));
  524.                         $styles[$the_style] = get_option($style->option_name);
  525.                     }
  526.                 }
  527.                 $admin_link_prefix = 'admin.php?page=';
  528.                 $popup             = new ubam_optimum_sqz_items();
  529.                 if (!file_exists(OPTSQZ_SQZ_POPUP_DIR) || !is_dir(OPTSQZ_SQZ_POPUP_DIR)) {
  530.                     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>';
  531.                 }
  532.                 include_once(OPTSQZ_TEMPLATE_DIR . "header.htm");
  533.                 include_once(OPTSQZ_TEMPLATE_DIR . "item-list.htm");
  534.                 include_once(OPTSQZ_TEMPLATE_DIR . "footer.htm");
  535.             }
  536.         }
  537.         function ubam_optimum_sqz_video_js($squeeze_pg)
  538.         {
  539.             if (empty($squeeze_pg->video_url) && empty($squeeze_pg->video_embed_code))
  540.                 return '';
  541.             $description = '';
  542.             if (!empty($squeeze_pg->video_description))
  543.                 $description = "*Video:" . htmlspecialchars($squeeze_pg->video_description);
  544.             if (preg_match('/youtube.com/i', $squeeze_pg->video_url)) {
  545.                 $sep        = "&";
  546.                 $parsed_url = parse_url($squeeze_pg->video_url);
  547.                 parse_str($parsed_url['query']);
  548.                 $borderColor = '#b1b1b1';
  549.                 if (!empty($squeeze_pg->video_ctrlcolor)) {
  550.                     $controls .= "{$sep}color1=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor) . "{$sep}color2=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor);
  551.                     $borderColor = $squeeze_pg->video_ctrlcolor;
  552.                 }
  553.                 if ($squeeze_pg->video_autoplay == 1)
  554.                     $controls .= "{$sep}autoplay=1";
  555.                 if ($squeeze_pg->video_loop == 1)
  556.                     $controls .= "{$sep}loop=1";
  557.                 $params      = '';
  558.                 $embedParams = '';
  559.                 if ($squeeze_pg->video_showfull == 1) {
  560.                     $controls .= "{$sep}fs=1";
  561.                     $params .= '<param name="allowFullScreen" value="true"></param>';
  562.                     $embedParams .= 'allowfullscreen="true" ';
  563.                 }
  564.                 $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\">";
  565.                 $videojs .= '<object width="' . $squeeze_pg->video_width . '" height="' . (intval($squeeze_pg->video_height) + 25) . '">';
  566.                 $videojs .= '<param name="movie" value="http://www.youtube.com/v/' . $v . '?showinfo=0' . $controls . '"';
  567.                 $videojs .= '<param name="allowScriptAccess" value="always"></param>';
  568.                 $videojs .= $params;
  569.                 $videojs .= '<embed src="http://www.youtube.com/v/' . $v . '?showinfo=0' . $controls . '" type="application/x-shockwave-flash" ';
  570.                 $videojs .= 'allowscriptaccess="always" ';
  571.                 $videojs .= 'width="' . $squeeze_pg->video_width . '" height="' . (intval($squeeze_pg->video_height) + 25) . '" ';
  572.                 $videojs .= $embedParams . '</embed></object></div></div>';
  573.             } elseif (!empty($squeeze_pg->video_url)) {
  574.                 $splashImage = '';
  575.                 $player      = OPTSQZ_PLUGIN_URL . "js/flowplayer3/flowplayer-3.2.3.swf";
  576.                 if (!empty($squeeze_pg->video_splashimage)) {
  577.                     $alt = '';
  578.                     if (!empty($description))
  579.                         $alt = "alt='$description'";
  580.                     $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 />';
  581.                 }
  582.                 $loop       = '';
  583.                 $autorewind = '';
  584.                 if ($squeeze_pg->video_loop == 1) {
  585.                     $loop = ', onBeforeFinish : function() { this.play(0);  return false; } ';
  586.                 } else if ($squeeze_pg->video_autorewind == 1) {
  587.                     $autorewind = ', onFinish : function () { this.seek(0); } ';
  588.                 }
  589.                 $sep         = ", ";
  590.                 $controls    = "";
  591.                 $borderColor = '#999999';
  592.                 if ($squeeze_pg->video_showctrl == 2) {
  593.                     $controls = "plugins: { controls: null } ";
  594.                 } else {
  595.                     if ($squeeze_pg->video_showstop == 1)
  596.                         $controls .= "stop:true";
  597.                     if ($squeeze_pg->video_showvol == 0)
  598.                         $controls .= (empty($controls) ? '' : $sep) . "volume:false, mute:false";
  599.                     if ($squeeze_pg->video_showtime == 1)
  600.                         $controls .= (empty($controls) ? '' : $sep) . "time:false";
  601.                     if ($squeeze_pg->video_showctrl == 0)
  602.                         $controls .= (empty($controls) ? '' : $sep) . "autoHide: 'never'";
  603.                     if ($squeeze_pg->video_showctrl == 1)
  604.                         $controls .= (empty($controls) ? '' : $sep) . "autoHide: 'always'";
  605.                     if ($squeeze_pg->video_ctrltrans == 1) {
  606.                         $controls .= (empty($controls) ? '' : $sep) . "backgroundColor: 'transparent', backgroundGradient: 'none'";
  607.                     } else {
  608.                         if (!empty($squeeze_pg->video_ctrlcolor)) {
  609.                             $controls .= (empty($controls) ? '' : $sep) . "backgroundColor:'{$squeeze_pg->video_ctrlcolor}'";
  610.                             $borderColor = $squeeze_pg->video_ctrlcolor;
  611.                         }
  612.                     }
  613.                     if ($squeeze_pg->video_showfull == 0)
  614.                         $controls .= (empty($controls) ? '' : $sep) . "fullscreen:false";
  615.                     if ($squeeze_pg->video_showseek == 0)
  616.                         $controls .= (empty($controls) ? '' : $sep) . "scrubber: false";
  617.                     $controls = "plugins: { controls: { " . $controls . " } }";
  618.                 }
  619.                 if (!empty($controls)) {
  620.                     $controls_text = "
  621.                    ,
  622.                    $controls
  623.                    ";
  624.                 }
  625.                 $videojs = "<script type='text/javascript' src='" . OPTSQZ_PLUGIN_URL . "js/flowplayer3/example/flowplayer-3.2.3.min.js'></script>";
  626.                 $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>";
  627.                 $videojs .= "<script  type='text/javascript'>\n";
  628.                 $videojs .= "flowplayer('optimum-sqz-video-div', { src: '$player', wmode: 'transparent' }, { \n";
  629.                 $videojs .= "       clip:  { \n";
  630.                 $videojs .= "        url: '" . $squeeze_pg->video_url . "', \n";
  631.                 $videojs .= "    scaling: 'scale', autoPlay: " . ($squeeze_pg->video_autoplay == 1 ? 'true' : 'false') . ", autoBuffering: " . ($squeeze_pg->video_autoload == 1 ? 'true' : 'false') . "  \n";
  632.                 $videojs .= "    $loop $autorewind \n";
  633.                 $videojs .= "    } \n";
  634.                 $videojs .= "    $controls_text \n";
  635.                 $videojs .= "}); \n";
  636.                 $videojs .= "</script> ";
  637.             } else {
  638.                 $borderColor = '#b1b1b1';
  639.                 if (!empty($squeeze_pg->video_ctrlcolor)) {
  640.                     $controls .= "{$sep}color1=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor) . "{$sep}color2=" . str_replace('#', '0x', $squeeze_pg->video_ctrlcolor);
  641.                     $borderColor = $squeeze_pg->video_ctrlcolor;
  642.                 }
  643.                 $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\">";
  644.                 $videojs .= $squeeze_pg->video_embed_code . '</div></div>';
  645.             }
  646.             return $videojs;
  647.         }
  648.         function parse_attributes($attrib_string)
  649.         {
  650.             $search_arr    = array(
  651.                 "\n",
  652.                 "<br />",
  653.                 "\t"
  654.             );
  655.             $replace_arr   = array(
  656.                 " ",
  657.                 " ",
  658.                 " "
  659.             );
  660.             $attrib_string = str_replace($search_arr, $replace_arr, $attrib_string);
  661.             $regex         = '@([^\s=]+)\s*=\s*(\'[^<\']*\'|"[^<"]*"|\S*)@';
  662.             preg_match_all($regex, $attrib_string, $matches);
  663.             $attr = array();
  664.             for ($i = 0; $i < count($matches[0]); $i++) {
  665.                 if (!empty($matches[0][$i]) && !empty($matches[1][$i])) {
  666.                     if (preg_match("/^'(.*)'$/", $matches[2][$i], $vmatch)) {
  667.                         $value = $vmatch[1];
  668.                     } else if (preg_match('/^"(.*)"$/', $matches[2][$i], $vmatch)) {
  669.                         $value = $vmatch[1];
  670.                     } else {
  671.                         $value = $matches[2][$i];
  672.                     }
  673.                     $key        = strtolower($matches[1][$i]);
  674.                     $attr[$key] = $value;
  675.                 }
  676.             }
  677.             return $attr;
  678.         }
  679.         function create_optin_html($squeeze_pg)
  680.         {
  681.             $optin_code        = $squeeze_pg->optin_code;
  682.             $optin_provider    = $squeeze_pg->optin_provider;
  683.             $optin_button_text = $squeeze_pg->optin_button_text;
  684.             if (empty($optin_code) || empty($optin_provider))
  685.                 return '';
  686.             $optin_base          = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . 'optin_base_tpl.htm');
  687.             $optin_base_name_row = file_get_contents(OPTSQZ_SQZ_TEMPLATE_DIR . 'optin_base_name_row_tpl.htm');
  688.             $htmlArray           = $this->parseHtml($optin_code);
  689.             $optin_out           = '<form method="post" name="optimumsqzoptinform" action=' . $htmlArray['FORM'][0]['ACTION'] . ' onSubmit="javascript: return osOptInValidate();">';
  690.             $name                = $squeeze_pg->optin_form_name_field;
  691.             $fname               = $squeeze_pg->optin_form_fname_field;
  692.             $lname               = $squeeze_pg->optin_form_lname_field;
  693.             $email               = $squeeze_pg->optin_form_email_field;
  694.             $optin_name_rows     = '';
  695.             $div                 = '<div style="width: 200px; margin: 0 auto;">';
  696.             if (!is_array($htmlArray['INPUT']))
  697.                 return '';
  698.             foreach ($htmlArray['INPUT'] as $input) {
  699.                 if (strpos(strtolower($input['TYPE']), 'hidden') !== false) {
  700.                     $optin_out .= '<input type="hidden" name=' . $input['NAME'] . ' value=' . $input['VALUE'] . '>';
  701.                 }
  702.                 if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($name)) && (strpos(strtolower($input['NAME']), $name) !== false)) {
  703.                     $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";
  704.                     $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>';
  705.                     $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
  706.                     $optin_name_rows .= $toptin_name_rows;
  707.                 }
  708.                 if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($fname)) && (strpos(strtolower($input['NAME']), $fname) !== false)) {
  709.                     $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";
  710.                     $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>';
  711.                     $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
  712.                     $optin_name_rows .= $toptin_name_rows;
  713.                 }
  714.                 if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (!empty($lname)) && (strpos(strtolower($input['NAME']), $lname) !== false)) {
  715.                     $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";
  716.                     $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>';
  717.                     $toptin_name_rows = str_replace('[[-optin_name-]]', $optin_name, $optin_base_name_row);
  718.                     $optin_name_rows .= $toptin_name_rows;
  719.                 }
  720.                 if ((strpos(strtolower($input['TYPE']), 'text') !== false) && (strpos(strtolower($input['NAME']), $email) !== false)) {
  721.                     $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";
  722.                     $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>';
  723.                 }
  724.             }
  725.             $format_out = $optin_base;
  726.             $format_out = str_replace('[[-optin_name_rows-]]', $optin_name_rows, $format_out);
  727.             $format_out = str_replace('[[-optin_email-]]', $optin_email, $format_out);
  728.             $format_out = str_replace('[[-optin_button_text-]]', $optin_button_text, $format_out);
  729.             $optin_out .= $format_out . '</form>';
  730.             return $optin_out;
  731.         }
  732.         function ubam_array_replace_recursive()
  733.         {
  734.             $arrays   = func_get_args();
  735.             $original = array_shift($arrays);
  736.             foreach ($arrays as $array) {
  737.                 foreach ($array as $key => $value) {
  738.                     if (is_array($value)) {
  739.                         $original[$key] = $this->ubam_array_replace_recursive($original[$key], $array[$key]);
  740.                     } else {
  741.                         $original[$key] = $value;
  742.                     }
  743.                 }
  744.             }
  745.             return $original;
  746.         }
  747.         function ubam_add_magic_quotes($array)
  748.         {
  749.             foreach ((array) $array as $k => $v) {
  750.                 if (is_array($v)) {
  751.                     $array[$k] = $this->ubam_add_magic_quotes($v);
  752.                 } else {
  753.                     $array[$k] = addslashes($v);
  754.                 }
  755.             }
  756.             return $array;
  757.         }
  758.         function ubam_remove_magic_quotes($array)
  759.         {
  760.             foreach ((array) $array as $k => $v) {
  761.                 if (is_array($v)) {
  762.                     $array[$k] = $this->ubam_remove_magic_quotes($v);
  763.                 } else {
  764.                     $array[$k] = stripslashes($v);
  765.                 }
  766.             }
  767.             return $array;
  768.         }
  769.         function compress_css($buffer)
  770.         {
  771.             $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
  772.             $buffer = str_replace(array(
  773.                 "\r\n",
  774.                 "\r",
  775.                 "\n",
  776.                 "\t",
  777.                 '  ',
  778.                 '    ',
  779.                 '    '
  780.             ), '', $buffer);
  781.             return $buffer;
  782.         }
  783.         function parseHtml($s_str)
  784.         {
  785.             $i_indicatorL   = 0;
  786.             $i_indicatorR   = 0;
  787.             $s_tagOption    = "";
  788.             $i_arrayCounter = 0;
  789.             $a_html         = array();
  790.             while (is_int(($i_indicatorL = strpos($s_str, "<", $i_indicatorR)))) {
  791.                 $i_indicatorL++;
  792.                 $i_indicatorR = strpos($s_str, ">", $i_indicatorL);
  793.                 $s_temp       = substr($s_str, $i_indicatorL, ($i_indicatorR - $i_indicatorL));
  794.                 $a_tag        = explode(' ', $s_temp);
  795.                 list(, $s_tagName, , ) = each($a_tag);
  796.                 $s_tagName     = strtoupper($s_tagName);
  797.                 $b_boolOptions = is_array(($s_tagOption = each($a_tag))) && $s_tagOption[1];
  798.                 if ($b_boolOptions) {
  799.                     $i_arrayCounter = (int) count($a_html[$s_tagName]);
  800.                     do {
  801.                         $eqPos = strpos($s_tagOption[1], '=');
  802.                         if ($eqPos != false) {
  803.                             $s_tagTokOption                                       = strtoupper(substr($s_tagOption[1], 0, $eqPos));
  804.                             $s_tagTokValue                                        = trim(substr($s_tagOption[1], ($eqPos + 1)));
  805.                             $a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] = $s_tagTokValue;
  806.                         }
  807.                         $b_boolOptions = is_array(($s_tagOption = each($a_tag))) && $s_tagOption[1];
  808.                     } while ($b_boolOptions);
  809.                 }
  810.             }
  811.             return $a_html;
  812.         }
  813.         function array_to_object($array = array())
  814.         {
  815.             if (!empty($array)) {
  816.                 $data = false;
  817.                 foreach ($array as $akey => $aval) {
  818.                     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')
  819.                         $aval = stripslashes($aval);
  820.                     $data->{$akey} = $aval;
  821.                 }
  822.                 return $data;
  823.             }
  824.             return false;
  825.         }
  826.         function ieversion()
  827.         {
  828.             $match = preg_match('/MSIE ([0-9]\.[0-9])/', $_SERVER['HTTP_USER_AGENT'], $reg);
  829.             if ($match == 0)
  830.                 return -1;
  831.             else
  832.                 return floatval($reg[1]);
  833.         }
  834.         function set_page_style_array()
  835.         {
  836.             if (!empty($_POST['ubam_optimum_sqz_page_style']))
  837.                 $page_style['style'] = $_POST['ubam_optimum_sqz_page_style'];
  838.             if (!empty($_POST['ubam_optimum_sqz_page_width']))
  839.                 $page_style['sheet']['width'] = $_POST['ubam_optimum_sqz_page_width'];
  840.             if (!empty($_POST['ubam_optimum_sqz_top_margin']))
  841.                 $page_style['sheet']['margin-top'] = $_POST['ubam_optimum_sqz_top_margin'];
  842.             if (!empty($_POST['ubam_optimum_sqz_body_bg_color']))
  843.                 $page_style['body']['background-color'] = $_POST['ubam_optimum_sqz_body_bg_color'];
  844.             if (!empty($_POST['ubam_optimum_sqz_show_gradient']))
  845.                 $page_style['body']['gradient'] = $_POST['ubam_optimum_sqz_show_gradient'];
  846.             if (!empty($_POST['ubam_optimum_sqz_show_borders']))
  847.                 $page_style['sheet-border']['show'] = $_POST['ubam_optimum_sqz_show_borders'];
  848.             if (!empty($_POST['ubam_optimum_sqz_bgimg_url']))
  849.                 $page_style['body']['bgimg']['background-image'] = $_POST['ubam_optimum_sqz_bgimg_url'];
  850.             if (!empty($_POST['ubam_optimum_sqz_bgimg_repeat']))
  851.                 $page_style['body']['bgimg']['background-repeat'] = $_POST['ubam_optimum_sqz_bgimg_repeat'];
  852.             if (!empty($_POST['ubam_optimum_sqz_bgimg_position']))
  853.                 $page_style['body']['bgimg']['background-position'] = $_POST['ubam_optimum_sqz_bgimg_position'];
  854.             if (!empty($_POST['ubam_optimum_sqz_bgimg_attachment']))
  855.                 $page_style['body']['bgimg']['background-attachment'] = $_POST['ubam_optimum_sqz_bgimg_attachment'];
  856.             if (!empty($_POST['ubam_optimum_sqz_postcontent_size']))
  857.                 $page_style['post-content']['font-size'] = $_POST['ubam_optimum_sqz_postcontent_size'];
  858.             if (!empty($_POST['ubam_optimum_sqz_postcontent_color']))
  859.                 $page_style['post-content']['color'] = $_POST['ubam_optimum_sqz_postcontent_color'];
  860.             if (!empty($_POST['ubam_optimum_sqz_postcontent_weight']))
  861.                 $page_style['post-content']['font-weight'] = $_POST['ubam_optimum_sqz_postcontent_weight'];
  862.             if (!empty($_POST['ubam_optimum_sqz_postcontent_style']))
  863.                 $page_style['post-content']['font-style'] = $_POST['ubam_optimum_sqz_postcontent_style'];
  864.             if (!empty($_POST['ubam_optimum_sqz_postcontent_align']))
  865.                 $page_style['post-content']['text-align'] = $_POST['ubam_optimum_sqz_postcontent_align'];
  866.             if (!empty($_POST['ubam_optimum_sqz_postcontent_font']))
  867.                 $page_style['post-content']['font-family'] = $_POST['ubam_optimum_sqz_postcontent_font'];
  868.             if (!empty($_POST['ubam_optimum_sqz_olul_size']))
  869.                 $page_style['ol-ul']['font-size'] = $_POST['ubam_optimum_sqz_olul_size'];
  870.             if (!empty($_POST['ubam_optimum_sqz_olul_color']))
  871.                 $page_style['ol-ul']['color'] = $_POST['ubam_optimum_sqz_olul_color'];
  872.             if (!empty($_POST['ubam_optimum_sqz_olul_font']))
  873.                 $page_style['ol-ul']['font-family'] = $_POST['ubam_optimum_sqz_olul_font'];
  874.             if (!empty($_POST['ubam_optimum_sqz_h1_size']))
  875.                 $page_style['h1']['font-size'] = $_POST['ubam_optimum_sqz_h1_size'];
  876.             if (!empty($_POST['ubam_optimum_sqz_h1_color']))
  877.                 $page_style['h1']['color'] = $_POST['ubam_optimum_sqz_h1_color'];
  878.             if (!empty($_POST['ubam_optimum_sqz_h1_weight']))
  879.                 $page_style['h1']['font-weight'] = $_POST['ubam_optimum_sqz_h1_weight'];
  880.             if (!empty($_POST['ubam_optimum_sqz_h1_style']))
  881.                 $page_style['h1']['font-style'] = $_POST['ubam_optimum_sqz_h1_style'];
  882.             if (!empty($_POST['ubam_optimum_sqz_h1_align']))
  883.                 $page_style['h1']['text-align'] = $_POST['ubam_optimum_sqz_h1_align'];
  884.             if (!empty($_POST['ubam_optimum_sqz_h1_font']))
  885.                 $page_style['h1']['font-family'] = $_POST['ubam_optimum_sqz_h1_font'];
  886.             if (!empty($_POST['ubam_optimum_sqz_h2_size']))
  887.                 $page_style['h2']['font-size'] = $_POST['ubam_optimum_sqz_h2_size'];
  888.             if (!empty($_POST['ubam_optimum_sqz_h2_color']))
  889.                 $page_style['h2']['color'] = $_POST['ubam_optimum_sqz_h2_color'];
  890.             if (!empty($_POST['ubam_optimum_sqz_h2_weight']))
  891.                 $page_style['h2']['font-weight'] = $_POST['ubam_optimum_sqz_h2_weight'];
  892.             if (!empty($_POST['ubam_optimum_sqz_h2_style']))
  893.                 $page_style['h2']['font-style'] = $_POST['ubam_optimum_sqz_h2_style'];
  894.             if (!empty($_POST['ubam_optimum_sqz_h2_align']))
  895.                 $page_style['h2']['text-align'] = $_POST['ubam_optimum_sqz_h2_align'];
  896.             if (!empty($_POST['ubam_optimum_sqz_h2_font']))
  897.                 $page_style['h2']['font-family'] = $_POST['ubam_optimum_sqz_h2_font'];
  898.             if (!empty($_POST['ubam_optimum_sqz_h3_size']))
  899.                 $page_style['h3']['font-size'] = $_POST['ubam_optimum_sqz_h3_size'];
  900.             if (!empty($_POST['ubam_optimum_sqz_h3_color']))
  901.                 $page_style['h3']['color'] = $_POST['ubam_optimum_sqz_h3_color'];
  902.             if (!empty($_POST['ubam_optimum_sqz_h3_weight']))
  903.                 $page_style['h3']['font-weight'] = $_POST['ubam_optimum_sqz_h3_weight'];
  904.             if (!empty($_POST['ubam_optimum_sqz_h3_style']))
  905.                 $page_style['h3']['font-style'] = $_POST['ubam_optimum_sqz_h3_style'];
  906.             if (!empty($_POST['ubam_optimum_sqz_h3_align']))
  907.                 $page_style['h3']['text-align'] = $_POST['ubam_optimum_sqz_h3_align'];
  908.             if (!empty($_POST['ubam_optimum_sqz_h3_font']))
  909.                 $page_style['h3']['font-family'] = $_POST['ubam_optimum_sqz_h3_font'];
  910.             if (!empty($_POST['ubam_optimum_sqz_h4_size']))
  911.                 $page_style['h4']['font-size'] = $_POST['ubam_optimum_sqz_h4_size'];
  912.             if (!empty($_POST['ubam_optimum_sqz_h4_color']))
  913.                 $page_style['h4']['color'] = $_POST['ubam_optimum_sqz_h4_color'];
  914.             if (!empty($_POST['ubam_optimum_sqz_h4_weight']))
  915.                 $page_style['h4']['font-weight'] = $_POST['ubam_optimum_sqz_h4_weight'];
  916.             if (!empty($_POST['ubam_optimum_sqz_h4_style']))
  917.                 $page_style['h4']['font-style'] = $_POST['ubam_optimum_sqz_h4_style'];
  918.             if (!empty($_POST['ubam_optimum_sqz_h4_align']))
  919.                 $page_style['h4']['text-align'] = $_POST['ubam_optimum_sqz_h4_align'];
  920.             if (!empty($_POST['ubam_optimum_sqz_h4_font']))
  921.                 $page_style['h4']['font-family'] = $_POST['ubam_optimum_sqz_h4_font'];
  922.             if (!empty($_POST['ubam_optimum_sqz_h5_size']))
  923.                 $page_style['h5']['font-size'] = $_POST['ubam_optimum_sqz_h5_size'];
  924.             if (!empty($_POST['ubam_optimum_sqz_h5_color']))
  925.                 $page_style['h5']['color'] = $_POST['ubam_optimum_sqz_h5_color'];
  926.             if (!empty($_POST['ubam_optimum_sqz_h5_weight']))
  927.                 $page_style['h5']['font-weight'] = $_POST['ubam_optimum_sqz_h5_weight'];
  928.             if (!empty($_POST['ubam_optimum_sqz_h5_style']))
  929.                 $page_style['h5']['font-style'] = $_POST['ubam_optimum_sqz_h5_style'];
  930.             if (!empty($_POST['ubam_optimum_sqz_h5_align']))
  931.                 $page_style['h5']['text-align'] = $_POST['ubam_optimum_sqz_h5_align'];
  932.             if (!empty($_POST['ubam_optimum_sqz_h5_font']))
  933.                 $page_style['h5']['font-family'] = $_POST['ubam_optimum_sqz_h5_font'];
  934.             if (!empty($_POST['ubam_optimum_sqz_h6_size']))
  935.                 $page_style['h6']['font-size'] = $_POST['ubam_optimum_sqz_h6_size'];
  936.             if (!empty($_POST['ubam_optimum_sqz_h6_color']))
  937.                 $page_style['h6']['color'] = $_POST['ubam_optimum_sqz_h6_color'];
  938.             if (!empty($_POST['ubam_optimum_sqz_h6_weight']))
  939.                 $page_style['h6']['font-weight'] = $_POST['ubam_optimum_sqz_h6_weight'];
  940.             if (!empty($_POST['ubam_optimum_sqz_h6_style']))
  941.                 $page_style['h6']['font-style'] = $_POST['ubam_optimum_sqz_h6_style'];
  942.             if (!empty($_POST['ubam_optimum_sqz_h6_align']))
  943.                 $page_style['h6']['text-align'] = $_POST['ubam_optimum_sqz_h6_align'];
  944.             if (!empty($_POST['ubam_optimum_sqz_h6_font']))
  945.                 $page_style['h6']['font-family'] = $_POST['ubam_optimum_sqz_h6_font'];
  946.             if (!empty($_POST['ubam_optimum_sqz_a_color']))
  947.                 $page_style['a']['color'] = $_POST['ubam_optimum_sqz_a_color'];
  948.             if (!empty($_POST['ubam_optimum_sqz_a_decoration']))
  949.                 $page_style['a']['text-decoration'] = $_POST['ubam_optimum_sqz_a_decoration'];
  950.             if (!empty($_POST['ubam_optimum_sqz_a_font']))
  951.                 $page_style['a']['font-family'] = $_POST['ubam_optimum_sqz_a_font'];
  952.             if (!empty($_POST['ubam_optimum_sqz_alink_color']))
  953.                 $page_style['a-link']['color'] = $_POST['ubam_optimum_sqz_alink_color'];
  954.             if (!empty($_POST['ubam_optimum_sqz_alink_decoration']))
  955.                 $page_style['a-link']['text-decoration'] = $_POST['ubam_optimum_sqz_alink_decoration'];
  956.             if (!empty($_POST['ubam_optimum_sqz_alink_font']))
  957.                 $page_style['a-link']['font-family'] = $_POST['ubam_optimum_sqz_alink_font'];
  958.             if (!empty($_POST['ubam_optimum_sqz_ahover_color']))
  959.                 $page_style['a-hover']['color'] = $_POST['ubam_optimum_sqz_ahover_color'];
  960.             if (!empty($_POST['ubam_optimum_sqz_ahover_decoration']))
  961.                 $page_style['a-hover']['text-decoration'] = $_POST['ubam_optimum_sqz_ahover_decoration'];
  962.             if (!empty($_POST['ubam_optimum_sqz_ahover_font']))
  963.                 $page_style['a-hover']['font-family'] = $_POST['ubam_optimum_sqz_ahover_font'];
  964.             if (!empty($_POST['ubam_optimum_sqz_avisited_color']))
  965.                 $page_style['a-visited']['color'] = $_POST['ubam_optimum_sqz_avisited_color'];
  966.             if (!empty($_POST['ubam_optimum_sqz_avisited_decoration']))
  967.                 $page_style['a-visited']['text-decoration'] = $_POST['ubam_optimum_sqz_avisited_decoration'];
  968.             if (!empty($_POST['ubam_optimum_sqz_avisited_font']))
  969.                 $page_style['a-visited']['font-family'] = $_POST['ubam_optimum_sqz_avisited_font'];
  970.             return $page_style;
  971.         }
  972.         function get_page_style_settings()
  973.         {
  974.             $the_style = htmlspecialchars(trim($_POST['style']));
  975.             if (empty($the_style))
  976.                 return '';
  977.             $base_style                                     = get_option("ubam_optimum_sqz_style_$the_style");
  978.             $page_style                                     = $this->ubam_remove_magic_quotes($base_style);
  979.             $output['ubam_optimum_sqz_page_style']          = $the_style;
  980.             $output['ubam_optimum_sqz_top_margin']          = $page_style['sheet']['margin-top'];
  981.             $output['ubam_optimum_sqz_body_bg_color']       = $page_style['body']['background-color'];
  982.             $output['ubam_optimum_sqz_show_gradient']       = $page_style['body']['gradient'];
  983.             $output['ubam_optimum_sqz_show_borders']        = $page_style['sheet-border']['show'];
  984.             $output['ubam_optimum_sqz_bgimg_url']           = $page_style['body']['bgimg']['background-image'];
  985.             $output['ubam_optimum_sqz_bgimg_repeat']        = $page_style['body']['bgimg']['background-repeat'];
  986.             $output['ubam_optimum_sqz_bgimg_position']      = $page_style['body']['bgimg']['background-position'];
  987.             $output['ubam_optimum_sqz_bgimg_attachment']    = $page_style['body']['bgimg']['background-attachment'];
  988.             $output['ubam_optimum_sqz_postcontent_size']    = $page_style['post-content']['font-size'];
  989.             $output['ubam_optimum_sqz_postcontent_color']   = $page_style['post-content']['color'];
  990.             $output['ubam_optimum_sqz_postcontent_weight']  = $page_style['post-content']['font-weight'];
  991.             $output['ubam_optimum_sqz_postcontent_style']   = $page_style['post-content']['font-style'];
  992.             $output['ubam_optimum_sqz_postcontent_align']   = $page_style['post-content']['text-align'];
  993.             $output['ubam_optimum_sqz_postcontent_font']    = $page_style['post-content']['font-family'];
  994.             $output['ubam_optimum_sqz_olul_size']           = $page_style['ol-ul']['font-size'];
  995.             $output['ubam_optimum_sqz_olul_color']          = $page_style['ol-ul']['color'];
  996.             $output['ubam_optimum_sqz_olul_font']           = $page_style['ol-ul']['font-family'];
  997.             $output['ubam_optimum_sqz_h1_size']             = $page_style['h1']['font-size'];
  998.             $output['ubam_optimum_sqz_h1_color']            = $page_style['h1']['color'];
  999.             $output['ubam_optimum_sqz_h1_weight']           = $page_style['h1']['font-weight'];
  1000.             $output['ubam_optimum_sqz_h1_style']            = $page_style['h1']['font-style'];
  1001.             $output['ubam_optimum_sqz_h1_align']            = $page_style['h1']['text-align'];
  1002.             $output['ubam_optimum_sqz_h1_font']             = $page_style['h1']['font-family'];
  1003.             $output['ubam_optimum_sqz_h2_size']             = $page_style['h2']['font-size'];
  1004.             $output['ubam_optimum_sqz_h2_color']            = $page_style['h2']['color'];
  1005.             $output['ubam_optimum_sqz_h2_weight']           = $page_style['h2']['font-weight'];
  1006.             $output['ubam_optimum_sqz_h2_style']            = $page_style['h2']['font-style'];
  1007.             $output['ubam_optimum_sqz_h2_align']            = $page_style['h2']['text-align'];
  1008.             $output['ubam_optimum_sqz_h2_font']             = $page_style['h2']['font-family'];
  1009.             $output['ubam_optimum_sqz_h3_size']             = $page_style['h3']['font-size'];
  1010.             $output['ubam_optimum_sqz_h3_color']            = $page_style['h3']['color'];
  1011.             $output['ubam_optimum_sqz_h3_weight']           = $page_style['h3']['font-weight'];
  1012.             $output['ubam_optimum_sqz_h3_style']            = $page_style['h3']['font-style'];
  1013.             $output['ubam_optimum_sqz_h3_align']            = $page_style['h3']['text-align'];
  1014.             $output['ubam_optimum_sqz_h3_font']             = $page_style['h3']['font-family'];
  1015.             $output['ubam_optimum_sqz_h4_size']             = $page_style['h4']['font-size'];
  1016.             $output['ubam_optimum_sqz_h4_color']            = $page_style['h4']['color'];
  1017.             $output['ubam_optimum_sqz_h4_weight']           = $page_style['h4']['font-weight'];
  1018.             $output['ubam_optimum_sqz_h4_style']            = $page_style['h4']['font-style'];
  1019.             $output['ubam_optimum_sqz_h4_align']            = $page_style['h4']['text-align'];
  1020.             $output['ubam_optimum_sqz_h4_font']             = $page_style['h4']['font-family'];
  1021.             $output['ubam_optimum_sqz_h5_size']             = $page_style['h5']['font-size'];
  1022.             $output['ubam_optimum_sqz_h5_color']            = $page_style['h5']['color'];
  1023.             $output['ubam_optimum_sqz_h5_weight']           = $page_style['h5']['font-weight'];
  1024.             $output['ubam_optimum_sqz_h5_style']            = $page_style['h5']['font-style'];
  1025.             $output['ubam_optimum_sqz_h5_align']            = $page_style['h5']['text-align'];
  1026.             $output['ubam_optimum_sqz_h5_font']             = $page_style['h5']['font-family'];
  1027.             $output['ubam_optimum_sqz_h6_size']             = $page_style['h6']['font-size'];
  1028.             $output['ubam_optimum_sqz_h6_color']            = $page_style['h6']['color'];
  1029.             $output['ubam_optimum_sqz_h6_weight']           = $page_style['h6']['font-weight'];
  1030.             $output['ubam_optimum_sqz_h6_style']            = $page_style['h6']['font-style'];
  1031.             $output['ubam_optimum_sqz_h6_align']            = $page_style['h6']['text-align'];
  1032.             $output['ubam_optimum_sqz_h6_font']             = $page_style['h6']['font-family'];
  1033.             $output['ubam_optimum_sqz_a_color']             = $page_style['a']['color'];
  1034.             $output['ubam_optimum_sqz_a_decoration']        = $page_style['a']['text-decoration'];
  1035.             $output['ubam_optimum_sqz_a_font']              = $page_style['a']['font-family'];
  1036.             $output['ubam_optimum_sqz_alink_color']         = $page_style['a-link']['color'];
  1037.             $output['ubam_optimum_sqz_alink_decoration']    = $page_style['a-link']['text-decoration'];
  1038.             $output['ubam_optimum_sqz_alink_font']          = $page_style['a-link']['font-family'];
  1039.             $output['ubam_optimum_sqz_ahover_color']        = $page_style['a-hover']['color'];
  1040.             $output['ubam_optimum_sqz_ahover_decoration']   = $page_style['a-hover']['text-decoration'];
  1041.             $output['ubam_optimum_sqz_ahover_font']         = $page_style['a-hover']['font-family'];
  1042.             $output['ubam_optimum_sqz_avisited_color']      = $page_style['a-visited']['color'];
  1043.             $output['ubam_optimum_sqz_avisited_decoration'] = $page_style['a-visited']['text-decoration'];
  1044.             $output['ubam_optimum_sqz_avisited_font']       = $page_style['a-visited']['font-family'];
  1045.             $json_out                                       = $this->json_encode($output);
  1046.             return $json_out;
  1047.         }
  1048.         function json_encode($a = false)
  1049.         {
  1050.             if (is_null($a))
  1051.                 return 'null';
  1052.             if ($a === false)
  1053.                 return 'false';
  1054.             if ($a === true)
  1055.                 return 'true';
  1056.             if (is_scalar($a)) {
  1057.                 if (is_float($a)) {
  1058.                     $a = str_replace(",", ".", strval($a));
  1059.                 }
  1060.                 static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
  1061.                 return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
  1062.             }
  1063.             $isList = true;
  1064.             for ($i = 0, reset($a); $i < count($a); $i++, next($a)) {
  1065.                 if (key($a) !== $i) {
  1066.                     $isList = false;
  1067.                     break;
  1068.                 }
  1069.             }
  1070.             $result = array();
  1071.             if ($isList) {
  1072.                 foreach ($a as $v)
  1073.                     $result[] = $this->json_encode($v);
  1074.                 return '[ ' . join(', ', $result) . ' ]';
  1075.             } else {
  1076.                 foreach ($a as $k => $v)
  1077.                     $result[] = $this->json_encode($k) . ': ' . $this->json_encode($v);
  1078.                 return '{ ' . join(', ', $result) . ' }';
  1079.             }
  1080.         }
  1081.     }
  1082. }
  1083. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement