Example #1
0
 if (!startsWith($aliasText, "/")) {
     $aliasText = "/" . $aliasText;
 }
 $alias = new Alias($conn);
 $alias->setAlias($aliasText);
 //must start with '/'
 $numAliases = sizeof($alias->getObjectsLikeThis());
 if ($numAliases != 0) {
     //is this because we only updated the pointer, or because it actually already exists?
     //simple check, if the hash with the new aliasText is the same as the old, it's just an update
     if ($key == hash('md5', KEY . $alias->getAlias())) {
         $numAliases = 0;
     }
 }
 $alias->setPointer($pointer);
 $alias->setId($aliasID);
 if ($alias->getAlias() != "/" && $numAliases == 0 && $alias->save() > 0) {
     echo '<h1>Alias Saved OK!</h1>';
     if ($alias->getType() != "url") {
         echo $alias->getAlias() . " will point to file ID: " . $pointer;
     } else {
         echo $alias->getAlias() . " will 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 {