Beispiel #1
0
 public function login()
 {
     //记录登陆失败者IP
     $ip = get_client_ip();
     $username = I("post.account", "", "trim");
     $password = I("post.password", "", "trim");
     if (empty($username)) {
         $this->error("用户名不能为空,请重新输入!");
     }
     if (empty($password)) {
         $this->error("密码不能为空,请重新输入!");
     }
     if (Admin::getInstance()->login($username, $password)) {
         $forward = cookie("forward");
         if (!$forward) {
             $forward = U("Admins:Index");
         } else {
             cookie("forward", NULL);
         }
         //增加登陆成功行为调用
         $admin_public_tologin = array('username' => $username, 'ip' => $ip);
         tag('admin_public_tologin', $admin_public_tologin);
         $this->success('成功登录后台管理系统', U('Index/index'));
     } else {
         //增加登陆失败行为调用
         $admin_public_tologin = array('username' => $username, 'password' => $password, 'ip' => $ip);
         tag('admin_public_tologin_error', $admin_public_tologin);
         $this->error("用户名或者密码错误,登陆失败!", U("login"));
     }
 }
Beispiel #2
0
/**
 * Renders and outputs a login form.
 *
 * This function outputs a full HTML document,
 * including <head> and footer.
 *
 * @param string|array $message The activity message
 */
function doLoginForm($message)
{
    global $textarray_script, $event, $step;
    include txpath . '/lib/txplib_head.php';
    $event = 'login';
    if (gps('logout')) {
        $step = 'logout';
    } elseif (gps('reset')) {
        $step = 'reset';
    }
    pagetop(gTxt('login'), $message);
    $stay = (cs('txp_login') and !gps('logout') ? 1 : 0);
    $reset = gps('reset');
    $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1));
    $out = array();
    if ($reset) {
        $out[] = hed(gTxt('password_reset'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), ' class="login-name"') . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish') . n) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1);
    } else {
        $out[] = hed(gTxt('login_to_textpattern'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), array('class' => 'login-name')) . graf(n . span(tag(gTxt('password'), 'label', array('for' => 'login_password')), array('class' => 'txp-label')) . n . span(fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), array('class' => 'txp-value')), array('class' => 'login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login') . n, array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish') . n) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot'));
        if (gps('event')) {
            $out[] = eInput(gps('event'));
        }
    }
    echo form(tag(join('', $out), 'section', array('role' => 'region', 'class' => 'txp-login', 'aria-labelledby' => 'txp-login-heading')), '', '', 'post', '', '', 'login_form') . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>';
    exit(0);
}
Beispiel #3
0
 public function get_config_by_app($app)
 {
     $config = array();
     if ($app && AppService::is_app_active($app)) {
         $configs = S("configs/app/all");
         $config = $configs[$app];
     }
     $config = $config ? $config : array();
     /*
      * 全局文件加载
      * **/
     foreach (AppService::$allAppConfigs as $app => $app_config) {
         if ($app_config['global_include'] && AppService::is_app_active($app)) {
             $config['include'] = array_merge_recursive((array) $config['include'], (array) $app_config['global_include']);
         }
         if ($app_config['force_global_include']) {
             $config['include'] = array_merge_recursive((array) $config['include'], (array) $app_config['force_global_include']);
         }
         if ($app_config['global_load_modules'] && AppService::is_app_active($app)) {
             $config['load_modules'] = array_merge_recursive((array) $config['load_modules'], (array) $app_config['global_load_modules']);
         }
     }
     tag("before_app_config_response", $config);
     return $config;
 }
Beispiel #4
0
 public function authenticate($company_sign_id, $login, $password)
 {
     $company = D("Account/Company")->where(array('sign_id' => $company_sign_id))->find();
     if (!$company) {
         return -1;
     }
     $user = $this->where(array("company_id" => $company['id'], "login" => $login))->relation(false)->find();
     if (!$user) {
         return -2;
     }
     $hashed = $this->generate_password($password, $user['rand_hash']);
     if ($user['password'] !== $hashed[0]) {
         return -3;
     }
     $params = array($user, $company);
     tag('after_user_authenticated', $params);
     list($user, $company) = $params;
     session('[destroy]');
     session('[start]');
     session('[regenerate]');
     $is_super_user = false;
     if ($company['superuser'] && $company['superuser'] == $user["id"]) {
         $is_super_user = true;
     }
     session('user', array("login" => $user["login"], "id" => $user["id"], "realname" => $user["realname"], "email" => $user["email"], "avatar" => $user["avatar"], "company" => $company, "is_super_user" => $is_super_user));
     return true;
 }
Beispiel #5
0
/**
 * AlbaToolsHelper.
 *
 * @package    symfony
 * @subpackage helper
 * @author     Fernando Toledo <*****@*****.**>
 * @version    SVN: $Id: NumberHelper.php 7757 2008-03-07 10:55:22Z fabien $
 */
function text2img($texto)
{
    if (is_null($texto)) {
        return null;
    }
    return tag('img', array('alt' => $texto, 'src' => url_for('albaTools/text2img?texto=' . $texto)));
}
/**
 * Returns the requirements information view.
 *
 * @return string  The (X)HTML.
 */
function Syntaxhighlighter_systemCheck()
{
    // RELEASE-TODO
    global $pth, $tx, $plugin_tx;
    define('SYNTAXHIGHLIGHTER_PHP_VERSION', '4.0.7');
    $ptx = $plugin_tx['syntaxhighlighter'];
    $imgdir = $pth['folder']['plugins'] . 'syntaxhighlighter/images/';
    $ok = tag('img src="' . $imgdir . 'ok.png" alt="ok"');
    $warn = tag('img src="' . $imgdir . 'warn.png" alt="warning"');
    $fail = tag('img src="' . $imgdir . 'fail.png" alt="failure"');
    $o = '<h4>' . $ptx['syscheck_title'] . '</h4>' . (version_compare(PHP_VERSION, SYNTAXHIGHLIGHTER_PHP_VERSION) >= 0 ? $ok : $fail) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_phpversion'], SYNTAXHIGHLIGHTER_PHP_VERSION) . tag('br') . "\n";
    foreach (array('pcre') as $ext) {
        $o .= (extension_loaded($ext) ? $ok : $fail) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_extension'], $ext) . tag('br') . "\n";
    }
    $o .= (!get_magic_quotes_runtime() ? $ok : $fail) . '&nbsp;&nbsp;' . $ptx['syscheck_magic_quotes'] . tag('br') . tag('br') . "\n";
    $o .= (strtoupper($tx['meta']['codepage']) == 'UTF-8' ? $ok : $fail) . '&nbsp;&nbsp;' . $ptx['syscheck_encoding'] . tag('br') . "\n";
    $folders = array();
    foreach (array('config/', 'css/', 'languages/') as $folder) {
        $folders[] = $pth['folder']['plugins'] . 'syntaxhighlighter/' . $folder;
    }
    foreach ($folders as $folder) {
        $o .= (is_writable($folder) ? $ok : $warn) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_writable'], $folder) . tag('br') . "\n";
    }
    return $o;
}
 public function __toString()
 {
     $name = $this->getPropertyValue('namePattern');
     $id = $this->getPropertyValue('namePattern');
     $imageHTML = tag('img', array('src' => theme_path('images/callout-left.png'), 'title' => 'Click here to edit', 'alt' => 'Edit', 'class' => 'callout dialogInvoker'));
     $placeholderGetters = $this->getPropertyValue('placeholderGetters');
     $id = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('idPattern'));
     $name = $this->generateAttributeValue($placeholderGetters, $this->getPropertyValue('namePattern'));
     $comments = $this->getValue();
     $commentExtract = '';
     $allComments = '';
     // show last comment only
     if (count($comments) > 0) {
         foreach ($comments as $comment) {
             $created = new DateTime($comment->getCreated());
             $createdAt = set_datepicker_date_format($created->format('Y-m-d')) . ' ' . $created->format('H:i');
             $formatComment = $createdAt . ' ' . $comment->getCreatedByName() . "\n\n" . $comment->getComments();
             $allComments = $formatComment . "\n\n" . $allComments;
         }
         $lastComment = $comments->getLast();
         $commentExtract = $this->trimComment($lastComment->getComments());
     }
     $commentContainerHTML = content_tag('span', $commentExtract, array('id' => $this->generateAttributeValue($placeholderGetters, 'commentContainer-{id}')));
     $hiddenFieldHTML = tag('input', array('type' => 'hidden', 'id' => $id, 'name' => $name, 'value' => $allComments));
     $commentHTML = content_tag('span', $commentContainerHTML . $imageHTML . $hiddenFieldHTML, array('class' => 'commentContainerLong'));
     if ($this->isHiddenOnCallback()) {
         return '&nbsp;';
     }
     return $commentHTML . $this->getHiddenFieldHTML();
 }
Beispiel #8
0
/**
 * Inserts JS.
 */
function jmd_save()
{
    $js = <<<EOD
//inc <save.js>
EOD;
    echo tag($js, 'script', ' type="text/javascript"');
}
 public function read()
 {
     if (!$_GET["includeRows"] or $_GET['workflow']) {
         return parent::read();
     }
     //        $this->readModel = "PurchaseView";
     //        $formData = parent::read(true);
     $formData = D("PurchaseView")->find($_GET['id']);
     $formData["inputTime"] = $formData["dateline"] * 1000;
     //        $formData["total_amount"] = $formData["total_price"];
     //        $formData["total_amount_real"] = $formData["total_price_real"];
     //        $formData["total_num"] = $formData["quantity"];
     $rowModel = D("PurchaseDetailView");
     $rows = $rowModel->where("PurchaseDetail.purchase_id=" . $formData["id"])->select();
     //        echo $rowModel->getLastSql();exit;
     $modelIds = array();
     $rowData = array();
     foreach ($rows as $v) {
         $tmp = explode(DBC("goods.unique.separator"), $v["factory_code_all"]);
         //根据factory_code_all factory_code - standard - version
         $factory_code = array_shift($tmp);
         $modelIds = array_merge($modelIds, $tmp);
         $v["modelIds"] = $tmp;
         $v["goods_id"] = sprintf("%s_%s_%s", $factory_code, $v["goods_id"], $v["goods_category_id"]);
         // factory_code, id, catid
         $v["goods_id_label"] = sprintf("%s", $v["goods_name"]);
         //             $v["amount"] = $v["price"];
         $rowData[$v["id"]] = $v;
     }
     //        array_flip(array_flip($modelIds));
     $formData["customer_id_label"] = $formData["customer"];
     $params = array($rowData, $modelIds);
     tag("assign_dataModel_data", $params);
     $formData["rows"] = reIndex($params[0]);
     /*
      * 相关单据
      * **/
     $relateItem = array();
     $id = abs(intval($_GET["id"]));
     if (isAppLoaded("store")) {
         $tmp = D("Stockin")->toRelatedItem("Purchase", $id);
         if ($tmp) {
             $relateItem = array_merge($relateItem, $tmp);
         }
     }
     if (isAppLoaded("finance")) {
         $tmp = D("FinancePayPlan")->toRelatedItem("Purchase", $id);
         if ($tmp) {
             $relateItem = array_merge($relateItem, $tmp);
         }
     }
     if ($formData["source_model"] == "ProducePlan" && $formData["source_id"] && isAppLoaded("produce")) {
         $tmp = D("ProducePlan")->getRelatedItem($formData["source_id"]);
         if ($tmp) {
             $relateItem[] = $tmp;
         }
     }
     $formData["relatedItems"] = $relateItem;
     $this->response($formData);
 }
function occurrence_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["oid"])) {
        $message = __('No occurrence selected.');
        $html->add(tag('p', $message));
        return $html;
    }
    if (is_array($vars["oid"])) {
        $oids = $vars["oid"];
    } else {
        $oids = array($vars["oid"]);
    }
    $removed_occurs = array();
    $unremoved_occurs = array();
    $permission_denied = array();
    foreach ($oids as $oid) {
        $occur = $phpcdb->get_occurrence_by_oid($oid);
        if (!$occur->can_modify()) {
            $permission_denied[] = $oid;
        } else {
            if ($phpcdb->delete_occurrence($oid)) {
                $removed_occurs[] = $oid;
                // TODO: Verify that the event still has occurences.
                $eid = $occur->get_eid();
            } else {
                $unremoved_occurs[] = $oid;
            }
        }
    }
    if (sizeof($removed_occurs) > 0) {
        if (sizeof($removed_occurs) == 1) {
            $text = __("Removed occurrence");
        } else {
            $text = __("Removed occurrences");
        }
        $text .= ': ' . implode(', ', $removed_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($unremoved_occurs) > 0) {
        if (sizeof($unremoved_occurs) == 1) {
            $text = __("Could not remove occurrence");
        } else {
            $text = __("Could not remove occurrences");
        }
        $text .= ': ' . implode(', ', $unremoved_occurs);
        $html->add(tag('p', $text));
    }
    if (sizeof($permission_denied) > 0) {
        if (sizeof($permission_denied) == 1) {
            $text = __("You do not have permission to remove the occurrence.");
        } else {
            $text = __("You do not have permission to remove occurrences.");
        }
        $text .= ': ' . implode(', ', $permission_denied);
        $html->add(tag('p', $text));
    }
    return message_redirect($html, "{$phpc_script}?action=display_event&phpcid={$phpcid}&eid={$eid}");
}
Beispiel #11
0
 function header()
 {
     $out[] = '<table id="pagetop" cellpadding="0" cellspacing="0">' . n . '<tr id="branding"><td><h1 id="textpattern">Textpattern</h1></td><td id="navpop">' . navPop(1) . '</td></tr>' . n . '<tr id="nav-primary"><td align="center" class="tabs" colspan="2">';
     if (!$this->is_popup) {
         $out[] = '<table cellpadding="0" cellspacing="0" align="center">' . n . '<tr><td id="messagepane">&nbsp;' . $this->announce($this->message) . '</td>';
         $secondary = '';
         foreach ($this->menu as $tab) {
             $tc = $tab['active'] ? 'tabup' : 'tabdown';
             $atts = ' class="' . $tc . '"';
             $hatts = ' href="?event=' . $tab['event'] . '" class="plain"';
             $out[] = tda(tag($tab['label'], 'a', $hatts), $atts);
             if ($tab['active'] && !empty($tab['items'])) {
                 $secondary = '</td></tr><tr id="nav-secondary"><td align="center" class="tabs" colspan="2">' . n . '<table cellpadding="0" cellspacing="0" align="center">' . n . '<tr>';
                 foreach ($tab['items'] as $item) {
                     $tc = $item['active'] ? 'tabup' : 'tabdown2';
                     $secondary .= '<td class="' . $tc . '"><a href="?event=' . $item['event'] . '" class="plain">' . $item['label'] . '</a></td>';
                 }
                 $secondary .= '</tr></table>';
             }
         }
         $out[] = '<td id="view-site" class="tabdown"><a href="' . hu . '" class="plain" target="_blank">' . gTxt('tab_view_site') . '</a></td>';
         $out[] = '</tr></table>';
         $out[] = $secondary;
     }
     $out[] = '</td></tr></table>';
     return join(n, $out);
 }
Beispiel #12
0
function file_download_list($atts)
{
    global $thisfile;
    extract(lAtts(array('break' => br, 'category' => '', 'class' => __FUNCTION__, 'form' => 'files', 'label' => '', 'labeltag' => '', 'limit' => '10', 'offset' => '0', 'sort' => 'filename asc', 'wraptag' => '', 'status' => '4'), $atts));
    if (!is_numeric($status)) {
        $status = getStatusNum($status);
    }
    $where = array('1=1');
    if ($category) {
        $where[] = "category IN ('" . join("','", doSlash(do_list($category))) . "')";
    }
    if ($status) {
        $where[] = "status = '" . doSlash($status) . "'";
    }
    $qparts = array('order by ' . doSlash($sort), $limit ? 'limit ' . intval($offset) . ', ' . intval($limit) : '');
    $rs = safe_rows_start('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', join(' and ', $where) . ' ' . join(' ', $qparts));
    if ($rs) {
        $out = array();
        while ($thisfile = nextRow($rs)) {
            $out[] = parse_form($form);
            $thisfile = '';
        }
        if ($out) {
            if ($wraptag == 'ul' or $wraptag == 'ol') {
                return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
            }
            return $wraptag ? tag(join($break, $out), $wraptag) : join(n, $out);
        }
    }
    return '';
}
Beispiel #13
0
 public function __toString()
 {
     $label = $this->getPropertyValue('label', $this->identifier);
     $id = $this->getId();
     $class = $this->getPropertyValue('class', 'plainbtn');
     return tag('input', array('type' => $this->getPropertyValue('type', 'button'), 'class' => $class, 'id' => $id, 'name' => $this->getPropertyValue('name', $id), 'onmouseover' => "this.className='{$class} {$class}hov'", 'onmouseout' => "this.className='{$class}'", 'value' => __($label)));
 }
Beispiel #14
0
/**
 * @name            jmd_example
 * @description     A glorified "Hello, World".
 * @author          Jon-Michael Deldin
 * @author_uri      http://jmdeldin.com
 * @version         0.1
 * @type            0
 * @order           5
 */
function jmd_example($attrs, $thing)
{
    $js = <<<EOF
//inc <example.js>
EOF;
    return tag($js, 'script', ' type="text/javascript"');
}
Beispiel #15
0
function thumbnail($img, $options = array(), $attributes = array())
{
    // Maintains Backwards Compatibility - you can pass a string or an array with [profile] set to pull
    // from YAML, or you can just pass the options in array format
    if (is_array($options)) {
        if (isset($options['profile'])) {
            $profile = $options['profile'];
            unset($options['profile']);
        } else {
            $profile = '';
        }
    } else {
        $profile = $options;
        $options = array();
    }
    //If a profile is set, pull the profile from YAML.  Else, just use the options
    //Note: you can override anything set in a profile by passing the overriden argument in options
    if ($profile) {
        $options = array_merge(getImageCacheProfile($profile), $options);
        // You can also set attributes in your imagecache profile
        if (isset($options['attributes'])) {
            $attributes = array_merge($attributes, $options['attributes']);
        }
    }
    $attributes['src'] = thumbnail_path($img, $options);
    return tag('img', $attributes);
}
Beispiel #16
0
function user_enable()
{
    global $vars, $phpcid, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (!is_admin()) {
        $html->add(tag('p', __('You must be an admin to enable users.')));
        return $html;
    }
    if (empty($vars["uid"])) {
        $html->add(tag('p', __('No user selected.')));
        return $html;
    }
    if (is_array($vars["uid"])) {
        $ids = $vars["uid"];
    } else {
        $ids = array($vars["uid"]);
    }
    foreach ($ids as $id) {
        if ($phpcdb->enable_user($id)) {
            $html->add(tag('p', __("Enabled user: {$id}")));
        } else {
            $html->add(tag('p', __("Could not enable user: {$id}")));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=admin&phpcid={$phpcid}");
}
function calendar_delete()
{
    global $vars, $phpcdb, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["cid"])) {
        $html->add(tag('p', __('No calendar selected.')));
        return $html;
    }
    $id = $vars["cid"];
    $calendar = $phpcdb->get_calendar($id);
    if (empty($calendar)) {
        soft_error(__("Invalid calendar ID."));
    }
    if (empty($vars["confirm"])) {
        $html->add(tag('p', __('Confirm you want to delete calendar:') . $calendar->get_title()));
        $html->add(" [ ", create_action_link(__('Confirm'), "calendar_delete", array("cid" => $id, "confirm" => "1")), " ] ");
        $html->add(" [ ", create_action_link(__('Deny'), "display_month"), " ] ");
        return $html;
    }
    if (!$calendar->can_admin()) {
        $html->add(tag('p', __("You do not have permission to remove calendar") . ": {$id}"));
        return $html;
    }
    if ($phpcdb->delete_calendar($id)) {
        $html->add(tag('p', __("Removed calendar") . ": {$id}"));
    } else {
        $html->add(tag('p', __("Could not remove calendar") . ": {$id}"));
    }
    return message_redirect($html, "{$phpc_script}?action=admin");
}
  /**
   * Builds open div tag ready with inforamtion for tooltip.js
   *
   * Example:
   * <code>
   *   <?php echo tooltip_div('my_element_id', 'css_class_for_it', array('style' => 'visibility: hidden')) ?>
   * </code>
   *
   * @param string HTML id of the element this tooltip is for
   * @param css_class CSS class to skin tooltip in (if not default)
   * @param array Other attributes for the tag. You can also pass string suitable for _parse_attributes()
   *
   * @return string An HTML div string
   *
   */
  function tooltip_div($element_id, $css_class = '', $options = array())
  {
    $options = _parse_attributes($options);
    $options['class'] = $css_class.' tooltip for_'.$element_id;

    return tag('div', $options, true);
  }
function category_delete()
{
    global $vars, $phpcdb, $phpcid, $phpc_script;
    $html = tag('div', attributes('class="phpc-container"'));
    if (empty($vars["catid"])) {
        return message_redirect(__('No category selected.'), "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
    }
    if (is_array($vars["catid"])) {
        $ids = $vars["catid"];
    } else {
        $ids = array($vars["catid"]);
    }
    $categories = array();
    foreach ($ids as $id) {
        $categories[] = $phpcdb->get_category($id);
    }
    foreach ($categories as $category) {
        if (empty($category['cid']) && !is_admin() || !$phpcdb->get_calendar($category['cid'])->can_admin()) {
            $html->add(tag('p', __("You do not have permission to delete category: ") . $category['catid']));
            continue;
        }
        if ($phpcdb->delete_category($category['catid'])) {
            $html->add(tag('p', __("Removed category: ") . $category['catid']));
        } else {
            $html->add(tag('p', __("Could not remove category: ") . $category['catid']));
        }
    }
    return message_redirect($html, "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
}
Beispiel #20
0
function translate()
{
    global $phpc_locale_path;
    if (!is_admin()) {
        permission_error(__('Need to be admin'));
        exit;
    }
    $handle = opendir($phpc_locale_path);
    if (!$handle) {
        return soft_error("Error reading locale directory.");
    }
    $output_tag = tag('div', tag('h2', __('Translate')));
    while (($filename = readdir($handle)) !== false) {
        $pathname = "{$phpc_locale_path}/{$filename}";
        if (strncmp($filename, ".", 1) == 0 || !is_dir($pathname)) {
            continue;
        }
        $msgs_path = "{$pathname}/LC_MESSAGES";
        $hash = parse_po_file("{$msgs_path}/messages.po");
        if ($hash === FALSE) {
            print nl2br("Error reading '{$msgs_path}/messages.po', aborted.\n");
        } else {
            $out = "{$msgs_path}/messages.mo";
            write_mo_file($hash, $out);
        }
        $output_tag->add(tag('div', sprintf(__('Translated "%s"'), $filename)));
    }
    closedir($handle);
    return $output_tag;
}
Beispiel #21
0
 public function testHelpersFacade()
 {
     $this->assertInstanceOf(\Clarity\Support\Auth\Auth::class, auth());
     $this->assertInstanceOf(\Phalcon\Config::class, config());
     $this->assertInstanceOf(\Phalcon\Mvc\Dispatcher::class, dispatcher());
     $this->assertInstanceOf(\Phalcon\Filter::class, filter());
     $this->assertInstanceOf(\Phalcon\Flash\Direct::class, flash()->direct());
     $this->assertInstanceOf(\Phalcon\Flash\Session::class, flash()->session());
     $this->assertInstanceOf(\League\Flysystem\Filesystem::class, flysystem());
     $this->assertInstanceOf(\League\Flysystem\MountManager::class, flysystem_manager());
     $this->assertInstanceOf(\Clarity\Support\Redirect\Redirect::class, redirect());
     $this->assertInstanceOf(\Clarity\Support\Phalcon\Http\Request::class, request());
     $this->assertInstanceOf(\Phalcon\Http\Response::class, response());
     $this->assertInstanceOf(\Phalcon\Mvc\Router::class, route());
     $this->assertInstanceOf(\Phalcon\Security::class, security());
     $this->assertInstanceOf(\Phalcon\Tag::class, tag());
     $this->assertInstanceOf(\Phalcon\Mvc\Url::class, url());
     $this->assertInstanceOf(\Phalcon\Mvc\View::class, view());
     # getting an error, will check later on
     $this->assertInstanceOf(\Monolog\Logger::class, logger());
     # adapter base functions
     // $this->assertInstanceOf(, cache());
     // $this->assertInstanceOf(, db());
     // $this->assertInstanceOf(, queue());
     // $this->assertInstanceOf(, session());
     $this->assertContains(url()->getBaseUri() . 'auth/login', route('showLoginForm'));
     $this->assertInstanceOf(\Phalcon\Mvc\View::class, view('welcome'));
 }
Beispiel #22
0
function button_to($name, $url = '', array $args = array())
{
    $params = array();
    if (is_array($name)) {
        $params = $name;
    } elseif (is_array($url)) {
        $params['action'] = (string) $name;
    } elseif (!isset($params['text'])) {
        $params['text'] = $name;
    }
    if (is_string($name) && is_array($url)) {
        $params = array_merge($url, $params);
    } elseif (!isset($params['action'])) {
        $params['action'] = $url;
    }
    $props = array('type' => FALSE, 'action' => '', 'method' => 'POST', 'remote' => FALSE, 'params' => FALSE, 'confirm' => FALSE, 'disabled' => FALSE, 'disable_with' => '');
    $params = array_merge($props, $params, array_intersect_key($args, $props));
    $args = array_diff_key($args, array_intersect_key($args, $props));
    $button = tag('input', array_merge(array('type' => 'submit', 'value' => $params['text'], 'disabled' => $params['disabled'], 'data-disable-with' => $params['disable_with'] ?: FALSE), $args));
    $extra = '';
    if ($params['method'] != 'POST') {
        $extra = tag('input', array('type' => 'hidden', 'name' => '_method', 'value' => strtolower($params['method'])));
    }
    $extra .= tag('input', array('type' => 'hidden', 'name' => '_token', 'value' => \Labourer\Web\Session::token()));
    return tag('form', array('class' => 'button-to', 'action' => $params['action'], 'method' => 'post', 'data-type' => $params['type'] ?: FALSE, 'data-confirm' => $params['confirm'] ?: FALSE, 'data-remote' => $params['remote'] ? 'true' : FALSE, 'data-params' => $params['params'] ? http_build_query($params['params']) : FALSE), "<div>{$extra}{$button}</div>");
}
 /**
  * Renders the view.
  *
  * @return string (X)HTML
  *
  * @global array The paths of system files and folders.
  * @global array The configuration of the plugins.
  * @global array The localization of the core.
  * @global array The localization of the plugins.
  */
 public function render()
 {
     global $pth, $plugin_cf, $tx, $plugin_tx;
     $phpVersion = '5.3.0';
     $ptx = $plugin_tx['advancedform'];
     $imgdir = $pth['folder']['plugins'] . 'advancedform/images/';
     $ok = tag('img src="' . $imgdir . 'ok.png" alt="ok"');
     $warn = tag('img src="' . $imgdir . 'warn.png" alt="warning"');
     $fail = tag('img src="' . $imgdir . 'fail.png" alt="failure"');
     $o = tag('hr') . '<h4>' . $ptx['syscheck_title'] . '</h4>' . (version_compare(PHP_VERSION, $phpVersion) >= 0 ? $ok : $fail) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_phpversion'], $phpVersion) . tag('br') . tag('br') . PHP_EOL;
     foreach (array('ctype', 'mbstring', 'pcre', 'session', 'spl') as $ext) {
         $o .= (extension_loaded($ext) ? $ok : $fail) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_extension'], $ext) . tag('br') . PHP_EOL;
     }
     $o .= tag('br') . (strtoupper($tx['meta']['codepage']) == 'UTF-8' ? $ok : $warn) . '&nbsp;&nbsp;' . $ptx['syscheck_encoding'] . tag('br') . PHP_EOL;
     $o .= (!get_magic_quotes_runtime() ? $ok : $warn) . '&nbsp;&nbsp;' . $ptx['syscheck_magic_quotes'] . tag('br') . PHP_EOL;
     $filename = $pth['folder']['plugins'] . 'jquery/jquery.inc.php';
     $o .= (file_exists($filename) ? $ok : $fail) . '&nbsp;&nbsp;' . $ptx['syscheck_jquery'] . tag('br') . PHP_EOL;
     $filename = $pth['folder']['plugins'] . $plugin_cf['advancedform']['captcha_plugin'] . '/captcha.php';
     $o .= (file_exists($filename) ? $ok : $warn) . '&nbsp;&nbsp;' . $ptx['syscheck_captcha_plugin'] . tag('br') . tag('br') . PHP_EOL;
     foreach (array('config/', 'css/', 'languages/') as $folder) {
         $folders[] = $pth['folder']['plugins'] . 'advancedform/' . $folder;
     }
     $folders[] = Data::folder();
     foreach ($folders as $folder) {
         $o .= (is_writable($folder) ? $ok : $warn) . '&nbsp;&nbsp;' . sprintf($ptx['syscheck_writable'], $folder) . tag('br') . PHP_EOL;
     }
     return $o;
 }
Beispiel #24
0
function event_delete()
{
    global $config;
    if (!is_user() && $config['anon_permission'] < 2) {
        soft_error(_('You do not have permission to delete events.'));
    }
    $del_array = explode('&', $_SERVER['QUERY_STRING']);
    $html = tag('div', attributes('class="box"', 'style="width: 50%"'));
    $ids = 0;
    foreach ($del_array as $del_value) {
        list($drop, $id) = explode("=", $del_value);
        if (preg_match('/^id$/', $drop) == 0) {
            continue;
        }
        $ids++;
        $event = get_event_by_id($id);
        if (!check_user($event['uid']) && $config['anon_permission'] < 2) {
            $html->add(tag('p', _('You do not have permission to remove item') . ": {$id}"));
            continue;
        }
        if (remove_event($id)) {
            $html->add(tag('p', _('Removed item') . ": {$id}"));
        } else {
            $html->add(tag('p', _('Could not remove item') . ": {$id}"));
        }
    }
    if ($ids == 0) {
        $html->add(tag('p', _('No items selected.')));
    }
    return $html;
}
Beispiel #25
0
function options_submit()
{
    global $calendar_name, $vars, $db;
    if (!is_admin()) {
        return tag('div', _('Permission denied'));
    }
    $query = "UPDATE " . SQL_PREFIX . "calendars SET\n";
    if (isset($vars['hours_24'])) {
        $query .= "hours_24 = 1,\n";
    } else {
        $query .= "hours_24 = 0,\n";
    }
    if (isset($vars['start_monday'])) {
        $query .= "start_monday = 1,\n";
    } else {
        $query .= "start_monday = 0,\n";
    }
    if (isset($vars['translate'])) {
        $query .= "translate = 1,\n";
    } else {
        $query .= "translate = 0,\n";
    }
    $query .= "anon_permission = '{$vars['anon_permission']}',\n" . "calendar_title = '{$vars['calendar_title']}',\n" . "subject_max = '{$vars['subject_max']}'\n" . "WHERE calendar={$calendar_name};";
    $result = $db->Execute($query) or db_error(_('Error reading options'), $query);
    return tag('div', _('Updated options'));
}
Beispiel #26
0
 public function bootstrap()
 {
     $data = array();
     foreach ($this->bootstrapConfigs as $k => $v) {
         if (in_array($k, $this->supportResponseBaseConfigKeys)) {
             $data[$k] = $v;
         }
     }
     // 已启用应用
     $data['loaded_apps'] = array_merge(AppService::$activeApps, AppService::$baseApps);
     // 已授权节点
     $data['authed_nodes'] = get_array_to_kv(AuthorizeService::$authed_nodes, "flag", "node");
     // 用户信息
     $data['all_users'] = UserService::get_all_basic_data();
     // 当前用户信息
     $data['user_info'] = D('Account/User')->get_current_user();
     // 系统首选项
     $system_preference = D('Home/Config', 'Service')->get_kv_config();
     foreach ($system_preference as $k => $v) {
         $system_preference[$k] = Schema::data_field_format($v['val'], $v['data_type']);
     }
     $data['system_preference'] = $system_preference;
     // 个人首选项
     $user_preference = D('Account/UserPreference', 'Service')->get_preference();
     foreach ($user_preference as $k => $v) {
         $user_preference[$k] = Schema::data_field_format($v['data'], $v['data_type']);
     }
     $data['user_preference'] = $user_preference;
     // 主页面包含
     $data['main_include'] = D('Home/Config', 'Service')->get_main_include();
     tag('before_bootstrap_config_response', $data);
     $this->response($data);
 }
Beispiel #27
0
function areatab($label, $event, $tarea, $area)
{
    $tc = $area == $event ? 'tabup' : 'tabdown';
    $atts = ' class="' . $tc . '"';
    $hatts = ' href="?event=' . $tarea . '" class="plain"';
    return n . t . t . t . tda(tag($label, 'a', $hatts), $atts);
}
function password_submit()
{
    global $vars, $phpcdb, $phpc_user;
    if (!is_user()) {
        return tag('div', __('You must be logged in.'));
    }
    verify_token();
    if (!$phpc_user->is_password_editable()) {
        soft_error(__('You do not have permission to change your password.'));
    }
    if (!isset($vars['old_password'])) {
        return tag('div', __('You must specify your old password.'));
    } else {
        $old_password = $vars['old_password'];
    }
    if ($phpc_user->password != md5($old_password)) {
        return tag('div', __('The password you entered did not match your old password.'));
    }
    if (empty($vars['password1'])) {
        return tag('div', __('You must specify a password'));
    }
    if (empty($vars['password2']) || $vars['password1'] != $vars['password2']) {
        return tag('div', __('Your passwords did not match'));
    }
    $passwd = md5($vars['password1']);
    $phpcdb->set_password($phpc_user->get_uid(), $passwd);
    return tag('div', __('Password updated.'));
}
Beispiel #29
0
 /**
  * 运行应用实例 入口文件使用的快捷方法
  * @access public
  * @return void
  */
 public static function run()
 {
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 加载动态项目公共文件和配置
     load_ext_file();
     // 项目初始化标签
     tag('app_init');
     // URL调度
     Dispatcher::dispatch();
     // 项目开始标签
     tag('app_begin');
     // Session初始化 支持其他客户端
     if (isset($_REQUEST[C("VAR_SESSION_ID")])) {
         session_id($_REQUEST[C("VAR_SESSION_ID")]);
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // 记录应用初始化时间
     if (C('SHOW_RUN_TIME')) {
         G('initTime');
     }
     App::exec();
     // 项目结束标签
     tag('app_end');
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
Beispiel #30
0
function clean($message = '')
{
    global $prefs;
    extract($prefs);
    pagetop("Cache Cleaner", ps("txp_token") === md5($lastmod) ? "Successful" : "Token expired. Please try again.");
    if (ps("txp_token") === md5($lastmod)) {
        echo "<div align=\"center\" style=\"margin-top:3em\">";
        printf("Deleted %s files. Cache is clean.", '' . txp_flushdir(true));
        echo "</div>";
    }
    echo "<div align=\"center\" style=\"margin-top:3em\">";
    echo form(tag("Cache-Cleaner", "h3") . graf("Usually you don't need to do that. Cache is <b>automatically</b> cleared <br />1)\n\t\t\t\t  after a certain amount of time <br />2) when a comment is posted, edited or moderated\n\t\t\t      <br />3) after a page-template or form-tag is modified.<br />4) after template import.<br />5) after article update.<br /><br />" . fInput("hidden", "txp_token", md5($lastmod)) . fInput("submit", "clean_cache", "Clean all cached Files", "smallerbox") . eInput("cache") . sInput("clean"), " style=\"text-align:center\""));
    echo tag("Cache Statistics", "h3");
    global $path_to_site;
    $count = array('size' => 0, 'num' => 0);
    $txp_cache_dir = txpath . "/cache";
    if (!empty($txp_cache_dir) and $fp = opendir($txp_cache_dir)) {
        while (false !== ($file = readdir($fp))) {
            if ($file[0] != ".") {
                $count['size'] += filesize("{$txp_cache_dir}/{$file}");
                ++$count['num'];
            }
        }
        closedir($fp);
        printf("There are %d cache files with a total size of %d kb.", $count['num'], floor($count['size'] / 1000));
    } else {
        echo "Cache is empty.";
    }
    include $path_to_site . '/textpattern/lib/txp_cache/cache-config.php';
    echo "</div>";
}