示例#1
0
 function verify_purchase($code, $api_key = null, $username = null, $item_id = null)
 {
     if (!$api_key) {
         $api_key = userpro_get_option('envato_api');
     }
     if (!$username) {
         $username = userpro_get_option('envato_username');
     }
     $Envato = new Envato_marketplaces();
     $Envato->set_api_key($api_key);
     $verify = $Envato->verify_purchase($username, $code);
     if ($item_id != '') {
         if (isset($verify->buyer) && $verify->item_id == $item_id) {
             return true;
         }
         return false;
     } else {
         if (isset($verify->buyer)) {
             return true;
         }
         return false;
     }
 }
示例#2
0
<?php

require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$Envato->set_api_key('7yh18l66xfg98cfcfwrfuc574sg6y11d');
?>
<div id="tb_generated_code_block" class="tb_generated_code_block">
<?php 
/*****************************************************
VARIABLES START
******************************************************/
date_default_timezone_set('Australia/Melbourne');
$timezone_to_print = date_default_timezone_get();
$date_to_print = date('m/d/Y h:i:s a', time());
// User
$tb_user_name = $_POST['tb_user_name'];
// Veify user purchase code
$tb_user_password = $_POST['tb_user_password'];
$verify_user_purchase_code = $Envato->verify_purchase('Smartik', $tb_user_password);
$verify_user_purchase_code_result = '';
if (isset($verify_user_purchase_code->buyer)) {
    $verify_user_purchase_code_result = 'yes';
} else {
    $verify_user_purchase_code_result = 'not';
}
// Main colors
$cp_FirstColor = $_POST['cp_FirstColor'];
if (empty($cp_FirstColor)) {
    $cp_FirstColor = '#4a7dff';
}
//First Color
示例#3
0
    public function create()
    {
        if (!$this->settings->info->guest_enable) {
            if (!$this->user->loggedin) {
                $this->template->error(lang("error_msg_tik3"));
            }
        }
        // IP Block check
        if ($this->ip_model->checkIpIsBlocked($_SERVER['REMOTE_ADDR'])) {
            $this->template->error(lang("error_msg_ip"));
        }
        $this->template->loadExternal('<script type="text/javascript" src="' . base_url() . 'scripts/ticket.js" /></script><script src="' . base_url() . 'scripts/tinymce/tinymce.min.js"></script>
			<script src="' . base_url() . 'scripts/tinymce/config.js"></script>');
        $this->load->helper('email');
        $this->load->library('upload');
        if (isset($_POST['s'])) {
            $email = $this->input->post("email", true);
            $name = $this->lib_filter->removeHTML($this->input->post("name", true));
            $priority = intval($this->input->post("priority", true));
            $category = intval($this->input->post("category", true));
            $subject = $this->lib_filter->removeHTML($this->input->post("subject", true));
            $message = $this->lib_filter->go($this->input->post("message"));
            if (!$this->settings->info->disable_captcha) {
                $captcha = $this->input->post("captcha", true);
                if ($captcha != $_SESSION['sc']) {
                    $fail = lang("error_msg_reg1");
                }
            }
            if ($priority < 0 || $priority > 3) {
                $fail = lang("error_msg_tik4");
            }
            if ($this->ticket_model->getCategory($category)->num_rows() == 0) {
                $fail = lang("error_msg_tik5");
            }
            if (strlen($name) > 255) {
                $fail = lang("error_msg_reg6");
            }
            if (empty($email)) {
                $fail = lang("error_msg_reg7");
            }
            if (empty($subject)) {
                $fail = lang("error_msg_tik6");
            }
            if (empty($message)) {
                $fail = lang("error_msg_tik7");
            }
            if (!valid_email($email)) {
                $fail = lang("error_msg_reg8");
            }
            // Check Custom Fields for valid data
            $custom_fields = $this->ticket_model->getCustomFields();
            $cfields = array();
            foreach ($custom_fields->result() as $r) {
                $data = $this->input->post("custom-field-" . $r->ID, true);
                if ($r->type == 0) {
                    $type = "text";
                    $data = $this->lib_filter->removeHTML($data);
                } elseif ($r->type == 1) {
                    $type = "email";
                    if (!valid_email($data)) {
                        $fail = lang("error_msg_reg8");
                    }
                } elseif ($r->type == 2) {
                    $options = explode(",", $r->selectoptions);
                    $pass = 0;
                    foreach ($options as $k => $v) {
                        if ($data == $k) {
                            $pass = 2;
                            $data = $v;
                        }
                    }
                    if ($pass == 0) {
                        $fail = lang("error_msg_tik8");
                    }
                } elseif ($r->type == 3) {
                    if (empty($this->settings->info->envato_api_key)) {
                        $this->template->error(lang("error_msg_tik9"));
                    }
                    require APPPATH . 'third_party/Envato_marketplaces.php';
                    $Envato = new Envato_marketplaces();
                    $Envato->set_cache_dir(APPPATH . 'third_party/envato_cache/');
                    $Envato->set_api_key($this->settings->info->envato_api_key);
                    $verify = $Envato->verify_purchase($this->settings->info->envato_api_username, $data);
                    // Quickie test.
                    if (isset($verify->buyer)) {
                        $json_data = json_decode($ch_data, true);
                        if ($json_data['verify-purchase']['item_name']) {
                            $data .= " - VERIFIED \n\t\t\t\t\t\t\t({$json_data['verify-purchase']['item_name']})";
                        } else {
                            $data .= " - " . lang("pg_sp_verify");
                        }
                    } else {
                        $data .= " - " . lang("pg_sp_verify_fail");
                    }
                }
                if ($r->required) {
                    if (empty($data)) {
                        $fail = lang("error_msg_tik10") . $r->name . "!";
                    }
                }
                $cfields[$r->name] = $data;
            }
            $fileInfo = array();
            if ($this->settings->info->file_enable) {
                // File upload script
                $this->upload->initialize(array("upload_path" => $this->settings->info->upload_path, "overwrite" => FALSE, "max_filename" => 300, "encrypt_name" => TRUE, "remove_spaces" => TRUE, "allowed_types" => "txt|gif|jpg|png|jpeg|", "max_size" => 600, "xss_clean" => TRUE));
                $attachments = 0;
                if ($this->upload->do_multi_upload("files")) {
                    $attachments = 1;
                    $fileInfo = $this->upload->get_multi_upload_data();
                }
            } else {
                $attachments = 0;
            }
            if (empty($fail)) {
                $pass = "";
                // Check if user is anon
                if (!$this->user->loggedin) {
                    if (!$this->settings->info->guest_enable) {
                        $this->template->error(lang("error_msg_tik3"));
                    }
                    $pass = $this->common->randomPassword();
                    $userid = 0;
                } else {
                    $userid = $this->user->info->ID;
                    unset($_SESSION['tid']);
                    unset($_SESSION['cod']);
                }
                $data = $this->ticket_model->create($userid, $email, $name, $priority, $category, $subject, $message, $cfields, $attachments, $pass);
                $replyid = $data['replyid'];
                $ticketid = $data['ticketid'];
                if ($this->settings->info->file_enable) {
                    if (count($fileInfo) > 0) {
                        foreach ($fileInfo as $file) {
                            $this->ticket_model->addFileToTicket($replyid, $file);
                        }
                    }
                }
                if (!$this->user->loggedin) {
                    // Grant Temp Access
                    $_SESSION['tid'] = $ticketid;
                    $_SESSION['cod'] = md5("blowfish28273273_" . $ticketid);
                    $msg = lang("flash_data_p29") . " {$ticketid}, " . lang("flash_data_p30") . " {$email} " . lang("flash_data_p31") . " {$pass} - " . lang("flash_data_p32");
                    $this->session->set_flashdata("globalmsg", $msg);
                    $this->email->from($this->settings->info->support_email, $this->settings->info->site_name);
                    $this->email->to($email);
                    $this->email->subject('Ticket Creation #' . $ticketid);
                    $this->email->message(lang("email_part1") . $name . ', <br /><br /> 
						' . lang("email_part6") . $this->settings->info->site_name . '.' . lang("email_part7") . '<br /><br /> 
						TicketID: ' . $ticketid . ' <br /><br /> Email: ' . $email . '
						 <br /><br /> Ticket Password: '******' <br /><br />
						 ' . lang("email_part16") . '<br /> <a href="' . site_url("tickets/anon_pro/?ticketid=" . $ticketid . "&email=" . $email . "&pass="******">' . site_url("tickets/anon_pro/?ticketid=" . $ticketid . "&email=" . $email . "&pass="******"email_part8") . '<a href="' . site_url() . '">' . site_urL() . '</a> ' . lang("email_part9") . ' <br /><br /> 
						 ' . lang("email_part5") . $this->settings->info->site_name);
                    $this->email->send();
                } else {
                    $this->session->set_flashdata("globalmsg", lang("flash_data_p33"));
                }
                // Email Staff
                if ($this->settings->info->alert_support_staff) {
                    $this->load->model("admin_model");
                    $agents = $this->admin_model->getAgents();
                    foreach ($agents->result() as $rr) {
                        $this->email->from($this->settings->info->support_email, $this->settings->info->site_name);
                        $this->email->to($rr->email);
                        $this->email->subject(lang("email_part15") . '(#' . $ticketid . ')');
                        $this->email->message('Dear ' . $rr->name . ',<br /><br />
							' . lang("email_part13") . $ticketid . '. ' . lang("email_part14") . ' <a href="' . site_url() . '">' . site_url() . '</a>.');
                        $this->email->send();
                    }
                }
                redirect(site_url("tickets/view/" . $ticketid));
            }
        }
        $categories = $this->ticket_model->getCategories();
        if (!$this->settings->info->disable_captcha) {
            $this->load->helper("captcha");
            $rand = rand(4000, 100000);
            $_SESSION['sc'] = $rand;
            $vals = array('word' => $rand, 'img_path' => './images/captcha/', 'img_url' => base_url() . 'images/captcha/', 'img_width' => 150, 'img_height' => 30, 'expiration' => 7200);
            $cap = create_captcha($vals);
        } else {
            $cap = "";
        }
        $custom_fields = $this->ticket_model->getCustomFields();
        if (!empty($fail)) {
            $this->template->loadContent("ticket/create.php", array("fail" => $fail, "cap" => $cap, "name" => $name, "email" => $email, "priority" => $priority, "category" => $category, "message" => $message, "subject" => $subject, "categories" => $categories, "custom_fields" => $custom_fields));
        } else {
            if ($this->user->loggedin) {
                $email = $this->user->info->email;
                $name = $this->user->info->name;
                $msg = null;
            } else {
                $email = null;
                $name = null;
                $msg = null;
            }
            if (isset($_POST['tmp_ticket'])) {
                $email = $this->lib_filter->removeHTML($this->input->post("tmp_email", true));
                $name = $this->lib_filter->removeHTML($this->input->post("tmp_name", true));
                $msg = $this->lib_filter->removeHTML($this->input->post("tmp_message", true));
            }
            $this->template->loadContent("ticket/create.php", array("cap" => $cap, "categories" => $categories, "custom_fields" => $custom_fields, "name" => $name, "email" => $email, "message" => $msg));
        }
    }
<?php

error_reporting(E_ALL);
ini_set('display_errors', '1');
require 'Envato_marketplaces.php';
$Envato = new Envato_marketplaces();
$account_info = $Envato->new_files('codecanyon', 'plugins');
# See what we got back....
$Envato->prettyPrint($account_info);
?>
<!doctype html>
<html>
<head>
	<meta charset=utf-8>
	<title>Popular Items Last Week</title>
</head>
<body>



</body>
</html>