-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfunc.php
More file actions
178 lines (141 loc) · 4.22 KB
/
func.php
File metadata and controls
178 lines (141 loc) · 4.22 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<?php include 'config.php';
function db($params = array())
{
if (isset($params['hostname'])) {
$hostname = $params['hostname'];
} else {
$hostname = CONF_HOSTNAME;
}
if (isset($params['username'])) {
$username = $params['username'];
} else {
$username = CONF_USERNAME;
}
if (isset($params['password'])) {
$password = $params['password'];
} else {
$password = CONF_PASSWORD;
}
if (isset($params['database'])) {
$database = $params['database'];
} else {
$database = CONF_DATABASE;
}
$conn = new mysqli($hostname, $username, $password, $database);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
return $conn;
}
function Q_array($sql = null)
{
$db = db();
if ($sql === null) {
return null;
} else {
if ($result = $db->query($sql))
{
return $result->fetch_all(MYSQLI_ASSOC);
$result->free();
}
/* close connection */
$db->close();
}
}
function Q_execute($sql = null)
{
$db = db();
if ($sql === null) {
return null;
} else {
if ($result = $db->query($sql))
{
return $result;
$result->free();
}
/* close connection */
$db->close();
}
}
function Q_count($sql = null)
{
$db = db();
if ($sql === null) {
return null;
} else {
if ($result = $db->query($sql))
{
return $result->num_rows;
$result->free();
}
/* close connection */
$db->close();
}
}
function Q_mres($param = null){
$db = db();
if ($param === null) {
return null;
} else {
return mysqli_real_escape_string($db, $param);
}
}
function redirect_to($page=null, $time=0.1)
{
if($page !== null){
echo "<meta http-equiv='refresh' content='". $time ."; url=". $page ."'>";
}
}
function site_url($slash=false)
{
$dir_project = CONF_DIR_PROJECT;
$http_host = $_SERVER['HTTP_HOST'];
$https_check = (!empty($_SERVER['HTTPS']) ? 'https' : 'http');
if($slash){
$siteurl = $https_check . '://' . $http_host . '/' .$dir_project.'/';
} else {
$siteurl = $https_check . '://' . $http_host . '/' .$dir_project;
}
return $siteurl;
}
function your_position(){
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
return $actual_link;
}
function session_me(){
if(isset($_SESSION['login'])){
if($_SESSION['login']){
return true;
}
}
return false;
}
/*function base_url($extnd = null)
{
$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
$url = str_replace("/index.php","", $_SERVER['SCRIPT_NAME']);
$parse_url = explode("/", $url);
$parse_url_end = end($parse_url);
$clean_url = str_replace($parse_url_end, "", $url);
if ($extnd == null)
{
$final_url = $clean_url;
} else {
$final_url = $clean_url . "" . $extnd;
}
$ret = "$http" . $_SERVER['SERVER_NAME'] . "" . $final_url;
return $ret;
}
function site_url($extnd = null)
{
$http = 'http' . ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 's' : '') . '://';
$url = str_replace("/index.php","", $_SERVER['SCRIPT_NAME']);
if ($extnd == null)
{
$final_url = $url;
} else {
$final_url = $url."/".$extnd;
}
$ret = "$http" . $_SERVER['SERVER_NAME'] . "" . $final_url;
return $ret;
}*/