function cw_is_survey_result_empty($data)
{
    if (is_array($data)) {
        foreach ($data as $_data) {
            if (!cw_is_survey_result_empty($_data)) {
                return false;
            }
        }
    } else {
        $data = trim($data);
        if (!empty($data)) {
            return false;
        }
    }
    # survey result is empty
    return true;
}
 }
 $page = 'on_surveys';
 if ($addons['image_verification'] && $show_antibot_arr[$page] == 'Y') {
     if (isset($antibot_input_str) && !empty($antibot_input_str)) {
         $antibot_err = cw_validate_image($antibot_validation_val[$page], $antibot_input_str);
     } else {
         $antibot_err = true;
     }
     if ($antibot_err) {
         $top_message['type'] = "E";
         $top_message['content'] = cw_get_langvar_by_name("msg_err_antibot");
         cw_header_location("index.php?target={$target}&survey_id=" . $survey_id);
     }
 }
 # Check if survey results is empty
 if (cw_is_survey_result_empty($data) || !is_array($data)) {
     $top_message['type'] = 'W';
     $top_message['content'] = cw_get_langvar_by_name("txt_survey_is_empty_message");
     cw_header_location("index.php?target={$target}&survey_id={$survey_id}");
 }
 # Save common data
 $query_data = array('survey_id' => $survey_id, 'date' => cw_core_get_time(), 'ip' => $CLIENT_IP, 'customer_id' => $fill_customer_id, 'code' => $current_language, 'from_mail' => empty($fill_user) ? "N" : "Y", 'as_result' => empty($fill_user) ? "" : $fill_user['as_result']);
 $survey_result_id = cw_array2insert("survey_results", $query_data);
 $quids = cw_query_hash("SELECT question_id, answers_type FROM {$tables['survey_questions']} WHERE survey_id = '{$survey_id}'", 'question_id', false);
 foreach ($data as $qid => $v) {
     $question = $quids[$qid];
     if (!$question) {
         continue;
     }
     $query_data = array('survey_result_id' => $survey_result_id, 'question_id' => $qid);
     if ($question['answers_type'] == 'N') {