예제 #1
0
 function execute($license, $action, $args)
 {
     $site = $this->get_post_var('site');
     $license_key = $this->get_post_var('license');
     $ip = $this->get_post_var('ip');
     $checker = new foolic_licensekey_checker();
     $validation_response = $checker->validate($license_key, $license, $site, $ip);
     $validation_message = '';
     $expires = '';
     $license_message = '';
     $domains = array();
     if ($checker->get_license_instance() !== false) {
         $validation_message = $checker->get_license_instance()->validation_message;
         if ($validation_response['valid'] === true) {
             $license_message = sprintf(__('Thank you for validating your %s license key : ', 'foolicensing'), $checker->get_license_instance()->name);
         } else {
             $license_message = sprintf(__('You do not have a valid %s license key : ', 'foolicensing'), $checker->get_license_instance()->name);
         }
     }
     if ($checker->get_licensekey_instance() !== false && $checker->get_licensekey_instance()->ID > 0) {
         $expires = $checker->get_licensekey_instance()->expires;
         $domains = $checker->get_licensekey_instance()->get_domains();
     }
     $details = array('slug' => $license, 'license_key' => $license_key, 'site' => $site, 'validation_date' => date(DATE_RFC822), 'response' => $validation_response, 'validation_message' => $validation_message, 'expires' => $expires, 'license_message' => $license_message, 'domains' => $domains);
     header('Content-type: application/json');
     echo json_encode($details);
 }
예제 #2
0
 function do_check()
 {
     $license_key = $this->get_requested_license_key();
     $site = $this->get_requested_site();
     $ip = $this->get_requested_ip();
     //validate all is good with the license
     $checker = new foolic_licensekey_checker();
     $this->validator_response = $checker->validate($license_key, $this->slug, $site, $ip);
     if ($checker->get_license_instance() !== false) {
         if ($this->validator_response['valid'] === true) {
             $this->license_message = sprintf(__('You have a valid %s license key : ', 'foolicensing'), $checker->get_license_instance()->name);
         } else {
             $this->license_message = sprintf(__('You do not have a valid %s license key : ', 'foolicensing'), $checker->get_license_instance()->name);
         }
     }
     $this->response->message = $this->validator_response['message'];
     if (!$this->validator_response['valid']) {
         $this->response->upgrade_notice = $this->validator_response['message'];
     }
 }
예제 #3
0
</th>
						<td><?php 
            echo $license->third_party_license_message;
            ?>
</td>
					</tr>
					<?php 
        } else {
            ?>
					<tr>
						<th><?php 
            _e('Status', 'foolicensing');
            ?>
</th>
						<td><?php 
            $valid = foolic_licensekey_checker::validate_license_key($key);
            ?>
							<span style="color:<?php 
            echo $valid['color'];
            ?>
"><?php 
            echo $valid['message'];
            ?>
</span>
						</td>
					</tr>
					<tr>
						<th><?php 
            _e('Expires', 'foolicensing');
            ?>
</th>
예제 #4
0
 function custom_column_content($column)
 {
     global $post;
     switch ($column) {
         case FOOLIC_CPT_LICENSE . '_version':
             $license = new foolic_license();
             $license->load($post);
             echo $license->update_version;
             break;
         case FOOLIC_CPT_LICENSE . '_domains':
             $license = new foolic_license();
             $license->load($post);
             $limit = $license->domain_limit;
             if ($limit == '' || $limit == '0') {
                 echo 'Unlimited';
             } else {
                 echo $limit;
             }
             break;
         case FOOLIC_CPT_LICENSE . '_expires':
             $license = new foolic_license();
             $license->load($post);
             $days = $license->expires_in_days;
             if ($days == '' || $days == '0') {
                 echo 'Never';
             } else {
                 echo sprintf(__('%s days', 'foolic'), $days);
             }
             break;
         case FOOLIC_CPT_LICENSE_KEY . '_issued':
             echo date('d M Y', strtotime($post->post_date));
             break;
         case FOOLIC_CPT_LICENSE_KEY . '_status':
             $licensekey = new foolic_licensekey();
             $licensekey->load($post);
             $valid = foolic_licensekey_checker::validate_license_key($licensekey);
             echo '<span title="' . $valid['message'] . '" style="color:' . $valid['color'] . '">' . $valid['status'] . '</span>';
             if ($licensekey->has_exceeded_domain_limit()) {
                 echo ' ' . __('Usage:', 'foolic') . ' (' . $licensekey->usage_html() . ')';
             }
             if ($licensekey->has_expired()) {
                 echo ' ' . __('Expires:', 'foolic') . ' ' . $licensekey->expires;
             }
             break;
     }
 }
        function render_licensekey_status_metabox($post)
        {
            $license_key = foolic_licensekey::get($post);
            ?>
            <input type="hidden" name="<?php 
            echo FOOLIC_CPT_LICENSE_KEY;
            ?>
_nonce" id="<?php 
            echo FOOLIC_CPT_LICENSE_KEY;
            ?>
_nonce" value="<?php 
            echo wp_create_nonce(plugin_basename($this->_plugin_file));
            ?>
" />
            <table class="form-table">
            <tbody>
            <?php 
            if (!empty($license_key->errors)) {
                ?>
            <tr>
                <td style="width:150px" class="first-column" valign="top"><?php 
                _e('Errors', 'foolic');
                ?>
</td>
                <td colspan="3">
                    <?php 
                foreach ($license_key->errors as $error) {
                    echo '<strong style="color:#f00">' . $error . '</span></br />';
                }
                ?>
                </td>
            </tr>
            <?php 
            }
            ?>
            <tr>
                <td style="width:150px" class="first-column" valign="top"><?php 
            _e('Status', 'foolic');
            ?>
</td>
                <td colspan="3">
                <?php 
            if ($license_key->is_new) {
                ?>
                    <?php 
                _e('The license key has not been issued yet', 'foolic');
                ?>
                <?php 
            } else {
                $valid = foolic_licensekey_checker::validate_license_key($license_key);
                ?>
                    <span style="color:<?php 
                echo $valid['color'];
                ?>
"><?php 
                echo $valid['message'];
                ?>
</span>
                <?php 
            }
            ?>
                </td>
            </tr>
            <?php 
            if (!$license_key->is_new) {
                ?>
            <tr>
                <td style="width:150px" class="first-column" valign="top"><?php 
                _e('Date Issued', 'foolic');
                ?>
</td>
                <td><?php 
                echo $license_key->date_issued;
                ?>
</td>
                <td style="width:150px" class="first-column" valign="top"><?php 
                _e('Activated', 'foolic');
                ?>
</td>
                <td><?php 
                echo $license_key->activated ? 'Yes' : '<strong>NO</strong>';
                ?>
</td>
            </tr>
            <?php 
                if (!empty($license_key->meta_display)) {
                    $counter = 0;
                    foreach ($license_key->meta_display as $key => $value) {
                        if ($counter == 0) {
                            echo '<tr>';
                        }
                        echo '<td style="width:150px" valign="top">' . $key . '</td>';
                        echo '<td>' . $value . '</td>';
                        $counter++;
                        if ($counter == 2) {
                            echo '</tr>';
                            $counter = 0;
                        }
                    }
                }
                ?>
            <?php 
            }
            ?>
            <?php 
            do_action('foolic_render_licensekey_status_metabox', $post);
            ?>
            </tbody>
            </table><?php 
        }
예제 #6
0
function foolic_validate_licensekey($licensekey, $license, $site = false, $ip = false)
{
    return foolic_licensekey_checker::validate($licensekey, $license, $site, $ip);
}