예제 #1
0
  fclose ($fp);
  return "";
}
      
$dir = opendir("data");
while ($file = readdir($dir)) {
  if (is_file("data/$file")) {
    $entry = readentry("data/$file");
    $attributes[$entry] = $file;
  }
}
closedir($dir);

if (is_array($selected)) {
  while(list($key,$val) = each($selected)) {
    $entry = readentry("data/$val");
    list($name,$desc) = explode(":",$entry);
    print "<br/><br/>Loading $desc<br>\n";
    $lc_name = str_replace(" ","", strtolower(str_replace(".txt","",$val)));
    $lc_name = ereg_replace("[^[:alnum:]]","",$lc_name);

    if ($lc_name == "") Fatal_Error("Name cannot be empty: $lc_name");
    Sql_Query("select * from {$tables['attribute']} where tablename = \"$lc_name\"");
    if (Sql_Affected_Rows()) Fatal_Error("Name is not unique enough");

    $query = sprintf('insert into %s (name,type,required,tablename) values("%s","%s",%d,"%s")',
    $tables["attribute"],addslashes($name),"select",1,$lc_name);
    Sql_Query($query);
    $insertid = Sql_Insert_id();

    $query = "create table $table_prefix"."listattr_$lc_name (id integer not null primary key auto_increment, name varchar(255) unique,listorder integer default 0)";
예제 #2
0
    }
    fclose($fp);
    return "";
}
$dir = opendir("data");
while ($file = readdir($dir)) {
    if (is_file("data/{$file}")) {
        $entry = readentry("data/{$file}");
        $attributes[$entry] = $file;
    }
}
closedir($dir);
if (!empty($_POST['selected']) && is_array($_POST['selected'])) {
    $selected = $_POST['selected'];
    while (list($key, $val) = each($selected)) {
        $entry = readentry("data/{$val}");
        list($name, $desc) = explode(":", $entry);
        print "<br/><br/>" . $GLOBALS['I18N']->get('Loading') . " {$desc}<br/>\n";
        $lc_name = str_replace(" ", "", strtolower(str_replace(".txt", "", $val)));
        $lc_name = preg_replace("/[\\W]/", "", $lc_name);
        if ($lc_name == "") {
            Fatal_Error($GLOBALS['I18N']->get('Name cannot be empty:') . " {$lc_name}");
        }
        Sql_Query("select * from {$tables['attribute']} where tablename = \"{$lc_name}\"");
        if (Sql_Affected_Rows()) {
            Fatal_Error($GLOBALS['I18N']->get('Name is not unique enough'));
        }
        $query = sprintf('insert into %s (name,type,required,tablename) values("%s","%s",%d,"%s")', $tables["attribute"], addslashes($name), "select", 1, $lc_name);
        Sql_Query($query);
        $insertid = Sql_Insert_Id($tables['attribute'], 'id');
        $query = "create table {$table_prefix}" . "listattr_{$lc_name} (id integer not null primary key auto_increment, name varchar(255) unique,listorder integer default 0)";