Пример #1
0
 /**
  *
  * @return mixed
  */
 public function actionCreate()
 {
     global $API_CODE;
     if (isset($_POST['user'])) {
         //Validation
         $new_data_error_msg = '';
         if (!strlen(trim($_POST['user'])) || !strlen(trim($_POST['content']))) {
             $new_data_error_msg = t('FILL_NOT_COMPLETE');
         } elseif (strlen($_POST['content'] > 580)) {
             $new_data_error_msg = t('WORDS_TOO_LONG');
         } elseif (ZFramework::app()->valid_code_open == 1 && gd_loaded() && !$this->_verifyCode->check($_POST['valid_code'])) {
             $new_data_error_msg = t('CAPTCHA_WRONG');
         }
         if ($new_data_error_msg) {
             if (defined('API_MODE')) {
                 $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => $new_data_error_msg);
                 die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
             }
             if (!empty($_POST['ajax'])) {
                 die($new_data_error_msg);
             } else {
                 show_message($new_data_error_msg, true, 'index.php');
             }
         }
         // Ready to send query to database
         $user = $this->_model->escape_string($_POST['user']);
         if (!isset($_SESSION['admin']) && $_POST['user'] == ZFramework::app()->admin) {
             $user = '******';
         }
         $userExists = $this->_model->queryAll(sprintf(parse_tbprefix("SELECT * FROM <sysuser> WHERE username='******'"), $this->_model->escape_string($_POST['user'])));
         if ($userExists && @$_SESSION['user'] != $_POST['user']) {
             $user = '******';
         }
         $content = $this->_model->escape_string($_POST['content']);
         if (isset($_SESSION['uid'])) {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uid , content , post_time , ip ) VALUES ( %d , '%s' , %d , '%s' )"), $_SESSION['uid'], $content, time(), getIp());
         } else {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uname , content , post_time , ip ) VALUES ( '%s' ,'%s' , %d , '%s')"), $user, $content, time(), getIp());
         }
         // Send query to database
         if (!$this->_model->query($sql_insert)) {
             die($this->_model->error());
         }
         performEvent('PostController/actionCreate', array($user, $content, time() + ZFramework::app()->timezone * 60 * 60));
         if (defined('API_MODE')) {
             $json_array = array('insert_id' => $this->_model->insert_id());
             die(function_exists('json_encode') ? json_encode($json_array) : CJSON::encode($json_array));
         }
         if (isset($_POST['ajax'])) {
             echo 'OK';
             return TRUE;
         }
     }
     if (defined('API_MODE')) {
         $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => t('ONLY_POST'));
         die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
     }
     header("Location:index.php");
 }
Пример #2
0
          <td><?php 
echo t('FILTER_WORDS');
?>
:</td><td><textarea class="span-9" name="filter_words" cols="20" rows="3"><?php 
echo ZFramework::app()->filter_words;
?>
</textarea></td>
          </tr>
          <tr>
          <td><?php 
echo t('ENABLE_CAPTCHA');
?>
:</td>
          <td>
          <?php 
if (gd_loaded()) {
    ?>
          <input name="valid_code_open" type="radio" value="1" <?php 
    if (ZFramework::app()->valid_code_open == 1) {
        ?>
 checked='checked' <?php 
    }
    ?>
 /><?php 
    echo t('YES');
    ?>
<input name="valid_code_open" type="radio" value="0" <?php 
    if (ZFramework::app()->valid_code_open == 0) {
        ?>
 checked='checked' <?php 
    }
Пример #3
0
require APPROOT . '/includes/database/YDB.php';
//载入配置文件,若尚未安装则载入默认的配置文件
if (file_exists(conf_path() . '/config.php')) {
    include_once conf_path() . '/config.php';
} else {
    include './sites/default/default.config.php';
}
//定义常量
define('CONFIGFILE', conf_path() . '/config.php');
define('MP_VERSION', '2.0 alpha');
define('THEMEDIR', 'themes/');
define('SMILEYDIR', 'http://mapleleaf.googlecode.com/files/');
if (!function_exists('json_encode')) {
    include 'CJSON.php';
}
include_once 'Imgcode.php';
//载入框架类
require 'ZFramework.php';
//检查服务器支持情况
$gd_exist = gd_loaded();
$zip_support = class_exists('ZipArchive') ? 'On' : 'Off';
if (is_installed()) {
    //若已经安装,执行IP检查
    if (is_baned(getIP())) {
        die('Access denied!');
    }
    is_closedMode();
} elseif ($_GET['action'] != 'install') {
    header("Location:index.php?action=install");
    exit;
}
Пример #4
0
function get_chart_markup($data_type, $chart_type, $chart_param1, $chart_param2)
{
    global $PHP_SELF;
    $result = '';
    $alt_title = '';
    if (gd_loaded()) {
        $alt_title = get_chart_title($data_type);
        if ($alt_title == '') {
            return '';
        }
        if ($chart_type == BAR_CHART) {
            $alt_title .= ' hit and miss percentage chart';
        } elseif ($chart_type == PIE_CHART) {
            $alt_title .= ' memory usage percentage chart';
        } else {
            return '';
        }
        $result = '<img src="' . $PHP_SELF;
        $result .= '?img=' . $data_type . '&amp;type=' . $chart_type;
        $result .= '&amp;p1=' . $chart_param1 . '&amp;p2=' . $chart_param2 . '" ';
        $result .= 'alt="' . $alt_title . '" width="' . IMG_WIDTH . '" height="' . IMG_HEIGHT . '" />';
    } else {
        $result = '<p class="notice">Enable GD library (<em>php_gd2.dll</em>) in order to see the charts.</p>';
    }
    return $result;
}
Пример #5
0
echo t('CONTENT');
?>
</td>
                        <td><textarea class="span-10" id="content" name="content" cols="45" rows="8" ></textarea></td>
                        <td><div id='smileys'><?php 
echo $smileys;
?>
</div>&nbsp;<br /><?php 
if (ConfigController::FILTER_TRIPTAGS == ZFramework::app()->filter_type) {
    echo t('ALLOWED_TAGS', array('{allowed_tags}' => htmlentities(ZFramework::app()->allowed_tags)));
}
?>
</td>
                    </tr>
                    <?php 
if (ZFramework::app()->valid_code_open && gd_loaded()) {
    ?>
                    <tr>
                        <td class="l"><?php 
    echo t('VALIDATE_CODE');
    ?>
</td>
                        <td class="left"><input id="valid_code" type="text" name="valid_code" size="4" maxlength="4" />&nbsp;<img id="captcha_img" src="index.php?action=captcha" title="<?php 
    echo t('CLICK_TO_REFRESH');
    ?>
" alt="<?php 
    echo t('CAPTCHA');
    ?>
" /></td>
                        <td class="left">&nbsp;</td>
                    </tr>