You are on page 1of 6

<?php /*********************/ /* */ /* Version : 5.1.0 */ /* Author : RM */ /* Comment : 071223 */ /* */ /*********************/ function get_nbtlm_license_server( ) { $nbtlm_license_server = "http://up9m.

com/4m72fe3ipkzugf6p/"; return $nbtlm_license_server; } function get_nb_product_name( ) { $nb_product = "They Like Me"; return $nb_product; } function get_nb_plugin_base_dir( ) { $nb_product = get_nb_product_name( ); $the_plugin_base_page = strtolower( str_replace( " ", "-", $nb_product ) ); return $the_plugin_base_page; } function get_nb_settings_page( ) { return "tlm.php"; } function get_nbtlm_support_email( ) { $support_email = "theylikeme@netbomber.com"; return $support_email; } function get_nbtlm_version( ) { $options = get_option( "nbtlm_options" ); $nbtlm_version = $options['nbtlm_version']; return $nbtlm_version; } function nbtlm_auth_status_lookup( $tlm_status_code ) { switch ( $tlm_status_code ) { case 0 : return "<span style=\"color:red;\">No license key exists for that email address.</span>"; case 1 : return "<span style=\"color:green;\">This site has been registered with your key, thank you!</span>"; case 2 : return "<span style=\"color:green;\">This site has already been register ed with your key, thank you!</span>"; case 5 :

return "<span style=\"color:green;\">Site is Authorised</span>"; case 13 : } return "<span style=\"color:red;\">No product named in auth request.</span>" ; return "There is a problem with the authorisation, please try again later, o r contact support."; } function nbtlm_check_auth( $tlm_auth_type = false, $tlm_actordeact = false ) { $nbtlm_license_server = get_nbtlm_license_server( ); $options = get_option( "nbtlm_options" ); $licString = ""; $licString = trailingslashit( $nbtlm_license_server ); if ( $tlm_auth_type == "check" ) { $licString .= "?remote_key_check="; } else { $licString .= "?remote_key_auth="; } $licString .= base64_encode( $options['nbtlm_key'] ); $licString .= "&remote_site="; $licString .= base64_encode( trailingslashit( site_url( ) ) ); if ( $tlm_actordeact == "deactivate" ) { $licString .= "&auth_type=".base64_encode( "deactivate" ); } else { $licString .= "&auth_type=".base64_encode( "activate" ); } $licString .= "&product=".base64_encode( $options['nbtlm_product_name'] ); return $licString; } function tlm_do_check( $licString ) { $auth_result = wp_remote_fopen( $licString ); $auth_text = nbtlm_auth_status_lookup( $auth_result ); return $auth_result; } function nb_auth_check( ) { $licString = nbtlm_check_auth( "check" ); $theresult = tlm_do_check( $licString ); return $theresult; } function nb_auth_init( ) { $licString = nbtlm_check_auth( ); $theresult = tlm_do_check( $licString ); return $theresult; } function tlmcron_function( )

{ $options = get_option( "nbtlm_options" ); if ( $options['nbtlm_auth_status'] != 0 ) { $authstatus = nb_auth_check( ); $arr = array( "nbtlm_key" => $options['nbtlm_key'], "nbtlm_last_check" => time( ), "nbtlm_auth_status" => $authstatus, "nbtlm_product_name" => $options['nbtlm_product_name'], "nbtlm_default_options_db" => $options['nbtlm_default_options_db'], "nbtlm_version" => $options['nbtlm_version'] ); update_option( "nbtlm_options", $arr ); } } function nbtlm_deactivate_license( ) { $nbtlm_license_server = get_nbtlm_license_server( ); $nb_product = get_nb_product_name( ); $support_email = get_nbtlm_support_email( ); $options = get_option( "nbtlm_options" ); $licString = nbtlm_check_auth( "auth", "deactivate" ); $theresult = tlm_do_check( $licString ); $licKey = $options['nbtlm_key']; if ( $theresult != 6 ) { wp_mail( $support_email, "Automated License Deactivation Request - Statu s Returned was \"".$theresult."\"", "Please check:\\r\\n".$licString."\\r\\n\\r\ \nKey:".$licKey."\\r\\nProduct:".$nb_product ); } delete_option( "nbtlm_options" ); wp_clear_scheduled_hook( "tlmcron_hook" ); } function nbtlm_delete_plugin_options( ) { $options = get_option( "nbtlm_options" ); if ( is_array( $options ) ) { delete_option( "nbtlm_options" ); } } function nbtlm_add_defaults( ) { $nb_product = get_nb_product_name( ); $tmp = get_option( "nbtlm_options" ); if ( $tmp['nbtlm_default_options_db'] == "1" { delete_option( "nbtlm_options" ); $arr = array( "nbtlm_key" => "", "nbtlm_last_check" => time( ), "nbtlm_auth_status" => "0", "nbtlm_product_name" => $nb_product, "nbtlm_default_options_db" => "1", "nbtlm_version" => "1.1" );

!is_array( $tmp ) )

update_option( "nbtlm_options", $arr ); } } function nbtlm_init( ) { register_setting( "nbtlm_plugin_options", "nbtlm_options", "nbtlm_validate_o ptions" ); } function nbtlm_add_options_page( ) { add_options_page( "They Like Me Settings Page", "They Like Me", "manage_opti ons", __FILE__, "nbtlm_render_form" ); } function nbtlm_render_form( ) { echo "\t<div class=\"wrap\">\r\n\t\t\r\n\t\t<!-- Display Plugin Icon, Header , and Description -->\r\n\t\t<div class=\"icon32\" id=\"icon-options-general\">< br /></div>\r\n\t\t<h2>They Like Me</h2>\r\n\t\t<p>Please enter the email addres s you used when purchasing the plugin, and save the changes. If all is well, you r plugin will be authenticated and made active.</p>\r\n <p>Any errors, pl ease contact us for support.</p>\r\n\t\t"; echo "\t\t<!-- Beginning of the Plugin Options Form -->\r\n\t\t<form method= \"post\" action=\"options.php\">\r\n\t\t\t"; settings_fields( "nbtlm_plugin_options" ); echo "\t\t\t"; $options = get_option( "nbtlm_options" ); echo "\t\t\t"; if ( strlen( $options['nbtlm_key'] ) != 0 ) { $authstatus = nb_auth_init( ); if ( $authstatus = 1 ) { $authstatus = nb_auth_check( ); } $arr = array( "nbtlm_key" => $options['nbtlm_key'], "nbtlm_last_check" => time( ), "nbtlm_auth_status" => $authstatus, "nbtlm_product_name" => $options['nbtlm_product_name'], "nbtlm_default_options_db" => $options['nbtlm_default_options_db'], "nbtlm_version" => $options['nbtlm_version'] ); update_option( "nbtlm_options", $arr ); } echo " "; $options = get_option( "nbtlm_options" ); echo "\t\t\t<!-- Table Structure Containing Form Controls -->\r\n\t\t\t<!-Each Plugin Option Defined on a New Table Row -->\r\n\t\t\t<table class=\"form-t able\">\r\n\r\n\t\t\t\t<!-- Textbox Control -->\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">EMail address used in purchase</th>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t \t"; if ( strlen( $options['nbtlm_key'] ) == 0 ) { echo "\t\t\t\t\t\t<input type=\"text\" size=\"57\" name=\"nbtlm_options[ nbtlm_key]\" value=\""; echo $options['nbtlm_key']; echo "\" />\r\n\t\t\t\t\t";

} else { echo "\t\t\t\t\t\t<input type=\"text\" size=\"57\" name=\"nbtlm_options[ nbtlm_key]\" value=\""; echo $options['nbtlm_key']; echo "\" readonly=\"readonly\" />\r\n\t\t\t\t\t"; } echo "\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t<!-- Last Chec k Time Control -->\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">Last auth chec k</th>\r\n\t\t\t\t\t<td>\r\n "; echo date( "Y-m-d H:i:s", $options['nbtlm_last_check'] ); echo "\t\t\t\t\t\t\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\r\n\t\t\t\t<!-- A uth Status Control -->\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">Last auth check status</th>\r\n\t\t\t\t\t<td>\r\n "; if ( strlen( $options['nbtlm_key'] ) != 0 ) { $currentstatus = nbtlm_auth_status_lookup( $options['nbtlm_auth_status'] ); echo $currentstatus; } echo "\t\t\t\t\t\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\r\n\t\t\t\t<!-- Pro duct Control -->\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">NetBomber Produc t Name</th>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<input type=\"text\" size=\"57\" na me=\"nbtlm_options[nbtlm_product_name]\" value=\""; echo $options['nbtlm_product_name']; echo "\" readonly=\"readonly\"/>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t \t\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">NetBomber Product Vers ion</th>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<input type=\"text\" size=\"57\" name= \"nbtlm_options[nbtlm_version]\" value=\""; echo $options['nbtlm_version']; echo "\" readonly=\"readonly\"/>\r\n\t\t\t\t\t</td>\r\n\t\t\t\t</tr>\r\n\t\t \t\t\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\t<th scope=\"row\">Database Options </th>\r\n\t\t\t\t\t<td>\r\n\t\t\t\t\t\t<label><input name=\"nbtlm_options[nbtlm_ default_options_db]\" type=\"checkbox\" value=\"1\" "; if ( isset( $options['nbtlm_default_options_db'] ) ) { checked( "1", $options['nbtlm_default_options_db'] ); } echo " /> Restore defaults upon plugin deactivation/reactivation</label>\r\n \t\t\t\t\t\t<br />"; echo "<s"; echo "pan style=\"color:#666666;margin-left:2px;\">Only check this if you ne ed to reset your email address upon Plugin reactivation</span>\r\n\t\t\t\t\t</td >\r\n\t\t\t\t</tr>\r\n <tr><td colspan=\"2\"><div style=\"margintop:10px;\"></div></td></tr>\r\n\t\t\t</table>\r\n "; if ( strlen( $options['nbtlm_key'] ) == 0 ) { echo "\t\t\t<p class=\"submit\">\r\n\t\t\t<input type=\"submit\" class=\ "button-primary\" value=\""; _e( "Save Changes" ); echo "\" />\r\n\t\t\t</p>\r\n "; } echo "\t\t</form>\r\n\r\n\t\t<p style=\"margin-top:15px;\">\r\n\t\t\t"; $prod_ver = base64_encode( get_nbtlm_version( ) ); $prod_name = base64_encode( get_nb_product_name( ) ); $advert = wp_remote_fopen( "http://www.netbomber.com/supportinfo.php?id=".$p rod_name."&v=".$prod_ver ); echo $advert; echo "\t\t</p>\r\n\r\n\t</div>\r\n\t";

} function nbtlm_validate_options( $input ) { $input['nbtlm_key'] = wp_filter_nohtml_kses( $input['nbtlm_key'] ); $input['nbtlm_last_check'] = wp_filter_nohtml_kses( $input['nbtlm_last_check '] ); return $input; } add_action( "admin_init", "nbtlm_init" ); add_action( "admin_menu", "nbtlm_add_options_page" ); add_action( "tlmcron_hook", "tlmcron_function" ); if ( !wp_next_scheduled( "tlmcron_hook" ) ) { wp_schedule_event( time( ), "twicedaily", "tlmcron_hook" ); } $options = get_option( "nbtlm_options" ); if ( $options['nbtlm_auth_status'] == 5 ) { add_action( "init", "tlm_init" ); add_action( "wp_head", "tlm_add" ); } else { } ?>

You might also like