/** * This function removes whitespaces and html and php tags from string and of that containing just english letters, * return that, else returns false; * @param string $input * @return bool|string */ function english_string_corrector($input) { if (!is_valid_string($input)) { return false; } if (!($input = string_corrector($input))) { return false; } return $input; }
/** * Get all the comments or a set number of them for the current post. * If $post_id is NULL, all the posts will be retrieved, for all the posts, even the * comments that are set as spam or are not yet approved. * * @access public * @param int $post_id * @param int|string $num * @return array **/ public function get_comments($post_id = NULL, $num = 'ham') { if (!empty($post_id) && !is_valid_number($post_id)) { return NULL; } // if (is_int($num) || is_string($num)) // return NULL; // FIXME - Right now if I want to get 10 comments that are not spam I can't. Fix: I need to add a third optional parameter that gives the choice to retrieve only the ham (default), only the spam or all comments // get the comments $this->db->select('a.id, a.post_id, a.author_name, a.author_email, a.author_website, a.body, a.created_at, a.parent_id, a.is_spam, posts.title AS post_title'); // CHANGED - for some reason I was retrieving the title of the post the comment belongs to. $this->db->from('comments a'); $this->db->join('posts', 'a.post_id = posts.id', 'left'); if (is_valid_number($post_id)) { $this->db->where('a.post_id', $post_id); } if (is_valid_string($num)) { if ($num === 'spam') { $this->db->where('a.is_spam', 1); } else { $this->db->where('a.is_spam', 0); } } $this->db->order_by('a.created_at', 'desc'); if (is_valid_number($num)) { $this->db->limit($num); } $query = $this->db->get(); // count the number of comments $count = $query->num_rows(); // if there is any comments, return the list of comments and their count if ($count > 0) { $comments = $query->result(); if ($num === 'formatted') { $comments = $this->_format_comments_array($comments); } return array('list' => $query->result(), 'count' => $count, 'new_comments_array' => $comments); } // else return NULL return NULL; }
/** * Adds a new custom segment at the end of the breadcrumbs array * * @access public * @param string $title : the title of the segment * @param string $url : the url of the segment the segment is referring to * @param array $breadcrumbs : the breadcrumbs array. If set to NULL this method will just return one segment array without merging it to anything * @return array : the new breadcrumbs array with the custom segment at the end or just the segment array */ public function new_segment($title, $url, $breadcrumbs = NULL) { if (!is_valid_string($title) || !is_valid_ci_url($url) || !is_array($breadcrumbs) && $breadcrumbs !== NULL) { if ($breadcrumbs === NULL) { return NULL; } return $breadcrumbs; } $segment = array('title' => $title, 'url' => $url); $data = array(); if ($breadcrumbs !== NULL) { $data = $breadcrumbs; } array_push($data, $segment); return $data; }
$username = trim($_POST['username']); $password = trim($_POST['password']); $passwordv = trim($_POST['passwordv']); $realname = trim($_POST['realname']); $realname = ucwords($realname); $email = trim($_POST['email']); $email = strtolower($email); if (is_user($username)) { echo "<font class=\"tdmain\">User \"{$username}\" already exists</font><p>\n"; $username = ''; } elseif (is_valid_string($username)) { echo "<font class=\"tdmain\">Username contains bad characters</font><p>\n"; $username = ''; } elseif (is_valid_string($password)) { echo "<font class=\"tdmain\">Password contains bad characters</font><p>\n"; } elseif (is_valid_string($passwordv)) { echo "<font class=\"tdmain\">Password (Verify) contains bad characters</font><p>\n"; } elseif ($password != $passwordv) { echo "<font class=\"tdmain\">Passwords don't match</font><p>\n"; } elseif (is_valid_realname($realname)) { echo "<font class=\"tdmain\">Realname contains bad characters</font><p>\n"; $realname = ''; } elseif (is_valid_email($email)) { echo "<font class=\"tdmain\">E-Mail contains bad characters</font><p>\n"; $email = ''; } else { echo "<font class=\"tdmain\">User \"{$username}\" addedd successfuly<p>\n"; $userid = count($htpUser); $htpUser[$userid]['username'] = $username; $htpUser[$userid]['password'] = crypt_password($username, $password); $htpUser[$userid]['realname'] = $realname;
/** * Adds a new custom segment at the end of the breadcrumbs array * * @access public * @param string $title : the title of the segment * @param string $url : the url of the segment the segment is referring to * @param array $breadcrumbs : the breadcrumbs array. If set to NULL this method will just return one segment array without merging it to anything * @return array : the new breadcrumbs array with the custom segment at the end or just the segment array */ public function new_segment($title, $url, $breadcrumbs = array()) { if (!is_valid_string($title) && !is_valid_ci_url($url) && !is_valid_slug($url) && !is_valid_number($url) && !is_array($breadcrumbs) && !empty($breadcrumbs)) { if (!empty($breadcrumbs)) { return FALSE; } return $breadcrumbs; } if (!empty($breadcrumbs) && !is_valid_ci_url($url)) { $last = $breadcrumbs[count($breadcrumbs) - 1]['url']; $url = strip_trailing_slash($last) . '/' . $url; } $segment = array('title' => $title, 'url' => $url); $breadcrumbs[] = $segment; return $breadcrumbs; }