/** * 附件文件保存 * * @param array $post_set 发帖信息设置 * @param array $attachary 附件信息数组 * @param array $configs 配置参数 * @access public * @return void */ function jieqi_post_attachfile(&$post_set, &$attachary, $configs) { //判断是否加水印 $make_image_water = false; if (function_exists('gd_info') && $configs['attachwater'] > 0 && JIEQI_MODULE_VTYPE != '' && JIEQI_MODULE_VTYPE != 'Free') { if (strpos($configs['attachwimage'], '/') === false && strpos($configs['attachwimage'], '\\') === false) { $water_image_file = $GLOBALS['jieqiModules'][$post_set['module']]['path'] . '/images/' . $configs['attachwimage']; } else { $water_image_file = $configs['attachwimage']; } if (is_file($water_image_file)) { $make_image_water = true; include_once JIEQI_ROOT_PATH . '/lib/image/imagewater.php'; } } $attachdir = jieqi_uploadpath($configs['attachdir'], $post_set['module']); if (!file_exists($attachdir)) { jieqi_createdir($attachdir); } $attachdir .= '/' . date('Ymd', $post_set['posttime']); if (!file_exists($attachdir)) { jieqi_createdir($attachdir); } foreach ($attachary as $k => $v) { $attach_save_path = $attachdir . '/' . $post_set['postid'] . '_' . $attachary[$k]['attachid'] . '.' . $attachary[$k]['postfix']; $tmp_attachfile = dirname($_FILES['attachfile']['tmp_name'][$v['order']]) . '/' . basename($attach_save_path); @move_uploaded_file($_FILES['attachfile']['tmp_name'][$v['order']], $tmp_attachfile); //图片加水印 if ($make_image_water && eregi("\\.(gif|jpg|jpeg|png)\$", $tmp_attachfile)) { $img = new ImageWater(); $img->save_image_file = $tmp_attachfile; $img->codepage = JIEQI_SYSTEM_CHARSET; $img->wm_image_pos = $configs['attachwater']; $img->wm_image_name = $water_image_file; $img->wm_image_transition = $configs['attachwtrans']; $img->jpeg_quality = $configs['attachwquality']; $img->create($tmp_attachfile); unset($img); } jieqi_copyfile($tmp_attachfile, $attach_save_path, 0777, true); } }
$newAttach->setVar('size', $infoary[$k]['size']); $newAttach->setVar('hits', 0); $newAttach->setVar('needexp', 0); $newAttach->setVar('uptime', $chapter->getVar('postdate', 'n')); if ($attachs_handler->insert($newAttach)) { $attachid = $newAttach->getVar('attachid'); $infoary[$k]['attachid'] = $attachid; } else { $infoary[$k]['attachid'] = 0; } $attach_save_path = $attachdir . '/' . $infoary[$k]['attachid'] . '.' . $infoary[$k]['postfix']; $tmp_attachfile = dirname($_FILES['attachfile']['tmp_name'][$v]) . '/' . basename($attach_save_path); @move_uploaded_file($_FILES['attachfile']['tmp_name'][$v], $tmp_attachfile); //图片加水印 if ($make_image_water && eregi("\\.(gif|jpg|jpeg|png)\$", $tmp_attachfile)) { $img = new ImageWater(); $img->save_image_file = $tmp_attachfile; $img->codepage = JIEQI_SYSTEM_CHARSET; $img->wm_image_pos = $jieqiConfigs['article']['attachwater']; $img->wm_image_name = $water_image_file; $img->wm_image_transition = $jieqiConfigs['article']['attachwtrans']; $img->jpeg_quality = $jieqiConfigs['article']['attachwquality']; $img->create($tmp_attachfile); unset($img); } jieqi_copyfile($tmp_attachfile, $attach_save_path, 0777, true); } } foreach ($infoary as $val) { $oldattachary[] = $val; }
if ($filtercolor >= 0) { $cindexary = imagecolorsforindex($imageres, $imagebgcolor); imagecolorset($imageres, $filtercolor, $cindexary['red'], $cindexary['green'], $cindexary['blue']); $filterwater = true; } } } } //保存去水印后图片 if ($filterwater) { $funname = 'image' . $imagetype; $funname($imageres, $imgattach_save_path); } //图片加水印 if ($make_image_water && eregi("\\.(gif|jpg|jpeg|png)\$", $imgattach_save_path)) { $img = new ImageWater(); $img->save_image_file = $imgattach_save_path; $img->codepage = JIEQI_SYSTEM_CHARSET; $img->wm_image_pos = $jieqiConfigs['article']['attachwater']; $img->wm_image_name = $water_image_file; $img->wm_image_transition = $jieqiConfigs['article']['attachwtrans']; $img->jpeg_quality = $jieqiConfigs['article']['attachwquality']; $img->create($imgattach_save_path); unset($img); } } @chmod($imgattach_save_path, 0777); } } } unset($newChapter);