Waraxe IT Security Portal
Login or Register
November 21, 2024
Menu
Home
Logout
Discussions
Forums
Members List
IRC chat
Tools
Base64 coder
MD5 hash
CRC32 checksum
ROT13 coder
SHA-1 hash
URL-decoder
Sql Char Encoder
Affiliates
y3dips ITsec
Md5 Cracker
User Manuals
AlbumNow
Content
Content
Sections
FAQ
Top
Info
Feedback
Recommend Us
Search
Journal
Your Account
User Info
Welcome, Anonymous
Nickname
Password
(Register)

Membership:
Latest: MichaelSnaRe
New Today: 0
New Yesterday: 0
Overall: 9144

People Online:
Visitors: 53
Members: 0
Total: 53
Full disclosure
APPLE-SA-11-19-2024-5 macOS Sequoia 15.1.1
Local Privilege Escalations in needrestart
APPLE-SA-11-19-2024-4 iOS 17.7.2 and iPadOS 17.7.2
APPLE-SA-11-19-2024-3 iOS 18.1.1 and iPadOS 18.1.1
APPLE-SA-11-19-2024-2 visionOS 2.1.1
APPLE-SA-11-19-2024-1 Safari 18.1.1
Reflected XSS - fronsetiav1.1
XXE OOB - fronsetiav1.1
St. Poelten UAS | Path Traversal in Korenix JetPort 5601
St. Poelten UAS | Multiple Stored Cross-Site Scripting in SEH utnserver Pro
Apple web content filter bypass allows unrestricted access to blocked content (macOS/iOS/iPadOS/visionO S/watchOS)
SEC Consult SA-20241112-0 :: Multiple vulnerabilities in Siemens Energy Omnivise T3000 (CVE-2024-38876, CVE-2024-38877, CVE-2024-38878, CVE-2024-38879)
Security issue in the TX Text Control .NET Server for ASP.NET.
SEC Consult SA-20241107-0 :: Multiple Vulnerabilities in HASOMED Elefant and Elefant Software Updater
Unsafe eval() in TestRail CLI
Log in Register Forum FAQ Memberlist Search
IT Security and Insecurity Portal

www.waraxe.us Forum Index -> PHP script decode requests -> [Need Help] Decrypt plugin.php
Post new topicReply to topic View previous topic :: View next topic
[Need Help] Decrypt plugin.php
PostPosted: Sun Oct 04, 2009 5:02 am Reply with quote
matafy
Regular user
Regular user
Joined: May 14, 2009
Posts: 21




Can anyone please decrypt this code.

Code:

<? eval(base64_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MDsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfQ0KCQkJfQ0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgJG5vdHJhY2s9IDA7DQogICAgICAgICAgICAgICAgICAgICAgICB9DQoNCgkJCWlmIChpc3NldCgkX1BPU1RbJ25vZm9sbG93J10pKSB7DQoJCQkJJG5vZm9sbG93PSB0cmltKCRfUE9TVFsnbm9mb2xsb3cnXSk7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkbm9mb2xsb3cgPT0gJ29uJykgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkbm9mb2xsb3c9IDE7IH0NCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICRub2ZvbGxvdz0gMDsgfQ0KCQkJfQ0KICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQ0KICAgICAgICAgICAgICAgICAgICAgICAgew0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICRub2ZvbGxvdz0gMDsNCiAgICAgICAgICAgICAgICAgICAgICAgIH0NCg0KCQkJaWYgKGlzc2V0KCRfUE9TVFsnd2VpZ2h0J10pKSB7DQoJCQkJJHdlaWdodCA9IDAgKyAkX1BPU1RbJ3dlaWdodCddOw0KCQkJCWlmICgkd2VpZ2h0ID4gOSkgew0KCQkJCQkkd2VpZ2h0ID0gOTsNCgkJCQl9IGVsc2VpZiAoJHdlaWdodCA8IDApIHsNCgkJCQkJJHdlaWdodCA9IDA7DQoJCQkJfQ0KCQkJfSBlbHNlIHsNCgkJCQkkd2VpZ2h0ID0gNTsNCgkJCX0NCg0KCQkJaWYgKCRlZGl0X2t3ZCkgew0KCQkJCWlmIChpc3NldCgkX1BPU1RbJ2lkJ10pKSB7DQoJCQkJCSRrd2RfaWQgPSAkX1BPU1RbJ2lkJ107DQoJCQkJC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ZGlzcGxheQ0KCWFkZF9maWx0ZXIoJ2NvbW1lbnRfdGV4dCcsICdhcF9hZGRfYWZmaWxpYXRlX2xpbmtzJywgMSk7')); ?>


Thanks in advance,
Matafy
View user's profile Send private message
PostPosted: Sun Oct 04, 2009 5:03 am Reply with quote
matafy
Regular user
Regular user
Joined: May 14, 2009
Posts: 21




For some strange reason the code doesn't show, but if you click and drag from < to >. You should then be able to copy and paste the code.
View user's profile Send private message
PostPosted: Sun Oct 04, 2009 7:41 am Reply with quote
zerobytes
Valuable expert
Valuable expert
Joined: Aug 30, 2008
Posts: 199




Change the eval to highlight_string and run on a server.

ZeroBytes

_________________
Decoded by ASD @ Lost-codes.co.uk
View user's profile Send private message Visit poster's website
PostPosted: Sun Oct 04, 2009 7:42 am Reply with quote
pexli
Valuable expert
Valuable expert
Joined: May 24, 2007
Posts: 665
Location: Bulgaria




Code:
//define('COMPLEMENTARY_COPY', 'WSO Owner');

if (!defined('MY_SCRIPT_NAME')) {
define('MY_SCRIPT_NAME', 'wp-affiliate-pro_dec.php');
}

if (!defined('AP_KWD_TABLE')) {
define('AP_KWD_TABLE', 'affiliatepro_links');
}

if (!defined('AP_TRK_TABLE')) {
define('AP_TRK_TABLE', 'affiliatepro_track');
}

//exit($_SERVER['SCRIPT_FILENAME']);
// Do the tracker first. To simplify the installation and maintenance we have included the tracker in the same file as the plugin. Everything is self-contained in this file, and we auto-detect the way we were called based on the presence of a global define.
if (!defined('ABSPATH')) {
//require_once('../../wp-config.php');
$pieces = explode('/',strstr($_SERVER['SCRIPT_FILENAME'],'/wp-content'));
for($i=0;$i<count($pieces)-2;$i++)
{
$path .= '../';
}
require_once($path.'wp-config.php');

/*// Track plugin installation path.
$path = dirname($_SERVER['SCRIPT_FILENAME']);
$searc_url="SELECT * FROM ".$wpdb->options." WHERE option_name='track_url'";
$num=$wpdb->query($searc_url);
if($num <= 0)
{
$sql_track="INSERT INTO ".$wpdb->options."(blog_id ,option_name ,option_value ,autoload)VALUES ('0', 'track_url', '".$path."', 'yes')";
$wpdb->query($sql_track);
}
else
{
$update="UPDATE ".$wpdb->options." SET option_value = '".$path."' WHERE option_name ='track_url'";
$wpdb->query($update);
}*/

// We use the blog home page as a redirect if we can't find the link ID in the database or if the given link ID looks fishy.
$securityRedirect = get_option('siteurl');

if (isset($_GET['id'])) {
$kwd_id = $_GET['id'];
} else {
// No ID set is a security breach. Someone is playing with our redirector.
header("Location: $securityRedirect");
exit();
}

// Trick to force convert to integer.
$kwd_id = 0 + $kwd_id;

// Record the click if the user hasn't disabled link tracking in Options.
if (get_option('ap_link_tracking') == 'Yes') {
if (isset($_SERVER['HTTP_REFERER'])) {
$referer = $_SERVER['HTTP_REFERER'];
} else {
$referer = '(direct request)';
}
// Sanitize the input
$referer = addslashes($referer);

$refererid = md5($referer);

// Do the advanced tracker
$table_name = $table_prefix . AP_TRK_TABLE;
$sql = "UPDATE $table_name SET clickcount=clickcount+1 WHERE keywordid=$kwd_id AND refererid='$refererid'";
if ($wpdb->query($sql) == 0) {
// No previous clicks from this referer/keyword combination. Add our data.
$sql = "INSERT INTO $table_name (id, keywordid, refererid, referer, clickcount) VALUES (NULL, $kwd_id, '$refererid', '$referer', 1)";
$wpdb->query($sql);
}

// Do the regular tracker
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "UPDATE $table_name SET clickcount=clickcount+1 WHERE id=$kwd_id";
$wpdb->query($sql);
}

// Get the affiliate link specified for this keyword
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "SELECT url FROM $table_name WHERE id=$kwd_id";
$url = $wpdb->get_var($sql);
if ($url == NULL) {
// We didn't find the ID in the database. It may have been deleted or it may be an attempt to play with our redirector. Show the blog home page instead.
header("Location: $securityRedirect");
} else {
header("Location: $url");
}
exit();
} // Tracker ends here


// Add a new menu under Options:, visible for all users with access levels 8+ (administrator role).
if (!function_exists('ap_add_pages')) {
function ap_add_pages() {
if (function_exists('add_options_page')) {
add_options_page('Configure WordPress Affiliate Pro', 'WordPress Affiliate Pro', 8, MY_SCRIPT_NAME, 'ap_options_page');
}
if (function_exists('add_management_page')) {
add_management_page('Manage WordPress Affiliate Pro', 'WordPress Affiliate Pro', 8, MY_SCRIPT_NAME, 'ap_manage_page');
}
}
}

if (!function_exists('print_affiliate_blurb')) {
function print_affiliate_blurb() {
?>
<div class=wrap>
<div>
<p><strong><font color="red">Earn $72.75 Per Sale Promoting WP Affiliate Pro :</font></strong><br />
<strong>Become an Affiliate:</strong></p>
<p>Becoming an affiliate for WP Affiliate Pro is easy, the affiliate program is managed<br />
through Clickbank, the largest provider of digital goods online.</p>

<p><strong>It's as easy as this:</strong></p>
<p><strong>Step 1:</strong></p>
<p>Get your clickbank ID (if you haven't got one, sign up at <a href="http://www.clickbank.com">http://www.clickbank.com</a>)<br />
it should look like:</p>
<p>http://Your-ClickBank-ID-Here.wpaffpro.hop.clickbank.net/</p>

<p>Or Automatically have your affiliate link created by <a href="http://www.clickbank.com/info/jmap.htm?vendor=WPAFFPRO">Clicking Here </a></p>
<p><strong>Step 2:</strong></p>
<p>Decide which method you would like to promote (if you already have a list, you can<br />
contact affiliates@wpaffiliatepro.com and organize a customized page to promote to), be it PPC,<br />
SEO, list promotion, blogging, leads etc.</p>
<p><strong>Step 3:</strong></p>

<p>Promote!</p>
<p>You earn a whopping $72.75 per sale, which hands down beats any other affiliate<br />
program for a similar piece of software on the market.</p>
<p>Enjoy the sales you're going to make ;)</p>
<p>Wealth and Abundance,</p>
<p>The team at IM Alliance</p>

</div>
<p> ;;</p>
</div>
<?
}
}


if (!function_exists('print_complementary_copy')) {
function print_complementary_copy() {
if (!defined('COMPLEMENTARY_COPY')) {
return ;
}
?>
<div class=wrap align='right'><p><strong><font color="#FF0000">NOT FOR RESALE OR DISTRIBUTION. THIS IS A COMPLEMENTARY COPY FOR <?=COMPLEMENTARY_COPY;?>.</font></strong></p></div>
<?
}
}


if (!function_exists('ap_install_plugin')) {
function ap_install_plugin() {//exit("ap_install_plugin");
global $table_prefix, $wpdb;

// Create the Keywords table if not already present
$table_name = $table_prefix . AP_KWD_TABLE;

// table if not created then
if ($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE ".$table_name." (
id mediumint(9) NOT NULL AUTO_INCREMENT,
keyword tinytext NOT NULL,
wordcount smallint(3) NOT NULL default '0',
caption tinytext,
url tinytext NOT NULL,
clickcount mediumint(9) NOT NULL default '0',
replacecount smallint(3) NOT NULL default '0',
weight smallint(1) unsigned NOT NULL default '5',
notrack smallint(1) NOT NULL default '0',
nofollow smallint(1) NOT NULL default '0',
UNIQUE KEY id(id)
);";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);

// Umesh update as complete
update_option('ap_db_upgrade', 'Ver21');
}

if (get_option('ap_db_upgrade') != 'Ver21')
{

// update to new version
$sql = "ALTER TABLE ".$table_name." ADD notrack SMALLINT(1) UNSIGNED DEFAULT '0' NOT NULL";
$wpdb->query($sql);
$sql = "ALTER TABLE ".$table_name." ADD nofollow SMALLINT(1) UNSIGNED DEFAULT '0' NOT NULL";
$wpdb->query($sql);

$url = get_option('siteurl') . '/wp-admin/options-general.php?page=wp-affiliate-pro_dec.php';
// Umesh update as complete
update_option('ap_db_upgrade', 'Ver21');
update_option('ap_version_msg', 'You have been updated to the latest version, to configure please click here!');

// header("Location: $url");
//exit();
}

// Is the table already installed?
if ($wpdb->get_var("show tables like '$table_name'") != $table_name) {
$sql = "CREATE TABLE ".$table_name." (
id mediumint(9) NOT NULL AUTO_INCREMENT,
keyword tinytext NOT NULL,
wordcount smallint(3) NOT NULL default '0',
caption tinytext,
url tinytext NOT NULL,
clickcount mediumint(9) NOT NULL default '0',
replacecount smallint(3) NOT NULL default '0',
weight smallint(1) unsigned NOT NULL default '5',
UNIQUE KEY id(id)
);";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);

// Mark update as complete
//update_option('ap_db_upgrade', 'Ver20');
}

// Create the click tracker table if not already present
$table_name = $table_prefix . AP_TRK_TABLE;

// Is the table already installed?
if ($wpdb->get_var("SHOW tables LIKE '$table_name'") != $table_name) {
$sql = "CREATE TABLE ".$table_name." (
id mediumint(9) NOT NULL AUTO_INCREMENT,
keywordid mediumint(9) NOT NULL default '0',
refererid varchar(32) NOT NULL default '',
referer tinytext NOT NULL,
clickcount mediumint(9) NOT NULL default '0',
UNIQUE KEY id(id),
KEY refererid(refererid)
);";
require_once(ABSPATH . 'wp-admin/upgrade-functions.php');
dbDelta($sql);

// Mark update as complete
update_option('ap_db_upgrade', 'Ver20');
}

if (get_option('ap_db_upgrade') != 'Ver18') {
// Upgrade to DB version 1.8
$table_name = $table_prefix . AP_TRK_TABLE;
$sql = "ALTER TABLE ".$table_name." DROP INDEX refererid, ADD INDEX refererid (refererid)";
$wpdb->query($sql);
}

if (get_option('ap_db_upgrade') < 'Ver20') {
// Upgrade to DB version 1.9
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "ALTER TABLE ".$table_name." ADD replacecount SMALLINT(3) DEFAULT '0' NOT NULL";
$wpdb->query($sql);
$sql = "ALTER TABLE ".$table_name." ADD weight SMALLINT(1) UNSIGNED DEFAULT '5' NOT NULL";
$wpdb->query($sql);
}

// Preset our options to default (all enabled)
update_option('ap_enable', 'Yes');
update_option('ap_new_window', 'Yes');
update_option('ap_link_tracking', 'Yes');
update_option('ap_replace_count', '0');
update_option('ap_replace_count_global', '0');
// Possible options are R for random or W for weighted random.
update_option('ap_replace_count_method', 'W');
update_option('ap_link_class', '');

}
}


// The function that renders the WordPress Affiliate Pro options page
if (!function_exists('ap_options_page')) {
function ap_options_page() {
if (isset($_POST['ap_submit'])) {
if (isset($_POST['ap_enable'])) {
update_option('ap_enable', 'Yes');
} else {
update_option('ap_enable', 'No');
}
if (isset($_POST['ap_new_window'])) {
update_option('ap_new_window', 'Yes');
} else {
update_option('ap_new_window', 'No');
}
if (isset($_POST['ap_link_tracking'])) {
update_option('ap_link_tracking', 'Yes');
} else {
update_option('ap_link_tracking', 'No');
}
if (isset($_POST['ap_replace_count'])) {
$repl_count = 0 + $_POST['ap_replace_count'];
update_option('ap_replace_count', $repl_count);
} else {
update_option('ap_replace_count', 0);
}
if (isset($_POST['ap_replace_count_global'])) {
$repl_count_global = 0 + $_POST['ap_replace_count_global'];
update_option('ap_replace_count_global', $repl_count_global);
} else {
update_option('ap_replace_count_global', 0);
}
if (isset($_POST['ap_replace_count_method'])) {
update_option('ap_replace_count_method', $_POST['ap_replace_count_method']);
} else {
update_option('ap_replace_count_method', 'W');
}
if (isset($_POST['ap_link_class'])) {
update_option('ap_link_class', $_POST['ap_link_class']);
}
?><div id="message" class="updated fade"><p><strong>Your options have been saved.</strong></p></div>
<? }
$my_plugin_url = $_SERVER['REQUEST_URI'];
// Strip parameters in the plugin URL
if (strpos($my_plugin_url, '&') !== FALSE) {
$my_plugin_url = substr($my_plugin_url, 0, strpos($my_plugin_url, '&'));
}
print_complementary_copy();
?>
<div class=wrap>
<form method="post" action="<?=$my_plugin_url;?>">

<h2>Configure WordPress Affiliate Pro</h2>
<? if (get_option('ap_enable')=='No') { ?>
<p align="center"><font color="#FF0000"><b>WordPress Affiliate Pro is currently DISABLED. To enable, see options below.</b></font></p>
<? } ?>
<p>Thank you for purchasing <a href="http://www.wordpressaffiliatepro.com/" target="_blank">WordPress Affiliate Pro</a>.</p>
<p>This is the place where you configure all global settings that affect how WordPress Affiliate Pro works. For additional information please consult the tutorials that came with your purchase or open a support ticket if you need any help.</p>
<p><label><input type="checkbox" name="ap_enable" value="1" <?=(get_option('ap_enable')=='Yes'?"checked":"");?> /> <b>Globally Enable WordPress Affiliate Pro</b>. <br />If disabled, your keywords will not be automatically replaced by affiliate links on your blog.</label></p>

<p><label><b>Maximum Replacements For Each Keyword Per Page</b><br /><input type="text" name="ap_replace_count" value="<?=(get_option('ap_replace_count')==''?"0":get_option('ap_replace_count'));?>" /><br />This option controls how many occurences of each keywords are replaced by affiliate links in any single page. Set to 0 to replace all occurences of each keyword. If there are too many affiliate links on a single page you can set this e.g. to 1 to replace only the first occurence of each keyword by the affiliate link. You can override this global limit and set a different limit on a keyword from the WordPress Affiliate Pro sub-menu in the Manage menu.</label></p>
<p><label><b>Maximum Affiliate Links (Total) Per Page</b><br /><input type="text" name="ap_replace_count_global" value="<?=(get_option('ap_replace_count_global')==''?"0":get_option('ap_replace_count_global'));?>" /><br />This number controls how many affiliate links are added to a page. Set to 0 for unlimited affiliate links, but if you find there are too many on a single page you can set this e.g. to 3 to insert up to 3 affiliate links per page.</label></p>
<p><label><b>Selection Method For Affiliate Links</b><br /><select name="ap_replace_count_method"><option value="W"<?=(get_option('ap_replace_count_method')=='W'?' selected':'')?>>Weighted Random</option><option value="R"<?=(get_option('ap_replace_count_method')=='R'?' selected':'')?>>Random</option></select><br />If you have limited the total number of affiliate links per page and have entered more affiliate links than this limit, this option controls how the links that show up are selected. Weighted Random takes into account the weight you have specified for each keyword giving those keywords with a higher weight a slightly better chance to show up. Random picks which affiliate links show up completely at random.</label></p>
<p><label><input type="checkbox" name="ap_new_window" value="1" <?=(get_option('ap_new_window')=='Yes'?"checked":"");?> /> <b>All Affiliate Links Should Open In New Window</b>. <br />Enable if you want all affiliate links to open up in a new window when clicked (recommended), disable to open them in the same browser window thus taking your visitors away from your blog.</label></p>

<p><label><b>Affiliate Links CSS Class Name</b><br /><input type="text" name="ap_link_class" value="<?=get_option('ap_link_class');?>" /><br />You can give all your affiliate links a different look than other regular links on your blog. You can make them red for instance for a slightly higher chance to be clicked. Here you specify the CSS class name to be used for all affiliate links, then go and set it up in your theme CSS file (Presentation -> Theme Editor then click on edit Stylesheet). Leave this empty to make affiliate links "blend" in to your blog theme by looking like regular links.</label></p>
<p><label><input type="checkbox" name="ap_link_tracking" value="1" <?=(get_option('ap_link_tracking')=='Yes'?"checked":"");?> /> <b>Enable Affiliate Links Click Tracking</b>. <br />You should enable this option if you want to automatically track the number of clicks made by your visitors through any of your affiliate links.</label></p>
<p class="submit">
<input type="submit" name="ap_submit" value="Update Options &raquo;" />
</p>

</form>
<p align="center">WordPress Affiliate Pro is Copyright &copy; 2008 by <a href="http://www.wpaffiliatepro.com" target="_blank">IM Alliance</a>. All rights reserved.</p>
</div>
<?
print_affiliate_blurb();
}
}


// The function that renders the WordPress Affiliate Pro management page
if (!function_exists('ap_manage_page')) {
function smart_short_text($text, $len) {
if (strlen($text)>$len) {
$result = substr($text, 0, $len) . '...';
} else {
$result = $text;
}
return $result;
}

function ap_manage_page() {
global $table_prefix, $wpdb;

$show_keyword_list = TRUE;
$show_add_keyword = TRUE;

$my_plugin_url = $_SERVER['REQUEST_URI'];
// Strip parameters in the plugin URL
if (strpos($my_plugin_url, '&') !== FALSE) {
$my_plugin_url = substr($my_plugin_url, 0, strpos($my_plugin_url, '&'));
}

// Do we have a sort preference for the keyword list?
$sortsql = '';
$sort_txt = 'unsorted';
$sort_url = '';
if (isset($_GET['sort'])) {
if ($_GET['sort'] == 'id') {
$sortsql = " ORDER BY id";
$sort_txt = 'ID';
$sort_url = '&amp;sort=id';
} elseif ($_GET['sort'] == 'kwd') {
$sortsql = " ORDER BY keyword";
$sort_txt = 'Keyword';
$sort_url = '&amp;sort=kwd';
} elseif ($_GET['sort'] == 'lnk') {
$sortsql = " ORDER BY url";
$sort_txt = 'Affiliate Link';
$sort_url = '&amp;sort=lnk';
} elseif ($_GET['sort'] == 'clk') {
$sortsql = " ORDER BY clickcount DESC";
$sort_txt = 'Click Counts';
$sort_url = '&amp;sort=clk';
}
}

// Detailed report for keyword
if (isset($_GET['op']) && ($_GET['op'] == 'dt') && isset($_GET['id'])) {
$kwd_id = $_GET['id'];
// force convert to integer trick
$kwd_id = 0 + $kwd_id;
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "SELECT keyword FROM $table_name WHERE id=$kwd_id";
$keyword = $wpdb->get_var($sql);
$dt_sort_txt = 'unsorted';
$dt_sort_sql = '';
if (isset($_GET['dt_sort'])) {
if ($_GET['dt_sort'] == 'id') {
$dt_sort_sql = " ORDER BY keywordid";
$dt_sort_txt = 'ID';
} elseif ($_GET['dt_sort'] == 'ref') {
$dt_sort_sql = " ORDER BY referer";
$dt_sort_txt = 'Referer page';
} elseif ($_GET['dt_sort'] == 'clk') {
$dt_sort_sql = " ORDER BY clickcount DESC";
$dt_sort_txt = 'Click Counts';
}
}
print_complementary_copy();
?>

<div class=wrap>
<h2>Detailed Keyword Report For &laquo;<?=$keyword;?>&raquo;</h2>
<p>Clicking on hyperlinked column headers will sort the list by that column. Currently the list is <?=($dt_sort_txt=='unsorted')?'<strong>unsorted</strong>':"sorted by <strong>$dt_sort_txt</strong>"?>.</p>
<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
<tr><th scope="col"><a href="<?=$my_plugin_url;?>&amp;dt_sort=id&amp;id=<?=$kwd_id?>&amp;op=dt<?=$sort_url?>" title="Click to sort by ID">ID</a></th><th scope="col"><a href="<?=$my_plugin_url;?>&amp;dt_sort=ref&amp;id=<?=$kwd_id?>&amp;op=dt<?=$sort_url?>" title="Click to sort by Referer">Referer page</a></th><th scope="col"><a href="<?=$my_plugin_url;?>&amp;dt_sort=clk&amp;id=<?=$kwd_id?>&amp;op=dt<?=$sort_url?>" title="Click to sort by Click Count">Clicks</a></th></tr>

<?
// Retrieve and display the keyword data from our database
$table_name = $table_prefix . AP_TRK_TABLE;
$sql = "SELECT * FROM $table_name WHERE keywordid=$kwd_id$dt_sort_sql";
$keywords = $wpdb->get_results($sql, ARRAY_A);
if (isset($keywords) && (count($keywords) > 0)) {
foreach ($keywords as $key=>$keyword) {
echo "<tr class='alternate'><th scope='row'>".$keyword['id']."</th><td>".$keyword['referer']."</td><td>".$keyword['clickcount']."</td></tr>";
}
} else {
echo "<tr style='background-color: '><td colspan='3'>No tracking data is currently available for the selected keyword.</td></tr>";
}
?>
</table>
<p><a href="<?=$my_plugin_url.$sort_url;?>">&laquo; Return to keyword list</a></p>
</div>
<?
$show_keyword_list = FALSE;
$show_add_keyword = FALSE;
} // detailed report for keyword ends here

// Reset click counts
if (isset($_POST['reset'])) {
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "UPDATE $table_name SET clickcount=0";
if ($wpdb->query($sql) === FALSE) { ?>
<div class="error"><p><strong>There was an error while reseting click counts.</strong></p></div>

<? } else { ?>
<div id="message" class="updated fade"><p><strong>You have successfully reset all click counts to 0.</strong></p></div>
<?
$table_name = $table_prefix . AP_TRK_TABLE;
$sql = "UPDATE $table_name SET clickcount=0";
$wpdb->query($sql);
}
} // click count reset ends here

// Add new/Edit existing keyword into the database
if (isset($_POST['action'])) {
if ($_POST['action'] == 'addkeyword') {
$edit_kwd = FALSE;
} else {
$edit_kwd = TRUE;
}
$err_msg = '';
$kwd = '';
$url = '';
$caption = '';
$repl_count = 0;

if (isset($_POST['url']) && (trim($_POST['url']) != '')) {
$url = trim($_POST['url']);
} else {
$err_msg = "The affiliate link was empty. You must type in the affiliate link.";
}
if (isset($_POST['keyword']) && (trim($_POST['keyword']) != '')) {
$kwd = trim($_POST['keyword']);
} else {
$err_msg = 'The keyword was empty. You need to type in the keyword that will be replaced by the affiliate link.';
}
if (isset($_POST['caption'])) {
$caption = trim($_POST['caption']);
}
if (isset($_POST['repl_count'])) {
$repl_count = 0 + $_POST['repl_count'];
}
if ( isset($_POST['notrack']) ) {
$notrack= trim($_POST['notrack']);
if ($notrack== 'on')
{
$notrack= 1;
} else {
$notrack= 0;
}
}
else {
$notrack= 0;
}

if (isset($_POST['nofollow'])) {
$nofollow= trim($_POST['nofollow']);
if ($nofollow == 'on') {
$nofollow= 1; }
else {
$nofollow= 0; }
}
else
{
$nofollow= 0;
}

if (isset($_POST['weight'])) {
$weight = 0 + $_POST['weight'];
if ($weight > 9) {
$weight = 9;
} elseif ($weight < 0) {
$weight = 0;
}
} else {
$weight = 5;
}

if ($edit_kwd) {
if (isset($_POST['id'])) {
$kwd_id = $_POST['id'];
$kwd_id = 0 + $kwd_id;
} else {
$err_msg = 'There was an error while retrieving the keyword id. This should not happen under regular usage. Are you messing with the data?';
}
}

$table_name = $table_prefix . AP_KWD_TABLE;
if ($edit_kwd == FALSE) {
// First make sure our keyword is unique in the database
$sql = "SELECT COUNT(*) FROM $table_name WHERE UPPER(keyword)=UPPER('$kwd')";
if ($wpdb->get_var($sql) != 0) {
$err_msg = 'This keyword is already defined and points to a different affiliate link.';
}
}

if ($err_msg != '') {?>
<div class="error"><p><strong><?=$err_msg;?></strong></p></div>
<? } else {
// All seems ok. Compute the number of individual words in the keyword and do some sanity checks.
$word_cnt = substr_count($kwd, ' ') + 1;
if ($edit_kwd) {
$sql = "UPDATE $table_name SET keyword='$kwd', wordcount=$word_cnt, caption='$caption', url='$url', replacecount=$repl_count, weight=$weight, notrack=$notrack, nofollow=$nofollow WHERE id=$kwd_id";
} else {
$sql = "INSERT INTO $table_name (id, keyword, wordcount, caption, url, clickcount, replacecount, weight, notrack,nofollow) VALUES (NULL, '$kwd', $word_cnt, '$caption', '$url', 0, $repl_count, $weight, $notrack, $nofollow)";
}

if ($wpdb->query($sql) === FALSE) { ?>
<div class="error"><p><strong>There was an error while saving to the database. Your keyword was NOT saved.</strong></p></div>
<? } else { ?>
<div id="message" class="updated fade"><p><strong>The keyword was successfully saved and it will be replaced automatically by the affiliate link you have defined.</strong></p></div>

<? }
}
} // Keyword addition ends here

// Edit existing keyword
if (isset($_GET['op']) && ($_GET['op'] == 'ed') && (isset($_GET['id']))) {
$kwd_id = $_GET['id'];
// force convert to integer trick
$kwd_id = 0 + $kwd_id;
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "SELECT * FROM $table_name WHERE id=$kwd_id";
$keyword = $wpdb->get_results($sql, ARRAY_A);
if (is_array($keyword)) {
$kwd = $keyword[0]['keyword'];
$caption = $keyword[0]['caption'];
$url = $keyword[0]['url'];
$repl_count = $keyword[0]['replacecount'];
$weight = $keyword[0]['weight'];
$nofollow = $keyword[0]['nofollow'];
$notrack = $keyword[0]['notrack'];
print_complementary_copy();
?>
<div class=wrap>
<h2>Edit Keyword</h2>
<form method="post" action="<?=$my_plugin_url.$sort_url;?>">
<p><strong>Keyword</strong> that will be replaced by the affiliate link:<br />
<input type="text" name="keyword" value="<?=$kwd?>" style="width: 40%;" /></p>
<p><strong>Affiliate Link</strong> (enter the complete affiliate link here, including the http:// part):<br />

<input type="text" name="url" value="<?=$url?>" style="width: 80%;" /></p>
<p><strong>Statusbar Text</strong> (leave empty to show the click tracker URL, your affiliate link is always hidden):<br />
<input type="text" name="caption" value="<?=$caption?>" style="width: 40%;" /></p>
<p><strong>Maximum Replacement Count</strong> (how many occurences of this keyword will be replaced on a page, 0 means replace all. If not 0, this will be used instead of the global setting):<br />
<input type="text" name="repl_count2" value="<?=$repl_count?>" style="width: 40%;" />
</p>

<p><strong>Keyword Weight</strong> for the weighted random link selection. This should be between 0 and 9 (leave unchanged if you don't know what this means):<br />
<input type="text" name="weight" value="<?=$weight?>" style="width: 40%;" /></p>
<p>Check this box is to add
<strong>rel=nofollow</strong> into the hyperlink it creates on a page.<br />

<input type="checkbox" name="nofollow" <? if ($nofollow == 1){
echo 'checked';
}?> />
</p>

<p>Check this box is to disable internal tracking system for this keyword.<br />
<input type="checkbox" name="notrack" <? if ($notrack== 1){
echo 'checked';}?> />
</p>
<p class="submit"><input type="hidden" name="action" value="editkeyword" /><input type="hidden" name="id" value="<?=$kwd_id?>" /><input type="submit" name="submit" value="Save Changes &raquo;" /></p>
</form>
<p><a href="<?=$my_plugin_url.$sort_url;?>">&laquo; Return to keyword list</a></p>
</div>
<?
$show_keyword_list = FALSE;
$show_add_keyword = FALSE;
}
} // Keyword editing ends here

// Deleting existing keyword
if (isset($_GET['op']) && ($_GET['op'] == 'del') && (isset($_GET['id']))) {
$kwd_id = $_GET['id'];
// force convert to integer trick
$kwd_id = 0 + $kwd_id;
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "DELETE FROM $table_name WHERE id=$kwd_id";
if ($wpdb->query($sql) === FALSE) { ?>
<div class="error"><p><strong>There was an error while deleting from the database. Your keyword was NOT deleted.</strong></p></div>
<? } else { ?>

<div id="message" class="updated fade"><p><strong>The keyword was successfully deleted from the database.</strong></p></div>
<?
// Delete any associated click-through data
$table_name = $table_prefix . AP_TRK_TABLE;
$sql = "DELETE FROM $table_name WHERE keywordid=$kwd_id";
$wpdb->query($sql);
}
} // Keyword deletion ends here

// Show keyword click count details
if (isset($_GET['op']) && ($_GET['op'] == 'dt') && (isset($_GET['id']))) {
$kwd_id = $_GET['id'];
// force convert to integer trick
$kwd_id = 0 + $kwd_id;
$table_name = $table_prefix . AP_TRK_TABLE;
} // click count details ends here

if ($show_keyword_list) {
print_complementary_copy();
?>
<div class=wrap>
<h2>Manage WordPress Affiliate Pro Links (<a href="#addkwd">add new</a>)</h2>
<? if (get_option('ap_enable')=='No') { ?>
<p align="center"><font color="#FF0000"><b>WordPress Affiliate Pro is currently DISABLED. To enable go to Options, WordPress Affiliate Pro.</b></font></p>

<? } ?>
<? if (get_option('ap_link_tracking')=='No') { ?>
<p align="center"><font color="#FF0000"><b>Link click tracking is currently DISABLED. To enable go to Options, WordPress Affiliate Pro.</b></font></p>
<? } ?>
<p>Thank you for purchasing <a href="http://www.wordpressaffiliatepro.com" target="_blank">WordPress Affiliate Pro</a>.</p>
<p>This is the place where you configure your keywords and affiliate links. For additional information please consult the tutorials that came with your purchase or open a support ticket if you need any help.</p>
<p>Clicking on hyperlinked column headers will sort the list by that column. Currently the list is <?=($sort_txt=='unsorted')?'<strong>unsorted</strong>':"sorted by <strong>$sort_txt</strong>"?>.</p>


<?
// Umesh update as start

$amsg = get_option('ap_version_msg');
if ($amsg != "") {
$url = get_option('siteurl') . '/wp-admin/options-general.php?page=wp-affiliate-pro_dec.php';
?>
<div id="message" class="updated fade"><p><strong><a href="<?=$url;?>"><?=$amsg;?></a></strong></p></div>

<?
update_option('ap_version_msg', '');
// Umesh update as complete
} ?>
<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
<tr><th scope="col"><a href="<?=$my_plugin_url;?>&amp;sort=id" title="Click to sort by ID">ID</a></th><th scope="col"><a href="<?=$my_plugin_url;?>&amp;sort=kwd" title="Click to sort by Keyword">Keyword</a></th><th scope="col">Weight</th><th scope="col">Replace Count</th><th scope="col"><a href="<?=$my_plugin_url;?>&amp;sort=lnk" title="Click to sort by Affiliate Link">Affiliate Link</a></th><th scope="col">Statusbar Text</th><th scope="col"><a href="<?=$my_plugin_url;?>&amp;sort=clk" title="Click to sort by Click Count">Clicks</a></th><th colspan="2">Action</th></tr>

<?
// Retrieve and display the keywords from our database
$table_name = $table_prefix . AP_KWD_TABLE;
$sql = "SELECT * FROM $table_name$sortsql";
$keywords = $wpdb->get_results($sql, ARRAY_A);
if (isset($keywords) && (count($keywords) > 0)) {
foreach ($keywords as $key=>$keyword) {
echo "<tr class='alternate'><th scope='row'>".$keyword['id']."</th><td>".$keyword['keyword']."</td><td align='center'>".$keyword['weight']."</td><td align='center'>".($keyword['replacecount']==0?'ALL':$keyword['replacecount'])."</td><td>".smart_short_text($keyword['url'], 40)."</td><td>".$keyword['caption']."</td><td align='center'>".$keyword['clickcount']." (<a href='$my_plugin_url&amp;id=".$keyword['id']."&amp;op=dt$sort_url' title='Click to show a detailed click through report for this keyword'>details</a>)</td><td><a href='$my_plugin_url&amp;id=".$keyword['id']."&amp;op=ed$sort_url'>Edit</a></td><td><a href='$my_plugin_url&amp;id=".$keyword['id']."&amp;op=del$sort_url'>Delete</a></td></tr>";
}


} else {
echo "<tr style='background-color: '><td colspan='7'>No affiliate links are defined. To add one or more affiliate links and their associated keywords please use the form below.</td></tr>";
}
?>
</table>

<form method="post" action="<?=$my_plugin_url.$sort_url;?>">
<p class="submit"><input type="hidden" name="reset" value="resetcounts" /><input type="submit" name="submit" value="Reset Click Counts &raquo;" /></p>
</form>

<p align="center">WordPress Affiliate Pro is Copyright &copy; 2008 by <a href="http://www.wpaffiliatepro.com/" target="_blank">IM Alliance</a>. All rights reserved.</p>
</div>
<?
} // if show keyword list
if ($show_add_keyword) {
?>

<div class=wrap>
<h2>Add New Keyword</h2>
<form method="post" id="addkwd" name="addkwd" action="<?=$my_plugin_url.$sort_url;?>">
<p><strong>Keyword</strong> that will be replaced by the affiliate link:<br />
<input type="text" name="keyword" value="<?=(isset($kwd)&&($err_msg!=''))?$kwd:''?>" style="width: 40%;" /></p>
<p><strong>Affiliate Link</strong> (enter the complete affiliate link here, including the http:// part):<br />

<input type="text" name="url" value="<?=(isset($url)&&($err_msg!=''))?$url:''?>" style="width: 80%;" /></p>
<p><strong>Statusbar Text</strong> (leave empty to show the click tracker URL, your affiliate link is always hidden):<br />
<input type="text" name="caption" value="<?=(isset($caption)&&($err_msg!=''))?$caption:''?>" style="width: 40%;" /></p>
<p><strong>Maximum Replacement Count</strong> (how many occurences of this keyword will be replaced on a page, 0 means replace all. If not 0, this will be used instead of the global setting):<br />
<input type="text" name="repl_count" value="<?=(isset($repl_count)&&($err_msg!=''))?$repl_count:'0'?>" style="width: 40%;" /></p>
<p><strong>Keyword Weight</strong> for the weighted random link selection. This should be between 0 and 9 (leave unchanged if you don't know what this means):<br />

<input type="text" name="weight" value="<?=(isset($weight)&&($err_msg!=''))?$weight:'5'?>" style="width: 40%;" /></p>
<p>Check this box is to add
<strong>rel=nofollow</strong> into the hyperlink it creates on a page.<br />
<input type="checkbox" name="nofollow" <? if (isset($nofollow)&&($err_msg!=''))
{
if ($nofollow == 1)
{
echo 'checked';
}
}?> />
</p>
<p>Check this box is to disable internal tracking system for this keyword.<br />
<input type="checkbox" name="notrack" <? if (isset($notrack)&&($err_msg!=''))
{
if ($notrack== 1)
{
echo 'checked';
}
}?> />
</p>

<p class="submit"><input type="hidden" name="action" value="addkeyword" /><input type="submit" name="submit" value="Add Keyword &raquo;" /></p>
</form>
</div>
<?
} // if show add keyword box
print_affiliate_blurb();
}
}


if (!function_exists('inHTMLTag')) {
function inHTMLTag($haystack, $offset) {
$haylen = strlen($haystack);

// Run some sanity checks first. If the offset is negative, the string length is is larger than the string length, return FALSE
if (($offset < 0) || ($offset > $haylen) || ($haylen == 0)) {
return FALSE;
}


// Search up to 250 characters to the left for the open HTML tag
$max_len = $offset - 250;
if ($max_len < 0) {
$max_len = 0;
}

$left = -1;
for ($i=$offset; $i>=$max_len; $i--) {
switch ($haystack{$i}) {
case '<':
$left = $i;
$i = $max_len;
break;
case '>':
$i = $max_len;
break;
}
}

// Search up to 250 characters to the right for the close HTML tag
$right = -1;
if ($left != -1) {
$max_len = $offset + 250;
if ($max_len > $haylen) {
$max_len = $haylen;
}

for ($i=$offset; $i < $max_len; $i++) {
switch ($haystack{$i}) {
case '>':
$right = $i;
$i = $max_len;
break;
case '<':
$i = $max_len;
break;
}
}
}

$result = (($left != -1) && ($right != -1) && ($left < $offset) && ($right > $offset));
return $result;
}

}


// PHP 5 compatibility function: stripos
if (!function_exists('stripos')) {
function stripos($haystack, $needle, $offset = null)
{
// Manipulate the string if there is an offset
$fix = 0;
if (!is_null($offset)) {
if ($offset > 0) {
$haystack = substr($haystack, $offset, strlen($haystack) - $offset);
$fix = $offset;
}
}

$segments = explode(strtolower($needle), strtolower($haystack), 2);

// Check there was a match
if (count($segments) === 1) {
return false;
}

$position = strlen($segments[0]) + $fix;
return $position;
}
}


if (!function_exists('ap_add_affiliate_links')) {
function ap_add_affiliate_links($content = '') {
global $table_prefix, $wpdb;

// If the processing is disabled via the Options menu then return the text unchanged
if (get_option('ap_enable')=='No') {
return $content;
}

if (get_option('ap_replace_count_method') == 'W') {
$weighted_random = TRUE;
} else {
$weighted_random = FALSE;
}

// Pull the list of keywords from the DB. If the link insertion method is Weighted Random then take that into account.
$table_name = $table_prefix . AP_KWD_TABLE;
if ($weighted_random) {
$weight_txt = 'ORDER BY weight DESC';
} else {
$weight_txt = '';
}
$sql = "SELECT * FROM $table_name $weight_txt";
$keywords = $wpdb->get_results($sql, ARRAY_A);

if (is_array($keywords)) {
// Retrieve the global options
$new_window = (get_option('ap_new_window') == 'Yes')?' target="_blank"':'';
$link_class = trim(get_option('ap_link_class'));
if ($link_class != '') {
$link_class = " class='$link_class'";
}
$replace_limit_global = get_option('ap_replace_count_global');
if ($replace_limit_global == 0) {
// Set "unlimited" to some arbitrary high value unlikely to be reached.
$replace_limit_global = 9999;
}
$replace_limit_keyword_global = get_option('ap_replace_count');
if ($replace_limit_keyword_global == 0) {
$replace_limit_keyword_global = 9999;
}

$base_url = get_option('siteurl') . '/wp-content/plugins/';

/*$tracker_url = $base_url . MY_SCRIPT_NAME;*/
// Retrieve plugin path from db
$searc_url = "SELECT * FROM ".$wpdb->options." WHERE option_name='active_plugins'";

$sdata = $wpdb->get_row($searc_url, ARRAY_A);

$sdarr = unserialize($sdata['option_value']);

foreach($sdarr as $k => $v)
{
$pos = strpos($v, "affiliate");
if($pos !== false) break;
}

$tracker_url = $base_url . $sdarr[$k]; //print_r($tracker_url);exit;


// ******************************* STEP 1 ********************************
// **** Build a (weighted) random list of available keywords. ****
// ***********************************************************************
$keyword_count = count($keywords);

// Initialize the Mersenne Twister random number generator (done automatically only on PHP > 4.2 so we take care of it here.)
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));

// Add the random (weighted) priority to each keyword. Also create the column arrays, to prepare for array_multisort and create the temporary keyword replacements.
$idx = 1;
foreach ($keywords as $key=>$val) {
$rand_prio = mt_rand(1, $keyword_count);
if ($weighted_random) {
// Keyword weight is 0 based, and we need it 1 based.
$rand_prio = $rand_prio * ($keywords[$key]['weight'] + 1);
}

$kwd_id[] = $val['id'];
$kwd_keyword[] = $val['keyword'];
$kwd_caption[] = $val['caption'];
$kwd_nofollow[] = $val['nofollow'];
$kwd_notrack[] = $val['notrack'];
$kwd_url[]= $val['url'];

if ($val['replacecount'] == 0) {
// Take into account the global option if no per-keyword setting is available.
$rc = $replace_limit_keyword_global;
} else {
$rc = $val['replacecount'];
}

$kwd_replacecount[] = $rc;
$kwd_priority[] = $rand_prio;
$kwd_searchpos[] = 0;
$kwd_tmprepl[] = "!!TMPAP$idx!!";
$idx++;
}

// Sort the array based on the keyword priority.
arsort($kwd_priority);

// Perform the first stage of replacements.
$keep_going = TRUE;
while ($keep_going) {
// We use done_work to keep track if at least one replacement occured per loop. If no replacements were done on the last loop, bail out. This is to prevent endless loops where user allows unlimited number of affiliate links per page and all keywords have unlimited replacements too.
$done_work = FALSE;
foreach ($kwd_priority as $key=>$val) {
if ($kwd_replacecount[$key] > 0) {

$kwdpos = stripos($content, $kwd_keyword[$key], $kwd_searchpos[$key]);
if ($kwdpos !== FALSE) {
// TODO: Add a global flag to allow the user to enable/disable replacement of keywords found within HTML tags.
if (! inHTMLTag($content, $kwdpos)) {
$content = substr($content, 0, $kwdpos) . $kwd_tmprepl[$key] . substr($content, $kwdpos + strlen($kwd_keyword[$key]));

$done_work = TRUE;
$replace_limit_global--;
$kwd_replacecount[$key]--;
}
// Next time we search only on the remaining text, not from the beginning again...
$kwd_searchpos[$key] = $kwdpos + strlen($kwd_keyword[$key]);
} else {
// If we haven't found any occurences of this keyword in this step, don't search for it in subsequent steps.
$kwd_replacecount[$key] = 0;
}
}

// If we've reached the maximum links per page, bail out...
if ($replace_limit_global == 0) {
$keep_going = FALSE;
break;
}
}

// No replacements on last loop? Bail out.
if ($done_work == FALSE) {
$keep_going = FALSE;
}
}

// Perform the second stage of replacements, where the temporary placeholder is exchanged with the final HTML.
$source = array();
$dest = array();
foreach ($kwd_priority as $key=>$val) {
$source[] = '/'.$kwd_tmprepl[$key].'/i';
if (trim($kwd_caption[$key]) != '') {
$caption = " onmouseover=\"top.window.status='".$kwd_caption[$key]."'; return true\" onmouseout=\"top.window.status=''; return true\"";
} else {
$caption = '';
}
$addnofollow = "";

if ($kwd_nofollow[$key] == 1)
{
$addnofollow = 'rel="nofollow"';
}
$addnotrack = "";

if ($kwd_notrack[$key] == 1)
{

$addnotrack = $kwd_url[$key];
}
else {
$addnotrack = $tracker_url."?id=".$kwd_id[$key];
}

//$dest[] = "<a href=$addedtags."'$caption$new_window$link_class>".$kwd_keyword[$key]."</a>";
$dest[] = "<a ". $addnofollow ." href='".$addnotrack ."'$caption$new_window$link_class>".$kwd_keyword[$key]."</a>";
}
if (count($source) > 0) {
$content = preg_replace($source, $dest, $content);
}
}
return $content;
}
}



// Make sure our installer gets called when the user activates the plugin. This in turn creates our data tables and sets the options to their default values.
add_action('activate_'.MY_SCRIPT_NAME, 'ap_install_plugin');ap_install_plugin();//exit("add_action");

// Insert the ap_add_pages() sink into the plugin hook list for 'admin_menu'
add_action('admin_menu', 'ap_add_pages');

// Insert the content rewriter sink into the filter hook list for the post display
add_filter('the_content', 'ap_add_affiliate_links', 1);

// TODO for next release: Allow the user to turn links into comments on and off
// Insert the content rewriter sink into the filter hook list for the comment display
add_filter('comment_text', 'ap_add_affiliate_links', 1);
View user's profile Send private message
PostPosted: Sun Oct 04, 2009 7:52 pm Reply with quote
matafy
Regular user
Regular user
Joined: May 14, 2009
Posts: 21




Thank You!
View user's profile Send private message
[Need Help] Decrypt plugin.php
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT
Page 1 of 1

Post new topicReply to topic


Powered by phpBB © 2001-2008 phpBB Group



Space Raider game for Android, free download - Space Raider gameplay video - Zone Raider mobile games
All logos and trademarks in this site are property of their respective owner. The comments and posts are property of their posters, all the rest (c) 2004-2024 Janek Vind "waraxe"
Page Generation: 0.041 Seconds