@ 2013-06-10T16:11:18Z <?php
class Download {
protected $db;
protected $client;
public $download;
public $downloads;
public $free_downloads;
public $downloads_count;
public $info;
public $file;
public $status;
function __construct($db,$client) {
$this->db = $db;
$this->client = $client;
}
public function getDownloads() {
if($result = $this->db->query("SELECT * FROM downloads WHERE client_id='".$this->db->real_escape_string($this->client['id'])."' ORDER BY id DESC")) {
$return = array();
while($a = $result->fetch_assoc()) {
$return[] = $a;
}
$this->downloads_count = $result->num_rows;
$this->downloads = $return;
$result->free();
} else {
die('Database error: ('.$this->db->errno.') '.$this->db->error);
}
}
public function getFreeDownloads() {
if($result = $this->db->query("SELECT * FROM products WHERE cat='freedownload' AND active='yes'")) {
$return = array();
while($a = $result->fetch_assoc()) {
$return[] = $a;
}
$this->free_downloads = $return;
$result->free();
} else {
die('Database error: ('.$this->db->errno.') '.$this->db->error);
}
}
public function getSingleDownload($id) {
if($result = $this->db->query("SELECT * FROM downloads WHERE id='".$this->db->real_escape_string($id)."' AND client_id='".$this->db->real_escape_string($this->client['id'])."'")) {
if($result->num_rows == 1) {
$this->status = 'OK';
$this->download = $result->fetch_array();
} else {
$this->status = 'Kon de download niet vinden.';
}
$result->free();
} else {
$this->status = 'Database error: ('.$this->db->errno.') '.$this->db->error;
}
}
public function getProduct($id) {
if($result = $this->db->query("SELECT * FROM products WHERE id='".$this->db->real_escape_string($id)."' AND cat='download' AND active='yes' OR id='".$this->db->real_escape_string($id)."' AND cat='freedownload' AND active='yes'")) {
if($result->num_rows == 1) {
$this->info = $result->fetch_array();
$this->status = 'OK';
} else {
$this->info = null;
$this->status = 'NOK';
}
$result->free();
} else {
$this->status = 'NOK';
die('Database error: ('.$this->db->errno.') '.$this->db->error);
}
}
public function addDownload($product_id,$key,$key2,$com='no',$uses) {
if($this->db->query("INSERT INTO downloads (client_id,product_id,key1,key2,com_use,uses,created) VALUES (
'".$this->db->real_escape_string($this->client['id'])."',
'".$this->db->real_escape_string($product_id)."',
'".$this->db->real_escape_string($key1)."',
'".$this->db->real_escape_string($key2)."',
'".$this->db->real_escape_string($com)."',
'".$this->db->real_escape_string(uses)."',
NOW()
)")) {
$this->status = 'OK';
} else {
$this->status = 'Database error: ('.$this->db->errno.') '.$this->db->error;
}
}
public function updateDownload($id) {
if($this->db->query("UPDATE downloads SET used=used+1 WHERE id='".$this->db->real_escape_string($id)."'")) {
$this->status = 'OK';
} else {
$this->status = 'Database error: ('.$this->db->errno.') '.$this->db->error;
}
}
public function download($id, $free=true) {
if($free == true) {
$this->getProduct($id);
if($this->status = 'OK') {
if($this->info['price'] > 0 || $this->info['cat'] != 'freedownload') {
$this->status = 'Kon download niet ophalen';
} else {
$this->file['name'] = 'MijnSweetGroups_FreeDownload_'.$this->info['id'].'_'.uniqid().'.zip';
$this->file['download'] = '/home/sweet/domains/sweetgroups.net/DOWNLOADS/'.$this->info['download_map'].'/';
$this->file['replace'] = array(
'{%WEBSITES%}' => 'UNLIMITED',
'{%UPDATE%}' => $this->info['description'],
'{%LICENSE_CAT%}' => 'FREE',
'{%LICENSE_KEY1%}' => 'NONE',
'{%LICENSE_KEY2%}' => 'NONE'
);
}
} else {
$this->status = 'Kon download niet ophalen';
}
} else {
$this->getSingleDownload($id);
if($this->status = 'OK') {
if($this->download['used'] < $this->download['uses']) {
$this->getProduct($this->download['product_id']);
if($this->status = 'OK') {
$this->file['id'] = $id;
if($this->info['download_map'] == '') {
$this->info['download_map'] = 'unknown';
}
if($this->download['com_use'] == 'yes') {
$this->file['name'] = 'MijnSweetGroups_Download_'.$this->download['id'].'_Com.zip';
$this->file['download'] = '/home/sweet/domains/sweetgroups.net/DOWNLOADS/'.$this->info['download_map'].'_com';
$this->file['replace'] = array(
'{%WEBSITES%}' => '1',
'{%UPDATE%}' => $this->info['description'],
'{%LICENSE_CAT%}' => 'SINGLE COMMERCIAL',
'{%LICENSE_KEY1%}' => $this->download['key1'],
'{%LICENSE_KEY2%}' => $this->download['key2']
);
} else {
$this->file['name'] = 'MijnSweetGroups_Download_'.$this->download['id'].'.zip';
$this->file['download'] = '/home/sweet/domains/sweetgroups.net/DOWNLOADS/'.$this->info['download_map'].'/';
$this->file['replace'] = array(
'{%WEBSITES%}' => '1',
'{%UPDATE%}' => $this->info['description'],
'{%LICENSE_CAT%}' => 'SINGLE',
'{%LICENSE_KEY1%}' => $this->download['key1'],
'{%LICENSE_KEY2%}' => $this->download['key2']
);
}
$this->status = 'OK';
} else {
$this->status = 'Kon download niet ophalen';
}
} else {
$this->status = 'Download is al reeds gebruikt of download is niet gevonden.';
}
} else {
$this->status = 'Kon download niet ophalen';
}
}
}
public function getStatus($status) {
switch($status) {
case 'notused': return '<span class="grey">Niet gebruikt</span>'; break;
case 'canceled': return '<span class="red">Geannuleerd</span>'; break;
case 'pending': return '<span class="orange">Wordt gemaakt</span>'; break;
case 'delivered': return '<span class="green">Geleverd</span>'; break;
default: return '<span class="grey">Onbekend</span>';
}
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.7 0.006 0.006 16.62 7.1.6 0.013 0.013 19.33 7.1.5 0.011 0.007 16.80 7.1.0 0.003 0.077 22.40 7.0.20 0.013 0.003 16.63 7.0.14 0.003 0.073 22.11 7.0.11 0.007 0.080 20.04 7.0.10 0.003 0.083 20.17 7.0.9 0.010 0.073 20.05 7.0.8 0.013 0.077 20.06 7.0.7 0.013 0.040 20.05 7.0.6 0.010 0.080 20.13 7.0.5 0.007 0.073 20.09 7.0.4 0.003 0.050 19.86 7.0.3 0.013 0.073 19.78 7.0.2 0.020 0.070 19.66 7.0.1 0.003 0.080 19.75 7.0.0 0.023 0.063 19.82 5.6.28 0.003 0.073 21.13 5.6.26 0.003 0.063 20.69 5.6.25 0.010 0.073 20.61 5.6.24 0.017 0.070 20.73 5.6.23 0.010 0.077 20.91 5.6.22 0.003 0.077 20.73 5.6.21 0.010 0.080 20.74 5.6.20 0.010 0.077 20.72 5.6.19 0.003 0.053 20.70 5.6.18 0.000 0.090 20.64 5.6.17 0.003 0.073 20.70 5.6.16 0.003 0.083 20.74 5.6.15 0.017 0.067 20.61 5.6.14 0.007 0.083 20.75 5.6.13 0.003 0.053 20.76 5.6.12 0.017 0.073 20.67 5.6.11 0.010 0.047 20.69 5.6.10 0.010 0.043 20.71 5.6.9 0.003 0.050 20.50 5.6.8 0.007 0.073 20.05 5.6.7 0.007 0.083 20.11 5.6.6 0.010 0.040 20.13 5.6.5 0.010 0.073 20.00 5.6.4 0.003 0.060 19.89 5.6.3 0.013 0.073 19.89 5.6.2 0.007 0.083 20.03 5.6.1 0.003 0.083 20.12 5.6.0 0.000 0.087 19.98 5.5.38 0.000 0.087 17.61 5.5.37 0.010 0.050 17.54 5.5.36 0.000 0.087 17.65 5.5.35 0.010 0.057 17.60 5.5.34 0.007 0.073 17.98 5.5.33 0.010 0.077 17.96 5.5.32 0.007 0.077 17.97 5.5.31 0.003 0.083 18.20 5.5.30 0.000 0.060 18.16 5.5.29 0.007 0.080 18.13 5.5.28 0.003 0.073 17.98 5.5.27 0.003 0.087 17.98 5.5.26 0.003 0.057 18.26 5.5.25 0.017 0.070 17.98 5.5.24 0.013 0.077 17.55 5.5.23 0.000 0.050 17.52 5.5.22 0.007 0.040 17.53 5.5.21 0.000 0.067 17.31 5.5.20 0.010 0.090 17.64 5.5.19 0.007 0.047 17.31 5.5.18 0.000 0.080 17.55 5.5.16 0.000 0.043 17.64 5.5.15 0.013 0.067 17.35 5.5.14 0.007 0.077 17.63 5.5.13 0.013 0.037 17.25 5.5.12 0.000 0.047 17.61 5.5.11 0.003 0.040 17.37 5.5.10 0.010 0.067 17.39 5.5.9 0.010 0.057 17.51 5.5.8 0.007 0.073 17.50 5.5.7 0.010 0.063 17.41 5.5.6 0.007 0.063 17.21 5.5.5 0.007 0.080 17.40 5.5.4 0.003 0.050 17.37 5.5.3 0.000 0.087 17.22 5.5.2 0.013 0.070 17.37 5.5.1 0.013 0.073 17.27 5.5.0 0.007 0.080 17.52 5.4.45 0.010 0.077 19.34 5.4.44 0.003 0.087 19.34 5.4.43 0.007 0.083 19.41 5.4.42 0.003 0.077 19.48 5.4.41 0.000 0.063 19.23 5.4.40 0.000 0.080 19.10 5.4.39 0.003 0.060 19.14 5.4.38 0.013 0.067 19.34 5.4.37 0.007 0.040 19.01 5.4.36 0.003 0.053 19.20 5.4.35 0.010 0.053 19.32 5.4.34 0.013 0.077 19.02 5.4.32 0.003 0.080 18.93 5.4.31 0.007 0.077 19.27 5.4.30 0.013 0.040 18.95 5.4.29 0.010 0.040 19.13 5.4.28 0.000 0.050 19.33 5.4.27 0.003 0.063 19.26 5.4.26 0.003 0.060 19.00 5.4.25 0.017 0.067 19.00 5.4.24 0.007 0.060 19.30 5.4.23 0.003 0.037 19.33 5.4.22 0.003 0.077 18.99 5.4.21 0.010 0.063 19.00 5.4.20 0.017 0.060 19.33 5.4.19 0.007 0.067 19.33 5.4.18 0.007 0.047 19.08 5.4.17 0.013 0.073 19.13 5.4.16 0.010 0.077 18.99 5.4.15 0.007 0.073 18.98 5.4.14 0.007 0.080 16.54 5.4.13 0.003 0.080 16.34 5.4.12 0.007 0.077 16.40 5.4.11 0.010 0.073 16.61 5.4.10 0.003 0.077 16.63 5.4.9 0.010 0.047 16.51 5.4.8 0.020 0.057 16.44 5.4.7 0.000 0.080 16.55 5.4.6 0.010 0.070 16.29 5.4.5 0.007 0.077 16.62 5.4.4 0.007 0.070 16.49 5.4.3 0.000 0.083 16.68 5.4.2 0.007 0.070 16.59 5.4.1 0.010 0.063 16.68 5.4.0 0.007 0.070 16.04 5.3.29 0.007 0.077 14.88 5.3.28 0.003 0.080 14.68 5.3.27 0.007 0.057 14.65 5.3.26 0.003 0.050 14.67 5.3.25 0.007 0.070 14.81 5.3.24 0.007 0.070 14.78 5.3.23 0.007 0.043 14.62 5.3.22 0.003 0.070 14.64 5.3.21 0.003 0.040 14.67 5.3.20 0.010 0.043 14.64 5.3.19 0.007 0.053 14.65 5.3.18 0.010 0.033 14.86 5.3.17 0.013 0.057 14.49 5.3.16 0.010 0.070 14.86 5.3.15 0.013 0.067 14.61 5.3.14 0.003 0.077 14.77 5.3.13 0.003 0.077 14.59 5.3.12 0.010 0.070 14.63 5.3.11 0.013 0.070 14.63 5.3.10 0.010 0.050 14.20 5.3.9 0.003 0.070 14.10 5.3.8 0.003 0.053 14.07 5.3.7 0.007 0.070 13.94 5.3.6 0.003 0.063 14.09 5.3.5 0.013 0.060 13.97 5.3.4 0.010 0.073 14.01 5.3.3 0.003 0.047 14.11 5.3.2 0.000 0.043 13.85 5.3.1 0.003 0.073 13.80 5.3.0 0.020 0.033 13.69
preferences:dark mode live preview
36.16 ms | 401 KiB | 5 Q