$aliasUpdate = "DELETE FROM `alias` where `id` = :ALIASID"; $aliasUpdate = $conn->prepare($aliasUpdate); $aliasUpdate->bindParam(':ALIASID', $file->getAliasID()); if ($aliasUpdate->execute()) { echo "Alias deleted Successfully."; } } else { //new or Update //ensure it is available! $alias = new Alias($conn); $alias->setAlias($fileAlias); $numAliases = sizeof($alias->getObjectsLikeThis()); if ($numAliases == 0) { if ($file->getAliasID() == 0) { $alias->setPointer($file->getId()); $alias->setType('file'); if ($alias->save() > 0) { //echo "Alias Saved"; $fileUpdate->setAliasID($alias->getId()); } } else { $aliasUpdate = "UPDATE `alias` set `alias` = :NEWALIAS where `id` = :ALIASID"; $aliasUpdate = $conn->prepare($aliasUpdate); $aliasUpdate->bindParam(':NEWALIAS', $fileAlias); $aliasUpdate->bindParam(':ALIASID', $file->getAliasID()); $fileUpdate->setAliasID($file->getAliasID()); if ($aliasUpdate->execute() > 0) { //echo "Alias updated Successfully."; } } } else {
adminPage(); $conn = getConnection(); if (strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') { $aliasText = issetOrBlank($_POST['alias']); $pointer = issetOrBlank($_POST['pointer']); //echo "Alias: ".$alias.", pointer: ".$pointer; if ($aliasText != "" && $pointer != "") { //we can add them if the alias doesn't already exist. if (!startsWith($aliasText, "/")) { $aliasText = "/" . $aliasText; } $alias = new Alias($conn); $alias->setAlias($aliasText); //must start with '/' $numAliases = sizeof($alias->getObjectsLikeThis()); $alias->setType("url"); $alias->setPointer($pointer); if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) { echo '<h1>Alias created OK!</h1>'; echo $alias->getAlias() . " will now point to: " . $pointer; } else { if ($numAliases > 0) { echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>'; } else { if ($alias->getAlias() == "/") { echo '<p>Alias cannot be saved as /</p>'; //shouldnt occur } else { echo '<p>Couldnt save...</p>'; } }
pa($file); } if (issetOrBlank($_POST['file-alias']) != "") { $alias = new Alias($conn); $fileAlias = issetOrBlank($_POST['file-alias']); if (!startsWith($fileAlias, "/")) { $fileAlias = "/" . $fileAlias; } $alias->setAlias($fileAlias); //must start with '/' //check if alias already exists first //pa( $alias->getObjectsLikeThis() ); //echo sizeof( $alias->getObjectsLikeThis() ); $numAliases = sizeof($alias->getObjectsLikeThis()); $alias->setPointer($file->getId()); $alias->setType("file"); if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) { echo '<h1>Alias created OK!</h1>'; $file->setAliasID($alias->getId()); if ($file->save() > 0) { echo '<p>File Updated</p>'; } } else { if ($numAliases > 0) { echo '<p>The Alias: ' . $alias->getAlias() . ' already exists</p>'; } else { if ($alias->getAlias() == "/") { echo '<p>Alias cannot be saved as /</p>'; //shouldnt occur } else { echo '<p>Couldnt save...</p>';