<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Test extends CI_Controller
{

    function __construct()
    {
        parent::__construct();
        $this->load->model('feedback_model');
        $this->load->model('Information_model');

    }

    // https://cht.mycht.cn/info.php/test/feedback/?tag=%3Chtml%3E%3Cdiv%3E%3C!--%40FEEDBACK_Shanghai%40--%3E%3C%2Fdiv%3E%3C%2Fhtml%3E
    public function feedback()
    {
        $tag = $this->input->get_post('tag');
        $template_path = 'mobile_first/ch';


        $feedback_array = array();
        preg_match_all('^<!--@FEEDBACK_(.*)@-->^', $tag, $feedback_array);
        if (!empty($feedback_array)) {
            foreach ($feedback_array[0] as $index => $tag_name) {
                $city_name = $feedback_array[1][$index];
                echo 'city_name: '.$city_name.'<br>';
                echo 'tag_name: '.htmlentities($tag_name).'<br>';
                echo 'feedback_data: <br>';
                $feedback_data = $this->feedback_model->get_feedback_by_city($city_name);
                var_dump($feedback_data);
                $feedback_content = $this->load->view(
                    $template_path . '-feedback',
                    array('feedback_data' => $feedback_data),
                    true);
                echo $feedback_content;
            }
        }
    }

   
}
