kuasha420

onpageseo-admin-license.php

Jul 15th, 2012
636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.40 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. if (!function_exists ('is_admin'))
  6.  
  7. {
  8.  
  9.     header('Status: 403 Forbidden');
  10.  
  11.     header('HTTP/1.1 403 Forbidden');
  12.  
  13.     exit();
  14.  
  15. }
  16.  
  17. elseif (!class_exists('OnPageSEOLicense'))
  18.  
  19. {
  20.  
  21.     class OnPageSEOLicense
  22.  
  23.     {
  24.  
  25.         /**
  26.  
  27.          * Instance Variables
  28.  
  29.          */
  30.  
  31.  
  32.  
  33.         var $licenseURL = 'http://www.easywpseo.com/license/';
  34.  
  35.         var $checkTime = 43200; // seconds
  36.  
  37.         var $licenseOptionName;
  38.  
  39.         var $licenseError = 0;
  40.  
  41.         var $license = array();
  42.  
  43.         var $options;
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.         /**
  52.  
  53.          * PHP 4 constructor (for backwards compatibility)
  54.  
  55.          *
  56.  
  57.          * @param   void
  58.  
  59.          * @return  bool    true
  60.  
  61.          */
  62.  
  63.  
  64.  
  65.         function OnPageSEOLicense(&$options)
  66.  
  67.         {
  68.  
  69.             $this->__construct(&$options);
  70.  
  71.             return;
  72.  
  73.         }
  74.  
  75.  
  76.  
  77.  
  78.  
  79.         /**
  80.  
  81.          * PHP 5 constructor
  82.  
  83.          *
  84.  
  85.          * @param   void
  86.  
  87.          * @return  void
  88.  
  89.          */
  90.  
  91.  
  92.  
  93.         function __construct(&$options)
  94.  
  95.         {
  96.  
  97.             // Plugin Options
  98.  
  99.             $this->options = &$options;
  100.  
  101.  
  102.  
  103.             // Set License Option Name
  104.  
  105.             $this->licenseOptionName = OPSEO_PREFIX.'_license_check';
  106.  
  107.  
  108.  
  109.             // Validate License Email & Serial Number
  110.  
  111.             if($this->validateEmailSerial())
  112.  
  113.             {
  114.  
  115.                 // Check License
  116.  
  117.                 $this->lastLicenseCheck();
  118.  
  119.             }
  120.  
  121.         }
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.         /**
  130.  
  131.          * Make sure user has entered license email and serial number
  132.  
  133.          *
  134.  
  135.          * @param   void
  136.  
  137.          * @return  bool
  138.  
  139.          */
  140.  
  141.  
  142.  
  143.         function validateEmailSerial()
  144.  
  145.         {
  146.  
  147.             if((!isset($this->options['license_email']) || (strlen(trim($this->options['license_email'])) == 0)) || (!isset($this->options['license_serial']) || (strlen(trim($this->options['license_serial'])) == 0)))
  148.  
  149.             {
  150.  
  151.                 // No Email and/or Serial Number
  152.  
  153.                 $this->licenseError = 1;
  154.  
  155.                 return false;
  156.  
  157.             }
  158.  
  159.             else { return true; }
  160.  
  161.         }
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.         function lastLicenseCheck()
  170.  
  171.         {
  172.  
  173.             // Get Options
  174.  
  175.             $this->getOptions();
  176.  
  177.  
  178.  
  179.             // Last Update Check
  180.  
  181.             if( strtotime(date('Y-m-d H:i:s')) > (strtotime($this->license['last_checked']) + $this->checkTime) )
  182.  
  183.             {
  184.  
  185.                 $this->getLicenseInfo();
  186.  
  187.  
  188.  
  189.                 // Update If No Errors
  190.  
  191.                 if(!$this->licenseError) { update_option($this->licenseOptionName, $this->license); }
  192.  
  193.             }
  194.  
  195.         }
  196.  
  197.  
  198.  
  199.  
  200.  
  201.         function getOptions()
  202.  
  203.         {
  204.  
  205.             // Last Update Check
  206.  
  207.             $this->license = get_option($this->licenseOptionName);
  208.  
  209.  
  210.  
  211.             // If User Changed License
  212.  
  213.             $this->licenseChanged();
  214.  
  215.  
  216.  
  217.             if(!$this->license)
  218.  
  219.             {
  220.  
  221.                 // Get License Information
  222.  
  223.                 $this->getLicenseInfo();
  224.  
  225.  
  226.  
  227.                 if(!$this->licenseError)
  228.  
  229.                 {
  230.  
  231.                     // Create New Option
  232.  
  233.                     $this->license = array('last_checked'=>date('Y-m-d H:i:s'), 'license_type'=>$this->license['license_type'], 'trial_expiration'=>$this->license['trial_expiration'], 'registered'=>$this->license['registered'], 'status'=>$this->license['status'], 'upgrade_url'=>$this->license['upgrade_url'], 'upgrade_message'=>stripslashes($this->license['upgrade_message']));
  234.  
  235.  
  236.  
  237.                     add_option($this->licenseOptionName, $this->license);
  238.  
  239.                 }
  240.  
  241.             }
  242.  
  243.         }
  244.  
  245.  
  246.  
  247.  
  248.  
  249.         function getLicenseInfo()
  250.  
  251.         {
  252.             // Request License Info From External URL
  253.  
  254.                                 $this->license['license_type'] = "developer";
  255.                                 return('license');
  256.             // Check If Trial License Has Expired
  257.             // NO Need :P
  258.             // Nulled By Kuasha420 @ blackhatteam.com :D
  259.         }
  260.        
  261.         function getLicenseName()
  262.  
  263.         {
  264.  
  265.             switch($this->license['license_type'])
  266.  
  267.             {
  268.  
  269.                 case 'free':
  270.  
  271.                     return('Free');
  272.  
  273.                     break;
  274.  
  275.  
  276.  
  277.                 case 'trial':
  278.  
  279.                     return('Expiring Trial');
  280.  
  281.                     break;
  282.  
  283.  
  284.  
  285.                 case 'single':
  286.  
  287.                     return('Single Site');
  288.  
  289.                     break;
  290.  
  291.  
  292.  
  293.                 case 'multi':
  294.  
  295.                     return('Multi Site');
  296.  
  297.                     break;
  298.  
  299.  
  300.  
  301.                 case 'developer':
  302.  
  303.                     return('Developer');
  304.  
  305.                     break;
  306.  
  307.  
  308.  
  309.                 case 'expired':
  310.  
  311.                     return('Expired Trial');
  312.  
  313.                     break;
  314.  
  315.  
  316.  
  317.                 default:
  318.  
  319.                     return('');
  320.  
  321.                     break;
  322.  
  323.             }
  324.  
  325.         }
  326.  
  327.  
  328.  
  329.  
  330.  
  331.         function getLicenseUsage()
  332.  
  333.         {
  334.  
  335.             switch($this->license['license_type'])
  336.  
  337.             {
  338.  
  339.                 case 'free':
  340.  
  341.                     return('You can use this on an unlimited number of sites that you own and also on your client\'s sites.');
  342.  
  343.                     break;
  344.  
  345.  
  346.  
  347.                 case 'trial':
  348.  
  349.                     return('Your license will expire '.$this->trialPeriodLeft().'.');
  350.  
  351.                     break;
  352.  
  353.  
  354.  
  355.                 case 'single':
  356.  
  357.                     return('You can use the plugin on one site.');
  358.  
  359.                     break;
  360.  
  361.  
  362.  
  363.                 case 'multi':
  364.  
  365.                     return('You can use the plugin on an unlimited number of sites that you own. (You cannot install the plugin on sites you do not personally own.)');
  366.  
  367.                     break;
  368.  
  369.  
  370.  
  371.                 case 'developer':
  372.  
  373.                     return('You can use the plugin on an unlimited number of sites that you own and also on your clients\' sites.');
  374.  
  375.                     break;
  376.  
  377.  
  378.  
  379.                 case 'expired':
  380.  
  381.                     return('Your trial has expired and you must upgrade to continue using the plugin.');
  382.  
  383.                     break;
  384.  
  385.  
  386.  
  387.                 default:
  388.  
  389.                     return('');
  390.  
  391.                     break;
  392.  
  393.             }
  394.  
  395.         }
  396.  
  397.  
  398.  
  399.  
  400.  
  401.         function trialPeriodLeft()
  402.  
  403.         {
  404.  
  405.             $secondsLeft = strtotime($this->license['trial_expiration']) - strtotime(date('Y-m-d H:i:s'));
  406.  
  407.             $timeLeft = (int)($secondsLeft / 86400);
  408.  
  409.  
  410.  
  411.             if($timeLeft > 1) { return('in'.$timeLeft.' days'); }
  412.  
  413.             elseif($timeLeft == 1) { return('in'.$timeLeft.' day'); }
  414.  
  415.             else { return('today'); }
  416.  
  417.         }
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.         function licenseChanged()
  426.  
  427.         {
  428.  
  429.             if( isset($this->options['old_license_email']) && (strlen(trim($this->options['old_license_email'])) > 0) && isset($this->options['old_license_serial']) && (strlen(trim($this->options['old_license_serial'])) > 0) && (($this->options['license_email'] != $this->options['old_license_email']) || ($this->options['license_serial'] != $this->options['old_license_serial'])) )
  430.  
  431.             {
  432.  
  433.                 if(sizeof($this->license) > 0) { delete_option($this->licenseOptionName); $this->license = array(); }
  434.  
  435.             }
  436.  
  437.         }
  438.  
  439.  
  440.  
  441.         function isLicenseError()
  442.  
  443.         {
  444.  
  445.             return($this->licenseError);
  446.  
  447.         }
  448.  
  449.  
  450.  
  451.         function getUpgradeURL()
  452.  
  453.         {
  454.  
  455.             return($this->license['upgrade_url'].'?email='.$this->options['license_email'].'&serial='.$this->options['license_serial']);
  456.  
  457.         }
  458.  
  459.  
  460.  
  461.         function getLicenseURL()
  462.  
  463.         {
  464.  
  465.             return($this->licenseURL.'?email='.$this->options['license_email'].'&serial='.$this->options['license_serial']);
  466.  
  467.         }
  468.  
  469.  
  470.  
  471.         function getLicenseType()
  472.  
  473.         {
  474.  
  475.             return($this->license['license_type']);
  476.  
  477.         }
  478.  
  479.  
  480.  
  481.         function getUpgradeMessage()
  482.  
  483.         {
  484.  
  485.             return(stripslashes($this->license['upgrade_message']));
  486.  
  487.         }
  488.  
  489.     }
  490.  
  491. }
  492.  
  493.  
  494.  
  495. ?>
Advertisement
Add Comment
Please, Sign In to add comment