function add() { global $sess, $title, $level, $description, $int_node, $thisnode, $glob_language; if (is_trail($title)) { $title = $title . "/"; } if (level_count($title) > 0) { include "directory/edit/err_invalidslash.html"; } else { $title = str_replace(' ', '_', $title); $obj['name'] = $thisnode['path'] . $title; $obj['name'] = str_replace(' ', '_', $obj['name']); $obj['parent'] = path2id($thisnode['path']); $obj['level'] = $level; $obj['objecttype'] = 'node'; $obj['description'] = $description; $obj['useraccess'] = 0; $obj['friendaccess'] = 0; $obj['owner'] = ''; $obj['language'] = $glob_language; $intid = path2id_ex($int_node, 1); $obj['intnode'] = $intid != -1 ? $intid : ""; add_object($obj, true); header("Location: " . $sess->url($thisnode['path'])); } }
function startElement($parser, $tagname, $attrs) { global $pool, $already_to_assess, $currentfile, $doit, $prefix, $number_updated, $number_inserted, $db_assessments; if ($tagname == "file") $currentfile = $attrs["file"]; if ($tagname == "path") { if ($currentfile) { $xid = path2id($prefix.$currentfile,$attrs["path"]); if (!$xid) { print "<div style='color:red'>Can't convert $currentfile#$attrs[path]</div>"; } else { $x = $already_to_assess[$xid]; $query = false; if ($x == "N") { $query = "UPDATE $db_assessments SET in_pool='Y' where id_pool='$pool' AND xid=$xid"; $number_updated++; } elseif (!$x) { $query = "INSERT INTO $db_assessments (id_pool,in_pool,inferred,xid) VALUES ($pool,'Y','N',$xid)"; $number_inserted++; } if ($query) { // print "<div>$query</div>"; sql_query($query); } } } else { print "<div style='color:red'>No current file for path $attrs[path]</div>"; } } }
function startElement($parser, $tagname, $attrs) { global $db_assessments, $collection_prefix; global $new_id_pool, $currentfile, $doit; if ($tagname == "file") $currentfile = $attrs["file"]; if ($tagname == "path") { if ($currentfile) { $xid = path2id($collection_prefix . $currentfile,$attrs["path"]); if (!$xid) { print "<div style='color:red'>Can't convert $currentfile#$attrs[path]</div>"; } else { if ($doit) sql_query("INSERT INTO $db_assessments (id_pool,in_pool,inferred,xid) VALUES ($new_id_pool, 'Y','N',$xid)","</div>"); // $attrs[file]#$attrs[path]\n"; } } else { print "<div style='color:red'>No current file for path $attrs[path]</div>"; } } }
function startElement($parser, $tagname, $attrs) { global $db_assessments, $collection_prefix, $stderr; global $new_id_pool, $currentfile, $doit; if ($tagname == "file") $currentfile = $attrs["file"]; if ($tagname == "path") { if ($currentfile) { $xid = path2id($collection_prefix . $currentfile,$attrs["path"]); if (!$xid) { fwrite($stderr,"Can't convert $currentfile#$attrs[path]\n"); } else { if ($doit) sql_query("INSERT INTO $db_assessments (id_pool,in_pool,inferred,xid,enabled) VALUES ($new_id_pool, 'Y','N',$xid,'Y')","</div>"); // $attrs[file]#$attrs[path]\n"; } } else { fwrite($stderr,"No current file for path $attrs[path]"); } } }
<?php page_open(array("sess" => "Linktrail_Session", "auth" => "Linktrail_Auth", "perm" => "Linktrail_Perm", "user" => "Linktrail_User")); // page access requires that the user is authenticated and has "admin" permission $perm->check("admin"); include "dbapi/comutils.inc"; include "dbapi/trails.inc"; include "dbapi/edit_links.inc"; include "template.inc"; $trail = base64_decode($trail); $trailid = path2id($trail); $obj['trail'] = $trailid; $obj['title'] = $title; $obj['description'] = $description; $obj['url'] = $url; $obj['position'] = 0; $obj['owner'] = $auth->auth["uid"]; add_link($obj, true); ?> <a href="./trail.php?v=<?php echo base64_encode($trail); ?> ">Debug: Back</a> <?php page_close();
function create($kat, $title, $description, $pass_language_check = false) { global $sess, $auth, $glob_language_name, $glob_language; if (!defined("SPELLING_INC")) { include "commonapi/spelling.inc"; } if (!strstr($kat, '/')) { $kat = base64_decode($kat); } $predef['kat'] = $kat; $predef['title'] = $title; $predef['description'] = $description; $title = str_replace(' ', '_', $title); $exists = get_node_info($kat . $title); $exists = $exists != -1; if (strstr($title, '/')) { $errfile = "err_invalidslash.html"; addform($predef, $errfile); exit; } elseif ($title == "") { $errfile = "err_notitle.html"; addform($predef, $errfile); exit; } elseif ($description == "") { $errfile = "err_nodesc.html"; addform($predef, $errfile); exit; } elseif ($exists) { $errfile = "err_object_exists.html"; addform($predef, $errfile); exit; } elseif (!check_language($description, $glob_language_name) and !$pass_language_check) { lang_query($kat, $title, $description); } else { $title = str_replace(' ', '_', $title); $obj['name'] = $kat . $title; $obj['parent'] = path2id($kat); $obj['level'] = level_count($kat); $obj['objecttype'] = "trail"; $obj['description'] = $description; $obj['useraccess'] = 4; $obj['friendaccess'] = 12; $obj['owner'] = $auth->auth["uid"]; $obj['language'] = $glob_language; add_object($obj, true); Header("Location: " . $sess->url(build_good_url($obj['name']) . "?reloadparent=1")); exit; // echo("Debug: dieses Fenster schliessen"); } }
function do_directory_table() { global $postgres; printf("\tCleaning postgres-table\n"); pg_exec($postgres, "DELETE FROM ltrDirectory") or die("Error while cleaning table"); printf("\tReading from MySQL... (and looking up nodes)\n"); $query = "SELECT ltrDirectory.*, ltrDirectory.LinkTo, ltrDirectoryData.*, FROM_UNIXTIME(UNIX_TIMESTAMP(ChangeDate)) as CompDate FROM ltrDirectory LEFT JOIN ltrDirectoryData ON ltrDirectory.Node_ID = ltrDirectoryData.Node_ID"; $res = mysql_query($query) or die("Could not query users data\n\n"); while ($row = mysql_fetch_array($res)) { foreach ($row as $key => $value) { $row[$key] = addslashes($value); } if ($row['AddDate'] == "") { $row['AddDate'] = $row['CompDate']; } if ($row['AddDate'] == "0000-00-00 00:00:00") { $row['AddDate'] = $row['CompDate']; } if ($row['LinkTo'] != "") { $row['LinkTo'] = path2id($row['LinkTo']); } if ($row['ObjectType'] == "trail") { $row['ObjectType'] = 1; } else { $row['ObjectType'] = 0; } null_check($row, 'IntNode'); null_check($row, 'Owner'); $nodes[] = $row; } begin_transaction(); foreach ($nodes as $node) { $query = sprintf("\n INSERT INTO\n ltrDirectory\n (Name, Node_ID, Parent, LinkTo, Level, Language, IntNode, Description, UserAccess,\n FriendAccess, ExtraLong, ChangeDate, Owner, AddDate, ObjectType)\n VALUES\n (\n '%s', %d, %d, %d, %d, %d, %s, '%s', %d,\n %d, %d, '%s', %s, '%s', %d\n )\n ", $node['Name'], $node['Node_ID'], $node['Parent'], $node['LinkTo'], $node['Level'], $node['Language'], $node['IntNode'], $node['Description'], $node['UserAccess'], $node['FriendAccess'], $node['ExtraLong'], $node['CompDate'], $node['Owner'], $node['AddDate'], $node['ObjectType']); // if ($node['LinkTo'] != "") die("\n\n$query\n\n"); $pg_res = pg_exec($postgres, $query); if (!$pg_res) { end_transaction(false); die("SQL-Error! Query:\n\n{$query}\n\n"); } else { printf("\tInserted Node: %s", $node['Name'] . "\n"); } } mysql_free_result($res); end_transaction(); }
pg_exec($postgres, $query) or die("Could not clean the directory\n"); $query = "SELECT ltrDirectory.*, ltrDirectoryData.*, FROM_UNIXTIME(UNIX_TIMESTAMP(ChangeDate)) as CompDate FROM ltrDirectory LEFT JOIN ltrDirectoryData ON ltrDirectory.Node_ID = ltrDirectoryData.Node_ID"; $res = mysql_query($query) or die("Could not query the directory\n"); $direntry = array(); while ($row = mysql_fetch_array($res)) { foreach ($row as $key => $value) { $row[$key] = addslashes($value); } if ($row['AddDate'] == '') { $row['AddDate'] = $row['CompDate']; } $direntries[] = $row; } printf("\tRead data...\n"); foreach ($direntries as $direntry) { $direntry['LinkTo'] = path2id($direntry['LinkTo']); if ($direntry['IntNode'] == "") { $direntry['IntNode'] = "NULL"; } $direntry['Owner'] = $direntry['Owner'] == "" ? 'NULL' : "'" . $direntry['Owner'] . "'"; $query = sprintf("\n INSERT INTO \n ltrDirectory\n (Name, Node_ID, Parent, LinkTo, Level, Language, \n IntNode, Description, UserAccess, FriendAccess, \n\tExtraLong, ChangeDate, Owner, AddDate)\n VALUES\n ('%s', %d, %d, %s, %d, %d,\n %s, '%s', %d, %d,\n\t%d, '%s', %s, '%s')\n ", $direntry['Name'], $direntry['Node_ID'], $direntry['Parent'], $direntry['LinkTo'], $direntry['Level'], $direntry['Language'], $direntry['IntNode'], $direntry['Description'], $direntry['UserAccess'], $direntry['FriendAccess'], $direntry['ExtraLong'], $direntry['CompDate'], $direntry['Owner'], $direntry['AddDate']); pg_exec($postgres, $query) or die("\nQuery-Error\n{$query}\n\n"); printf("\tInserted " . $direntry['Name'] . "\n"); } mysql_free_result($res); printf("\nWorking on the links...\n"); $query = "DELETE FROM ltrLinks"; pg_exec($postgres, $query) or die("Could not clean the links\n"); $query = "SELECT ltrLinks.*, FROM_UNIXTIME(UNIX_TIMESTAMP(ChangeDate)) as CompDate FROM ltrLinks"; $res = mysql_query($query) or die("Could not query the links\n"); $direntry = array();
function validate_and_set(&$http_vars) { global $nodeinfo; $errors = array(); if ($http_vars['field_title_1'] == "" or $http_vars['field_trail_1'] == "") { $errors[] = "You must fill out Trail 1"; } if (count($errors) == 0) { $trail1id = path2id(urldecode($http_vars['field_trail_1'])); if ($trail1id == -1) { $errors[] = "Trail 1 (" . $http_vars['field_trail_1'] . ") was not found in the database. Please correct the path"; } } if ($http_vars['field_trail_2'] != "") { $trail2id = path2id(urldecode($http_vars['field_trail_2'])); if ($trail2id == -1) { $errors[] = "Trail 2 was not found in the database. Please correct the path"; } } else { $trail2id = ""; } if (count($errors) != 0) { slot_edit_error($errors); } $slot['id'] = $http_vars['id']; $slot['node'] = $nodeinfo['id']; $slot['trail_1_id'] = $trail1id; $slot['trail_1_text'] = $http_vars['field_title_1']; $slot['trail_2_id'] = $trail2id; $slot['trail_2_text'] = $http_vars['field_title_2']; $slot['description'] = $http_vars['field_description']; $slot['next'] = ""; $slot['islive'] = isset($http_vars['field_slot_live']) ? "y" : "n"; return $slot; }