<?php
/**
 * Created by PhpStorm.
 * User: zw
 * Date: 17-12-3
 * Time: 下午21:05
 */


if (!function_exists('create_editor')) {
    function create_editor($id, $value = '', $config = array())
    {
        include_once "../public/resource/lib/Ckeditor/ckeditor.php";
        $CKEditor = new CKEditor('http://' . $_SERVER['HTTP_HOST'] . '/resource/lib/Ckeditor/');
        $_config['filebrowserBrowseUrl'] = '/resource/lib/Ckfinder/ckfinder.html';

        $_config['filebrowserImageBrowseUrl'] = '/resource/lib/Ckfinder/ckfinder.html?Type=Images';
        if (!empty($config)) {
            $_config = array_merge($_config, $config);
        }
        $CKEditor->editor("describe", $value, $_config);
    }
}

/**
 * 检查手机号码
 *
 * @param $phone
 * @return bool
 */
function check_phone($phone){
    $preg_phone = '/^1[3456789]{1}\d{9}$/';

    if (preg_match($preg_phone, $phone)) {
        $result = true;
    } else {
        $result = false;
    }

    return $result;
}