php error_reporting -1 function render tmp data null base null if empt

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
error_reporting(-1);
function render($tmp, $data=null, $base = null) {
if(!empty($data)) {
#extract($data);
}
ob_start();
require "views/index.php";
$c = ob_get_clean();
require 'views/base.php';
}
function passgen($len=12) {
$s = '1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
$r = '';
for ($i = 0; $i < $len; $i++) {
$r .= $s[mt_rand(0, mb_strlen($s)-1)];
}
return $r;
}
$r = isset($_GET['r']) ? trim($_GET['r']) : null;
$arr = array('index', 'save', 'go');
switch($r) {
default:
render('index');
break;
case 'go':
$log = new Memcache;
$connect = $log->connect('localhost', 11233);
$link = isset($_GET['link']) ? trim($_GET['link']) : null;
$link = addslashes($link);
$link = trim($link, '/');
$random_tag = rand(1, 2000000000);
$query = sprintf("SELECT * FROM links_table WHERE name='%s' LIMIT 1", $link);
$log->set("select{$random_tag}", $query);
$get = $log->get("select{$random_tag}");
$x = json_decode($get, 1);
//if($x[0]['id'] == 1) echo 'lolka';
print_r($x);
if($x[0]['type'] == 1) {
header("Location: " . $x[0]['link']);
exit;
}
break;
case 'all':
$log = new Memcache;
$connect = $log->connect('localhost', 11233);
$type_name = 'links_table';
$id = 1;
$random_tag = rand(1, 2000000000);
$query = "SELECT * FROM links_table WHERE id=1";
$log->set("select{$random_tag}", $query);
$get = $log->get("select{$random_tag}");
$x = json_decode($get, 1);
print_r($x);
break;
case 'save':
$link = isset($_POST['link']) ? $_POST['link'] : null;
if(isset($_POST)) {
if(mb_strlen($link) > 2) {
$x = passgen(6);
$log = new Memcache;
$connect = $log->connect('localhost', 11233);
$type_name = 'links_table';
$id = 1;
$random_tag = rand(1, 2000000000);
$query = sprintf("SELECT * FROM links_table WHERE link='%s' LIMIT 1", $link);
$log->set("select{$random_tag}", $query);
$get = $log->get("select{$random_tag}");
$cc = json_decode($get, 1);
$data = array(
"name:" . $x,
"link:" . $link
);
$desc = implode("\x1", $data);
//$set = $log->set("add_event({$type_name},{$id})", $desc);
if (!isset($cc[0])) {
$set = $log->set("add_event({$type_name},{$id})", $desc);
} else {
$set = true;
$x = $cc[0]['name'];
}
if ($set) {
echo 'http://cutlink.local/' . $x;
} else {
echo 'error';
}
} else {
echo 'error';
}
}
break;
}