<commit_before><?php

class Main extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('meme_model');
    }

    public function index() {
        $this->hot();
    }

    public function hot($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_hot_memes($from, $amount+1), "Hot", 'hot', $from, $amount);
    }

    public function top($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_top_memes($from, $amount+1), "Top", 'top', $from, $amount);
    }

    public function new_memes($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_new_memes($from, $amount+1), "New", 'new', $from, $amount);
    }

    public function newest() {
        if ($this->input->method(false) !== 'post') {
            show_404();
        }

        $last_meme = $this->input->post('lastMeme');

        if (!isset($last_meme)) {
            show_404();
        }

        $last_meme_date = $this->meme_model->retrieve(intval($last_meme))->Date;
        $new_memes = $this->meme_model->get_newer_than($last_meme_date);

        if (count($new_memes) > 0) {
            $this->load->view("pages/meme_xml", array('memes' => $new_memes));
        }
    }

    public function getMemesXML() {
      $type = $_REQUEST["type"];
		  $from = $_REQUEST["from"];
      $amount = $_REQUEST["amount"];

      if ($type === "new") {
        $this->_display_ajax_memes( $this->meme_model->get_new_memes($from, $amount), 'new', $from, $amount);
      } else if ($type === "top") {
        $this->_display_ajax_memes( $this->meme_model->get_top_memes($from, $amount), 'top', $from, $amount);
      } else if ($type === "hot") {
        $this->_display_ajax_memes( $this->meme_model->get_hot_memes($from, $amount), 'hot', $from, $amount);
      }
    }

    private function _display_ajax_memes($memes, $selection, $from, $amount) {
      if (count($memes) === 0) {
        echo "null";
        exit;<commit_msg>added default values for /main/getMemesXML parameters<commit_after><?php

class Main extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('meme_model');
    }

    public function index() {
        $this->hot();
    }

    public function hot($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_hot_memes($from, $amount+1), "Hot", 'hot', $from, $amount);
    }

    public function top($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_top_memes($from, $amount+1), "Top", 'top', $from, $amount);
    }

    public function new_memes($from = 0, $amount = 5) {
      $this->_display_memes($this->meme_model->get_new_memes($from, $amount+1), "New", 'new', $from, $amount);
    }

    public function newest() {
        if ($this->input->method(false) !== 'post') {
            show_404();
        }

        $last_meme = $this->input->post('lastMeme');

        if (!isset($last_meme)) {
            show_404();
        }

        $last_meme_date = $this->meme_model->retrieve(intval($last_meme))->Date;
        $new_memes = $this->meme_model->get_newer_than($last_meme_date);

        if (count($new_memes) > 0) {
            $this->load->view("pages/meme_xml", array('memes' => $new_memes));
        }
    }

    public function getMemesXML() {
      $type = isset($_REQUEST["type"]) ? $_REQUEST["type"] : 'hot';
		  $from = isset($_REQUEST["from"]) ? $_REQUEST["from"] : 0;
      $amount = isset($_REQUEST["amount"]) ? $_REQUEST["amount"] : 5;

      if ($type === "new") {
        $this->_display_ajax_memes( $this->meme_model->get_new_memes($from, $amount), 'new', $from, $amount);
      } else if ($type === "top") {
        $this->_display_ajax_memes( $this->meme_model->get_top_memes($from, $amount), 'top', $from, $amount);
      } else if ($type === "hot") {
        $this->_display_ajax_memes( $this->meme_model->get_hot_memes($from, $amount), 'hot', $from, $amount);
      }
    }

    private function _display_ajax_memes($memes, $selection, $from, $amount) {
      if (count($memes) === 0) {
        echo "null";
        exit;
{'fraction_non_alphanumeric': 0.19549052530582875, 'fraction_numerical': 0.008635164307987527, 'mean_word_length': 3.001919385796545, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3606123', 'n_tokens_mistral': 1481, 'n_tokens_neox': 1428, 'n_words': 254}