Exemplo n.º 1
0
<?php

/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-9-16
 * Time: 上午11:37
 * To change this template use File | Settings | File Templates.
 */
include '../inc/common.inc.php';
include '../inc/upload.class.php';
$img = array();
$up = _upload('Filedata');
$file = $up->insertid;
if ($file['file_id'] > 0) {
    $img = array('dbQuery' => $file['$dbQuery'], 'file_id' => $file['file_id'], 'key_path' => $file['key_path'], 'key' => $file['key'], 'width' => $file['width'], 'height' => $file['height'], 'type' => $file['type']);
    $img['farm'] = "farm1";
    $img['bucket'] = "hbimg";
    $img['success'] = true;
    $img['ret'] = 0;
    $img['msg'] = "上传成功";
    $img['errorcode'] = 0;
    $img['file_path'] = $GLOBALS['app']['scheme'] . "://" . $GLOBALS['app']['host'] . "/" . $file['key_path'] . $file['key'];
} else {
    $img = $up->error;
    $img['ret'] = 1;
    $img['msg'] = "上传失败";
}
echo json_encode($img);
Exemplo n.º 2
0
/**
 * 文件上传处理。单个文件上传,多个分多次请求
 * 调用demo
 * upload('file','D:/www/');
 */
function upload($fileInput, $path = './')
{
    global $config, $L;
    $file = $_FILES[$fileInput];
    if (!isset($file)) {
        show_json($L['upload_error_null'], false);
    }
    $file_name = iconv_system($file['name']);
    $info = _upload($file['tmp_name'], $file['size'], $path . $file_name);
    show_json($info['data'], $info['code'], $info['path']);
}
 function addgroup_action()
 {
     if (!$GLOBALS['session']->get('uid')) {
         sheader(url('user', 'login'));
     }
     $updateid = intval($_REQUEST['updateid']);
     $group = array();
     if ($updateid) {
         $group = $this->group->GetOne('and id=' . $updateid);
     }
     if (submitcheck('commit')) {
         $userinfo = $this->user->GetOne('and uid=' . $GLOBALS['session']->get('uid'));
         $data['subject'] = strip_tags(trim($_POST['title']));
         $data['groupsite'] = $userinfo['sitename'];
         $data['oldprice'] = floatval($_POST['yuan_money']) ? floatval($_POST['yuan_money']) : 100;
         $data['nowprice'] = floatval($_POST['now_money']);
         $data['url'] = strip_tags(trim($_POST['url']));
         $data['discount'] = intval($data['nowprice'] * 100 / $data['oldprice']) / 10;
         $data['lasttime'] = strtotime($_POST['over_date']);
         $data['grouptype'] = intval($_POST['class_id']);
         $cityinfo = explode('-', $_POST['city']);
         $data['cityid'] = $cityinfo[0];
         $data['cityname'] = $cityinfo[1];
         $data['keyword'] = strip_tags(trim($_POST['key_word']));
         $data['userid'] = $userinfo['uid'];
         if ($_FILES['file_img']['error'] == 0) {
             $data['thumb'] = _upload('file_img', $GLOBALS['uploaddir'] . '/' . date('Y/m'));
             if ($group && $group['thumb']) {
                 unlink($group['thumb']);
             }
         }
         if ($updateid) {
             if ($group['userid'] == $GLOBALS['session']->get('uid')) {
                 if ($group['ispassed']) {
                     sheader(url('user', 'grouplist'), 3, '已审核通过了,不能再修改', 'member_redirect');
                 } else {
                     if ($this->group->UpdateData($data, 'and id=' . $updateid)) {
                         sheader(url('user', 'grouplist'), 3, '数据更新成功,请等待管理员审核', 'member_redirect');
                     } else {
                         sheader(url('user', 'grouplist'), 3, '数据未做任何改变', 'member_redirect');
                     }
                 }
             } else {
                 sheader(url('user', 'grouplist'), 3, '您无此权限', 'member_redirect');
             }
         } else {
             $data['updatetime'] = $GLOBALS['timestamp'];
             if ($this->group->InsertData($data)) {
                 sheader(url('user', 'grouplist'), 3, '数据添加成功,请等待管理员审核', 'member_redirect');
             } else {
                 sheader(url('user', 'grouplist'), 3, '数据添加失败', 'member_redirect');
             }
         }
     } else {
         if ($group && $group['ispassed']) {
             sheader(url('user', 'grouplist'), 3, '已审核通过了,不能再修改', 'member_redirect');
         }
         if ($group && $group['userid'] != $GLOBALS['session']->get('uid')) {
             sheader(url('user', 'grouplist'), 3, '您无此权限', 'member_redirect');
         }
         include template('member_tuan');
     }
 }
Exemplo n.º 4
0
    die('no updir');
}
if (!is_numeric($page_id)) {
    die('wrong updir');
}
mso_checkreferer();
$ext = substr(strrchr($fn, '.'), 1);
$allowed_ext = explode('|', mso_get_option('allowed_types', 'general', 'mp3|gif|jpg|jpeg|png|zip|txt|rar|doc|rtf|pdf|html|htm|css|xml|odt|avi|wmv|flv|swf|wav|xls|7z|gz|bz2|tgz'));
if (!in_array(strtolower($ext), $allowed_ext)) {
    die('not allowed');
}
// Закончили проверки.
// Полный путь к каталогу.
$up_dir = getinfo('uploads_dir') . '_pages/' . $page_id . '/';
// Сама загрузка файла и создание миниатюр.
_upload($up_dir, $fn);
function _upload($up_dir, $fn, $r = array())
{
    $fn = _slug($fn);
    $ext = substr(strrchr($fn, '.'), 1);
    $name = substr($fn, 0, strlen($fn) - strlen($ext) - 1);
    // Если имя файла пустое, только расширение.
    if ($fn == '.' . $ext) {
        $fn = '1' . $fn;
    }
    // Если файл уже существует.
    if (file_exists($up_dir . $fn)) {
        for ($i = 1; $i < 100; $i++) {
            $fn = $name . '-' . $i . '.' . $ext;
            if (!file_exists($up_dir . $fn)) {
                break;
Exemplo n.º 5
0
    function settingdata_action()
    {
        if (submitcheck('commit')) {
            unset($_POST['con']);
            unset($_POST['act']);
            $type = $_POST['dotype'];
            unset($_POST['commit'], $_POST['dotype']);
            $setting_mod = new common('setting');
            if ($_FILES['site_logo']['name']) {
                $filename = explode('.', $_FILES['site_logo']['name']);
                $container = 'and variable="site_logo"';
                $data['content'] = _upload('site_logo', 'data/logo', 'logo.' . $filename[1]);
                $datalist = $setting_mod->GetOne($container);
                if ($datalist) {
                    $setting_mod->UpdateData($data, $container);
                } else {
                    $data['variable'] = 'site_logo';
                    $setting_mod->InsertData($data);
                }
            }
            $changeadmin = '';
            foreach ($_POST as $k => $v) {
                if ($k == 'adminpath' && $v != $GLOBALS['setting']['adminpath']) {
                    $changeadmin = $v;
                }
                $container = 'and variable="' . $k . '"';
                $data['content'] = strip_tags($v);
                $datalist = $setting_mod->GetOne($container);
                if ($datalist) {
                    $updatesql[$k] = $v;
                } else {
                    $insertsql[$k] = $v;
                }
            }
            if ($insertsql) {
                foreach ($insertsql as $key => $val) {
                    $setting_mod->InsertData(array('variable' => $key, 'content' => $val));
                }
            }
            if ($updatesql) {
                foreach ($updatesql as $key => $val) {
                    $setting_mod->UpdateData(array('content' => $val), 'and variable="' . $key . '"');
                }
            }
            if ($type == 'template') {
                $dofile = cleancache('', 'data/compile');
                if (!$dofile) {
                    echo '<SCRIPT LANGUAGE="JavaScript">
					<!--
						alert("模板更新成功,清空系统编译失败,请手动清除");
					//-->
					</SCRIPT>';
                } else {
                    echo '<SCRIPT LANGUAGE="JavaScript">
					<!--
						alert("模板更新成功");
					//-->
					</SCRIPT>';
                }
            }
            deletef('setting');
            if (!empty($changeadmin)) {
                echo '后台路径参数已修改,为了系统安全,请您继续做以下工作:<ul><li>1、连接ftp,将controls/' . $GLOBALS['setting']['adminpath'] . '.class.php文件名修改为:' . $changeadmin . '.class.php</li><li>2、打开' . $changeadmin . '.class.php,将文件中' . $GLOBALS['setting']['adminpath'] . '_controller替换为:' . $changeadmin . '_controller</li><li>3、修改完毕后,<a href="' . SITE_ROOT . '/?con=' . $changeadmin . '" target="_top">重新进入后台</a></li></ul>';
            } else {
                if ($_REQUEST['custom_url']) {
                    sheader($_REQUEST['custom_url'], 3, '修改成功', 'redirect', true);
                } else {
                    sheader('index.php?con=' . $GLOBALS['setting']['adminpath'] . '&act=setting&type=' . $type, 3, '修改成功', 'redirect', true);
                }
            }
        }
    }
 function linkmodify_action()
 {
     $updateid = $_REQUEST['updateid'];
     $link_mod = new common('link');
     if (submitcheck('commit')) {
         $data['title'] = trim(strip_tags($_POST['title']));
         $data['url'] = substr($_POST['url'], 0, 4) == 'http' ? trim($_POST['url']) : 'http://' . $_POST['url'];
         $data['dec'] = trim(strip_tags($_POST['dec']));
         $data['type'] = intval($_POST['type']);
         if ($_FILES['thumb']['name']) {
             $data['thumb'] = _upload('thumb', 'data/upload/tempimg');
         }
         if ($updateid > 0) {
             if ($link_mod->UpdateData($data, 'and id=' . $updateid)) {
                 deletef('link');
                 sheader('index.php?con=admin&act=link', 3, '修改成功', 'redirect', true);
             }
         } else {
             if ($link_mod->InsertData($data)) {
                 deletef('link');
                 sheader('index.php?con=admin&act=link', 3, '添加成功', 'redirect', true);
             }
         }
     } else {
         if ($updateid) {
             $link = $link_mod->GetOne('and id=' . $updateid);
         }
         include ROOT_PATH . '/views/admin/link_form.php';
     }
 }