Esempio n. 1
0
 public function fieldsFormSubmit($rid = 0)
 {
     global $_GPC, $_W;
     $id = intval($_GPC['reply_id']);
     $insert = array('rid' => $rid, 'picture' => $_GPC['picture'], 'description' => $_GPC['description'], 'periodlottery' => intval($_GPC['periodlottery']), 'maxlottery' => intval($_GPC['maxlottery']), 'rule' => htmlspecialchars_decode($_GPC['rule']), 'hitcredit' => intval($_GPC['hitcredit']), 'misscredit' => intval($_GPC['misscredit']), 'background' => $_GPC['bg']);
     if (!empty($insert['background'])) {
         file_image_crop(IA_ROOT . '/resource/attachment/' . $insert['background'], IA_ROOT . '/resource/attachment/' . $insert['background'], 310, 190, 5);
     }
     if (empty($id)) {
         pdo_insert($this->tablename, $insert);
     } else {
         if (!empty($_GPC['picture'])) {
             file_delete($_GPC['picture-old']);
         } else {
             unset($insert['picture']);
         }
         pdo_update($this->tablename, $insert, array('id' => $id));
     }
     if (!empty($_GPC['award-title'])) {
         foreach ($_GPC['award-title'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $update = array('title' => $title, 'description' => $_GPC['award-description'][$index], 'probalilty' => $_GPC['award-probalilty'][$index], 'total' => $_GPC['award-total'][$index], 'activation_code' => '', 'activation_url' => '');
             if (empty($update['inkind']) && !empty($_GPC['award-activation-code'][$index])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code'][$index]);
                 $update['activation_code'] = iserializer($activationcode);
                 $update['total'] = count($activationcode);
                 $update['activation_url'] = $_GPC['award-activation-url'][$index];
             }
             pdo_update('scratchcard_award', $update, array('id' => $index));
         }
     }
     //处理添加
     if (!empty($_GPC['award-title-new'])) {
         foreach ($_GPC['award-title-new'] as $index => $title) {
             if (empty($title)) {
                 continue;
             }
             $insert = array('rid' => $rid, 'title' => $title, 'description' => $_GPC['award-description-new'][$index], 'probalilty' => $_GPC['award-probalilty-new'][$index], 'inkind' => intval($_GPC['award-inkind-new'][$index]), 'total' => intval($_GPC['award-total-new'][$index]), 'activation_code' => '', 'activation_url' => '');
             if (empty($insert['inkind'])) {
                 $activationcode = explode("\n", $_GPC['award-activation-code-new'][$index]);
                 $insert['activation_code'] = iserializer($activationcode);
                 $insert['total'] = count($activationcode);
                 $insert['activation_url'] = $_GPC['award-activation-url-new'][$index];
             }
             pdo_insert('scratchcard_award', $insert);
         }
     }
 }
Esempio n. 2
0
 /**
  * @param $upload_name
  * @param string $asname
  * @param bool $thumb
  * @param int $width
  * @param int $height
  * @param int $position
  * @return string
  */
 public function upload_img($upload_name, $asname = '', $thumb = true, $width = 320, $height = 240, $position = 5)
 {
     //文件操作类
     load()->func('file');
     $upfile = $_FILES[$upload_name];
     $name = $upfile['name'];
     $type = $upfile['type'];
     $size = $upfile['size'];
     $tmp_name = $upfile['tmp_name'];
     $error = $upfile['error'];
     //上传路径
     $upload_path = IA_ROOT . "/attachment/thinkidea_rencai/";
     load()->func('file');
     @mkdirs($upload_path);
     if (intval($error) > 0) {
         message('上传错误:错误代码:' . $upload_name . '-' . $error, 'referer', 'error');
     } else {
         //上传文件大小0为不限制,默认2M
         $maxfilesize = empty($this->module['config']['maxfilesize']) ? 2 : intval($this->module['config']['maxfilesize']);
         if ($maxfilesize > 0) {
             if ($size > $maxfilesize * 1024 * 1024) {
                 message('上传文件过大' . $_FILES["file"]["error"], 'referer', 'error');
             }
         }
         //允许上传的图片类型
         $uptypes = array('image/jpg', 'image/png', 'image/jpeg');
         //判断文件的类型
         if (!in_array($type, $uptypes)) {
             message('上传文件类型不符:' . $type, 'referer', 'error');
         }
         //存放目录
         if (!file_exists($upload_path)) {
             mkdir($upload_path);
         }
         //移动文件
         if (!move_uploaded_file($tmp_name, $upload_path . date("YmdHi") . '_' . $name)) {
             message('移动文件失败,请检查服务器权限', 'referer', 'error');
         }
         $srcfile = $upload_path . date("YmdHi") . '_' . $name;
         $desfile = $upload_path . date("YmdHi") . '_' . $name . '.' . $asname . '.thumb.jpg';
         if ($thumb) {
             file_image_thumb($srcfile, $desfile, $width);
         } else {
             file_image_crop($srcfile, $desfile, $width, $height, 5);
         }
         return date("YmdHi") . '_' . $name . '.' . $asname . '.thumb.jpg';
     }
 }