<commit_before><?php

/**
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class Launch extends CI_Controller {
 
	public function index()
	{
		show_404();
	}

	// this alias function should be removed once formhub has changed to using get_survey_url()
	public function launchSurvey(){
		//return call_user_func_array("get_survey_url", func_get_args());
		$this->load->helper('subdomain');
		$this->load->model('Survey_model', '', TRUE);
		$subdomain = get_subdomain();

		if (isset($subdomain))
		{
			show_404();
		}
		else 
		{
			extract($_POST);

			if (!empty($server_url) && strlen(trim($server_url)) > 1 && !empty($form_id) && strlen(trim($form_id)) > 1)
			{
				$server_url = trim($server_url);
				$form_id = trim($form_id);
				
				$submission_url = (strrpos($server_url, '/') === strlen($server_url)-1) ? 
					$server_url.'submission' :$server_url.'/submission';

				$data_url = (empty($data_url)) ? NULL : $data_url;
				$email = (empty($email)) ? NULL : $email;

				$result = $this->Survey_model->launch_survey($server_url, $form_id, $submission_url, $data_url, $email);

				echo json_encode($result);
			}	
			else
			{
				echo json_encode(array('success'=>FALSE, 'reason'=>'empty'));
			}
		}
	}

	public function get_survey_url()
	{
		$this->load->helper('subdomain');
		$this->load->model('Survey_model', '', TRUE);
		$subdomain = get_subdomain();

		if (isset($subdomain))
		{
			show_404();
		}
		else 
		{
			extract($_POST);

			if (!empty($server_url) && strlen(trim($server_url)) > 1 && !empty($form_id) && strlen(trim($form_id)) > 1)
			{
				$server_url = trim($server_url);
				$form_id = trim($form_id);
				
				$submission_url = (strrpos($server_url, '/') === strlen($server_url)-1) ? 
					$server_url.'submission' :$server_url.'/submission';

				$data_url = (empty($data_url)) ? NULL : $data_url;
				$email = (empty($email)) ? NULL : $email;

				$result = $this->Survey_model->launch_survey($server_url, $form_id, $submission_url, $data_url, $email);

				echo json_encode($result);
			}	
			else
			{
				echo json_encode(array('success'=>FALSE, 'reason'=>'empty'));
			}
		}
	}

	/**
	 * For now this function just cleans test entries in the surveys table. In the future,
	 * we could add removal of obsolete surveys (found to not be 'live' for extended period)
	 */
	public function clean()
	{
		$this->load->model('Survey_model', '', TRUE);
		$number_deleted = $this->Survey_model->remove_test_entries();
		echo $number_deleted.' test entries deleted.';
	}

}
?>
<commit_msg>attempt to alias get_survey_url function<commit_after><?php

/**
 * Copyright 2012 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

class Launch extends CI_Controller {
 
	public function index()
	{
		show_404();
	}

	// this alias function should be removed once formhub has changed to using get_survey_url()
	public function launchSurvey(){
		return call_user_func("get_survey_url");
	}

	public function get_survey_url()
	{
		$this->load->helper('subdomain');
		$this->load->model('Survey_model', '', TRUE);
		$subdomain = get_subdomain();

		if (isset($subdomain))
		{
			show_404();
		}
		else 
		{
			extract($_POST);

			if (!empty($server_url) && strlen(trim($server_url)) > 1 && !empty($form_id) && strlen(trim($form_id)) > 1)
			{
				$server_url = trim($server_url);
				$form_id = trim($form_id);
				
				$submission_url = (strrpos($server_url, '/') === strlen($server_url)-1) ? 
					$server_url.'submission' :$server_url.'/submission';

				$data_url = (empty($data_url)) ? NULL : $data_url;
				$email = (empty($email)) ? NULL : $email;

				$result = $this->Survey_model->launch_survey($server_url, $form_id, $submission_url, $data_url, $email);

				echo json_encode($result);
			}	
			else
			{
				echo json_encode(array('success'=>FALSE, 'reason'=>'empty'));
			}
		}
	}

	/**
	 * For now this function just cleans test entries in the surveys table. In the future,
	 * we could add removal of obsolete surveys (found to not be 'live' for extended period)
	 */
	public function clean()
	{
		$this->load->model('Survey_model', '', TRUE);
		$number_deleted = $this->Survey_model->remove_test_entries();
		echo $number_deleted.' test entries deleted.';
	}

}
?>

{'fraction_non_alphanumeric': 0.1507031546940327, 'fraction_numerical': 0.007601672367920942, 'mean_word_length': 3.914098972922502, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2486444', 'n_tokens_mistral': 1940, 'n_tokens_neox': 1695, 'n_words': 449}