-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_addLic.php
executable file
·64 lines (46 loc) · 1.55 KB
/
db_addLic.php
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
<?
include('_common.php');
if (isUserAtLeastAdmin()) {
function ChangeSpecialCharsBack($s) {
$myStr = $s;
$myStr = str_replace("***nl***","\n",$myStr);
$myStr = str_replace("***am***","&",$myStr);
$myStr = str_replace("***eq***","=",$myStr);
$myStr = str_replace("***pl***","+",$myStr);
$myStr = str_replace("***qu***","?",$myStr);
return $myStr;
}
$input_id = $_GET["id"];
$input_n = $_GET["n"];
$input_b = $_GET["b"];
if (trim($input_n) && trim($input_b)) {
db_connect();
//mysql_connect() or die ("Problem connecting to DataBase");
$query = "SELECT * FROM t_lic WHERE id='".db_escape_string($input_id)."';";
$result = mysql_db_query("strstr", $query);
$result = db_runQuery($query);
//if record exists - UPDATE fields - else INSERT fields
if ($result) {
if ($r = mysql_fetch_array($result)) {
//UPDATE
$query2 = sprintf("UPDATE t_lic SET caption='%s',brief='%s' WHERE id='%s';".
db_escape_string($input_n),db_escape_string($input_b),db_escape_string($input_id));
//$result2 = mysql_db_query("strstr", $query2);
$result2 = db_runQuery($query2);
//mysql_free_result($result2);
db_freeResult($result2);
} else {
//INSERT
$query2 = sprintf("INSERT INTO t_lic VALUES ('','%s','%s');",
db_escape_string($input_n),db_escape_string($input_b));
//$result2 = mysql_db_query("strstr", $query2);
$result2 = db_runQuery($query2);
//mysql_free_result($result2);
db_freeResult($result2);
}
}
//mysql_free_result($result);
db_freeResult($result);
}
}
?>