-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.php
More file actions
57 lines (48 loc) · 1.46 KB
/
common.php
File metadata and controls
57 lines (48 loc) · 1.46 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
<?php
include "dbconfig.php";
$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name) or die("DB connect fail");
mysqli_query($conn, "set names utf8");
function dbquery($sql) {
global $conn;
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
return $res;
}
function dbfetch($res) {
$row = mysqli_fetch_array($res);
return $row;
}
function dbqueryfetch($sql) {
global $conn;
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
$row = mysqli_fetch_array($res);
return $row;
}
function alert_redir($msg, $url) {
$msg = str_replace("\n", "\\n", $msg);
echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
echo("<script>\n");
if($msg) echo("alert(\"$msg\");\n");
if($url) echo("window.location='$url';\n");
else echo("history.back();\n");
echo("</script>\n");
exit;
}
function alert($msg) {
$msg = str_replace("\n", "\\n", $msg);
echo("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
echo("<script>\n");
if($msg) echo("alert(\"$msg\");\n");
echo("</script>\n");
}
function get_chu_name($id) {
$sql = "select name from chuname where id='$id'";
$row = dbqueryfetch($sql);
return $row['name'];
}
function check_song_like($song, $user) {
$sql = "select * from musiclike where music_no='$song' and member_id='$user'";
$row = dbqueryfetch($sql);
if($row['music_no'] == "") return false;
else return true;
}
?>