function show($id, $text = "") { if (!session::get("tooltips")) { // display text from database if ($id) { $helpArray = fetch_to_array(database::query("SELECT * FROM system WHERE name='{$id}'"), ""); if ($helpArray) { $entry = current($helpArray); } $right = right::get_field($id); $user = right::get("rights"); $temp = $entry[text]; // admin informations if (right::superuser()) { $temp .= "<hr><table>"; $temp .= "<tr><td>fieldname</td><td>{$id}</td></tr>"; // fieldname $temp .= "<tr><td>edit</td><td>" . right::int2string($right[edit]) . "</td></tr>"; // edit rights $temp .= "<tr><td>view</td><td>" . right::int2string($right[view]) . "</td></tr>"; // view rights $temp .= "</table>"; $clickEvent = " onmousedown = edit("{$id}")"; } if ($text) { $temp .= "<hr>{$text}"; } return "onmouseover='return overlib("" . $temp . "");' onmouseout='return nd()' {$clickEvent}"; } // display special text } }
function action($_arg) { //------------------------------------------------------------------------------ // extrace action from coordinate system while ($entry = each($_arg)) { $argArray = explode("_", $entry[key]); if (count($argArray) > 1) { $indexString = $argArray[0]; $valueString = $argArray[1]; $_arg[$indexString] = $valueString; if (isset($argArray[2])) { $_arg['_ID'] = $argArray[2]; } } } //echoalert($_arg); //echoalert($_SESSION); //------------------------------------------------------------------------------ // parse reset value if ($_arg[reset]) { $_arg = array(); session::destroy(searchshow); session::destroy(show); session::destroy(search); session::destroy(searchtype); session::destroy(searchcom); session::destroy(searchorder); session::destroy(searchString); session::destroy(searchexact); session::destroy(searchstart); session::destroy(searchowner); session::destroy(searchentrytype); session::destroy(searchstatus); } //------------------------------------------------------------------------------ // parse action parameter switch ($_arg[action]) { //------------------------------------------------------------------------------ // login / out case login: // login user user::login($_arg[user], $_arg[password]); // restore program status if new session restore_status(); // reset linking session::destroy("linkaction"); session::destroy("link"); break; case logout: // logout user user::logout(); break; case changedo: // change password if ($password = $_GET[password]) { database::query("UPDATE user SET password='******' WHERE ID='" . session::get("user") . "'"); echojavascript("Passwort erfolgreich geändert"); } break; //------------------------------------------------------------------------------ // inherit entrytype to children //------------------------------------------------------------------------------ // inherit entrytype to children case inherit: $childArray = thesaurus::get_child($_arg[id]); foreach ($childArray as $entry) { database::query("UPDATE entry SET entrytype={$_arg['entrytype']} WHERE ID={$entry}"); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case update: if ($_arg[orderdefault]) { session::set(orderdefault, $_arg[id]); } elseif (isset($_arg[orderdefault])) { session::destroy(orderdefault); } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case edit: session::set("edit", TRUE); session::set("show", $_arg[id]); session::destroy("searchshow"); break; case noedit: session::destroy("edit"); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case open: session::open($_arg[id]); break; case close: session::close($_arg[id]); break; case closeall: session::close_all(); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case deleteid: end_link(); hide(); database::delete($_arg[id]); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case suchen: if (!$_arg[searchString] and ($_arg[searchowner] or $_arg[searchtype] or $_arg[searchstatus])) { $_arg[searchString] = "%"; } if ($_arg[searchString]) { session::set("searchshow", true); } // show search result session::set("search", $_arg[searchString]); session::set("searchcom", $_arg[searchcom]); session::set("searchorder", $_arg[searchorder]); session::set("searchentrytype", $_arg[searchentrytype]); session::set("searchstatus", $_arg[searchstatus]); if ($_arg[searchowner]) { session::set("searchowner", $_arg[searchowner]); } else { session::destroy("searchowner"); } switch ($_arg[searchtype]) { case 0: session::destroy("searchexact"); session::destroy("searchstart"); break; case 1: session::destroy("searchexact"); session::set("searchstart", TRUE); break; case 2: session::destroy("searchstart"); session::set("searchexact", TRUE); break; } break; case hidesearch: session::destroy(searchshow); break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case show: session::destroy("searchshow"); $_arg[linkaction] = ""; if ($_arg[id] == NULL) { break; } elseif ($_arg[id] > 0) { session::set("show", $_arg[id]); break; } else { session::delete("show"); break; } break; //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ case swap: if ($_arg[id]) { thesaurus::swap_link($_arg[id], $_arg[_ID]); } break; case change: if ($_arg[id]) { // thesaurus::change_link($_arg); } break; case add: // add new descriptor session::destroy("show"); session::destroy("searchshow"); // session::set("",1); break; // clean database // clean database case correct: thesaurus::validate(true); echoalert("Datenbank bereinigt"); break; //------------------------------------------------------------------------------ // open hyrarchy down to selected entry //------------------------------------------------------------------------------ // open hyrarchy down to selected entry case showhyrarchy: if ($_arg[id]) { $hyrarchyArray = thesaurus::get_hyrarchy($_arg[id]); // don't open selected entry // array_pop($hyrarchyArray); foreach ($hyrarchyArray as $entry) { // echo $entry . " "; echo session::open($entry); } session::set("hyrarchy", TRUE); // hide search window session::destroy("searchshow"); // if nothing selected for display, show ID if (!session::get(show)) { session::set("show", $_arg[id]); } break; } //------------------------------------------------------------------------------ // debug on/off //------------------------------------------------------------------------------ // debug on/off case debugon: system::setval(debug, TRUE); break; case debugoff: system::setval(debug, FALSE); // legend on/off // legend on/off case legendon: session::set("legend", TRUE); break; case legendoff: session::destroy("legend"); break; // display / hide non descriptors // display / hide non descriptors case toggleND: if (session::get("descriptor")) { session::destroy("descriptor"); } else { session::set("descriptor", TRUE); } break; // display / hide orders // display / hide orders case toggleVI: if (session::get("visible")) { session::destroy("visible"); } else { session::set("visible", TRUE); } break; // toggle tooltips on/off // toggle tooltips on/off case off: session::set("tooltips", TRUE); break; case on: session::destroy("tooltips"); break; // toggle hyrarchy // toggle hyrarchy case hyrarchyon: session::set("hyrarchy", TRUE); break; case hyrarchyoff: session::set("hyrarchy", FALSE); break; } //------------------------------------------------------------------------------ // parse linkaction parameter switch ($_arg[linkaction]) { // link case link: session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linktype", $_arg[linktype]); break; // execute linking // execute linking case linkdo: switch (session::get('linkaction')) { case link: database::parent_insert(session::get("link"), $_arg[id], session::get("linktype")); session::set("show", session::get("link")); // set display to linked objects // with BS set linked descriptor to "no descriptor" if (session::get("linktype") == 2) { database::set_desc($_arg[id], 0); } // session::destroy("link"); // end linking break; case change: database::link_change(session::get('linkparent'), session::get('link'), $_arg['id']); // parent,oldlink,newlink break; } break; case linkend: end_link(); break; // unlink // unlink case unlink: if ($_arg[id]) { database::parent_delete(session::get("show"), $_arg[id]); } break; // change OB // change OB case change: if ($_arg[id]) { session::set("link", $_arg[id]); session::set("linkaction", $_arg[linkaction]); session::set("linkparent", $_arg[_ID]); session::set("linktype", $_arg[linktype]); } break; } // TEMP SETTINGS // if not link rights, set descriptor and visible to true if (!right::link()) { session::set(descriptor, FALSE); } //if (!right::link()) session::set(visible,TRUE); // save program status save_status($_SESSION); }
break; } // clear bit of edit right switch ($delview) { case 1: $view = $view & 6; break; case 2: $view = $view & 5; break; case 4: $view = $view & 3; break; } right::set_field($field, $edit, $view); $right = right::get_field($field); $edit = $right[edit]; $view = $right[view]; echo "<form method='get' action=editright.php>"; // display formular echo form::field("text", "tooltext", $right[text], 50, "", "Tooltip"); echo form::field("submit", "s1", "speichern"); echo form::field("hidden", "field", $field); echo "<hr>"; // right array echo "<table>"; echo "<tr>"; echo "<th> </th>"; echo "<th>Lesen</th>"; echo "<th>Schreiben</th>"; echo "<th>Verlinken</th>";
echo form::field("password", "password", "", 30, "", "Password ", "", "new-password"); echo "<br>"; echo form::field("submit", "action", "anlegen"); echo form::field("hidden", "action", "add"); echo "</fieldset>"; echo "</form>"; // ---------------------------------------------------------------------------- // list groups $groupArray = group::get_list(); echo "<fieldset><legend>Gruppen</legend>"; echo "<table>"; echo "<th>group</th>"; echo "<th>rights</th>"; foreach ($groupArray as $entry) { echo "<tr>"; echo "<td>" . $entry[text] . "</td>"; echo "<td>" . right::int2string($entry[rights], group::superuser($entry[value])) . "</td>"; echo "</tr>"; } echo "</table>"; echo "</fieldset>"; echo "</div>"; } else { form::standard(); } ?> </body> </html>
function edit() { if (right::write()) { if (session::get("edit")) { echo form::link("endedit", "edit", "index.php?action=noedit", "noedit"); } else { echo form::link("edit", "edit", "index.php?action=edit", "edit"); } } }
function header() { echo "<b class='big'>"; if (!thesaurus::is_thesaurus(session::get("link"))) { echo form::link("", "Hierarchie", "index.php?action=show&id=0&linkaction=linkdo"); } else { echo "Hierarchie"; } // title line echo "</b>"; // insert thesaurus if (right::link()) { // new only if write permission echo form::link("add", "add", "index.php?action=add&parent=0", "add-thesaurus"); } // close complete tree action::closeall(); // Show Link activity if ($linkID = session::get("link")) { echo "<br><i><span class='red'>"; $linktype = thesaurus::get_type_short(session::get("linktype")); if (session::get('linkaction') == "change") { $linkArray = thesaurus::get_descriptor($linkID); $parentArray = thesaurus::get_descriptor(session::get("linkparent")); echo "<b>" . $linktype . " '" . $linkArray[name] . "'</b> von <b>'" . $parentArray[name] . "'</b> ändern"; } else { $linkArray = thesaurus::get_descriptor($linkID); echo "Neuen <b>" . $linktype . "</b> für <b>'{$linkArray['name']}'</b> verlinken"; } echo "</span><span class='normal'><br>Aktion beenden "; echo form::link("delete", "end", "index.php?linkaction=linkend", "end-linking"); echo "</i>"; } echo "<hr align='left' width='400px'>"; }
function show() { if (system::getval(debug)) { echo "<div id='login_debug'>"; } else { echo "<div id='login'>"; } if ($userID = session::get("user")) { // change password if ($_GET[action] == "change") { echo "<form method='get' action='index.php'>"; echo form::field("password", "password", "", "", "", "<i>Neues Passort</i>", "", "newpassword"); echo form::field("submit", "b1", "ändern"); echo form::field("hidden", "action", "changedo"); echo "</form>"; } else { echo "<span class='normal'>Angemeldet: </span><span class='red'>" . user::name($userID) . " </span>"; echo form::link("", " - abmelden ", "index.php?action=logout", "logout"); echo form::link("", " - Passwort ändern ", "index.php?action=change", "change-password"); // if su display admin echo form::link("", " - Administration", "admin.php", "admin"); if ($_SESSION['show']) { echo form::link("", " - Import into <b>" . thesaurus::name($_SESSION['show']) . "</b>", "import.php?id=" . $_SESSION['show'], "import"); } // menu switches action::hyrarchy(); // toggle hyrarchy off / on action::descriptor(); action::visible(); action::tooltips(); // toggle tooltips off / on if (right::write()) { action::edit(); } // show edit function action::listit(); action::debug(); } } else { echo "<span class='normal'>"; echo "<form method='get' action='index.php'>"; echo "<i>Benutzername </i><input type='text' name='user' value='{$user}'>"; echo " <i>Passwort </i><input type='password' name='password'>"; echo " <input type='submit' name='action' value='anmelden'>"; echo "<input type='hidden' name='action' value='login'>"; echo "</form>"; echo "</span>"; } // display javascript status /* echo "<span class='small'>"; if (session::get("JS")) echo "JavaScript aktiv"; else echo "kein Javascript"; echo "</span>";*/ echo "</div>"; }
$_JS = 0; ?> </noscript> </head> <body> <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div> <?php //echoalert($_JS); // connect database $daba = new database(); $daba->connect("localhost", "iggmp", "1s87J37r0"); $daba->select("thesaurus"); if (right::link()) { thesaurus::validate(); } // show login or logged user user::show(); // headline ?> <div id='header'> <a href='index.php'>OpenThesaurus</a><br> <?php // show count of entries echo " <i class='normal'>("; echo database::count() . " Einträge mit "; echo database::linkcount() . " Verknüpfungen"; echo ")</i>";
function validate($action = "") { // check entries with undefined links $sqlRef = database::query("SELECT * FROM parent"); $tempString = ""; // loop over all link entries while ($entry = mysql_fetch_array($sqlRef)) { if (!$action) { $parentName = thesaurus::get_name($entry[parent]); $childName = thesaurus::get_name($entry[child]); if (!thesaurus::get_descriptor($entry[parent]) and $entry[parent] != 0) { $tempString .= "Oberbegriff {$entry['parent']} von <b>'{$childName}'</b> <i>({$entry['child']})</i> existiert nicht<br>"; } if (!thesaurus::get_descriptor($entry[child])) { $tempString .= "Unterbegriff {$entry['child']} von <b>'{$parentName}'</b> <i>({$entry['parent']})</i> existiert nicht<br>"; } } else { if ((!thesaurus::get_descriptor($entry[parent]) or !thesaurus::get_descriptor($entry[child])) and $entry[parent] != 0) { database::query("DELETE FROM parent WHERE ID={$entry['ID']}"); } } // check crosslinks between thesauri if (thesaurus::get_thesaurus($entry[parent]) and thesaurus::get_thesaurus($entry[parent]) != thesaurus::get_thesaurus($entry[child])) { $crossString .= form::link("", $entry[parent], "index.php?action=show&id={$entry['parent']}") . " <=> " . form::link("", $entry[child], "index.php?action=show&id={$entry['child']}") . " link in different thesauri<br>"; } } // display error messages if (right::link() and ($tempString or $crossString)) { echo "<div id='alert' class='red'>"; if ($tempString) { echo "<b>OB / UB Fehler</b><br>{$tempString}<br>"; echo "Datenbank bereinigen "; echo form::link("delete", "Datenbank bereinigen", "index.php?action=correct", "correct", ""); } // display error message if ($crossString) { echo "<b>Crosslink Fehler</b><br>{$crossString}<br>"; // echo "Datenbank bereinigen "; // echo form::link("delete","Datenbank bereinigen","index.php?action=correct","correct",""); } echo "</div>"; } // rewrite thesaurus links $sqlRef = database::query("SELECT * FROM entry"); while ($entry = mysql_fetch_array($sqlRef)) { $tempArray = thesaurus::get_hyrarchy($entry[ID]); if (is_array($tempArray)) { $thesaurus = $tempArray[0]; } else { $thesaurus = $tempArray; } database::query("UPDATE entry SET thesaurus='{$thesaurus}' WHERE ID='{$entry['ID']}'"); } }
function comment($id, $name, $error) { echo "<fieldset><legend>Erläuterungen</legend>"; echo "<textarea class='{$error}' name='comment' cols='45' rows='5' "; echo help::show("comment-field", ""); if (right::write()) { echo ">"; } else { echo " readonly>"; } echo $name; echo "</textarea>"; // display legend for comment area if (session::get("legend")) { echo form::link("help-off", "no help", "index.php?action=legendoff", "nolegend"); form::legend(); } else { echo form::link("help-on", "help", "index.php?action=legendon", "nolegend"); } echo "</fieldset>"; }
<?php // show count of entries echo " <i class='normal'>("; echo database::count() . " Einträge mit "; echo database::linkcount() . " Verknüpfungen"; echo ")</i>"; ?> </div> <div id='status'>V2.3 - Thomas H Winkler - 2010-2011</div> <?php if (right::read()) { // Insert values into database $mandatory = array("name"); $errorArray = database::insert($_GET, $mandatory); $errorArray = $display->set_default($errorArray, $mandatory); //------------------------------------------------------------------------------ // Form fields if (session::get("hyrarchy")) { echo "<div id='info' class='info'>"; } else { echo "<div id='infobig' class='info'>"; } // big info window form::insert_entry($_GET, $errorArray); echo "</div>"; if (session::get("show")) {
function int2string($right, $su = false) { $text = ""; if ($right & 1) { $text .= "R"; } if ($right & 2) { $text .= "W"; } if ($right & 4) { $text .= "L"; } if (right::superuser() and $su) { $text .= " su"; } return $text; }