<commit_before><?php
class PageDB extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

    function getMenuItems()
    {
              $this->db->select('name');
			  $this->db->order_by("ord", "asc");
			  $this->db->where('status', 1); 
			  $query = $this->db->get('pages');
			  return $query;
    }
	
	function getAllMenuItems()
    {
              $data = $this->db->query("SELECT name FROM pages");
              return $data;
    }
	
	function is_closed($page)
	{
		$page = mysql_real_escape_string($page);
		$page = str_replace('_', ' ', $page);
		$data = $this->db->query("SELECT status FROM pages WHERE name='$page'");
		if($data->row('status') == 3){
			return true;
		}
	}
	
    function getPageContent($page)
    {        
			 $page = mysql_real_escape_string($page);
		     $page = str_replace('_', ' ', $page);
             $data = $this->db->query("SELECT content FROM pages WHERE name='$page'");
             return $data->row('content');
    }
	
    function getWidgets()
    {
              $this->db->select('*');
			  $this->db->order_by("ord", "asc");
			  $query = $this->db->get('widgets');
			  return $query;
    }
	
	function getPageData($page)
	{
			$page = mysql_real_escape_string($page);
			$page = str_replace('_',' ', $page);
			$data = $this->db->query("SELECT * FROM pages WHERE name='$page'");
			return $data;
	}
	
	function deletePage($page)
	{
			$page = mysql_real_escape_string($page);
			if($page == 'start'){
				show_error('<p>You may not delete the start page.</p><br /><a href="admin"><input type="buton" value="Back"></a>');
			}
			$page = mysql_real_escape_string($page);
			$page = str_replace('_', ' ', $page);
			$this->db->query("DELETE FROM pages WHERE name='$page'");
	}
	
	function addPage($page)
	{
			$page = htmlentities(mysql_real_escape_string($page));
			$this->db->query("INSERT INTO pages (`id`, `name`, `content`, `ord`, `status`) VALUES (NULL, '$page', '<p>Page content</p>', '10', '1');");
	}
	
	function page_exists($page)
	{
			$page = mysql_real_escape_string($page);
			$page = str_replace('_',' ',$page);
			$query = $this->db->query("SELECT id FROM pages WHERE name='$page'");
			if($query->num_rows() == 0){
				return false;
			}else{
				return true;
			}
	}<commit_msg>Can no longer add pages with names that already exists<commit_after><?php
class PageDB extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }

    function getMenuItems()
    {
              $this->db->select('name');
			  $this->db->order_by("ord", "asc");
			  $this->db->where('status', 1); 
			  $query = $this->db->get('pages');
			  return $query;
    }
	
	function getAllMenuItems()
    {
              $data = $this->db->query("SELECT name FROM pages");
              return $data;
    }
	
	function is_closed($page)
	{
		$page = mysql_real_escape_string($page);
		$page = str_replace('_', ' ', $page);
		$data = $this->db->query("SELECT status FROM pages WHERE name='$page'");
		if($data->row('status') == 3){
			return true;
		}
	}
	
    function getPageContent($page)
    {        
			 $page = mysql_real_escape_string($page);
		     $page = str_replace('_', ' ', $page);
             $data = $this->db->query("SELECT content FROM pages WHERE name='$page'");
             return $data->row('content');
    }
	
    function getWidgets()
    {
              $this->db->select('*');
			  $this->db->order_by("ord", "asc");
			  $query = $this->db->get('widgets');
			  return $query;
    }
	
	function getPageData($page)
	{
			$page = mysql_real_escape_string($page);
			$page = str_replace('_',' ', $page);
			$data = $this->db->query("SELECT * FROM pages WHERE name='$page'");
			return $data;
	}
	
	function deletePage($page)
	{
			$page = mysql_real_escape_string($page);
			if($page == 'start'){
				show_error('<p>You may not delete the start page.</p><br /><a href="admin"><input type="buton" value="Back"></a>');
			}
			$page = mysql_real_escape_string($page);
			$page = str_replace('_', ' ', $page);
			$this->db->query("DELETE FROM pages WHERE name='$page'");
	}
	
	function addPage($page)
	{
			if($this->page_exists($page)){
				return false;
			}
			$page = htmlentities(mysql_real_escape_string($page));
			$this->db->query("INSERT INTO pages (`id`, `name`, `content`, `ord`, `status`) VALUES (NULL, '$page', '<p>Page content</p>', '10', '1');");
	}
	
	function page_exists($page)
	{
			$page = mysql_real_escape_string($page);
			$page = str_replace('_',' ',$page);
			$query = $this->db->query("SELECT id FROM pages WHERE name='$page'");
			if($query->num_rows() == 0){
				return false;
			}else{
				return true;
			}
	}
{'fraction_non_alphanumeric': 0.2015852613538989, 'fraction_numerical': 0.002570694087403599, 'mean_word_length': 3.1064204045734387, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 82, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6248077', 'n_tokens_mistral': 1771, 'n_tokens_neox': 1556, 'n_words': 318}