if (filesize($tmp) > $config->get('avatar_size') * 1000) { $ecode = 1; } // check height & width $size = getimagesize($tmp); if ($size[0] > $config->get('avatar_height')) { $ecode = 2; } if ($size[1] > $config->get('avatar_width')) { $ecode = 3; } // check filetype $ext = getFileExt($_FILES['avatar']['name']); $ext = strtolower($ext); $validExt = strtolower($config->get('avatar_types')); $validExt = explode(',', $validExt); if (!in_array($ext, $validExt)) { $ecode = 4; } if ($ecode > 0) { unlink($tmp); jsRedirect('usercp.php?action=avatars&ecode=' . $ecode); } // everything is good, add the avatar $file = time() . '-' . $user->id . '.' . $ext; move_uploaded_file($tmp, './avatars/' . $file); $id = $user->id; $type = $_POST['type']; remove_avatar($db, array('owner_id' => $user->id, 'type' => $type)); $db->query('INSERT INTO ' . db_avatars . " VALUES (\r\n'', '{$id}', '{$file}', '1', '{$type}'\r\n);"); jsRedirect('usercp.php?action=avatars');
<?php /** * ======================================= * D E L E T E A V A T A R * ======================================= */ if (!defined('IN_NLB3')) { echo 'NLB3 Denies Direct Access'; exit; } if (isset($_GET['id'])) { $w = array('owner_id' => $user->id, 'avatar_id' => $_GET['id']); remove_avatar($db, $w); } jsRedirect('usercp.php?action=avatars');
<?php /** * 模糊化微信聊天记录截图 * * 给聊天记录上方联系人昵称、右边头像、右边头像模糊化(for Jonns) * * @create 2015年4月8日00:00:00 * * @author AnyeGates <*****@*****.**> */ $proccess_dir = realpath('before'); // 源文件目录 $result_dir = __DIR__ . '/result'; // 处理后的图片存放目录 remove_avatar($proccess_dir, $result_dir); // 开始处理! /** * 遍历目录和处理里面所有文件 * * @param string $proccess_dir 源目录 * @param string $result_dir 存放目录 * @return void */ function remove_avatar($proccess_dir, $result_dir) { list($dirs, $files) = get_all_files_and_dirs($proccess_dir); foreach ($dirs as $dir) { // 按照源目录结构创建结果的目录 $dirname = $result_dir . $dir; echo "查询 {$dirname} 是否存在……\n";