static function login($data) { if (!isset($data["username"])) { return self::UM_NoUserError; } else { $u = false; $logged = false; //check nick and password $u = self::loadUserByNickname($data["username"]); // assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) { $logged = true; } if ($u === false) { //check mail and password $u = self::loadUserByMail($data["username"]); // assumo che la password mi sia arrivata in chiaro attraverso una connessione sicura if ($u !== false && $u->getPassword() == Filter::encodePassword($data["password"])) { header("location: " . FileManager::appendToRootPath()); } } if ($u !== false) { if ($logged) { if (Session::start($u)) { return true; } else { return self::UM_NoSessionError; } } return self::UM_NoPasswordError; } return self::UM_NoUserError; } }
static function showLoginForm($error = null) { if ($error == null && count($_POST) > 0) { if (isset($_POST["username"])) { $data["username"] = $_POST["username"]; } else { $error[] = "non c'è lo username"; } if (isset($_POST["password"])) { $data["password"] = $_POST["password"]; } else { $error[] = "password non presente"; } if (count($error) > 0) { $s = FileManager::appendToRootPath("error?e=" . $error[0]); } else { $dataFiltered = Filter::filterArray($data); if (($logged = UserManager::login($data)) === true) { $s = FileManager::appendToRootPath(""); } else { require_once 'errors/errors.php'; $s = FileManager::appendToRootPath("error?e=" . $logged); } } if (!headers_sent()) { header("location: " . $s); } else { ?> <script type="text/javascript"> location.href = "<?php echo $s; ?> "; </script> <?php } } ?> <form name="login" action="<?php echo FileManager::appendToRootPath("Login"); ?> " method="post"> <?php //<!-- show error messages --> if ($error != null) { foreach ($error as $valore) { echo $valore . "<br/>"; } } ?> <p><input type="text" name="username" value="" /></p> <p><input type="password" name="password" value="" /></p> <p><input class="button" type="submit" value="Accedi"></form></p> <?php }
static function showNoPostWarning() { ?> <div class="post nopost" id="nopost"> <div class="post_header"> <div class="post_headline clear">What are you waiting?</div> <div class="post_title">No Post in this site yet!</div> <div class="post_subtitle">Write a new post right now!</div> </div> <div class="post_content clear"> <p><span id="post_place_publichi" class="post_place">PUBLICHI</span> - Wait! PubliChi is empty? What happened?</p> <p>You just installed it? So, what are you waiting? Write a <a href="<?php echo FileManager::appendToRootPath("Post/New"); ?> ">new post</a> and start a brand new site!!</p> <p>Come on! This screen is soo boring!!!</p> <div class="post_authorname"><a href="<?php echo FileManager::appendToRootPath("User/ioesisto"); ?> ">IoEsisto</a></div> </div> </div> <?php }
private static function createLinkPath($where = "") { require_once 'file_manager.php'; return FileManager::appendToRootPath($where); }
static function showPost($post, $options = null) { if (isset($options[self::SHORTEST]) && $options[self::SHORTEST]) { self::showShortPost($post); return; } ?> <div class="post <?php echo $post->getType(); ?> " id="post<?php echo $post->getID(); ?> "> <div class="pb_header"><?php if (!isset($options[self::NO_DATE]) || !$options[self::NO_DATE]) { ?> <div class="post_creationDate"><?php echo format_datetime($post->getCreationDate()); ?> </div><?php } if (!isset($options[self::NO_CATEGORIES]) || !$options[self::NO_CATEGORIES]) { ?> <div class="post_categories"><?php $first = true; $cats = explode(",", $post->getCategories()); foreach ($cats as $cat) { if ($first) { $first = false; } else { echo ", "; } echo '<a href="' . FileManager::appendToRootPath('Category/' . trim(Filter::decodeFilteredText($cat))) . '">' . trim(Filter::decodeFilteredText($cat)) . '</a>'; } ?> </div><?php } ?> <div class="clear"></div> </div> <div class="post_header"> <div class="post_headline clear"><?php echo Filter::decodeFilteredText($post->getHeadline()); ?> </div><?php $title_class = "post_title"; if (isset($options[self::SMALL_TITLE]) && $options[self::SMALL_TITLE]) { $title_class .= " small_title"; } ?> <div class="<?php echo $title_class; ?> "><a href="<?php echo FileManager::appendToRootPath($post->getPermalink()); ?> "><?php echo Filter::decodeFilteredText($post->getTitle()); ?> </a></div> <div class="post_subtitle"><?php echo Filter::decodeFilteredText($post->getSubtitle()); ?> </div> </div> <div class="post_content clear"> <span id="post_place_<?php echo $post->getID(); ?> " class="post_place"></span><?php if (is_array($post->getContent())) { $first = true; foreach ($post->getContent() as $cont) { if ($first) { $first = false; } else { echo " "; } //echo Filter::decodeFilteredText($cont); //$photo=Filter::decodeFilteredText($cont); $path = "/IoEsisto/v02/" . $cont->getPath(); echo "<a href='{$path}'><img src='" . $path . "' width='100' height='50'></a>"; } } else { echo Filter::decodeFilteredText($post->getContent()); } if (!is_null($post->getPlace())) { require_once "maps/geolocate.php"; MapManager::printInfoInElement($post->getPlace(), "post_place_" . $post->getID()); } ?> <div class="post_authorname"><a href="<?php echo FileManager::appendToRootPath("User/" . $post->getAuthorName()); ?> "><?php echo $post->getAuthorName(); ?> </a></div> </div> <div class="post_footer clear"> <div class="post_vote"> <div class="vote_image"><a href="<?php echo $post->getFullPermalink() . "/Vote?vote=yes"; ?> ">sì</a></div> <div class="vote_image"><a href="<?php echo $post->getFullPermalink() . "/Vote?vote=no"; ?> ">no</a></div> Voto: <?php echo $post->getAvgVote(); ?> </div> <?php if (!isset($options[self::NO_TAGS]) || !$options[self::NO_TAGS]) { if (!is_null($post->getTags()) && trim($post->getTags()) != "") { ?> <div class="post_tags">Tag: <?php $first = true; $tags = explode(",", $post->getTags()); foreach ($tags as $tag) { if ($first) { $first = false; } else { echo ", "; } echo '<a href="' . FileManager::appendToRootPath('Tag/' . trim(Filter::decodeFilteredText($tag))) . '">' . trim(Filter::decodeFilteredText($tag)) . '</a>'; } ?> </div><?php } } if (!isset($options[self::NO_MODIF_DATE]) || !$options[self::NO_MODIF_DATE]) { ?> <div class="post_modificationDate">Ultima modifica: <?php echo format_datetime($post->getModificationDate()); ?> </div><?php } ?> </div><?php if (!isset($options[self::NO_COMMENTS]) || !$options[self::NO_COMMENTS]) { self::showComments($post); } ?> </div> <?php }