view interface/add_word_list.php @ 5:cbbb7ef22394

Change urls from "localmonographs" to "localgazetteers".
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Fri, 30 Jan 2015 10:17:44 +0100
parents b12c99b7c3f0
children
line wrap: on
line source

<?php
header("Content-Type: text/html;charset=utf-8");

/**
* "Lib_mb_utf8.php" is a set of common functions used to convert encode of text
* "config.php" containing a system name variable. Please make it the same as the system's folder name.
*/
include_once('Lib_mb_utf8.php');
include_once('config.php');

$link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password);
mysql_query("SET NAMES utf8");

if (!$link_mysql) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db($mysql_database, $link_mysql);
if (!$db_selected) {
    die ('Can\'t use foo : ' . mysql_error());
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if ($_POST['text']){	
	if (get_magic_quotes_gpc()) {
		$name = stripslashes($_POST['text']);
	} else {
		$name = $_POST['text'];
	}

	$query1 = sprintf("INSERT INTO `wordlist` (`name`, `systemName`) VALUES (%s, %s)",
					GetSQLValueString($name, "text"),
					GetSQLValueString($systemNAME, "text"));
	$result1 = mysql_query($query1);
	file_put_contents("wordlist/".mysql_insert_id().".txt", "");
}


?>