Example #1
0
 public function testDeleteMedia()
 {
     $picture = array('rel_type' => 'content', 'rel_id' => 3, 'title' => 'My new pic to del', 'media_type' => 'picture', 'src' => 'http://lorempixel.com/400/200/');
     $saved_pic_id = save_media($picture);
     $picture_data = get_media_by_id($saved_pic_id);
     $to_delete = array('id' => $saved_pic_id);
     $delete = delete_media($to_delete);
     $title = $picture_data['title'];
     $picture_null = get_media_by_id($saved_pic_id);
     $this->assertEquals($picture_null, false);
     $this->assertEquals(is_array($picture_data), true);
     $this->assertEquals($title, 'My new pic to del');
     $this->assertEquals(!$delete, false);
 }
Example #2
0
 public function copy($data)
 {
     $new_cont_id = false;
     if (defined('MW_API_CALL')) {
         $to_trash = true;
         $adm = $this->app->user_manager->is_admin();
         if ($adm == false) {
             return array('error' => 'You must be admin to copy content!');
         }
     }
     if (isset($data['id'])) {
         $this->app->event_manager->trigger('content.before.copy', $data);
         $cont = get_content_by_id($data['id']);
         if ($cont != false and isset($cont['id'])) {
             $new_cont = $cont;
             if (isset($new_cont['title'])) {
                 $new_cont['title'] = $new_cont['title'] . ' copy';
             }
             $new_cont['id'] = 0;
             $content_cats = array();
             $cats = content_categories($cont['id']);
             if (!empty($cats)) {
                 foreach ($cats as $cat) {
                     if (isset($cat['id'])) {
                         $content_cats[] = $cat['id'];
                     }
                 }
             }
             if (!empty($content_cats)) {
                 $new_cont['categories'] = $content_cats;
             }
             $new_cont_id = $this->save($new_cont);
             $cust_fields = get_custom_fields('content', $data['id'], true);
             if (!empty($cust_fields)) {
                 foreach ($cust_fields as $cust_field) {
                     $new = $cust_field;
                     $new['id'] = 0;
                     $new['rel_id'] = $new_cont_id;
                     $new_item = save_custom_field($new);
                 }
             }
             $images = get_pictures($data['id']);
             if (!empty($images)) {
                 foreach ($images as $image) {
                     $new = $image;
                     $new['id'] = 0;
                     $new['rel_id'] = $new_cont_id;
                     $new['rel_type'] = 'content';
                     $new_item = save_media($new);
                 }
             }
         }
     }
     return $new_cont_id;
 }
Example #3
0
    $pager = pagination($total, $pindex, $psize);
} elseif ($operation == 'post') {
    $id = intval($_GPC['id']);
    if (empty($id)) {
        ca('poster.add');
    } else {
        ca('poster.edit|poster.view');
    }
    $item = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_poster') . " WHERE id =:id and uniacid=:uniacid limit 1", array(':id' => $id, ':uniacid' => $_W['uniacid']));
    if (!empty($item)) {
        $data = json_decode(str_replace('"', "'", $item['data']), true);
    }
    if (checksubmit('submit')) {
        load()->model('account');
        $acid = pdo_fetchcolumn('select acid from ' . tablename('account_wechats') . ' where uniacid=:uniacid limit 1', array(':uniacid' => $_W['uniacid']));
        $data = array('uniacid' => $_W['uniacid'], 'title' => trim($_GPC['title']), 'type' => intval($_GPC['type']), 'keyword' => trim($_GPC['keyword']), 'bg' => save_media($_GPC['bg']), 'data' => htmlspecialchars_decode($_GPC['data']), 'resptitle' => trim($_GPC['resptitle']), 'respthumb' => save_media($_GPC['respthumb']), 'respdesc' => trim($_GPC['respdesc']), 'respurl' => trim($_GPC['respurl']), 'isdefault' => intval($_GPC['isdefault']), 'createtime' => time(), 'oktext' => trim($_GPC['oktext']), 'waittext' => trim($_GPC['waittext']), 'subcredit' => intval($_GPC['subcredit']), 'submoney' => $_GPC['submoney'], 'reccredit' => intval($_GPC['reccredit']), 'recmoney' => $_GPC['recmoney'], 'subtext' => trim($_GPC['subtext']), 'bedown' => intval($_GPC['bedown']), 'beagent' => intval($_GPC['beagent']), 'isopen' => intval($_GPC['isopen']), 'opentext' => trim($_GPC['opentext']), 'openurl' => trim($_GPC['openurl']), 'paytype' => intval($_GPC['paytype']), 'subpaycontent' => trim($_GPC['subpaycontent']), 'recpaycontent' => trim($_GPC['recpaycontent']), 'templateid' => trim($_GPC['templateid']), 'entrytext' => trim($_GPC['entrytext']));
        if ($data['isdefault'] == 1) {
            pdo_update('ewei_shop_poster', array('isdefault' => 0), array('uniacid' => $_W['uniacid'], 'isdefault' => 1, 'type' => $data['type']));
        }
        if (!empty($id)) {
            pdo_update('ewei_shop_poster', $data, array('id' => $id, 'uniacid' => $_W['uniacid']));
            plog('poster.edit', "修改超级海报 ID: {$id}");
        } else {
            pdo_insert('ewei_shop_poster', $data);
            $id = pdo_insertid();
            plog('poster.add', "添加超级海报 ID: {$id}");
        }
        $rule = pdo_fetch("select * from " . tablename('rule') . ' where uniacid=:uniacid and module=:module and name=:name  limit 1', array(':uniacid' => $_W['uniacid'], ':module' => 'ewei_shop', ':name' => "ewei_shop:poster:" . $data['type']));
        if (empty($rule)) {
            $rule_data = array('uniacid' => $_W['uniacid'], 'name' => 'ewei_shop:poster:' . $data['type'], 'module' => 'ewei_shop', 'displayorder' => 0, 'status' => 1);
            pdo_insert('rule', $rule_data);
Example #4
0
 public function html_images($detail = '')
 {
     $detail = htmlspecialchars_decode($detail);
     preg_match_all("/<img.*?src=[\\'| \"](.*?(?:[\\.gif|\\.jpg|\\.png|\\.jpeg]?))[\\'|\"].*?[\\/]?>/", $detail, $imgs);
     $images = array();
     if (isset($imgs[1])) {
         foreach ($imgs[1] as $img) {
             $im = array("old" => $img, "new" => save_media($img));
             $images[] = $im;
         }
     }
     foreach ($images as $img) {
         $detail = str_replace($img['old'], $img['new'], $detail);
     }
     return $detail;
 }
Example #5
0
        foreach ($_GPC['displayorder'] as $id => $displayorder) {
            pdo_update('ewei_shop_creditshop_category', array('displayorder' => $displayorder), array('id' => $id));
        }
        plog('creditshop.category.edit', '批量修改分类的排序');
        message('分类排序更新成功!', $this->createPluginWebUrl('creditshop/category', array('op' => 'display')), 'success');
    }
    $list = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_creditshop_category') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder DESC");
} elseif ($operation == 'post') {
    $id = intval($_GPC['id']);
    if (empty($id)) {
        ca('creditshop.category.add');
    } else {
        ca('creditshop.category.edit|creditshop.category.view');
    }
    if (checksubmit('submit')) {
        $data = array('uniacid' => $_W['uniacid'], 'name' => trim($_GPC['catename']), 'enabled' => intval($_GPC['enabled']), 'isrecommand' => intval($_GPC['isrecommand']), 'displayorder' => intval($_GPC['displayorder']), 'thumb' => save_media($_GPC['thumb']));
        if (!empty($id)) {
            pdo_update('ewei_shop_creditshop_category', $data, array('id' => $id));
            plog('creditshop.category.edit', "修改积分商城分类 ID: {$id}");
        } else {
            pdo_insert('ewei_shop_creditshop_category', $data);
            $id = pdo_insertid();
            plog('creditshop.category.add', "添加积分商城分类 ID: {$id}");
        }
        message('更新分类成功!', $this->createPluginWebUrl('creditshop/category', array('op' => 'display')), 'success');
    }
    $item = pdo_fetch("select * from " . tablename('ewei_shop_creditshop_category') . " where id=:id and uniacid=:uniacid limit 1", array(":id" => $id, ":uniacid" => $_W['uniacid']));
} elseif ($operation == 'delete') {
    ca('creditshop.category.delete');
    $id = intval($_GPC['id']);
    $item = pdo_fetch("SELECT id,name FROM " . tablename('ewei_shop_creditshop_category') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . "");
Example #6
0
        foreach ($_GPC['displayorder'] as $id => $displayorder) {
            pdo_update('ewei_shop_creditshop_adv', array('displayorder' => $displayorder), array('id' => $id));
        }
        plog('creditshop.adv.edit', '批量修改幻灯片的排序');
        message('分类排序更新成功!', $this->createPluginWebUrl('creditshop/adv', array('op' => 'display')), 'success');
    }
    $list = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_creditshop_adv') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder DESC");
} elseif ($operation == 'post') {
    $id = intval($_GPC['id']);
    if (empty($id)) {
        ca('creditshop.adv.add');
    } else {
        ca('creditshop.adv.edit|creditshop.adv.view');
    }
    if (checksubmit('submit')) {
        $data = array('uniacid' => $_W['uniacid'], 'advname' => trim($_GPC['advname']), 'link' => trim($_GPC['link']), 'enabled' => intval($_GPC['enabled']), 'displayorder' => intval($_GPC['displayorder']), 'thumb' => save_media($_GPC['thumb']));
        if (!empty($id)) {
            pdo_update('ewei_shop_creditshop_adv', $data, array('id' => $id));
            plog('creditshop.adv.edit', "修改积分商城幻灯片 ID: {$id}");
        } else {
            pdo_insert('ewei_shop_creditshop_adv', $data);
            $id = pdo_insertid();
            plog('creditshop.adv.add', "添加积分商城幻灯片 ID: {$id}");
        }
        message('更新幻灯片成功!', $this->createPluginWebUrl('creditshop/adv', array('op' => 'display')), 'success');
    }
    $item = pdo_fetch("select * from " . tablename('ewei_shop_creditshop_adv') . " where id=:id and uniacid=:uniacid limit 1", array(":id" => $id, ":uniacid" => $_W['uniacid']));
} elseif ($operation == 'delete') {
    ca('creditshop.adv.delete');
    $id = intval($_GPC['id']);
    $item = pdo_fetch("SELECT id,advname FROM " . tablename('ewei_shop_creditshop_adv') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . "");
Example #7
0
     $spec_id = $get_spec_id;
 } else {
     pdo_insert('ewei_shop_goods_spec', $a);
     $spec_id = pdo_insertid();
 }
 $spec_item_ids = $_POST["spec_item_id_" . $get_spec_id];
 $spec_item_titles = $_POST["spec_item_title_" . $get_spec_id];
 $spec_item_shows = $_POST["spec_item_show_" . $get_spec_id];
 $spec_item_thumbs = $_POST["spec_item_thumb_" . $get_spec_id];
 $spec_item_oldthumbs = $_POST["spec_item_oldthumb_" . $get_spec_id];
 $itemlen = count($spec_item_ids);
 $itemids = array();
 for ($n = 0; $n < $itemlen; $n++) {
     $item_id = "";
     $get_item_id = $spec_item_ids[$n];
     $d = array("uniacid" => $_W['uniacid'], "specid" => $spec_id, "displayorder" => $n, "title" => $spec_item_titles[$n], "show" => $spec_item_shows[$n], "thumb" => save_media($spec_item_thumbs[$n]));
     $f = "spec_item_thumb_" . $get_item_id;
     if (is_numeric($get_item_id)) {
         pdo_update("ewei_shop_goods_spec_item", $d, array("id" => $get_item_id));
         $item_id = $get_item_id;
     } else {
         pdo_insert('ewei_shop_goods_spec_item', $d);
         $item_id = pdo_insertid();
     }
     $itemids[] = $item_id;
     $d['get_id'] = $get_item_id;
     $d['id'] = $item_id;
     $spec_items[] = $d;
 }
 if (count($itemids) > 0) {
     pdo_query("delete from " . tablename('ewei_shop_goods_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id} and id not in (" . implode(",", $itemids) . ")");
Example #8
0
        }
    }
    if (empty($parent)) {
        $level = 1;
    } else {
        if (empty($parent['parentid'])) {
            $level = 2;
        } else {
            $level = 3;
        }
    }
    if (checksubmit('submit')) {
        if (empty($_GPC['catename'])) {
            message('抱歉,请输入分类名称!');
        }
        $data = array('uniacid' => $_W['uniacid'], 'name' => trim($_GPC['catename']), 'enabled' => intval($_GPC['enabled']), 'displayorder' => intval($_GPC['displayorder']), 'isrecommand' => intval($_GPC['isrecommand']), 'ishome' => intval($_GPC['ishome']), 'description' => $_GPC['description'], 'parentid' => intval($parentid), 'thumb' => save_media($_GPC['thumb']), 'advimg' => save_media($_GPC['advimg']), 'advurl' => trim($_GPC['advurl']));
        if (!empty($id)) {
            unset($data['parentid']);
            pdo_update('ewei_shop_category', $data, array('id' => $id));
            load()->func('file');
            file_delete($_GPC['thumb_old']);
            plog('shop.category.edit', "修改分类 ID: {$id}");
        } else {
            pdo_insert('ewei_shop_category', $data);
            $id = pdo_insertid();
            plog('shop.category.add', "添加分类 ID: {$id}");
        }
        message('更新分类成功!', $this->createWebUrl('shop/category', array('op' => 'display')), 'success');
    }
} elseif ($operation == 'delete') {
    ca('shop.category.delete');
Example #9
0
         if (!is_dir($datapath)) {
             load()->func('file');
             @mkdirs($datapath, "777");
         }
         file_put_contents($datapath . "/shop_" . $_W['uniacid'], $set['shop']['style']);
         plog('sysset.save.pay', '修改系统设置-模板设置');
     } elseif ($op == 'member') {
         $shop = is_array($_GPC['shop']) ? $_GPC['shop'] : array();
         $set['shop']['levelname'] = trim($shop['levelname']);
         $set['shop']['levelurl'] = trim($shop['levelurl']);
         plog('sysset.save.pay', '修改系统设置-会员设置');
     } elseif ($op == 'category') {
         $shop = is_array($_GPC['shop']) ? $_GPC['shop'] : array();
         $set['shop']['catlevel'] = trim($shop['catlevel']);
         $set['shop']['catshow'] = intval($shop['catshow']);
         $set['shop']['catadvimg'] = save_media($shop['catadvimg']);
         $set['shop']['catadvurl'] = trim($shop['catadvurl']);
         plog('sysset.save.pay', '修改系统设置-分类层级设置');
     } elseif ($op == 'contact') {
         $shop = is_array($_GPC['shop']) ? $_GPC['shop'] : array();
         $set['shop']['qq'] = trim($shop['qq']);
         $set['shop']['address'] = trim($shop['address']);
         $set['shop']['phone'] = trim($shop['phone']);
         $set['shop']['description'] = trim($shop['description']);
         plog('sysset.save.pay', '修改系统设置-联系方式设置');
     }
 }
 $data = array('uniacid' => $_W['uniacid'], 'sets' => iserializer($set));
 if (empty($setdata)) {
     pdo_insert('ewei_shop_sysset', $data);
 } else {
Example #10
0
        $params[':cate'] = intval($_GPC['cate']);
    }
    $sql = 'SELECT * FROM ' . tablename('ewei_shop_creditshop_goods') . " where  1 and {$condition} ORDER BY displayorder DESC,id DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize;
    $list = pdo_fetchall($sql, $params);
    $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('ewei_shop_creditshop_goods') . " where 1 and {$condition}", $params);
    $pager = pagination($total, $pindex, $psize);
    $category = pdo_fetchall("select id,name,thumb from " . tablename('ewei_shop_creditshop_category') . ' where uniacid=:uniacid order by displayorder desc', array(':uniacid' => $_W['uniacid']), 'id');
} elseif ($operation == 'post') {
    $id = intval($_GPC['id']);
    if (empty($id)) {
        ca('creditshop.goods.add');
    } else {
        ca('creditshop.goods.view|creditshop.goods.edit');
    }
    if (checksubmit('submit')) {
        $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'title' => trim($_GPC['title']), 'cate' => intval($_GPC['cate']), 'thumb' => save_media($_GPC['thumb']), 'price' => $_GPC['price'], 'type' => intval($_GPC['type']), 'chance' => intval($_GPC['chance']), 'chanceday' => intval($_GPC['chanceday']), 'total' => intval($_GPC['total']), 'totalday' => intval($_GPC['totalday']), 'credit' => intval($_GPC['credit']), 'money' => trim($_GPC['money']), 'rate1' => trim($_GPC['rate1']), 'rate2' => trim($_GPC['rate2']), 'status' => intval($_GPC['status']), 'usecredit2' => intval($_GPC['usecredit2']), 'showlevels' => is_array($_GPC['showlevels']) ? implode(",", $_GPC['showlevels']) : '', 'buylevels' => is_array($_GPC['buylevels']) ? implode(",", $_GPC['buylevels']) : '', 'showgroups' => is_array($_GPC['showgroups']) ? implode(",", $_GPC['showgroups']) : '', 'buygroups' => is_array($_GPC['buygroups']) ? implode(",", $_GPC['buygroups']) : '', 'istime' => intval($_GPC['istime']), 'istop' => intval($_GPC['istop']), 'isrecommand' => intval($_GPC['isrecommand']), 'isendtime' => intval($_GPC['isendtime']), 'endtime' => strtotime($_GPC['endtime']), 'timestart' => strtotime($_GPC['timestart']), 'timeend' => strtotime($_GPC['timeend']), 'share_title' => trim($_GPC['share_title']), 'share_icon' => save_media($_GPC['share_icon']), 'share_desc' => trim($_GPC['share_desc']), 'followneed' => intval($_GPC['followneed']), 'followtext' => trim($_GPC['followtext']), 'detail' => m('common')->html_images($_GPC['detail']), 'subtitle' => trim($_GPC['subtitle']), 'subdetail' => m('common')->html_images($_GPC['subdetail']), 'usedetail' => m('common')->html_images($_GPC['usedetail']), 'goodsdetail' => m('common')->html_images($_GPC['goodsdetail']), 'noticedetail' => m('common')->html_images($_GPC['noticedetail']), 'area' => trim($_GPC['area']), 'dispatch' => trim($_GPC['dispatch']), 'isverify' => intval($_GPC['isverify']), 'storeids' => is_array($_GPC['storeids']) ? implode(',', $_GPC['storeids']) : '', 'noticeopenid' => trim($_GPC['noticeopenid']));
        if (!empty($data['isverify'])) {
            $data['dispatch'] = 0;
        }
        $data['vip'] = !empty($data['showlevels']) || !empty($data['showgroups']) ? 1 : 0;
        if (!empty($id)) {
            pdo_update('ewei_shop_creditshop_goods', $data, array('id' => $id, 'uniacid' => $_W['uniacid']));
            plog('creditshop.goods.edit', "编辑积分商城商品 ID: {$id} <br/>商品名称: {$data['title']}");
        } else {
            pdo_insert('ewei_shop_creditshop_goods', $data);
            $id = pdo_insertid();
            plog('creditshop.goods.add', "添加积分商城商品 ID: {$id}  <br/>商品名称: {$data['title']}");
        }
        message('更新商品成功!', $this->createPluginWebUrl('creditshop/goods', array('op' => 'post', 'id' => $id)), 'success');
    }
    $item = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_creditshop_goods') . " WHERE id =:id and uniacid=:uniacid limit 1", array(':uniacid' => $_W['uniacid'], ':id' => $id));
Example #11
0
 } else {
     pdo_insert('ewei_shop_goods_spec', $a);
     $spec_id = pdo_insertid();
 }
 $spec_item_ids = $_POST["spec_item_id_" . $get_spec_id];
 $spec_item_titles = $_POST["spec_item_title_" . $get_spec_id];
 $spec_item_shows = $_POST["spec_item_show_" . $get_spec_id];
 $spec_item_thumbs = $_POST["spec_item_thumb_" . $get_spec_id];
 $spec_item_oldthumbs = $_POST["spec_item_oldthumb_" . $get_spec_id];
 $spec_item_virtuals = $_POST["spec_item_virtual_" . $get_spec_id];
 $itemlen = count($spec_item_ids);
 $itemids = array();
 for ($n = 0; $n < $itemlen; $n++) {
     $item_id = "";
     $get_item_id = $spec_item_ids[$n];
     $d = array("uniacid" => $_W['uniacid'], "specid" => $spec_id, "displayorder" => $n, "title" => $spec_item_titles[$n], "show" => $spec_item_shows[$n], "thumb" => save_media($spec_item_thumbs[$n]), "virtual" => $data['type'] == 3 ? $spec_item_virtuals[$n] : 0);
     $f = "spec_item_thumb_" . $get_item_id;
     if (is_numeric($get_item_id)) {
         pdo_update("ewei_shop_goods_spec_item", $d, array("id" => $get_item_id));
         $item_id = $get_item_id;
     } else {
         pdo_insert('ewei_shop_goods_spec_item', $d);
         $item_id = pdo_insertid();
     }
     $itemids[] = $item_id;
     $d['get_id'] = $get_item_id;
     $d['id'] = $item_id;
     $spec_items[] = $d;
 }
 if (count($itemids) > 0) {
     pdo_query("delete from " . tablename('ewei_shop_goods_spec_item') . " where uniacid={$_W['uniacid']} and specid={$spec_id} and id not in (" . implode(",", $itemids) . ")");
Example #12
0
<?php

global $_W, $_GPC;
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
if ($operation == 'display') {
    ca('shop.notice.view');
    $list = pdo_fetchall("SELECT * FROM " . tablename('ewei_shop_notice') . " WHERE uniacid = '{$_W['uniacid']}' ORDER BY displayorder DESC");
} elseif ($operation == 'post') {
    $id = intval($_GPC['id']);
    if (empty($id)) {
        ca('shop.notice.add');
    } else {
        ca('shop.notice.edit|shop.notice.view');
    }
    if (checksubmit('submit')) {
        $data = array('uniacid' => $_W['uniacid'], 'displayorder' => intval($_GPC['displayorder']), 'title' => trim($_GPC['title']), 'thumb' => save_media($_GPC['thumb']), 'link' => trim($_GPC['link']), 'detail' => htmlspecialchars_decode($_GPC['detail']), 'status' => intval($_GPC['status']), 'createtime' => time());
        if (!empty($id)) {
            pdo_update('ewei_shop_notice', $data, array('id' => $id));
            plog('shop.notice.edit', "修改公告 ID: {$id}");
        } else {
            pdo_insert('ewei_shop_notice', $data);
            $id = pdo_insertid();
            plog('shop.notice.add', "修改公告 ID: {$id}");
        }
        message('更新店铺公告成功!', $this->createWebUrl('shop/notice', array('op' => 'display')), 'success');
    }
    $notice = pdo_fetch("SELECT * FROM " . tablename('ewei_shop_notice') . " WHERE id = '{$id}' and uniacid = '{$_W['uniacid']}'");
} elseif ($operation == 'delete') {
    ca('shop.notice.delete');
    $id = intval($_GPC['id']);
    $notice = pdo_fetch("SELECT id,title  FROM " . tablename('ewei_shop_notice') . " WHERE id = '{$id}' AND uniacid=" . $_W['uniacid'] . "");
Example #13
0
            exit(json_encode($result));
        }
        $path = '/images/ewei_shop/' . $_W['uniacid'];
        if (!is_dir(ATTACHMENT_ROOT . $path)) {
            mkdirs(ATTACHMENT_ROOT . $path);
        }
        $_W['uploadsetting'] = array();
        $_W['uploadsetting']['image']['folder'] = $path;
        $_W['uploadsetting']['image']['extentions'] = $_W['config']['upload']['image']['extentions'];
        $_W['uploadsetting']['image']['limit'] = $_W['config']['upload']['image']['limit'];
        $file = file_upload($_FILES[$field], 'image');
        if (is_error($file)) {
            $result['message'] = $file['message'];
            exit(json_encode($result));
        }
        $result['status'] = "success";
        $result['url'] = $file['url'];
        $result['error'] = 0;
        $result['filename'] = $file['path'];
        $result['url'] = save_media($_W['attachurl'] . $result['filename']);
        pdo_insert('core_attachment', array('uniacid' => $_W['uniacid'], 'uid' => $_W['member']['uid'], 'filename' => $_FILES[$field]['name'], 'attachment' => $result['filename'], 'type' => 1, 'createtime' => TIMESTAMP));
        exit(json_encode($result));
    } else {
        $result['message'] = '请选择要上传的图片!';
        exit(json_encode($result));
    }
} elseif ($operation == 'remove') {
    $file = $_GPC['file'];
    file_delete($file);
    show_json(1);
}
Example #14
0
$debug = false;
// secure page
require '../../cgi/login.php';
debug_msg("User is logged in as {$username}");
// File upload details
$file = $_FILES["tutorial"];
switch ($file["type"]) {
    case 'text/xml':
        $result = save_xml_tutorial($file);
        $loc = $result ? "file_manager.php?msg=File {$result} uploaded." : "overwrite_confirm.php";
        break;
    case 'image/gif':
    case 'image/jpeg':
    case 'image/png':
        $result = save_media($file);
        $msg = $result ? "File {$result} uploaded." : "File {$result} not uploaded. Is it over 1MB limit?";
        $loc = "file_manager.php?msg={$msg}";
        break;
    case 'archive/zip':
        debug_msg("zip file");
        $loc = "file_manager.php?msg=Archive support coming soon.";
        break;
    default:
        debug_msg("File type is " . $file["type"]);
        $loc = "file_manager.php?msg=Unsupported type.";
}
header("Location: {$loc}");
function save_xml_tutorial(&$file)
{
    global $username;