Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // do now load for guests
- if (!Zend_Auth::getInstance()->hasIdentity()) {
- Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('Please sign in first'), 'on');
- Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoUrl('/');
- return;
- }
- $newbadge = $model = new Application_Model_Addons();
- $sql = "
- SELECT badge
- FROM codes
- ";
- require_once 'MainClass.php';
- require_once 'BadgeForm.php';
- $Getpurchasedbadge = new Addon_Getpurchasedbadge_Main();
- if ($Getpurchasedbadge->hasBadge($newbadge)) {
- ?>
- <h3>Get your "Convention" badge</h3>
- <hr/><br />
- <div class="row">
- <div class="col-md-6 col-md-offset-3" style="text-align: center">
- <h4>You already have this badge!</h4>
- </div>
- </div> <!-- end row -->
- <br /><br />
- <?php
- return;
- }
- $form = new Addon_Form_Getpurchasedbadge();
- $translator = Zend_Registry::get('Zend_Translate');
- // form is submitted and valid?
- if(isset($_POST['identifier']) && $_POST['identifier'] == 'GetPurchasedBadge')
- {
- if($form->isValid($_POST))
- {
- $license_to_check = $model = new Application_Model_Addons();
- $sql = "
- SELECT code
- FROM codes
- ";
- $license_to_check = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $license_to_check);
- if(!empty($license_to_check)){
- //Initialize curl
- $url = 'http://example.com?code='.$license_to_check;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 4_3_2 like Mac OD X; en-us) AppleWebKit/535.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5");
- $ch_data = curl_exec($ch);
- curl_close($ch);
- if(!empty($ch_data))
- {
- $json_data = json_decode($ch_data, true);
- // check response
- if(isset($json_data['is_valid']) && $json_data['is_valid'] == true){
- if ($Getpurchasedbadge->assignBadge($newbadge, $license_to_check)) {
- Application_Plugin_Alerts::success(Zend_Registry::get('Zend_Translate')->translate('You got yourself a badge!'), 'on');
- } else {
- Application_Plugin_Alerts::error(Zend_Registry::get('Zend_Translate')->translate('You already have this badge!'), 'on');
- }
- // flush
- Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector')->gotoUrl('/');
- return;
- }
- }
- }
- }
- $form->getElement('itemcode')->setValue('')->setErrors(array(Zend_Registry::get('Zend_Translate')->translate('Please check if your item purchase code is valid.')));
- }
- ?>
- <h3><img height="45" src="<?php echo Application_Plugin_Common::getFullBaseUrl().'/addons/'.basename(__DIR__).'/badge.png'?>"> Get a "Purchased" badge</h3>
- <hr/><br />
- <div class="row">
- <div class="col-md-6 col-md-offset-3">
- <p>If you have purchased SocialStrap script and you want people to know this fact then you've come to the right place. Fill up the form below and get yourself a badge.</p>
- <br />
- <?php echo $form->render()?>
- </div>
- </div> <!-- end row -->
- <br /><br />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement