$value) { if ($params_line != '') { $params_line .= '&'; } $params_line .= "$key=$value"; } $params_line_key = $params_line . '&key=' . $private_key; $token = sha1("$path?$params_line_key"); return "$path?$params_line&sign=$token"; } function adwit_find_or_create_customer() { $adwit_data = adwit_options(); $result = array('status' => 0); //status 0 = can't create account or allready exist if ($adwit_data && isset($adwit_data['adwit_express_key']) && !empty($adwit_data['adwit_express_key'])) { $result['status'] = 2; //has account, 0 zones if (Adwit_Banner_Manager_Admin::_adwit_user_has_zones()) { $result['status'] = 1; //has account and zones } $result['data'] = $adwit_data; return $result; } global $current_user; get_currentuserinfo(); $wp_url = Adwit_Banner_Manager_Admin::_get_wp_url(); $adwit_wp_email = $current_user->user_email; $adwit_regie_id = 5; $adwit_wp_url = $wp_url; $adwit_wp_lang = 'EN'; $url_express_create_account = ADWIT_HOME_URL . "/campaign_ads/user_add?email=" . $adwit_wp_email . "®ie_id=" . $adwit_regie_id . "&url=" . $adwit_wp_url . "&lang=" . $adwit_wp_lang; $get_account = wp_remote_fopen($url_express_create_account); if (empty($get_account) or $get_account == 'D') { return $result; } $cust_arr = explode(';', $get_account); if (!empty($get_account) && is_array($cust_arr) && !empty($cust_arr[1])) { $adwit_data['adwit_express_email'] = $cust_arr[0]; $adwit_data['adwit_express_key'] = $cust_arr[1]; $adwit_data['adwit_express_publisher_id'] = $cust_arr[2]; $adwit_data['adwit_express_ads_enabled'] = 0; update_option('adwit_options', $adwit_data); $result['status'] = 2; //has account, 0 zones } $result['data'] = $adwit_data; return $result; } function _adwit_user_has_zones(){ $adwit_data = adwit_options(); if ($adwit_data['ads'] != NULL && !empty($adwit_data['ads'])){ return true; } $adwit_banner_data = adwit_widget_options(); $list_av_zones = array(); foreach ($adwit_banner_data as $k => $v ){ if (empty($v) || $k['_multiwidget']){ continue; } $list_av_zones[] = $v; } if (!empty($list_av_zones)){ $adwit_data = adwit_options(); $adwit_data['adwit_express_ads_enabled'] = 1; update_option('adwit_options', $adwit_data); return true; } return false; } function _get_wp_url($getfull=false) { $s = empty($_SERVER ["HTTPS"]) ? '' : ($_SERVER ["HTTPS"] == "on") ? "s" : ""; $protocol = strtolower($_SERVER ["SERVER_PROTOCOL"]); $protocol = substr($protocol, 0, strpos($protocol, "/")); $protocol .= $s; $port = ($_SERVER ["SERVER_PORT"] == "80") ? "" : (":" . $_SERVER ["SERVER_PORT"]); if ($getfull == true) { $res = $protocol . "://" . $_SERVER ['SERVER_NAME'] . $port . $_SERVER ['REQUEST_URI']; } else { $res = $protocol . "://" . $_SERVER ['SERVER_NAME'] . $port; } return $res; } function adwit_check_ads() { $adwit_data = adwit_options(); $count_ads = Adwit_Banner_Manager_Admin::_count_adwit_ads(); $adwit_data['adwit_express_ads_enabled'] = 0; if ($count_ads >= 1) { $adwit_data['adwit_express_ads_enabled'] = 1; } update_option('adwit_options', $adwit_data); get_option('adwit_options'); return $count_ads; } function _count_adwit_ads() { $adwit_data = adwit_options(); $res = count($adwit_data['ads']); return $res; } function _get_bann_list() { $res = array(); $res['468x60'] = array('id' => 2, 'class' => "adwit_banner", 'width' => "117px", 'height' => "17px", 'bgcolor' => " #ffcfa0"); $res['728x90'] = array('id' => 1, 'class' => "adwit_banner", 'width' => "182px", 'height' => "22px", 'bgcolor' => " #ffaf70"); $res['160x600'] = array('id' => 5, 'class' => "adwit_banner", 'width' => "40px", 'height' => "150px", 'bgcolor' => " #ff8f40"); $res['120x600'] = array('id' => 4, 'class' => "adwit_banner", 'width' => "30px", 'height' => "150px", 'bgcolor' => " #ff9f90"); $res['200x200'] = array('id' => 8, 'class' => "adwit_banner", 'width' => "50px", 'height' => "50px", 'bgcolor' => " #ffcf70"); $res['250x250'] = array('id' => 7, 'class' => "adwit_banner", 'width' => "62px", 'height' => "62px", 'bgcolor' => " #ffaf40"); $res['300x250'] = array('id' => 6, 'class' => "adwit_banner", 'width' => "75px", 'height' => "62px", 'bgcolor' => " #ff8fa0"); $res['120x240'] = array('id' => 10, 'class' => "adwit_banner", 'width' => "30px", 'height' => "60px", 'bgcolor' => " #ff6f70"); $res['336x280'] = array('id' => 12, 'class' => "adwit_banner", 'width' => "84px", 'height' => "70px", 'bgcolor' => " #ffcf40"); $res['180x150'] = array('id' => 11, 'class' => "adwit_banner", 'width' => "45px", 'height' => "37px", 'bgcolor' => " #ffafa0"); $res['125x125'] = array('id' => 9, 'class' => "adwit_banner", 'width' => "31px", 'height' => "31px", 'bgcolor' => " #ff8f70"); $res['234x60'] = array('id' => 3, 'class' => "adwit_banner", 'width' => "58px", 'height' => "17px", 'bgcolor' => " #ff6f40"); return $res; } function _get_date_now_adwit_format() { return date('Y-m-d') . '_' . date('h') . 'h' . date('i'); } function _get_adwit_post_type_data($ads, $type='page') { $res = array(); if (is_array($ads) && !empty($ads)) { foreach ($ads as $key => $val) { if (0 == strcmp($type, substr($key, 0, strlen($type)))) { $res[$key] = $val; } } } return $res; } function _get_adwit_ads_data() { $options = adwit_options(); $res = array(); if (is_page ()) { $res = Adwit_Banner_Manager_Admin::_get_adwit_post_type_data($options['ads'], 'page'); } elseif (is_single() || is_archive()) { $res = Adwit_Banner_Manager_Admin::_get_adwit_post_type_data($options['ads'], 'post'); } elseif (is_home ()) { $res = Adwit_Banner_Manager_Admin::_get_adwit_post_type_data($options['ads'], 'home'); } elseif (is_search ()) { $res = Adwit_Banner_Manager_Admin::_get_adwit_post_type_data($options['ads'], 'search'); } return $res; } function _get_adwit_ads($pos='') { if (empty($pos)) { return ''; } $post_type = ''; if (is_page ()) { $post_type = 'page_' . $pos; } elseif (is_single() || is_archive()) { $post_type = 'post_' . $pos; } elseif (is_home ()) { $post_type = 'home_' . $pos; } elseif (is_search ()) { $post_type = 'search_' . $pos; } $adwit_ads = Adwit_Banner_Manager_Admin::_get_adwit_ads_data(); $script_pos = ''; if ($adwit_ads[$post_type . '_left']) { $script_pos .= '