Download Pro-Version here Author: Ven Tesh Version: 1.4.0 Author URI: http://www.blasho.com/about/ */ add_action('admin_init', 'AffiLinker_Operations'); add_action('admin_menu', 'AffiLinker_CreateMenu'); add_filter('the_content', 'AffiLinker_InsertAffiliateLinks'); add_filter('get_comment', 'AffiLinker_InsertAffiliateLinksToComment'); $link = ''; $linkformat = ''; $linkformat4comm = ''; $linknofollow = ''; $linklink_target = ''; $linkhead = ''; $linkclass = ''; $afflt = array( 'AffiLinker Activation Form', 'AffiLinker - General Settings' ); function AffiLinker_create_ad_widget() { register_widget( 'AffiLinkerWidget' ); } class AffiLinkerWidget extends WP_Widget { function AffiLinkerWidget() { //Constructor parent::WP_Widget(false, $name = 'AffiLinker Cloud', array( 'description' => 'Widget to create list/cloud of Affiliate links.' )); } function widget($args, $instance) { extract($args); echo $before_widget; $affl_underline_options_array = array( "", "text-decoration: none; border-bottom:1px dotted;", "text-decoration: none; border-bottom:2px dotted;", "text-decoration: none; border-bottom:1px dashed;", "text-decoration: none; border-bottom:2px dashed;", "text-decoration: none; border-bottom:1px solid red;", "text-decoration: none; border-bottom:2px solid red;", "text-decoration: none; border-bottom:3px double;", "text-decoration: none; border-bottom:4px double;", "text-decoration: underline overline;" ); $family_array = array( "Default Font", "Arial", "Arial Black", "Comic", "Comic Sans MS", "Courier", "Courier New", "Franklin Gothic", "Georgia", "Helvetica", "Impact", "Lucida Sans", "Microsoft Sans Serif", "Monaco", "MV Boli", "Tahoma", "Times", "Times New Roman", "Trebuchet MS", "Verdana"); $affl_widget_title = get_option("affl_widget_title"); $affl_widget_title = esc_attr($instance['affl_widget_title']); $affl_widget_title = $affl_widget_title ? $affl_widget_title : 'AffiLinker Cloud'; $affl_link_term = get_option("affl_link_term"); echo "\n" . $before_title; echo $affl_widget_title; echo $after_title; global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name); $affl_widget_no_keywords_counter = 0; $affl_widget_interactive_opt = esc_attr($instance['affl_widget_interactive_opt']); $affl_widget_interactive_opt = $affl_widget_interactive_opt ? $affl_widget_interactive_opt : '0'; $affl_widget_avoid_dup = esc_attr($instance['affl_widget_avoid_dup']); $affl_widget_avoid_dup = affl_widget_avoid_dup ? $affl_widget_avoid_dup : '0'; $affl_widget_no_keywords = esc_attr($instance['affl_widget_no_keywords']); $affl_widget_no_keywords = $affl_widget_no_keywords ? $affl_widget_no_keywords : '10'; $affl_widget_type = esc_attr($instance['affl_widget_type']); $affl_widget_type = $affl_widget_type ? $affl_widget_type : '21'; $affl_widget_font_startpx = esc_attr($instance['affl_widget_font_startpx']); $affl_widget_font_startpx = $affl_widget_font_startpx ? $affl_widget_font_startpx : '10'; $affl_widget_font_endpx = esc_attr($instance['affl_widget_font_endpx']); $affl_widget_font_endpx = $affl_widget_font_endpx ? $affl_widget_font_endpx : '25'; $affl_widget_no_keywords = esc_attr($instance['affl_widget_no_keywords']); $affl_widget_no_keywords = $affl_widget_no_keywords ? $affl_widget_no_keywords : '10'; if ($affl_widget_type == 20) echo ''; //echo $after_title; //wp125_write_ads(); echo $after_widget; } function update($new_instance, $old_instance) { //update and save the widget return $new_instance; } function form($instance) { $affl_widget_title = esc_attr($instance['affl_widget_title']); $affl_widget_title = $affl_widget_title ? $affl_widget_title : 'AffiLinker Cloud'; $affl_widget_no_keywords = esc_attr($instance['affl_widget_no_keywords']); $affl_widget_no_keywords = $affl_widget_no_keywords ? $affl_widget_no_keywords : '10'; $affl_widget_type = esc_attr($instance['affl_widget_type']); $affl_widget_type = $affl_widget_type ? $affl_widget_type : '21'; $affl_widget_font_startpx = esc_attr($instance['affl_widget_font_startpx']); $affl_widget_font_startpx = $affl_widget_font_startpx ? $affl_widget_font_startpx : '10'; $affl_widget_font_endpx = esc_attr($instance['affl_widget_font_endpx']); $affl_widget_font_endpx = $affl_widget_font_endpx ? $affl_widget_font_endpx : '25'; $affl_widget_interactive_opt = esc_attr($instance['affl_widget_interactive_opt']); $affl_widget_interactive_opt = $affl_widget_interactive_opt ? $affl_widget_interactive_opt : '0'; $affl_widget_avoid_dup = esc_attr($instance['affl_widget_avoid_dup']); $affl_widget_avoid_dup = $affl_widget_avoid_dup ? $affl_widget_avoid_dup : '0'; echo ' Widget Title :

No of Keywords to Display :
Put -1 to list all keywords

How To Display AffiLinks ?
'; echo ''; } else { echo ' '; } echo '
'; echo '
For Keywords as Cloud:
Minimum Font px
Maximum Font px'; /* if ($affl_widget_type == 3) { echo '  Keywords as Random Cloud

'; } else { echo '  Keywords as Random Cloud

'; } */ if ($affl_widget_interactive_opt == 1) { echo '

  Enable Interactive AffiLinks'; } else { echo '

  Enable Interactive AffiLinks'; } if ($affl_widget_avoid_dup == 1) { echo '
  Show Only Unique AffiLinks'; } else { echo '
  Show Only Unique AffiLinks'; } echo ''; } } function myplugin_register_widgets() { register_widget( 'My_Recent_Posts_Widget' ); } add_action( 'widgets_init', 'AffiLinker_create_ad_widget' ); function AffiLinker_write_ads_widget($args) { extract($args); echo $before_widget; $affl_underline_options_array = array( "", "text-decoration: none; border-bottom:1px dotted;", "text-decoration: none; border-bottom:2px dotted;", "text-decoration: none; border-bottom:1px dashed;", "text-decoration: none; border-bottom:2px dashed;", "text-decoration: none; border-bottom:1px solid red;", "text-decoration: none; border-bottom:2px solid red;", "text-decoration: none; border-bottom:3px double;", "text-decoration: none; border-bottom:4px double;", "text-decoration: underline overline;" ); $family_array = array( "Default Font", "Arial", "Arial Black", "Comic", "Comic Sans MS", "Courier", "Courier New", "Franklin Gothic", "Georgia", "Helvetica", "Impact", "Lucida Sans", "Microsoft Sans Serif", "Monaco", "MV Boli", "Tahoma", "Times", "Times New Roman", "Trebuchet MS", "Verdana"); $affl_widget_title = get_option("affl_widget_title"); echo "\n" . $before_title; echo $affl_widget_title; echo $after_title; global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name); $affl_widget_interactive_opt = get_option("affl_widget_interactive_opt"); $affl_widget_avoid_dup = get_option("affl_widget_avoid_dup"); $affl_widget_no_keywords = get_option("affl_widget_no_keywords"); $affl_widget_type = get_option("affl_widget_type"); $affl_widget_font_startpx = get_option("affl_widget_font_startpx"); $affl_widget_font_endpx = get_option("affl_widget_font_endpx"); $affl_link_term = get_option("affl_link_term"); $affl_widget_no_keywords_counter = 0; if ($affl_widget_type == 0) echo ''; echo $after_title; //wp125_write_ads(); echo $after_widget; } //add_action("plugins_loaded", "AffiLinker_create_ad_widget"); //Create the Widget function makeStringSecure ($string) { $string = trim($string); $string = strip_tags($string); $string = htmlentities($string, ENT_NOQUOTES); $string = stripslashes($string); $string = mysql_real_escape_string($string); return $string; } add_action('init', 'AffiLinker_NavigateToLink'); function AffiLinker_NavigateToLink() { if (1/*!is_admin()*/) { $reqURL = $_SERVER['REQUEST_URI']; $fullURL = 'http://'.$_SERVER['HTTP_HOST'].$reqURL; $affl_link_term = get_option("affl_link_term"); //echo $fullURL; $hopURL = '/' . $affl_link_term . '/'; //echo ' - ' . $hopURL; if ($hopURL != '' && $hopURL != '//') if (stristr($fullURL, $hopURL) !== false) { $reqArr = explode('/', $reqURL); foreach ($reqArr as $key=>$token) { if ($token=='') { unset($reqArr[$key]); } } $tag = array_pop($reqArr); global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; $table_name_stat = $wpdb->prefix . "AffiLinker_db_stat"; /* $tag = "testkey"; $sel_query = "SELECT * FROM ". $table_name . " WHERE alt_link_keyword='" . $tag ."'"; echo $sel_query; */ $tag = str_replace('-',' ',$tag); $tag = trim($tag); if (strpos($tag,'%') != FALSE) { $iso_char_found = true; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name); } else { $iso_char_found = false; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " WHERE keywords like '%" . $tag ."%'" ); } // echo ' - tag ' . $tag; //echo $wpdb->num_rows; if ($wpdb->num_rows <= 0) { // header('Location: ' . $row->link); //echo ' - 0 - '; die; } //echo ' - 1 - '; if ( 1 /*!is_admin() && !is_feed() && !is_user_logged_in()*/ ) { $keyword_matched = 1; foreach($myrows as $row) { if(!is_null($row->keywords)) { $keys = explode(',',$row->keywords); foreach($keys as $key) { $tag = str_replace(array("\r\n"), '', $tag); $key = str_replace(array("\r\n"), '', $key); $key = trim($key); $tag = trim($tag); //echo '[ ' . $key . ' - ' . $tag . ' ]'; if ($iso_char_found == true) { $key = urldecode($key); $tag = urldecode(makeStringSecure($tag)); } //echo '[ ' . urldecode( $key) . ' - ' . urldecode(makeStringSecure($tag)) . ' ]'; $keyword_matched = strcasecmp($key, $tag); if ($keyword_matched == 0) { $FullRef_URL = $_SERVER['HTTP_REFERER']; //matched $afflink_update_query = "UPDATE ". $table_name ." SET link_hit_count=link_hit_count+1 WHERE id='$row->id'"; //echo $afflink_update_query; //die; if ($FullRef_URL != '') $results = $wpdb->query( $afflink_update_query ); break; } } } if ($keyword_matched == 0) { break; } } } $FullRef_URL = $_SERVER['HTTP_REFERER']; if ($FullRef_URL != '') { $table_name_stat_uniq = $wpdb->prefix . "AffiLinker_db_stat_uniq"; $affl_ip_address = $_SERVER['REMOTE_ADDR']; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name_stat_uniq . " WHERE hit_keyword='$key' AND affl_ip_address='$affl_ip_address'"); if ($wpdb->num_rows <= 0) { $rows_affected = $wpdb->insert( $table_name_stat_uniq, array( 'affl_ip_address' => $affl_ip_address, 'hit_keyword' => $key) ); } $keyword_row_stat = $wpdb->get_results( "SELECT * FROM ". $table_name_stat . " WHERE hit_keyword='$key' AND referral_link='" . $FullRef_URL . "'"); if ($wpdb->num_rows > 0) { foreach($keyword_row_stat as $row_stat) { //existing rec $rows_affected = $wpdb->update( $table_name_stat, array('link_hit_count' => $row_stat->link_hit_count + 1), array( 'hit_keyword' => $key, 'referral_link' => $FullRef_URL )); break; } } else { $rows_affected = $wpdb->insert( $table_name_stat, array( 'referral_link' => $FullRef_URL, 'hit_keyword' => $key, 'link_hit_count' => 1) ); } } header('Location: ' . $row->link); ob_end_flush(); exit(); } } } function AffiLinker_Operations() { global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; $table_name_stat = $wpdb->prefix . "AffiLinker_db_stat"; if($_POST['aal_sent']=='ok') { $rowchk = 4; $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name); $rown = 0; $rowchk = $rowchk - 2; foreach($myrows as $row) { $rown = $rown + 1; } if ($rown >= ($rowchk+1)) { wp_redirect("admin.php?page=affilinker/affilinker.php"); } else { $link = filter_input(INPUT_POST, 'link', FILTER_SANITIZE_SPECIAL_CHARS); $keywords = filter_input(INPUT_POST, 'keywords', FILTER_SANITIZE_SPECIAL_CHARS); $link_color = filter_input(INPUT_POST, 'link_color', FILTER_SANITIZE_SPECIAL_CHARS); $bg_color = filter_input(INPUT_POST, 'bg_color', FILTER_SANITIZE_SPECIAL_CHARS); $hover_color = filter_input(INPUT_POST, 'hover_color', FILTER_SANITIZE_SPECIAL_CHARS); $hover_bg_color = filter_input(INPUT_POST, 'hover_bg_color', FILTER_SANITIZE_SPECIAL_CHARS); $hover_title_text = filter_input(INPUT_POST, 'hover_title_text', FILTER_SANITIZE_SPECIAL_CHARS); $font_size = filter_input(INPUT_POST, 'font_size', FILTER_SANITIZE_SPECIAL_CHARS); $font_family = filter_input(INPUT_POST, 'font_family', FILTER_SANITIZE_SPECIAL_CHARS); $link_style_bold = filter_input(INPUT_POST, 'link_style_bold', FILTER_SANITIZE_SPECIAL_CHARS); $link_style_italics = filter_input(INPUT_POST, 'link_style_italics', FILTER_SANITIZE_SPECIAL_CHARS); $affl_underline_options = filter_input(INPUT_POST, 'affl_underline_options', FILTER_SANITIZE_SPECIAL_CHARS); $link_nofollow = filter_input(INPUT_POST, 'link_nofollow', FILTER_SANITIZE_SPECIAL_CHARS); $link_target = filter_input(INPUT_POST, 'link_target', FILTER_SANITIZE_SPECIAL_CHARS); $include_keyword = filter_input(INPUT_POST, 'include_keyword', FILTER_SANITIZE_SPECIAL_CHARS); $alt_link_keyword = filter_input(INPUT_POST, 'alt_link_keyword', FILTER_SANITIZE_SPECIAL_CHARS); $keyword_priority = filter_input(INPUT_POST, 'keyword_priority', FILTER_SANITIZE_SPECIAL_CHARS); //$link_hit_count = filter_input(INPUT_POST, 'link_hit_count', FILTER_SANITIZE_SPECIAL_CHARS); $link_hit_count = 0; if ($keywords != '') { $rows_affected = $wpdb->insert( $table_name, array( 'link' => $link, 'keywords' => $keywords, 'link_color' => $link_color, 'bg_color' => $bg_color, 'hover_color' => $hover_color, 'hover_bg_color' => $hover_bg_color, 'font_size' => $font_size, 'font_family' => $font_family, 'link_style_bold' => $link_style_bold, 'link_style_italics' => $link_style_italics, 'affl_underline_options' => $affl_underline_options, 'link_nofollow' => $link_nofollow, 'link_target' => $link_target, 'include_keyword' => $include_keyword, 'alt_link_keyword' => $alt_link_keyword, 'link_hit_count' => $link_hit_count, 'keyword_priority' => $keyword_priority, 'hover_title_text' => $hover_title_text ) ); } wp_redirect("admin.php?page=affilinker/affilinker.php#down"); } } if ($_POST['affl_savegs_changes']=='ok') { check_admin_referer('AffiLinker-AFFL_gsettings'); $affl_num_of_keywords = filter_input(INPUT_POST, 'affl_num_of_keywords', FILTER_SANITIZE_SPECIAL_CHARS); $affl_num_of_keywords_percomment = filter_input(INPUT_POST, 'affl_num_of_keywords_percomment', FILTER_SANITIZE_SPECIAL_CHARS); $affl_num_samekey_perpost = filter_input(INPUT_POST, 'affl_num_samekey_perpost', FILTER_SANITIZE_SPECIAL_CHARS); $affl_num_samekey_oncommsec = filter_input(INPUT_POST, 'affl_num_samekey_oncommsec', FILTER_SANITIZE_SPECIAL_CHARS); $affl_link_term = filter_input(INPUT_POST, 'affl_link_term', FILTER_SANITIZE_SPECIAL_CHARS); $affl_postcontrol = filter_input(INPUT_POST, 'affl_postcontrol', FILTER_SANITIZE_SPECIAL_CHARS); $affl_ignoreposts = filter_input(INPUT_POST, 'affl_ignoreposts', FILTER_SANITIZE_SPECIAL_CHARS); $affl_onlyposts = filter_input(INPUT_POST, 'affl_onlyposts', FILTER_SANITIZE_SPECIAL_CHARS); $affl_link_on_comments = filter_input(INPUT_POST, 'affl_link_on_comments', FILTER_SANITIZE_SPECIAL_CHARS); $affl_link_on_homepage = filter_input(INPUT_POST, 'affl_link_on_homepage', FILTER_SANITIZE_SPECIAL_CHARS); $affl_keyword_priority = filter_input(INPUT_POST, 'affl_keyword_priority', FILTER_SANITIZE_SPECIAL_CHARS); $affl_interactive_afflinks = filter_input(INPUT_POST, 'affl_interactive_afflinks', FILTER_SANITIZE_SPECIAL_CHARS); $afflinker_enable = filter_input(INPUT_POST, 'afflinker_enable', FILTER_SANITIZE_SPECIAL_CHARS); $affl_num_of_wordcount = filter_input(INPUT_POST, 'affl_num_of_wordcount', FILTER_SANITIZE_SPECIAL_CHARS); $afflinker_jquery_opt = filter_input(INPUT_POST, 'afflinker_jquery_opt', FILTER_SANITIZE_SPECIAL_CHARS); if ($afflinker_enable == '') { $afflinker_enable = 0; } if ($affl_num_of_keywords == '') { $affl_num_of_keywords = 5; } if ($affl_num_of_keywords_percomment == '') { $affl_num_of_keywords_percomment = 5; } if ($affl_num_samekey_perpost == '') { $affl_num_samekey_perpost = 2; } if ($affl_num_samekey_oncommsec == '') { $affl_num_samekey_oncommsec = 2; } if ($affl_link_term == '') { $affl_link_term = 'visit'; } if ($affl_postcontrol == '') { $affl_postcontrol = 1; } if ($affl_link_on_comments == '') { $affl_link_on_comments = 0; } if ($affl_link_on_homepage == '') { $affl_link_on_homepage = 1; } if ($affl_keyword_priority == '') { $affl_keyword_priority = 0; } if ($affl_interactive_afflinks == '') { $affl_interactive_afflinks = 1; } if ($affl_num_of_wordcount == '') { $affl_num_of_wordcount = -1; } if ($afflinker_jquery_opt == '') { $afflinker_jquery_opt = 1; } update_option("affl_num_of_keywords", $affl_num_of_keywords); update_option("affl_num_of_keywords_percomment", $affl_num_of_keywords_percomment); update_option("affl_num_samekey_perpost", $affl_num_samekey_perpost); update_option("affl_num_samekey_oncommsec", $affl_num_samekey_oncommsec); update_option("affl_link_term", $affl_link_term); update_option("affl_num_of_wordcount", $affl_num_of_wordcount); update_option("affl_postcontrol", $affl_postcontrol); update_option("affl_ignoreposts", $affl_ignoreposts); update_option("affl_onlyposts", $affl_onlyposts); update_option("affl_link_on_comments", $affl_link_on_comments); update_option("affl_link_on_homepage", $affl_link_on_homepage); update_option("affl_keyword_priority", $affl_keyword_priority); update_option("affl_interactive_afflinks", $affl_interactive_afflinks); update_option("afflinker_enable", $afflinker_enable); update_option("afflinker_jquery_opt", $afflinker_jquery_opt); } if($_POST['SubmitAll']=='Save All Changes') { $idall = $_POST['checkboxall']; $linkall = $_POST['link']; $keywordsall = $_POST['keywords']; $link_hit_countall = $_POST['link_hit_count']; $link_nofollowall = $_POST['link_nofollow']; $link_targetall = $_POST['link_target']; $include_keywordall = $_POST['include_keyword']; $link_colorall = $_POST['link_color']; $bg_colorall = $_POST['bg_color']; $hover_colorall = $_POST['hover_color']; $hover_bg_colorall = $_POST['hover_bg_color']; $font_sizeall = $_POST['font_size']; $font_familyall = $_POST['font_family']; $link_style_boldall = $_POST['link_style_bold']; $link_style_italicsall = $_POST['link_style_italics']; $affl_underline_optionsall = $_POST['affl_underline_options']; $hover_title_textall = $_POST['hover_title_text']; $alt_link_keywordall = $_POST['alt_link_keyword']; $keyword_priorityall = $_POST['keyword_priority']; $count = count($linkall); for($ids=0; $ids < $count; $ids++) { $nofollowset = 0; for ($i=0; $i < count($link_nofollowall); $i++) { if ($link_nofollowall[$i] == $idall[$ids]) { $nofollowset = 1; break; } } $targetset = 0; for ($i=0; $i < count($link_targetall); $i++) { if ($link_targetall[$i] == $idall[$ids]) { $targetset = 1; break; } } $include_keywordset = 0; for ($i=0; $i < count($include_keywordall); $i++) { if ($include_keywordall[$i] == $idall[$ids]) { $include_keywordset = 1; break; } } $link_style_boldset = 0; for ($i=0; $i < count($link_style_boldall); $i++) { if ($link_style_boldall[$i] == $idall[$ids]) { $link_style_boldset = 1; break; } } $link_style_italicsset = 0; for ($i=0; $i < count($link_style_italicsall); $i++) { if ($link_style_italicsall[$i] == $idall[$ids]) { $link_style_italicsset = 1; break; } } $alt_link_keywordset = 0; for ($i=0; $i < count($alt_link_keywordall); $i++) { if ($alt_link_keywordall[$i] == $idall[$ids]) { $alt_link_keywordset = 1; break; } } $keyword_priorityset = 0; for ($i=0; $i < count($keyword_priorityall); $i++) { if ($keyword_priorityall[$i] == $idall[$ids]) { $keyword_priorityset = 1; break; } } $keywordsall[$ids] = str_replace(array("\r\n"), ' ', $keywordsall[$ids]); $rows_affected = $wpdb->update( $table_name, array( 'link' => $linkall[$ids], 'keywords' => $keywordsall[$ids], 'link_color' => $link_colorall[$ids], 'bg_color' => $bg_colorall[$ids], 'hover_color' => $hover_colorall[$ids], 'hover_bg_color' => $hover_bg_colorall[$ids], 'font_size' => $font_sizeall[$ids], 'font_family' => $font_familyall[$ids], 'link_style_bold' => $link_style_boldset, 'link_style_italics' => $link_style_italicsset, 'affl_underline_options' => $affl_underline_optionsall[$ids], 'link_nofollow' => $nofollowset, 'link_target' => $targetset, 'include_keyword' => $include_keywordset, 'alt_link_keyword' => $alt_link_keywordset, 'link_hit_count' => $link_hit_countall[$ids], 'keyword_priority' => $keyword_priorityset, 'hover_title_text' => $hover_title_textall[$ids] ), array( 'id' => $idall[$ids] )); wp_redirect("admin.php?page=affilinker/affilinker.php#up"); } } if($_POST['SubmitAll']=='Delete Selected') { // check_admin_referer('AffiLinker_deleteselected'); $checked = $_POST['checkbox1']; $count = count($checked); for($ids=0; $ids < $count; $ids++) { $wpdb->query("DELETE FROM ". $table_name ." WHERE id = '". $checked[$ids] ."' LIMIT 1"); } wp_redirect("admin.php?page=affilinker/affilinker.php#up"); } if($_POST['stats']=='Clear All Stats') { global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db_stat"; $wpdb->query("DELETE FROM ". $table_name); $table_name = $wpdb->prefix . "AffiLinker_db_stat_uniq"; $wpdb->query("DELETE FROM ". $table_name); $table_name = $wpdb->prefix . "AffiLinker_db"; $wpdb->query("UPDATE " . $table_name . " SET link_hit_count=0"); } } function AffiLinker_CreateMenu() { add_menu_page('AffiLinker', 'AffiLinker', 8, __FILE__, 'AffiLinker_MainPage'); add_submenu_page(__FILE__, 'Track Links', 'Track Links', 8, 'tracklinkspage', 'AffiLinker_TrackAffiliates'); add_submenu_page(__FILE__, 'General Settings', 'General Settings', 8, 'affilinkergeneralsettings', 'AFFL_GeneralSettings'); wp_enqueue_script ('hidenseek', '/wp-content/plugins/affilinker/hidenseek.js', array('jquery')); wp_enqueue_script ('jscolor', '/wp-content/plugins/affilinker/jscolor.js', array('jquery')); } function AFFL_GeneralSettings() { global $afflt; echo '

'; echo '

'.$afflt[1].'



'; $affl_num_of_keywords = get_option("affl_num_of_keywords"); if ($affl_num_of_keywords == '') { $affl_num_of_keywords = 5; } $affl_num_of_keywords_percomment = get_option("affl_num_of_keywords_percomment"); if ($affl_num_of_keywords_percomment == '') { $affl_num_of_keywords_percomment = 5; } $affl_num_samekey_perpost = get_option("affl_num_samekey_perpost"); if ($affl_num_samekey_perpost == '') { $affl_num_samekey_perpost = 2; } $affl_num_samekey_oncommsec = get_option("affl_num_samekey_oncommsec"); if ($affl_num_samekey_oncommsec == '') { $affl_num_samekey_oncommsec = 2; } $affl_link_term = get_option("affl_link_term"); if ($affl_link_term == '') { $affl_link_term = 'visit'; } $affl_postcontrol = get_option("affl_postcontrol"); if ($affl_postcontrol == '') { $affl_postcontrol = 1; } $affl_ignoreposts = get_option("affl_ignoreposts"); $affl_onlyposts = get_option("affl_onlyposts"); $affl_link_on_comments = get_option("affl_link_on_comments"); $affl_link_on_homepage = get_option("affl_link_on_homepage"); if ($affl_link_on_comments == '') { $affl_link_on_comments = 0; } if ($affl_link_on_homepage == '') { $affl_link_on_homepage = 1; } $affl_keyword_priority = get_option("affl_keyword_priority"); $affl_interactive_afflinks = get_option("affl_interactive_afflinks"); if ($affl_keyword_priority == '') { $affl_keyword_priority = 0; } if ($affl_interactive_afflinks == '') { $affl_interactive_afflinks = 1; } $afflinker_jquery_opt = get_option("afflinker_jquery_opt"); if ($afflinker_jquery_opt == '') { $afflinker_jquery_opt = 1; } $afflinker_enable = get_option("afflinker_enable"); $affl_num_of_wordcount = get_option("affl_num_of_wordcount"); if ($affl_num_of_wordcount == '') { $affl_num_of_wordcount = -1; } if ( function_exists('wp_nonce_field') ) wp_nonce_field('AffiLinker-AFFL_gsettings'); echo '
Get AffiLinker Pro-Version to manage unlimited Affiliate Links and unlock all features.

Do the configurations below on how you want AffiLinker to work with your wordpress blog.


'; echo ''; echo ''; echo '
AffiLinker Troubles You ? '; if ($afflinker_enable == 1) { echo ' Enable AffiLinker
'; } else { echo ' Enable AffiLinker
'; } echo 'Uncheck to keep AffiLinker plugin disabled, it works only in admin area and stays slient on your blog.
Number of Links per Post/Page
Specify the number of Links to add on a particular page or blog post.
Number of Same Links per Post/Page
Specify the number of same links allowed to add on a particular page or blog post.
Control AffiLinker by Blog Post/Page '; if ($affl_postcontrol == 1) { echo ' Default - Show In All Blog Posts/Pages '; } else { echo ' Default - Show In All Blog Posts/Pages '; } if ($affl_postcontrol == 2) { echo '

 Ignore The Below Blog Posts/Pages'; } else { echo '

 Ignore The Below Blog Posts/Pages'; } echo '
Specify blog post/page IDs seperated by comma, AffiLinker NEVER converts any keyword into link on these blog posts.

'; if ($affl_postcontrol == 3) { echo ' Add Only on Below Blog Posts/Pages'; } else { echo ' Add Only on Below Blog Posts/Pages'; } echo '
Specify blog post/page IDs seperated by comma, AffiLinker converts keyword into link ONLY on these blog posts.

Minimum word count required
(Pro-Version only) Replaces only the blog posts/pages which has more than the specified number of words. -1 represents no limit.
Donot Add Links on Homepage '; if ($affl_link_on_homepage == 0) { echo ' Donot Add
Not recommended when you show only excerpts (instead of full blog post) on homepage.'; } else { echo ' Donot Add
Not recommended when you show only excerpts (instead of full blog post) on homepage.'; } echo '
Add Links on Comments '; if ($affl_link_on_comments == 1) { echo ' Enable
'; } else { echo ' Enable
'; } echo '
Number of Links on Comment section
Specify the number of links to add on the comment section.
Number of Same Links Allowed on Comment Section
Specify the number of same links allowed to add on the comment section.
Priority Keyword '; if ($affl_keyword_priority == 1) { echo ' Enable
 Disable
'; } else { echo ' Enable
 Disable
'; } echo ' (Pro-Version only) When Enabled, AffiLinker will replace Priority Keywords into links first and then the replacement for Non-Priority Keywords. When Disabled, all keywords are treated as equal priority.
Interactive Affiliate Links '; if ($affl_interactive_afflinks == 1) { echo ' Enable
'; echo ' Disable
'; } else { echo ' Enable
'; echo ' Disable
'; } echo 'When Enabled, AffiLinker turns affiliate links into interactive affiliate links based on the font, size, color, link style settings as specified by you for each keyword. When Disabled, links are displayed in default style matching your blog.
Your choice of Link Term : http://www.yoursite.com//keyword-here/
(Pro-Version only) Spice up the links with your own Link Term.
JQuery Script '; if ($afflinker_jquery_opt == 1) { echo ' Enable
'; echo ' Disable
'; } else { echo ' Enable
'; echo ' Disable
'; } echo 'If there are any JQuery Conflicts, you can Uncheck this. By default this is Enabled.
'; echo '
'; } function AffiLinker_TrackAffiliates() { echo ''; echo ''; global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db_stat"; if($_POST['hitcountsort']=='Sort Up') { // check_admin_referer('AffiLinker_sort'); // $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " ORDER BY link_hit_count DESC"); $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " GROUP BY hit_keyword ORDER BY SUM(link_hit_count) DESC"); } else if($_POST['hitcountsort']=='Sort Down') { $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " GROUP BY hit_keyword ORDER BY SUM(link_hit_count) ASC"); } else { $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " GROUP BY hit_keyword"); } echo '

'; echo '

Track Affiliate Links


Get AffiLinker Pro-Version to manage unlimited Affiliate Links and unlock all features.

'; ?> '; $sortlink = '?page=affilinker.php&AffiLinker_Do=sort'; $sortlink = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($sortlink, 'AffiLinker_sort') : $sortlink; echo ' '; $table_name_stat_uniq = $wpdb->prefix . "AffiLinker_db_stat_uniq"; $row_counter = 1; foreach($myrows as $row) { $row_counter = $row_counter + 1; $bluebk = $row_counter % 2; $id = $row->id; $keyword = $row->hit_keyword; $link_hit_count = $row->link_hit_count; $deletelink = '?page=affilinker.php&AffiLinker_Do=delete&id='. $id; $deletelink = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($deletelink, 'AffiLinker_delete_link') : $deletelink; // echo '
  • Link: '. $link .'   Keywords: '. $keywords .'    Delete
  • '; ?> style="background-color:#E8D9FF;" style="background-color:#D2B0FF;" > get_results( "SELECT * FROM ". $table_name . " WHERE hit_keyword='$keyword'"); $countfortablehdr = 0; foreach ($mysubrows as $subrow) { if ($countfortablehdr == 0) { echo ''; } ?>
    Keyword
    Total Clicks
    Unique Clicks
    '; echo $keyword; ?>
    get_results( "SELECT * FROM ". $table_name_stat_uniq . " WHERE hit_keyword='$keyword'"); echo $wpdb->num_rows; ?>
    '; $countfortablehdr = 1; } echo ''; } if ($countfortablehdr == 1) { echo '
    Keyword
    Total Clicks
    Unique Clicks
    '; // print_r($myrows); } function AffiLinker_MainPage() { global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; if($_GET['AffiLinker_Do']=='sort') { // check_admin_referer('AffiLinker_sort'); $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name . " ORDER BY link_hit_count DESC"); } else { $myrows = $wpdb->get_results( "SELECT * FROM ". $table_name ); } echo '

    '; echo '

    Manage AffiLinker



    '; if ( function_exists('wp_nonce_field') ) wp_nonce_field('AffiLinker_add_link'); echo '
    Get AffiLinker Pro-Version to manage unlimited Affiliate Links and unlock all features.
    '; echo ''; echo ''; echo ''; echo '

    AffiLinker - Basic Options


    Just fill the affiliate link (not only affiliate link, you could add any URL as you like) and add the list of keywords seperated by comma below. Don"t forget to check the Interactive Options. Once you are done, click the "Quickly Add Link" button or "Add Link" button. Now all these Keywords will be replaced by Links in your blog according to your configurations.


    Enter Your Ad/Affiliate Link :
    Enter Keywords Seperated by Comma :
    Example: Canon PowerShot, Canon Camera, canon camera, Digital Camera, Digital camera
    Keywords are case-sensitive to have more control.

    AffiLinker - Interactive Options


    The following are the interactive options which helps you to turn a normal Affiliate Link into Interactive Affiliate Link. You can customize the colors, style, font size of the Link so that it appears unique and catchy to your readers.


    Choose the Color of Link :
    When not selected, it takes the default anchor text link color matching to your blog.
    Choose the Background Color of Link :
    When not selected, it takes the default anchor text background color matching to your blog.
    Choose the Hover Color of Link :
    Hover color effects are applicable for blog posts, pages only. When not selected, it takes the default hover color matching to your blog.
    Choose the Hover Background Color :
    Hover background color effects are applicable for blog posts, pages only. When not selected, it takes the default hover background color matching to your blog.
    Link Font size :
    (Pro-Version only) When not selected, it takes the default anchor text font size matching to your blog.
    Link Font Name :
    (Pro-Version only) When not selected, it takes the default anchor text font name matching to your blog.
    More Link Style Options : Bold Link
    Italics Link
    Even More Link Style (Underline) Options :  Default Underline

      Light Dotted       Weight Dotted

      Light Dashed       Weight Dashed

      Light Solid          Weight Solid

      Light Double        Weight Double

      Line Covered
    Title Text :
    (Pro-Version only) The title text that appears when your visitor hovers the mouse over an affiliate link. Leave it blank, if you don't want to use.

    AffiLinker - Control Behaviour


    Now you can control the behaviour of AffiLinker like how to show the Link on-page for users as well as for search engines.


    Make it Search Engine Friendly : Add NoFollow
    Applicable only for Comment section, AffiLinker Widget. Affiliate links on Posts/Pages are always invisible to search engines.
    Where to open the page once the link is clicked by user ? Same Window
    Uncheck to open the page in new window.
    Hide Affiliate Link with Professional Link   Hide Link.
    Example: If the keyword is "buy product" and Link Term is "visit", your affiliate link will be automatically replaced by a professional link: '; echo bloginfo('url'); echo '/visit/buy-product/
    Make this a Priority Keyword :  
    Priority Keyword

    (Pro-Version only) When you make it Priority Keyword, AffiLinker will replace these keywords into links first and then looks for Non-Priority Keywords. This helps when you limit the number of links per post, priority keywords are given more importance than other keywords.
    Show these keywords in AffiLinker Cloud Widget Show in Cloud
    Uncheck to exclude these keywords in AffiLinker Cloud Widget.
    Hint: To enable widget, Go to Appearance->Widget and Drag-n-drop the AffiLinker Cloud widget to sidebar or footbar


    Get AffiLinker Pro-Version to manage unlimited Affiliate Links and unlock all features. This lite version supports only 3 Affiliate Links.

    Manage All Links


    '; $sortlink = '?page=affilinker/affilinker.php&AffiLinker_Do=sort'; $sortlink = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($sortlink, 'AffiLinker_sort') : $sortlink; echo '
    '; if ( function_exists('wp_nonce_field') ) wp_nonce_field('AffiLinker_deleteselected'); echo '    '; $row_counter = 1; foreach($myrows as $row) { $row_counter = $row_counter + 1; $bluebk = $row_counter % 2; $id = $row->id; $link = $row->link; $keywords = $row->keywords; $link_color = $row->link_color; $bg_color = $row->bg_color; $hover_color = $row->hover_color; $hover_bg_color = $row->hover_bg_color; $font_size = $row->font_size; $font_family = $row->font_family; $link_nofollow = $row->link_nofollow; $link_target = $row->link_target; $include_keyword = $row->include_keyword; $alt_link_keyword = $row->alt_link_keyword; $keyword_priority = $row->keyword_priority; $link_style_bold = $row->link_style_bold; $link_style_italics = $row->link_style_italics; $affl_underline_options = $row->affl_underline_options; $hover_title_text = $row->hover_title_text; $link_hit_count = $row->link_hit_count; $deletelink = '?page=affilinker.php&AffiLinker_Do=delete&id='. $id; $deletelink = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($deletelink, 'AffiLinker_delete_link') : $deletelink; // echo '
  • Link: '. $link .'   Keywords: '. $keywords .'    Delete
  • '; ?> style="background-color:#E8D9FF;" style="background-color:#D2B0FF;" >
    Affiliate Link Keywords Color Font size Font Name Other Options Hit Count
     
    Add comma seperated keywords
    Link Color

    Background Color

    Hover Color

    Hover Background Color
    Priority Keyword
    '; } else { echo ' Priority Keyword
    '; } if ($alt_link_keyword == 1) { echo ' Hide Affiliate Link
    '; } else { echo ' Hide Affiliate Link
    '; } if ($link_nofollow == 1) { echo ' Add NoFollow
    '; } else { echo ' Add NoFollow
    '; } ?> Same Window
    '; } else { echo ' Same Window
    '; } if ($link_style_bold == 1) { echo ' Bold
    '; } else { echo ' Bold
    '; } if ($link_style_italics == 1) { echo ' Italics
    '; } else { echo ' Italics
    '; } if ($include_keyword == 1) { echo ' Show in Cloud
    '; } else { echo ' Show in Cloud
    '; } $affl_underline_options_id_array = array(0,1, 2, 3, 4, 5,6,7,8,9); $affl_underline_options_name_array = array( "Default Underline", "Light Dotted", "Weight Dotted", "Light Dashed", "Weight Dashed", "Light Solid", "Weight Solid", "Light Double", "Weight Double", "Line Covered" ); echo ''; echo '
    Title:
    '; ?>
    Affiliate Link Keywords Color Font size Font Name Other Options Hit Count
      

    Get AffiLinker Pro-Version to manage unlimited Affiliate Links and unlock all features. This lite version supports only 3 Affiliate Links.
    '; // print_r($myrows); } $number_of_keywordsreplaced = 0; global $replace_count_per_keyword; global $ascript; global $cssscript; $prev_comment_text = 'A'; function AffiLinker_InsertAffiliateLinksToComment ($comment) { // global $number_of_keywordsreplaced; global $prev_comment_text; if ($prev_comment_text != $comment) { $prev_comment_text = $comment; } else if ( $prev_comment_text == $comment ) { return $comment; } // echo '[' . 'TEST' . ']'; $affl_link_on_comments = get_option("affl_link_on_comments"); if ($affl_link_on_comments == 1) { $number_of_keywords2replace1 = get_option("affl_num_of_keywords_percomment") - $GLOBALS['number_of_keywordsreplaced']; // echo '[' . $number_of_keywords2replace1 . ']'; if ($number_of_keywords2replace1 > 0) { $comment->comment_content = AffiLinker_InsertAffiliateLinks($comment->comment_content, 1, $number_of_keywords2replace1); // echo $comment->comment_content; } } return $comment; } function my_custom_jscript () { global $ascript; global $cssscript; if ($ascript != '') { $afflinker_jquery_opt = get_option("afflinker_jquery_opt"); if ($afflinker_jquery_opt == '') { $afflinker_jquery_opt = 1; update_option("afflinker_jquery_opt", $afflinker_jquery_opt); } if ($afflinker_jquery_opt == 1) { echo ""; } echo ""; } if ($cssscript != '') { echo $cssscript; } } function getencryptedLink ($linkhead) { $linkhead_e = ''; $len = strlen($linkhead); $id = 0; while ($id < $len) { $linkhead_e = $linkhead_e . chr(ord($linkhead[$id])+2); $id = $id + 1; } return $linkhead_e; } function detectUTF8($string) { return preg_match('%(?: [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte |\xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs |[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte |\xED[\x80-\x9F][\x80-\xBF] # excluding surrogates |\xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 |[\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 |\xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )+%xs', $string); } function AffiLinker_InsertAffiliateLinks($content, $affl_comment_callback = 0, $number_of_keywords2replace = 0) { if (get_option("affl_link_on_homepage") != 0) { if ( is_home() ) { return $content; } } global $ascript; global $cssscript; global $link; global $linkformat; global $linkformat4comm; global $linknofollow; global $linklink_target; // global $number_of_keywordsreplaced; global $linkhead; global $linkclass; $afflinker_enable = get_option("afflinker_enable"); if ($afflinker_enable == 0) { return $content; } global $wp_query; $thePostID = $wp_query->post->ID; $affl_postcontrol = get_option("affl_postcontrol"); if ($affl_comment_callback != 1) // $uperb fix, intelligent fellow { $ascript = ''; $cssscript = ''; } if ($affl_postcontrol == 2) { $affl_ignoreposts = get_option("affl_ignoreposts"); $affl_ignoreposts_list = explode(',',$affl_ignoreposts); foreach($affl_ignoreposts_list as $ignoreposts_list) { $ignoreposts_list = trim($ignoreposts_list); if ($ignoreposts_list == $thePostID) { return $content; } } } else if ($affl_postcontrol == 3) { $affl_onlyposts = get_option("affl_onlyposts"); $affl_onlyposts_list = explode(',',$affl_onlyposts); $continue_key_replace = 0; foreach($affl_onlyposts_list as $onlyposts_list) { $onlyposts_list = trim($onlyposts_list); if ($onlyposts_list == $thePostID) { $continue_key_replace = 1; break; } } if ($continue_key_replace == 0) { return $content; } } $affl_num_of_wordcount = get_option("affl_num_of_wordcount"); $affl_num_of_wordcount_tot = sizeof(explode(' ',$content)); if ($affl_num_of_wordcount != -1) { if ($affl_num_of_wordcount_tot < $affl_num_of_wordcount) { return $content; } } // get number replaces allowed per keyword if ($affl_comment_callback == 1) { $replace_count_per_keyword = get_option("affl_num_samekey_oncommsec"); } else { $replace_count_per_keyword = get_option("affl_num_samekey_perpost"); } $affl_interactive_afflinks = get_option("affl_interactive_afflinks"); $affl_link_term = get_option("affl_link_term"); $affl_underline_options_array = array( "", "text-decoration: none; border-bottom:1px dotted;", "text-decoration: none; border-bottom:2px dotted;", "text-decoration: none; border-bottom:1px dashed;", "text-decoration: none; border-bottom:2px dashed;", "text-decoration: none; border-bottom:1px solid red;", "text-decoration: none; border-bottom:2px solid red;", "text-decoration: none; border-bottom:3px double;", "text-decoration: none; border-bottom:4px double;", "text-decoration: underline overline;" ); $family_array = array( "Default Font", "Arial", "Arial Black", "Comic", "Comic Sans MS", "Courier", "Courier New", "Franklin Gothic", "Georgia", "Helvetica", "Impact", "Lucida Sans", "Microsoft Sans Serif", "Monaco", "MV Boli", "Tahoma", "Times", "Times New Roman", "Trebuchet MS", "Verdana"); $keyword_counter = 0; $replaced_counter = 0; $replaced_counter_previteration = 0; $replaced_countervalue = 0; $affl_keyword_priority_enable = get_option("affl_keyword_priority"); if ($affl_keyword_priority_enable == 1) { $priority_keys_done = 0; // first pri keywords } else { $priority_keys_done = 2; } //find_more_keys: while (1) { global $wpdb; $table_name = $wpdb->prefix . "AffiLinker_db"; if ($priority_keys_done == 0) { // echo '----PRI----'; $myrows = $wpdb->get_results( "SELECT id,link,keywords, alt_link_keyword, link_color, bg_color,hover_color,hover_bg_color, font_size, font_family, link_style_bold, link_style_italics, affl_underline_options, link_nofollow, link_target, include_keyword, hover_title_text FROM ". $table_name . " WHERE keyword_priority <> 1"); } else if ($priority_keys_done == 1) { // echo '----NPRI----'; $myrows = $wpdb->get_results( "SELECT id,link,keywords, alt_link_keyword, link_color, bg_color, hover_color,hover_bg_color, font_size, font_family, link_style_bold, link_style_italics, affl_underline_options, link_nofollow, link_target, include_keyword, hover_title_text FROM ". $table_name . " WHERE keyword_priority <> 1" ); } else if ($priority_keys_done == 2) { // echo '----ALL----'; $myrows = $wpdb->get_results( "SELECT id,link,keywords, alt_link_keyword, link_color, bg_color, hover_color,hover_bg_color, font_size, font_family, link_style_bold, link_style_italics,affl_underline_options, link_nofollow, link_target, include_keyword, hover_title_text FROM ". $table_name); } $patterns = array(); if ($affl_comment_callback == 1) { $keyword_replace_totcount = $number_of_keywords2replace; //get_option("affl_num_of_keywords_percomment"); } else { $keyword_replace_totcount = get_option("affl_num_of_keywords"); // first comment callback, reset the replaced count $GLOBALS['number_of_keywordsreplaced'] = 0; } if ($keyword_replace_totcount <= 0) { // nothing to replace return $content; } if(is_null($myrows)) { if ($priority_keys_done == 0) { $priority_keys_done = 1; //pri keywords done //goto find_more_keys; continue; } add_action('wp_footer', 'my_custom_jscript'); return $content; } else { foreach($myrows as $row) { // $link = $row->link; $link = 'http://'.$_SERVER['HTTP_HOST'] . '/' . $affl_link_term . '/'. $row->alt_link_keyword . '/'; $keywords = $row->keywords; if(!is_null($keywords)) { $keys = explode(',',$keywords); foreach($keys as $key) { $key = trim($key); if (1 /*$replaced_keywords [$key] < $replace_count_per_keyword*/) { if ($row->alt_link_keyword == 1) { $link = 'http://'.$_SERVER['HTTP_HOST'] . '/' . $affl_link_term . '/'. str_replace(' ','-',$key) . '/'; } else { $link = $row->link; } $link = strtolower($link); // $keyword_counter = $keyword_counter + 1; $d = new DOMDocument(); @$d->loadHTML(''.$content); foreach ($d->childNodes as $item) if ($item->nodeType == XML_PI_NODE) $d->removeChild($item); $d->encoding = 'UTF-8'; $x = new DOMXpath($d); $aff_query_result = $x->query("//text()[ contains(.,'".$key."') and not(ancestor::h1) and not(ancestor::h2) and not(ancestor::h3) and not(ancestor::h4) and not(ancestor::h5) and not(ancestor::h6) and not(ancestor::a) and not(ancestor::img)]"); if(!empty($aff_query_result)) { foreach( $aff_query_result as $node) { if ($affl_interactive_afflinks == 0) { $randno4css = 'c' . rand(); $linkclass = 'class ="' . $randno4css . '"'; } else if ($affl_interactive_afflinks == 1) if ( (!is_null($row->link_color)) || (!is_null($row->bg_color)) || (!is_null($row->hover_color)) || (!is_null($row->hover_bg_color)) || ($row->font_size != 0) ||($row->font_family != 0) || ($row->link_style_bold == 1) || ($row->link_style_italics == 1) ) { if ($affl_comment_callback != 1) { $randno4css = 'c' . rand(); $randno4cssid = $randno4css . 'id'; // id for hidden a tag $linkformat = ''; //if (!is_null($row->link_color)) if ($row->link_color != '') { $linkformat = $linkformat . 'color:' . $row->link_color . ';'; } //if (!is_null($row->bg_color)) if ($row->bg_color != '') { $linkformat = $linkformat . 'background-color:' . $row->bg_color . ';'; } if ($row->font_size != 0) { $linkformat = $linkformat . 'font-size:' . $row->font_size . 'px;'; } if ($row->font_family != 0) { $linkformat = $linkformat . 'font-family:' . $family_array[$row->font_family] . ';'; } if ($row->link_style_bold == 1) { $linkformat = $linkformat . 'font-weight:bold;'; } if ($row->link_style_italics == 1) { $linkformat = $linkformat . 'font-style:italic;'; } if ($row->affl_underline_options != 0) { $linkformat = $linkformat . $affl_underline_options_array[$row->affl_underline_options]; } if ($linkformat != '') $linkformat = '"; // id for span tag $linkclass = 'class ="' . $randno4css . '"'; } else { //if (!is_null($row->link_color)) $linkformat4comm = 'style="'; if ($row->link_color != '') { $linkformat4comm = $linkformat4comm . 'color:' . $row->link_color . ';'; } //if (!is_null($row->bg_color)) if ($row->bg_color != '') { $linkformat4comm = $linkformat4comm . 'background-color:' . $row->bg_color . ';'; } if ($row->font_size != 0) { $linkformat4comm = $linkformat4comm . 'font-size:' . $row->font_size . 'px;'; } if ($row->font_family != 0) { $linkformat4comm = $linkformat4comm . 'font-family:' . $family_array[$row->font_family] . ';'; } if ($row->link_style_bold == 1) { $linkformat4comm = $linkformat4comm . 'font-weight:bold;'; } if ($row->link_style_italics == 1) { $linkformat4comm = $linkformat4comm . 'font-style:italic;'; } if ($row->affl_underline_options != 0) { $linkformat4comm = $linkformat4comm . $affl_underline_options_array[$row->affl_underline_options]; } $linkformat4comm = $linkformat4comm . '"'; } } if ($row->link_nofollow == 1) { $linknofollow = ' rel = "nofollow"'; } else { $linknofollow = ''; } if ($row->link_target == 1) { $linklink_target = ' target = "_self" '; } else { $linklink_target = ' target = "_blank" '; } $linkhead = '"' . $link . '" '; $patterns[0] = '|\\b' . $key . '\\b|'; if ($affl_comment_callback != 1) { $textContent = preg_replace_callback( $patterns[0] , create_function('$m', 'global $link;global $linkformat;global $linknofollow;global $linklink_target;global $linkhead;global $linkclass; // $replacements[0] = $linkformat . "". $m[0] .""; $replacements[0] = "". $m[0] .""; return $replacements[0];') ,$node->textContent, 1, $replaced_countervalue ); //$linkhead = str_replace(array('http://','"', ' '), '', $linkhead); $linkhead = str_replace('"', '', $linkhead); $cssscript = $cssscript . $linkformat; if (detectUTF8($key) == 0) $ascript = $ascript . "jQuery('#" . $randno4css . "').wrapInner(jQuery('').attr('href', function(){return getme('" . getencryptedLink($linkhead) . "');})"; else $ascript = $ascript . "jQuery('#" . $randno4css . "').wrapInner(jQuery('').attr('href', function(){return '" . $linkhead . "';})"; if ($affl_interactive_afflinks == 1) { //$ascript = $ascript . ".attr('style', 'color:" . $row->link_color . ";')"; $ascript = $ascript . ".attr('id', '" . $randno4cssid . "')"; } if ($row->link_target == 1) { $ascript = $ascript . ".attr({target:'_self'})"; } else { $ascript = $ascript . ".attr({target:'_blank'})"; } $ascript = $ascript . ".attr({rel:'nofollow'})"; if (!is_null($row->hover_title_text)) { $ascript = $ascript . ".attr({title:'" . $row->hover_title_text . "'})"; } $ascript = $ascript . ");"; } else { // echo $linkformat4comm; $textContent = preg_replace_callback( $patterns[0] , create_function('$m', 'global $link;global $linkformat4comm;global $linknofollow;global $linklink_target;global $linkhead;global $linkclass; $replacements[0] = "". $m[0] .""; return $replacements[0];') ,$node->textContent, 1, $replaced_countervalue ); } $replaced_counter = $replaced_counter + $replaced_countervalue; if ( $replaced_counter > $keyword_replace_totcount) { break; } if ($replaced_countervalue > 0) { if ( $replaced_keywords [$key] == ' ' ) { $replaced_keywords [$key] = 0; } $replaced_keywords [$key] = $replaced_keywords [$key] + 1; // echo '[' . $key . ' - ' . $replaced_keywords [$key] . ']'; if ($replaced_keywords [$key] <= $replace_count_per_keyword) { if ($affl_comment_callback == 1) { // note down replaced count for comment $GLOBALS['number_of_keywordsreplaced'] = $GLOBALS['number_of_keywordsreplaced'] + 1; } $textContent = str_replace (array('&','&', '&'), ' affhack1 ',$textContent); $newNode = $d->createDocumentFragment(); $newNode->appendXML($textContent); $node->parentNode->replaceChild($newNode, $node); $content = preg_replace('/^/', '', str_replace( array('', '', '', ''), array('', '', '', ''), $d->saveHTML())); $content = str_replace(array('‘','’', '“' , '”', '~\x2013~', '~\x2014~','~\x8E~',' affhack1 ', 'Â'), array( '‘', '’', '“', '”', '–', '—','','&',''), $content); } else { $replaced_keywords [$key] = $replaced_keywords [$key] - 1; $replaced_counter = $replaced_counter - 1; } // echo '[' . $replaced_counter .'-' . $affl_comment_callback . ']'; } } } } if ($replaced_counter > $keyword_replace_totcount) { // echo '[END]'; break; } } } if ($replaced_counter > $keyword_replace_totcount) { break; } } if ($replaced_counter < $keyword_replace_totcount) { // echo '----MORE----'; if ($priority_keys_done == 0) { $priority_keys_done = 1; //pri keywords done //goto find_more_keys; continue; } add_action('wp_footer', 'my_custom_jscript'); // there are 0 replacements return $content; /* if ($replaced_counter_previteration == $replaced_counter) { echo '----NO MORE----'; if ($priority_keys_done == 0) { $priority_keys_done = 1; //pri keywords done //goto find_more_keys; continue; } add_action('wp_footer', 'my_custom_jscript'); // there are 0 replacements return $content; } else { echo '----MORE----'; // still we could find more replacements, hunt again $replaced_counter_previteration = $replaced_counter; //goto find_more_keys; continue; } */ } } if ($replaced_counter >= $keyword_replace_totcount) { break; } } add_action('wp_footer', 'my_custom_jscript'); return $content; } // Installation register_activation_hook(__FILE__,'AffiLinker_Install'); function AffiLinker_Install() { global $wpdb; $table_name = $wpdb->prefix . "affilinker_db"; $affilinker_db_version = "200"; if(strcasecmp($wpdb->get_var("SHOW TABLES LIKE '$table_name'"), $table_name) != 0) { add_option("affilinker_db_version", $affilinker_db_version); add_option("affl_num_of_keywords", 5); add_option("affl_num_of_keywords_percomment", 5); add_option("affl_postcontrol", 1); add_option("affl_ignoreposts", "0,1,2"); add_option("affl_onlyposts", "2,1, 0"); add_option("affl_link_on_comments", 0); add_option("affl_link_on_homepage", 1); add_option("affl_keyword_priority", 0); add_option("affl_interactive_afflinks", 1); add_option("afflinker_enable", 1); add_option("affl_num_of_wordcount", -1); add_option("affl_widget_title", ""); add_option("affl_widget_no_keywords", 10); add_option("affl_widget_type", 0); add_option("affl_widget_font_startpx", 10); add_option("affl_widget_font_endpx", 25); add_option("affl_widget_interactive_opt", 0); add_option("affl_widget_avoid_dup", 0); add_option("affl_num_samekey_perpost", 2); add_option("affl_num_samekey_oncommsec", 2); add_option("affl_num_enable", 0); add_option("affl_num_count", 0); add_option("affl_link_term", 'visit'); add_option("affl_updurl", ''); add_option("affl_updav", 10); } $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, link text NOT NULL, keywords text, link_color text, bg_color text, hover_color text, hover_bg_color text, font_size int(12), font_family text, link_style_bold int(12), link_style_italics int(12), affl_underline_options int(12) NOT NULL, link_nofollow int(12) NOT NULL, link_target int(12) NOT NULL, include_keyword int(12) NOT NULL, alt_link_keyword int(12) NOT NULL, link_hit_count int(12), keyword_priority int(12) NOT NULL, UNIQUE KEY id (id), hover_title_text text );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); $table_name = $wpdb->prefix . "AffiLinker_db_stat"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, referral_link text, hit_keyword text, link_hit_count int(12), UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); $table_name = $wpdb->prefix . "AffiLinker_db_stat_uniq"; $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, hit_keyword text, affl_ip_address text, UNIQUE KEY id (id) );"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); update_option("affilinker_db_version", $affilinker_db_version); } ?>