/**
  * @author Gaetan SENELLE
  * @return Response
  */
 public function render()
 {
     $response = new Response();
     $exception = $this->error;
     $code = $this->_code($exception);
     $message = $this->_message($exception, $code);
     $url = $this->controller->request->here();
     $isDebug = Configure::read('debug');
     $response->statusCode($code);
     if (method_exists($exception, 'responseHeader')) {
         $this->controller->response->header($exception->responseHeader());
     }
     $classname = get_class($exception);
     if (preg_match('@\\\\([\\w]+)$@', $classname, $matches)) {
         $classname = $matches[1];
     } else {
         $classname = null;
     }
     if (!$isDebug && !$exception instanceof ApiException && !$exception instanceof HttpException) {
         $classname = null;
     }
     $data = ['exception' => ['type' => $classname, 'message' => $message, 'url' => h($url), 'code' => $code], 'success' => false];
     $response->body(json_encode($data));
     $response->type('json');
     return $response;
 }
Example #2
1
 public function get_headline()
 {
     //$cache = get_cache_function( $this->steam_user->get_id() );
     $headline = array();
     if (PLATFORM_ID == "bid") {
         $user_url = PATH_URL . "home/";
     } else {
         $user_url = PATH_URL . "profile/";
     }
     $user_name = h($this->steam_user->get_name());
     $headline[] = array("name" => h($this->steam_user->get_full_name()), "link" => $user_url);
     if (is_string($context = $this->get_context())) {
         switch ($context) {
             case "profile":
                 $headline[] = array("name" => gettext("Profile"), "link" => "");
                 break;
             case "documents":
                 $headline[] = array("name" => gettext("Documents"), "link" => "");
                 break;
             case "communication":
                 $headline[] = array("name" => gettext("Communication"), "link" => "");
                 break;
             case "groups":
                 $headline[] = array("name" => gettext("Groups"), "link" => "");
                 break;
             case "contacts":
                 $headline[] = array("name" => gettext("Contacts"), "link" => "");
                 break;
         }
     }
     return $headline;
 }
Example #3
0
 /**
  * Returns a flag for a passed country/region
  */
 public function getFlagIcon($region, $filePathOnly = false)
 {
     $val = \Core::make('helper/validation/strings');
     if ($val->alphanum($region, false, true)) {
         $region = h(strtolower($region));
     } else {
         $region = false;
     }
     if ($region) {
         $v = \View::getInstance();
         if ($v->getThemeDirectory() != '' && file_exists($v->getThemeDirectory() . '/' . DIRNAME_IMAGES . '/' . DIRNAME_IMAGES_LANGUAGES . '/' . $region . '.png')) {
             $icon = $v->getThemePath() . '/' . DIRNAME_IMAGES . '/' . DIRNAME_IMAGES_LANGUAGES . '/' . $region . '.png';
         } elseif (file_exists(DIR_APPLICATION . '/' . DIRNAME_IMAGES . '/' . DIRNAME_IMAGES_LANGUAGES . '/' . $region . '.png')) {
             $icon = REL_DIR_APPLICATION . '/' . DIRNAME_IMAGES . '/' . DIRNAME_IMAGES_LANGUAGES . '/' . $region . '.png';
         } else {
             $icon = ASSETS_URL . '/' . DIRNAME_IMAGES . '/' . DIRNAME_IMAGES_LANGUAGES . '/' . $region . '.png';
         }
         if (isset($icon)) {
             if ($filePathOnly) {
                 return $icon;
             } else {
                 return '<img class="ccm-region-flag img-responsive" id="ccm-region-flag-' . $region . '" src="' . $icon . '" alt="' . $region . '" />';
             }
         }
     }
 }
Example #4
0
 function ElemInit()
 {
     $id = (int) get('id', 0);
     $root_id = domainRootID();
     if ($id) {
         // если нет своего value, то вывести value из языка по умолчанию
         # получаем данные по id
         $row = sql_getRow('SELECT id,module,name,def,value FROM strings WHERE id=' . $id);
         if (!$row['value'] || !$row['def']) {
             # получаем данные для такого module, name
             $temp_row = sql_getRow('SELECT * FROM strings WHERE module="' . $row['module'] . '" AND name="' . $row['name'] . '" AND lang="' . LANG_DEFAULT . '" AND root_id=' . getMainRootID());
             if ($temp_row) {
                 if ($temp_row['value']) {
                     $row['value'] = $temp_row['value'];
                 }
                 if ($temp_row['def']) {
                     $row['def'] = $temp_row['def'];
                 }
             }
         }
         $this->elem_fields['columns']['value']['value'] = h($row['value']);
         $this->elem_fields['columns']['def'] = array('type' => 'hidden', 'value' => h($row['def']));
     }
     $this->elem_fields['columns']['root_id'] = array('type' => 'select', 'func' => 'getRoots');
     if (!$id && $root_id) {
         $this->elem_fields['columns']['root_id']['value'] = $root_id;
     }
     $this->elem_fields['columns']['lang'] = array('type' => 'hidden');
     if (!$id) {
         $this->elem_fields['columns']['lang']['value'] = '';
     }
     return parent::ElemInit();
 }
Example #5
0
 private static function parse_conf(&$setting_config)
 {
     $nc_config = $GLOBALS['config'];
     if (is_array($nc_config['db']['slave']) && !empty($nc_config['db']['slave'])) {
         $dbslave = $nc_config['db']['slave'];
         $sid = array_rand($dbslave);
         $nc_config['db']['read'] = $dbslave[$sid];
     } else {
         $nc_config['db']['read'] = $nc_config['db'][1];
     }
     $nc_config['db']['write'] = $nc_config['db'][1];
     $setting_config = $nc_config;
     $setting = ($setting = f("setting")) ? $setting : h("setting", TRUE, "file");
     if ($nc_config['thumb']['save_type'] == 1) {
         $nc_config['thumb_url'] = SiteUrl;
     } else {
         if ($nc_config['thumb']['save_type'] == 2 && preg_match("/^http:\\/\\/[\\.\\-\\w]+/", $nc_config['thumb']['url'])) {
             $nc_config['thumb_url'] = $nc_config['thumb']['url'];
         } else {
             if ($nc_config['thumb']['save_type'] == 3 && $setting['ftp_open']) {
                 $nc_config['thumb_url'] = $setting['ftp_access_url'];
             } else {
                 $nc_config['thumb_url'] = SiteUrl;
             }
         }
     }
     $setting_config = array_merge_recursive($setting, $nc_config);
 }
Example #6
0
 public function weibo()
 {
     // 解析参数
     $_REQUEST['param'] = unserialize(urldecode($_REQUEST['param']));
     $active_field = $_REQUEST['param']['active_field'] == 'title' ? 'title' : 'body';
     $this->assign('has_status', $_REQUEST['param']['has_status']);
     $this->assign('is_success_status', $_REQUEST['param']['is_success_status']);
     $this->assign('status_title', t($_REQUEST['param']['status_title']));
     // 解析模板(统一使用模板的body字段)
     $_REQUEST['data'] = unserialize(urldecode($_REQUEST['data']));
     $content = model('Template')->parseTemplate(t($_REQUEST['tpl_name']), array($active_field => $_REQUEST['data']));
     // 设置微博发布框的权限
     $type = array('at', 'image', 'video', 'file', 'contribute');
     $actions = array();
     foreach ($type as $value) {
         $actions[$value] = false;
     }
     $this->assign('actions', $actions);
     $this->assign('title', $content['title']);
     $this->assign('initHtml', $content['body']);
     $this->assign('content', h($content[$active_field]));
     $this->assign('source', $_REQUEST['data']['source']);
     $this->assign('sourceUrl', $_REQUEST['data']['url']);
     $this->assign('type', $_REQUEST['data']['type']);
     $this->assign('type_data', $_REQUEST['data']['type_data']);
     $this->assign('button_title', t(urldecode($_REQUEST['button_title'])));
     $this->assign('addon_info', urldecode($_REQUEST['addon_info']));
     $this->display();
 }
Example #7
0
 public function __construct()
 {
     Language::read("common");
     Language::read("microshop");
     if (c("microshop_isuse") != "1") {
         header("location: " . SiteUrl);
         exit;
     }
     Tpl::setdir("default");
     self::cp();
     Tpl::setlayout("microshop_layout");
     if ($_GET['column'] && strtoupper(CHARSET) == "GBK") {
         $GLOBALS['_GET'] = Language::getgbk($_GET);
     }
     Tpl::output("nav_list", ($nav = f("nav")) ? $nav : h("nav", TRUE, "file"));
     $search_type = array();
     $search_type['goods'] = Language::get("nc_microshop_goods");
     $search_type['personal'] = Language::get("nc_microshop_personal");
     $search_type['store'] = Language::get("nc_microshop_store");
     Tpl::output("search_type", $search_type);
     if (!empty($_SESSION['member_id']) || 0 < intval($_SESSION['member_id'])) {
         self::get_member_avatar($_SESSION['member_id']);
     }
     if (!c("site_status")) {
         halt(c("closed_reason"));
     }
     Tpl::output("html_title", Language::get("nc_microshop") . "-" . c("site_name"));
     Tpl::output("seo_keywords", c("microshop_seo_keywords"));
     Tpl::output("seo_description", c("microshop_seo_description"));
     $this->queryCart();
 }
    function render()
    {
        //路径
        $baseDir = $this->_context->get('base_dir', $this->_context->baseDir() . 'js/fckeditor/');
        $baseDir = h(rtrim($baseDir, '/\\') . '/');
        $width = $this->get('width', "100%");
        $height = $this->get('height', "250px");
        $value = $this->get('value', '');
        $class = $this->get('class', '');
        //控件的id
        $id = $this->id();
        $config = $this->get('config');
        if (!is_array($config)) {
            $config = array();
        }
        $out = Q::control('memo', $id, array('value' => $value, 'class' => $class))->render();
        $out .= <<<EOT
\t<script type="text/javascript" src="{$baseDir}fckeditor.js"></script>
<script type="text/javascript">
var oFCKeditor = new FCKeditor('{$id}');
oFCKeditor.BasePath = "{$baseDir}";
oFCKeditor.Height="{$height}";
oFCKeditor.Width="{$width}";
oFCKeditor.ReplaceTextarea();
</script>\t
EOT;
        return $out;
    }
function auth_error($exception = null)
{
    global $connection, $adminer, $token;
    $session_name = session_name();
    $error = "";
    if (!$_COOKIE[$session_name] && $_GET[$session_name] && ini_bool("session.use_only_cookies")) {
        $error = lang('Session support must be enabled.');
    } elseif (isset($_GET["username"])) {
        if (($_COOKIE[$session_name] || $_GET[$session_name]) && !$token) {
            $error = lang('Session expired, please login again.');
        } else {
            $password =& get_session("pwds");
            if (isset($password)) {
                $error = h($exception ? $exception->getMessage() : (is_string($connection) ? $connection : lang('Invalid credentials.')));
                $password = null;
            }
        }
    }
    page_header(lang('Login'), $error, null);
    echo "<form action='' method='post' onclick='eventStop(event);'>\n";
    $adminer->loginForm();
    echo "<div>";
    hidden_fields($_POST, array("driver", "server", "username", "password", "permanent"));
    // expired session
    echo "</div>\n";
    echo "</form>\n";
    page_footer("auth");
}
 function checklogin()
 {
     $strVerify = h($_POST['verify']);
     if (md5($strVerify) != $_SESSION['verify']) {
         $this->error('验证码错误');
         exit;
     }
     if ($this->uid) {
         $map['id'] = $this->uid;
     } else {
         $map['email'] = h($_POST['account']);
     }
     $map['passwd'] = md5($_POST['password']);
     $pUser = D('User');
     $user = $pUser->where($map)->field("id,name,active,admin_level")->find();
     if ($user) {
         //登陆成功
         $_SESSION["userInfo"] = serialize($user);
         Session::set('ThinkSnSAdmin', $user['id']);
         $this->assign('jumpUrl', U('Index/index'));
         $this->success('登陆成功');
     } else {
         $this->error('登陆失败');
     }
 }
Example #11
0
 public function toHTML()
 {
     // change to facilitate lists
     $id = 'search_' . $this->fieldname;
     $name = 'Search[' . $this->fieldname . ']';
     if (count($this->options) > get_config('AUTOCOMPLETE_SELECT_LIMIT')) {
         $html = '';
         $selected = $this->value;
         if (empty($selected)) {
             $selected = $this->default;
         }
         $html .= '<input type="hidden" name="' . $name . '" id="' . $id . '" value="' . $selected . '" />';
         $text_value = isset($this->options[$selected]) ? $this->options[$selected] : '';
         $html .= '<input alt="Autocomplete enabled" type="text" id="' . $id . '_text" value="' . $text_value . '" class="uz-autocomplete  ui-autocomplete-input icon slim" data-id="' . $id . '" data-action="array"  />';
         $html .= '<script type="text/javascript">' . 'var ' . $id . '=' . json_encode(dataObject::toJSONArray($this->options)) . '</script>';
     } else {
         $html = '<select id="' . $id . '" name="' . $name . '">';
         foreach ($this->options as $val => $opt) {
             $selected = '';
             if ($this->value === "{$val}" || is_null($this->value) && $this->default === "{$val}") {
                 $selected = 'selected="selected"';
             }
             $html .= '<option value="' . $val . '" ' . $selected . '>' . h(prettify($opt)) . '</option>';
         }
         $html .= '</select></li>';
     }
     return $this->labelHTML() . $html;
 }
 /**
  * 保存公告数据
  * @param array $data 公告相关数据
  * @return boolean|integer 若成功返回公告ID,失败返回false
  */
 public function saveArticle($data)
 {
     // 处理数据
     $add['uid'] = $save['uid'] = $GLOBALS['ts']['mid'];
     $add['title'] = $save['title'] = t($data['title']);
     $add['content'] = $save['content'] = h($data['content']);
     $add['attach'] = $save['attach'] = trim(t($data['attach_ids']), '|');
     // 附件ID
     $add['mtime'] = $save['mtime'] = time();
     $add['type'] = $save['type'] = intval($data['type']);
     if (empty($add['title'])) {
         $this->error = L('PUBLIC_COMMENT_MAIL_TITLE');
         // 标题不可为空
         return false;
     }
     if (empty($add['content'])) {
         $this->error = L('PUBLIC_COMMENT_MAIL_REQUIRED');
         // 内容不可为空
         return false;
     }
     if (!empty($data['id'])) {
         // 编辑操作
         $map['id'] = $data['id'];
         return $this->where($map)->save($save);
     } else {
         // 添加操作
         if ($id = $this->add($add)) {
             $edit['sort'] = $id;
             return $this->where('id=' . $id)->save($edit);
         }
     }
 }
 /**
  * Create link containing a Font Awesome icon.
  *
  * @param string $icon Font Awesome icon (excluding the fa- prefix)
  * @param string $title Link text
  * @param string|array $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
  * @param array $options Array of options and HTML attributes.
  * @param string $confirmMessage JavaScript confirmation message.
  * @return string An `<a />` element.
  */
 public function link($icon, $title, $url = null, $options = array(), $confirmMessage = false)
 {
     $escapeTitle = true;
     if (isset($options['escapeTitle'])) {
         $escapeTitle = $options['escapeTitle'];
         unset($options['escapeTitle']);
     } elseif (isset($options['escape'])) {
         $escapeTitle = $options['escape'];
     }
     if ($escapeTitle === true) {
         $title = h($title);
     } elseif (is_string($escapeTitle)) {
         $title = htmlentities($title, ENT_QUOTES, $escapeTitle);
     }
     // Determine whether to include a space between the icon and title.
     $space = isset($options['space']) && $options['space'] === false ? '' : ' ';
     // Append/Prepend the Font Awesome icon.
     if (empty($title)) {
         $title = '<i class="fa fa-' . $icon . '"></i>';
     } elseif (empty($options['before'])) {
         $title .= $space . '<i class="fa fa-' . $icon . '"></i>';
     } else {
         $title = '<i class="fa fa-' . $icon . '"></i>' . $space . $title;
     }
     unset($options['before']);
     $options['escape'] = false;
     return $this->Html->link($title, $url, $options, $confirmMessage);
 }
Example #14
0
 function pagesList($type)
 {
     global $self, $PG_DIR;
     $list = array();
     $dir = opendir($PG_DIR);
     while ($file = readdir($dir)) {
         if (preg_match("/\\.txt\$/", $file)) {
             $files[] = substr($file, 0, strlen($file) - 4);
         }
     }
     if (is_array($files)) {
         sort($files);
         foreach ($files as $file) {
             $list[] = "<a href=\"{$self}?page=" . u($file) . "\">" . h($file) . "</a>";
         }
     }
     if ($type == "comma") {
         $ret = implode(", ", $list);
     } else {
         if ($type == "list") {
             $ret = "<ul><li>" . implode("</li><li>", $list) . "</li></ul>";
         }
     }
     return $ret;
 }
Example #15
0
	public function view($page = 0) {
		$list = new LogList();
        $this->requireAsset('select2');
        $levels = array();
        foreach(Log::getLevels() as $level) {
            $levels[$level] = Log::getLevelDisplayName($level);
        }
        $this->set('levels', $levels);
        $channels = array('' => t('All Channels'));
        foreach(Log::getChannels() as $channel) {
            $channels[$channel] = Log::getChannelDisplayName($channel);
        }
        $r = Request::getInstance();
        if ($r->query->has('channel') && $r->query->get('channel') != '') {
            $list->filterByChannel($r->query->get('channel'));
            $this->set('selectedChannel', h($r->query->get('channel')));
        }
        if ($r->query->has('level')) {
            $selectedlevels = $r->get('level');
            if (is_array($selectedlevels) && count($selectedlevels) != 8) {
                $list->filterByLevels($selectedlevels);
            }
        }
        if ($r->query->has('keywords') && $r->query->get('keywords') != '') {
            $list->filterByKeywords($r->query->get('keywords'));
        }

        $entries = $list->getPage();
        $this->set('list', $list);
        $this->set('entries', $entries);

        $this->set('levels', $levels);
        $this->set('channels', $channels);

       }
Example #16
0
 public function url($url, $full = false)
 {
     if (is_string($url) && preg_match(sprintf('/^%s.+/', preg_quote('//', '/')), $url)) {
         return h($url);
     }
     return parent::url($url, $full);
 }
Example #17
0
 /**
  * Creates form fields and JavaScript includes to add a color picker widget.
  * <code>
  *     $dh->output('background-color', '#f00');
  * </code>
  * @param string $inputName
  * @param value  $string
  * @param array  $options
  */
 public function output($inputName, $value = null, $options = array())
 {
     $view = View::getInstance();
     $view->requireAsset('core/colorpicker');
     $form = Loader::helper('form');
     $r = Request::getInstance();
     if ($r->request->has($inputName)) {
         $value = h($r->request->get($inputName));
     }
     $strOptions = '';
     $i = 0;
     $defaults = array();
     $defaults['value'] = $value;
     $defaults['className'] = 'ccm-widget-colorpicker';
     $defaults['showInitial'] = true;
     $defaults['showInput'] = true;
     $defaults['allowEmpty'] = true;
     $defaults['cancelText'] = t('Cancel');
     $defaults['chooseText'] = t('Choose');
     $defaults['preferredFormat'] = 'rgb';
     $defaults['showAlpha'] = false;
     $defaults['clearText'] = t('Clear Color Selection');
     $defaults['appendTo'] = '.ui-dialog';
     $strOptions = json_encode(array_merge($defaults, $options));
     $identifier = new \Concrete\Core\Utility\Service\Identifier();
     $identifier = $identifier->getString(32);
     print "<input type=\"text\" data-color-picker=\"{$identifier}\" name=\"{$inputName}\" value=\"{$value}\" id=\"ccm-colorpicker-{$inputName}\" />";
     print "<script type=\"text/javascript\">";
     print "\$(function () { \$('[data-color-picker={$identifier}]').spectrum({$strOptions}); })";
     print "</script>";
 }
 function _initialize()
 {
     if (!is_numeric($_GET['uid']) && is_string($_GET['uid'])) {
         $domainuser = D('User')->getUserByIdentifier(h($_GET['uid']), 'domain');
         if ($domainuser) {
             $this->uid = $domainuser['uid'];
             $this->assign('uid', $this->uid);
         } else {
             $this->error(L('user_not_exist'));
         }
     } else {
         $this->assign('uid', intval($_GET['uid']));
     }
     if ('detail' != ACTION_NAME) {
         $user_info = D('User')->getUserByIdentifier($this->uid);
         if ($user_info) {
             $userinfo = array('Địa chỉ mblog' => U('home/Space/index', array('uid' => $user_info['domain'] ? $user_info['domain'] : $this->uid)), 'Giới tính' => getSex($user_info['sex']), 'Nơi sống' => $user_info['location']);
             // 基本信息-钩子
             Addons::hook('home_space_profile_base', array('uid' => $this->uid, 'user_info' => &$userinfo));
             $this->assign('userinfo', $userinfo);
         } else {
             $this->error(L('user_not_exist'));
         }
         $this->__getSpaceCount($this->uid);
     }
 }
 public function doshorturl()
 {
     $data['shorturl_type'] = $_POST['shorturl_type'];
     $data['customize_url'] = h($_POST['customize_url']);
     model('Xdata')->lput('shorturl', $data);
     $this->redirect('admin/Plugin/shorturl');
 }
 /**
  * 实现接口
  *
  */
 function render()
 {
     //得到子菜单的标题
     $menu_title = $this->_extract('menu');
     //的到子菜单的属性
     $sub_menu = Q::ini('appini/admin_sub_menus/' . $menu_title);
     //是否存在
     if (!is_array($sub_menu)) {
         $sub_menu = array();
     }
     //得到当前的属性
     $currentmenu = $this->_extract('current');
     //输出子菜单 如果是当前的加上css
     $out = "<ul>\n";
     foreach ($sub_menu as $menu) {
         //是否是当前菜单
         if ($menu['title'] == $currentmenu) {
             $out .= "<li class=\"current\">";
         } else {
             $out .= "<li>";
         }
         $out .= '<a href="' . url($menu['udi']) . '"> <span>';
         $out .= h($menu['title']) . '</span>';
         $out .= "</a></li>\n";
     }
     $out .= "</ul>\n";
     return $out;
 }
Example #21
0
 function column_content($column, $issue)
 {
     switch ($column) {
         case 'subject':
             return $this->Html->link($issue['Issue']['subject'], array('controller' => 'issues', 'action' => 'show', 'id' => $issue['Issue']['id']));
         case 'author':
             return $this->Candy->format_username($issue['Author']);
         case 'tracker':
             return h($issue['Tracker']['name']);
         case 'status':
             return h($issue['Status']['name']);
         case 'priority':
             return h($issue['Priority']['name']);
         case 'assigned_to':
             return strlen($issue['Issue']['assigned_to_id']) ? $this->Candy->format_username($issue['AssignedTo']) : '';
         case 'updated_on':
             return $this->Candy->format_time($issue['Issue']['updated_on']);
         case 'category':
             return $issue['Category']['name'];
         case 'fixed_version':
             return $this->Candy->link_to_version($issue['FixedVersion']);
         case 'start_date':
             return $this->Candy->format_date($issue['Issue']['start_date']);
         case 'due_date':
             return $this->Candy->format_date($issue['Issue']['start_date']);
         case 'estimated_hours':
             return sprintf(__('%.2f hour', true), $issue['Issue']['estimated_hours']);
         case 'done_ratio':
             return $this->Candy->progress_bar($issue['Issue']['done_ratio'], array('width' => '80px', 'legend' => $issue['Issue']['done_ratio'] . '%'));
         case 'created_on':
             return $this->Candy->format_date($issue['Issue']['created_on']);
         default:
             return $column;
     }
 }
 public static function getBody()
 {
     $result = '';
     foreach (self::$data as $title => $data) {
         $result .= '<table border="1" style="width:90%; background:#eee; font-size:12px; color:#222; text-align:left; border-collapse:collapse;">';
         // head line
         if (is_array($data['meta']) && count($data['meta'])) {
             $result .= '<tr>';
             foreach ($data['meta'] as $cell) {
                 $result .= '<th style="background:#bdb; padding:7px;">' . h($cell) . '</th>';
             }
             $result .= '</tr>';
         }
         // information lines
         if (is_array($data['data']) && count($data['data'])) {
             foreach ($data['data'] as $row) {
                 $result .= '<tr>';
                 foreach ($row as $cell) {
                     $result .= '<td style="padding:7px;">' . h($cell) . '</td>';
                 }
                 $result .= '</tr>';
             }
         }
         $result .= '</table>';
     }
     return '<div style="clear:both;"></div>' . $result;
 }
Example #23
0
 function ckeditor($fieldName, $options = array())
 {
     //CakePHP 1.2.4.8284
     $options = $this->_initInputField($fieldName, $options);
     //If you have probelms, try adding a second underscore to _initInputField.  I haven't tested this, but some commenters say it works.
     //$options = $this->__initInputField($fieldName, $options);
     $value = null;
     $config = null;
     $events = null;
     if (array_key_exists('value', $options)) {
         $value = $options['value'];
         if (!array_key_exists('escape', $options) || $options['escape'] !== false) {
             $value = h($value);
         }
         unset($options['value']);
     }
     if (array_key_exists('config', $options)) {
         $config = $options['config'];
         unset($options['config']);
     }
     if (array_key_exists('events', $options)) {
         $events = $options['events'];
         unset($options['events']);
     }
     require_once WWW_ROOT . 'js' . DS . 'ckeditor' . DS . 'ckeditor.php';
     $CKEditor = new CKEditor();
     $CKEditor->basePath = $this->webroot . 'js/ckeditor/';
     return $CKEditor->editor($options['name'], $value, $config, $events);
 }
Example #24
0
/**
 * Обработчик ошибок, возникающих при работе функций любого типа (шаблоны, функции и т.д.)
 *
 * @param $output Ошибочный вывод.
 * @return string Информация об шибке
 */
function doit_ob_error_handler($output)
{
    $error = error_get_last();
    if ($error['type'] == 1) {
        $parent_function = d()->_active_function();
        if (d()->db->errorCode() != 0) {
            $db_err = d()->db->errorInfo();
            $_message = '<br>Также зафиксирована ошибка базы данных:<br>' . $db_err[2] . " (" . $db_err[1] . ")";
            if (iam('developer')) {
                if ($db_err[1] == '1146') {
                    $_message .= '<br> Создать таблицу <b>' . h(d()->bad_table) . '</b>? <form method="get" action="/admin/scaffold/new" style="display:inline;" target="_blank"><input type="submit" value="Создать"><input type="hidden" name="table" value="' . h(d()->bad_table) . '"></form> ';
                }
                if ($db_err[1] == '1054') {
                    //Попытка создать столбик для таблицы
                    //Unknown column 'user_id'
                    $_column_name = array();
                    if (preg_match_all("/Unknown\\scolumn\\s\\'(.*?)\\'/", $db_err[2], $_column_name) == 1) {
                        $_column_name = $_column_name[1][0];
                        $_message .= '<br> Создать столбец <b>' . h($_column_name) . '</b> в таблице ' . h(d()->bad_table) . '? <form method="post" action="/admin/scaffold/create_column" style="display:inline;" target="_blank"><input type="submit" value="Создать"><input type="hidden" name="table" value="' . h(d()->bad_table) . '"><input type="hidden" name="column" value="' . h($_column_name) . '"></form> ';
                    }
                }
                $_message .= '<br> Провести обработку схемы? <form method="get" action="/admin/scaffold/update_scheme" style="display:inline;" target="_blank"><input type="submit" value="Провести"></form><br>';
            }
        }
        $errfile = substr($error['file'], strlen($_SERVER['DOCUMENT_ROOT']));
        return print_error_message(' ', $error['line'], $errfile, $error['message'], 'Ошибка при выполнении функции ' . $parent_function . ' ' . $_message);
    }
    return $output;
}
 public function index()
 {
     $id = SlAuth::user('id');
     if (!$id) {
         $this->cakeError('error403');
     }
     $this->AuthUser->id = $id;
     if (isset($this->data['AuthUser']['password'])) {
         if ($this->_passwordMatch()) {
             if ($this->AuthUser->saveField('password', SlAuth::password($this->data['AuthUser']['password']), true)) {
                 $this->Session->setFlash(__t('Password changed'), array('class' => 'success'));
             }
         }
     } elseif (isset($this->data['AuthUser']['email'])) {
         // email validation
     } else {
         // security
         unset($this->data['AuthUser']['id']);
         unset($this->data['AuthUser']['password']);
         unset($this->data['AuthUser']['email']);
         $this->AuthUser->save($this->data);
     }
     $this->set('user', $user = $this->AuthUser->read());
     $this->set('title', __t('Welcome, {$name}', array('name' => h($user['AuthUser']['fullname']))));
 }
Example #26
0
 public function displayField($item, $model, $field, $options = array())
 {
     extract(array_intersect_key($options, array('type' => null, 'url' => array(), 'options' => array())));
     switch ($type) {
         case 'boolean':
             $out = $this->status($item[$model][$field]);
             break;
         default:
             $out = h($item[$model][$field]);
             break;
     }
     if (!empty($url)) {
         if (isset($url['pass'])) {
             $passVars = is_string($url['pass']) ? array($url['pass']) : $url['pass'];
             foreach ($passVars as $passField) {
                 $url[] = $item[$model][$passField];
             }
             unset($url['pass']);
         }
         if (isset($url['named'])) {
             $namedVars = is_string($url['named']) ? array($url['named']) : $url['named'];
             foreach ($namedVars as $namedField) {
                 $url[$namedField] = $item[$model][$namedField];
             }
             unset($url['named']);
         }
         $out = $this->Html->link($out, $url, $options);
     }
     return $out;
 }
Example #27
0
 /**
  * Return a nested array of errors for the passed html string
  * Fudge the markup slightly so that the tag which is invalid is highlighted
  *
  * @param string $html ''
  * @param string &$out ''
  * @return array
  */
 public function process($html = '', &$out = '')
 {
     $errors = $this->tidyErrors($html, $out);
     if (!$errors) {
         return array();
     }
     $result = array('Error' => array(), 'Warning' => array(), 'Misc' => array());
     $errors = explode("\n", $errors);
     $markup = explode("\n", $out);
     foreach ($errors as $error) {
         preg_match('@line (\\d+) column (\\d+) - (\\w+): (.*)@', $error, $matches);
         if ($matches) {
             list($original, $line, $column, $type, $message) = $matches;
             $line = $line - 1;
             $string = '</strong>';
             if (isset($markup[$line - 1])) {
                 $string .= h($markup[$line - 1]);
             }
             $string .= '<strong>' . h(@$markup[$line]) . '</strong>';
             if (isset($markup[$line + 1])) {
                 $string .= h($markup[$line + 1]);
             }
             $string .= '</strong>';
             $result[$type][$string][] = h($message);
         } elseif ($error) {
             $message = $error;
             $result['Misc'][h($message)][] = h($message);
         }
     }
     $this->results = $result;
     return $result;
 }
Example #28
0
 /**
  * Convenience method for htmlspecialchars.
  *
  * @param string|array|object $text Text to wrap through htmlspecialchars. Also works with arrays, and objects.
  *    Arrays will be mapped and have all their elements escaped. Objects will be string cast if they
  *    implement a `__toString` method. Otherwise the class name will be used.
  * @param bool $double Encode existing html entities.
  * @param string $charset Character set to use when escaping. Defaults to config value in `mb_internal_encoding()`
  * or 'UTF-8'.
  * @return string Wrapped text.
  * @link http://book.cakephp.org/3.0/en/core-libraries/global-constants-and-functions.html#h
  */
 function h($text, $double = true, $charset = null)
 {
     if (is_string($text)) {
         //optimize for strings
     } elseif (is_array($text)) {
         $texts = [];
         foreach ($text as $k => $t) {
             $texts[$k] = h($t, $double, $charset);
         }
         return $texts;
     } elseif (is_object($text)) {
         if (method_exists($text, '__toString')) {
             $text = (string) $text;
         } else {
             $text = '(object)' . get_class($text);
         }
     } elseif (is_bool($text)) {
         return $text;
     }
     static $defaultCharset = false;
     if ($defaultCharset === false) {
         $defaultCharset = mb_internal_encoding();
         if ($defaultCharset === null) {
             $defaultCharset = 'UTF-8';
         }
     }
     if (is_string($double)) {
         $charset = $double;
     }
     return htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, $charset ? $charset : $defaultCharset, $double);
 }
Example #29
0
 /**
  * Creates form fields and JavaScript includes to add a color picker widget.
  * <code>
  *     $dh->output('background-color', '#f00');
  * </code>
  * @param string $fieldFormName
  * @param string $fieldLabel
  * @param string $value
  * @param bool $includeJavaScript
  */
 public function output($inputName, $value = null, $options = array())
 {
     $html = '';
     $view = View::getInstance();
     $view->requireAsset('core/colorpicker');
     $form = Loader::helper('form');
     $r = Request::getInstance();
     if ($r->request->has($inputName)) {
         $value = h($r->request->get($inputName));
     }
     $strOptions = '';
     $i = 0;
     $options['value'] = $value;
     $options['className'] = 'ccm-widget-colorpicker';
     $options['showInitial'] = true;
     $options['showInput'] = true;
     $options['cancelText'] = t('Cancel');
     $options['chooseText'] = t('Choose');
     $options['preferredFormat'] = 'rgb';
     $options['clearText'] = t('Clear Color Selection');
     $strOptions = json_encode($options);
     print "<input type=\"text\" name=\"{$inputName}\" value=\"{$value}\" id=\"ccm-colorpicker-{$inputName}\" />";
     print "<script type=\"text/javascript\">";
     print "\$(function() { \$('#ccm-colorpicker-{$inputName}').spectrum({$strOptions}); })";
     print "</script>";
 }
Example #30
0
 public function get_headline()
 {
     $cache = get_cache_function($this->koala_group->get_id());
     $headline = array();
     $group_url = PATH_URL . "groups/" . $this->koala_group->get_id() . "/";
     if (($category = $this->koala_group->get_steam_object()->get_environment()) && $cache->call("lms_steam::group_is_public", $this->koala_group->get_id())) {
         $headline[] = array("name" => h($category->get_name()), "link" => PATH_URL . "groups/?cat=" . $category->get_id());
         $headline[] = array("name" => $this->koala_group->get_display_name(), "link" => $group_url);
     } else {
         $headline[] = array("name" => h($this->koala_group->get_name()));
     }
     if (is_string($context = $this->get_context())) {
         switch ($context) {
             case "documents":
                 //TODO: move this into documents extension somehow?
                 $headline[] = array("name" => gettext("Documents"), "link" => "");
                 break;
             case "communication":
                 $headline[] = array("name" => gettext("Communication"), "link" => "");
                 break;
             case "members":
                 $headline[] = array("name" => gettext("Members"), "link" => "");
                 break;
         }
         // try extensions:
         foreach ($this->koala_group->get_extensions() as $extension) {
             $tmp_headline = $extension->get_headline($headline, $this->get_context(), $this->get_context_params());
             if (is_array($tmp_headline)) {
                 return $tmp_headline;
             }
         }
     }
     return $headline;
 }