comparison interface/add_word_list.php @ 0:b12c99b7c3f0

commit for previous development
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 19 Jan 2015 17:13:49 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b12c99b7c3f0
1 <?php
2 header("Content-Type: text/html;charset=utf-8");
3
4 /**
5 * "Lib_mb_utf8.php" is a set of common functions used to convert encode of text
6 * "config.php" containing a system name variable. Please make it the same as the system's folder name.
7 */
8 include_once('Lib_mb_utf8.php');
9 include_once('config.php');
10
11 $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
12 mysql_query("SET NAMES utf8");
13
14 if (!$link_mysql) {
15 die('Could not connect: ' . mysql_error());
16 }
17
18 $db_selected = mysql_select_db($mysql_database, $link_mysql);
19 if (!$db_selected) {
20 die ('Can\'t use foo : ' . mysql_error());
21 }
22
23 if (!function_exists("GetSQLValueString")) {
24 function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
25 {
26 $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
27
28 $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
29
30 switch ($theType) {
31 case "text":
32 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
33 break;
34 case "long":
35 case "int":
36 $theValue = ($theValue != "") ? intval($theValue) : "NULL";
37 break;
38 case "double":
39 $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
40 break;
41 case "date":
42 $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
43 break;
44 case "defined":
45 $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
46 break;
47 }
48 return $theValue;
49 }
50 }
51
52 if ($_POST['text']){
53 if (get_magic_quotes_gpc()) {
54 $name = stripslashes($_POST['text']);
55 } else {
56 $name = $_POST['text'];
57 }
58
59 $query1 = sprintf("INSERT INTO `wordlist` (`name`, `systemName`) VALUES (%s, %s)",
60 GetSQLValueString($name, "text"),
61 GetSQLValueString($systemNAME, "text"));
62 $result1 = mysql_query($query1);
63 file_put_contents("wordlist/".mysql_insert_id().".txt", "");
64 }
65
66
67 ?>