n $r; } // 版块版主权限判断: allowtop, allowmove, allowupdate, allowdelete, allowbanuser, allowviewip, allowdeleteuser function forum_access_mod($fid, $gid, $access) { global $grouplist, $forumlist, $uid; // 结果缓存,加速判断! static $result = array(); $k = $fid . '-' . $gid . '-' . $access; if (isset($result[$k])) return $result[$k]; if (1 == $gid || 2 == $gid) return TRUE; // 管理员有所有权限 if (3 == $gid || 4 == $gid) { $group = $grouplist[$gid]; $forum = $forumlist[$fid]; $r = !empty($group[$access]) && in_string($uid, $forum['moduids']); } else { $r = FALSE; } $result[$k] = $r; return $r; } function forum_is_mod($fid, $gid, $uid) { global $grouplist, $forumlist; if (1 == $gid || 2 == $gid) return TRUE; // 管理员有所有权限 if (3 == $gid || 4 == $gid) { if (0 == $fid) return TRUE; // 此处不严谨! $group = $grouplist[$gid]; $forum = $forumlist[$fid]; return in_string($uid, $forum['moduids']); } return FALSE; } // ------------> 其他方法 function forum_access_format(&$access) { if (empty($access)) return; } function forum_access_count($cond = array()) { $n = db_count('forum_access', $cond); return $n; } ?> !empty($attach) and attach_big_insert($attach); $attachlist = $imagelist = $filelist = ''; $images = 0; $files = 0; // 处理不在 message 中的图片,删除掉没有插入的附件 if ($message) { // 只有评论会传pid list($attachlist, $imagelist, $filelist) = $pid ? well_attach_find_by_pid($pid) : well_attach_find_by_tid($tid); if (!empty($imagelist)) { $aids = array(); foreach ($imagelist as $key => $attach) { $image_url = $conf['upload_url'] . 'website_attach/' . $attach['filename']; if (FALSE === strpos($message, $image_url)) { unset($attachlist[$attach['aid']], $imagelist[$attach['aid']]); $aids[] = $attach['aid']; $path = $conf['upload_path'] . 'website_attach/' . $attach['filename']; is_file($path) and unlink($path); // 删除云储存文件 } } !empty($aids) and well_attach__delete($aids); } $images = count($imagelist); $files = count($filelist); } $return += array('tid' => $tid, 'pid' => $pid, 'icon' => $icon, 'message' => $message, 'images' => $images, 'files' => $files); return $return; } // 关联内容中的文件,逐渐放弃使用该函数,使用 well_attach_assoc_handle() function well_attach_assoc_file($arr = array()) { global $conf, $time; $uid = array_value($arr, 'uid', 0); $tid = array_value($arr, 'tid', 0); $post_create = array_value($arr, 'post_create', 0); // 创建回复 $pid = array_value($arr, 'pid', 0); $images = array_value($arr, 'images', 0); $files = array_value($arr, 'files', 0); $message = array_value($arr, 'message'); if (!$tid && !$pid) return $message; $attach_dir_save_rule = array_value($conf, 'attach_dir_save_rule', 'Ym'); $day = date($attach_dir_save_rule, $time); $path = $conf['upload_path'] . 'website_attach/' . $day; $url = $conf['upload_url'] . 'website_attach/' . $day; is_dir($path) || mkdir($path, 0777, TRUE); if (!empty($arr['sess_tmp_files'])) { $message = urldecode($message); preg_match_all('#]+src="(.*?)"#i', $message, $match); $localurlarr = array( 'http://' . $_SERVER['SERVER_NAME'] . '/', 'https://' . $_SERVER['SERVER_NAME'] . '/', ); // 跳过云储存 $conf['cloud_url'] and $localurlarr[] = $conf['cloud_url']; /*$match[1] Array ( [0] => https://nimg.ws.126.net/?url=http://dingyue.ws.126.net/2021/1109/d3321a58j00r29xq20013c000hk00h4g.jpg&thumbnail=650x2147483647&quality=80&type=jpg [1] => https://nimg.ws.126.net/?url=http://dingyue.ws.126.net/2021/1109/e4974b87j00r29xq30013c000fi00i3g.jpg&thumbnail=650x2147483647&quality=80&type=jpg [2] => upload/tmp/1_KAUXKFMJHFTUMNS.jpg [3] => https://nimg.ws.126.net/?url=http://dingyue.ws.126.net/2021/1109/5a7be552j00r29xq3001qc000hs00hvg.jpg&thumbnail=650x2147483647&quality=80&type=jpg )*/ $upload_arr = array(); $http_arr = array(); if (!empty($match[1])) { foreach ($match[1] as $_url) { foreach ($localurlarr as $localurl) { if ($localurl == substr($_url, 0, strlen($localurl))) continue 2; } if (substr($_url, 0, 7) == 'http://' || substr($_url, 0, 8) == 'https://') { $http_arr[] = $_url; } elseif (substr($_url, 0, 11) == 'upload/tmp/' || substr($_url, 0, 12) == '/upload/tmp/' || substr($_url, 0, 14) == '../upload/tmp/') { $upload_arr[] = $_url; } } } $attach = array(); foreach ($arr['sess_tmp_files'] as $file) { // 过滤非内容图,不包括附件 if (!in_array($file['url'], $upload_arr) && 0 != $file['isimage']) { unlink($file['path']); continue; } // 后台提交的内容需要替换掉../ $file['url'] = $file['backstage'] ? str_replace('../upload/', 'upload/', $file['url']) : str_replace('/upload/', 'upload/', $file['url']); // 内容附件 将文件移动到 upload/website_attach 目录 $filename = file_name($file['url']); // 绝对路径 $destfile = $path . '/' . $filename; // 相对路径 $desturl = $url . '/' . $filename; // 复制 xn_copy($file['path'], $destfile) || xn_log("xn_copy($file[path]), $destfile) failed, tid:$tid, pid:$pid", 'php_error'); if (is_file($destfile) && filesize($destfile) == filesize($file['path'])) unlink($file['path']); // 按照$destfile文件路径,上传至云储存或图床,返回数据.附件分离,最优方案是redis队列,单独写上传云储存php文件,nohup后台运行,将队列数据上传云储存,然后根据aid更新附件表attach_on、image_url自动,根据tid更新主题表attach_on。关联附件上传云储存,有可能导致超时。 $attacharr = array( /*'tid' => $tid, 'pid' => $pid,*/ 'uid' => $uid, 'filesize' => $file['filesize'], 'width' => $file['width'], 'height' => $file['height'], 'filename' => $day . '/' . $filename, 'orgfilename' => $file['orgfilename'], //'image_url' => '', // 图床文件完整网址 'filetype' => $file['filetype'], 'create_date' => $time, 'isimage' => $file['isimage'] ); $tid and $attacharr += $pid ? array('pid' => $pid) : array('tid' => $tid); $attach[] = $attacharr; // 关联内容再入库 //$aid = well_attach_create($attach); $file['backstage'] and $message = str_replace('../upload/', 'upload/', $message); $message = str_replace($file['url'], $desturl, $message); } !empty($attach) and attach_big_insert($attach); // 清空 session $_SESSION['tmp_website_files'] = array(); } // 更新附件数 $update = array(); $_images = 0; $_files = 0; // 处理不在 message 中的图片,删除掉没有插入的图片附件 if ($message) { // 只有评论会传pid list($attachlist, $imagelist, $filelist) = $pid ? well_attach_find_by_pid($pid) : well_attach_find_by_tid($tid); if (!empty($imagelist)) { $aids = array(); foreach ($imagelist as $key => $attach) { $url = $conf['upload_url'] . 'website_attach/' . $attach['filename']; if (FALSE === strpos($message, $url)) { unset($attachlist[$attach['aid']], $imagelist[$attach['aid']]); $aids[] = $attach['aid']; $path = $conf['upload_path'] . 'website_attach/' . $attach['filename']; is_file($path) and unlink($path); // 删除云储存文件 } } !empty($aids) and well_attach__delete($aids); } $_images = count($imagelist); $images != $_images and $update['images'] = $_images; $_files = count($filelist); $files != $_files and $update['files'] = $_files; } if (empty($update)) return $pid ? array($message, $_images, $_files) : $message; if ($pid) { if ($post_create) { $update['message'] = $message; comment__update($pid, $update); } else { // 编辑回复返回的数据 return array($message, $_images, $_files); } } else { well_thread_update($tid, $update); } return $message; } // thumbnail:主题主图 post:内容图片或附件 function well_attach_assoc_type($type) { switch ($type) { case 'thumbnail': $k = 'tmp_thumbnail'; break; case 'post': $k = 'tmp_website_files'; break; default: return NULL; break; } $sess_tmp_files = _SESSION($k); // 如果session中没有,从数据库中获取储存的session //if (empty($sess_tmp_files) && preg_match('#' . $k . '\|(a\:1\:\{.*\})#', _SESSION('data'), $matches)) $sess_tmp_files = unserialize(str_replace(array('+', '='), array('_', '.'), $matches['1'])); return $sess_tmp_files; } // Create thumbnail function well_attach_create_thumbnail($arr) { global $conf, $time, $forumlist, $config; $uid = array_value($arr, 'uid', 0); $tid = array_value($arr, 'tid', 0); $fid = array_value($arr, 'fid', 0); $forum = array_value($forumlist, $fid); $picture = $config['picture_size']; $picture = isset($forum['thumbnail']) ? $forum['thumbnail'] : $picture['picture_size']; $pic_width = $picture['width']; $pic_height = $picture['height']; $attachlist = well_attach_assoc_type('post'); if (empty($attachlist)) return; $attach_dir_save_rule = array_value($conf, 'attach_dir_save_rule', 'Ym'); $day = date($attach_dir_save_rule, $time); $path = $conf['upload_path'] . 'thumbnail/' . $day; is_dir($path) || mkdir($path, 0777, TRUE); $tmp_file = $conf['upload_path'] . 'tmp/' . $uid . '_' . $tid . '_' . $time . '.jpeg'; $i = 0; foreach ($attachlist as $val) { ++$i; if (1 == $val['isimage'] && 1 == $i) { 'clip' == array_value($conf, 'upload_resize', 'clip') ? well_image_clip_thumb($val['path'], $tmp_file, $pic_width, $pic_height) : well_image_thumb($val['path'], $tmp_file, $pic_width, $pic_height); break; } } $destfile = $path . '/' . $uid . '_' . $tid . '_' . $time . '.jpeg'; xn_copy($tmp_file, $destfile) || xn_log("xn_copy($tmp_file), $destfile) failed, tid:$tid", 'php_error'); } function well_save_remote_image($arr) { global $conf, $time, $forumlist, $config; $message = array_value($arr, 'message'); $tid = array_value($arr, 'tid', 0); $fid = array_value($arr, 'fid', 0); $uid = array_value($arr, 'uid', 0); $thumbnail = array_value($arr, 'thumbnail', 0); $save_image = array_value($arr, 'save_image', 0); $attach_dir_save_rule = array_value($conf, 'attach_dir_save_rule', 'Ym'); $day = date($attach_dir_save_rule, $time); $attach_dir = $conf['upload_path'] . 'website_attach/' . $day . '/'; $attach_url = $conf['upload_url'] . 'website_attach/' . $day . '/'; is_dir($attach_dir) || mkdir($attach_dir, 0777, TRUE); if ($thumbnail) { $picture = $config['picture_size']; $forum = array_value($forumlist, $fid); $picture = isset($forum['thumbnail']) ? $forum['thumbnail'] : $picture['picture_size']; $pic_width = $picture['width']; $pic_height = $picture['height']; $thumbnail_path = $conf['upload_path'] . 'thumbnail/' . $day . '/'; is_dir($thumbnail_path) || mkdir($thumbnail_path, 0777, TRUE); $tmp_file = $thumbnail_path . $uid . '_' . $tid . '_' . $time . '.jpeg'; } $localurlarr = array( 'http://' . $_SERVER['SERVER_NAME'] . '/', 'https://' . $_SERVER['SERVER_NAME'] . '/', ); // 跳过云储存 $conf['cloud_url'] and $localurlarr[] = $conf['cloud_url']; //$save_image_quality = array_value($conf, 'save_image_quality', 0); $save_image_quality = 0; $message = urldecode($message); //$message = str_replace('&', '&', $message); //$message = htmlspecialchars_decode($message); preg_match_all('#]+src="(http.*?)"#i', $message, $match); if (!empty($match[1])) { $n = 0; $i = 0; foreach ($match[1] as $url) { foreach ($localurlarr as $localurl) { if ($localurl == substr($url, 0, strlen($localurl))) continue 2; } $full_url = htmlspecialchars_decode($url); $message = str_replace($url, $full_url, $message); $getimgsize = getimagesize($full_url); if (FALSE === $getimgsize) continue; // 非图片跳出 $filename = $uid . '_' . xn_rand(16); if (1 == $getimgsize[2]) { $filename .= '.gif'; $destpath = $attach_dir . $filename; } elseif (in_array($getimgsize[2], array(2, 3, 15, 18))) { $filename .= '.jpeg'; $destpath = $attach_dir . $filename; } else { continue; // 非常见图片格式跳出 } $desturl = $attach_url . $filename; $_message = str_replace($full_url, $desturl, $message); if ($message != $_message) { if ($save_image) { if (0 == $save_image_quality) { $imgdata = https_request($full_url); //$destpath = $attach_dir . $filename; file_put_contents_try($destpath, $imgdata); } else { // 图片压缩 GD 库效率低下 ImageMagick 需要额外安装扩展 switch ($getimgsize[2]) { case 1: // GIF $imgdata = imagecreatefromgif($full_url); break; case 2: // JPG $imgdata = imagecreatefromjpeg($full_url); break; case 3: // PNG $imgdata = imagecreatefrompng($full_url); break; case 15: // WBMP $imgdata = imagecreatefromwbmp($full_url); break; case 18: // WEBP $imgdata = imagecreatefromwebp($full_url); break; } imagejpeg($imgdata, $destpath, $save_image_quality); imagedestroy($imgdata); } } // 创建缩略图 if ($thumbnail) { if (1 == ++$i) { if (empty($save_image)) { $imgdata = https_request($full_url); file_put_contents_try($destpath, $imgdata); } // 裁切保存到缩略图目录 'clip' == array_value($conf, 'upload_resize', 'clip') ? well_image_clip_thumb($destpath, $tmp_file, $pic_width, $pic_height, $getimgsize) : well_image_thumb($destpath, $tmp_file, $pic_width, $pic_height, $getimgsize); well_thread_update($tid, array('icon' => $time)); } if (empty($save_image)) { is_file($destpath) and unlink($destpath); continue; } } $filesize = strlen($imgdata); $attach = array('tid' => $tid, 'uid' => $uid, 'filesize' => $filesize, 'width' => $getimgsize[0], 'height' => $getimgsize[1], 'filename' => "$day/$filename", 'orgfilename' => $filename, 'filetype' => 'image', 'create_date' => $time, 'downloads' => 0, 'isimage' => 1); $aid = well_attach_create($attach); $n++; } $message = preg_replace('#( $n)); } return $message; } function well_get_image_url($url) { if ($n = strpos($url, '.jpg')) { $_n = $n + 4; } elseif ($n = strpos($url, '.jpeg')) { $_n = $n + 5; } elseif ($n = strpos($url, '.png')) { $_n = $n + 4; } elseif ($n = strpos($url, '.gif')) { $_n = $n + 4; } elseif ($n = strpos($url, '.bmp')) { $_n = $n + 4; } $url = $n ? mb_substr($url, 0, $_n, 'UTF-8') : NULL; return $url; } ?> // 频道和全局置顶主题 foreach ($arrlist as $val) { if (in_array($val['fid'], $fids) && 2 == $val['sticky']) { $sticky2[$val['tid']] = $val; } elseif (3 == $val['sticky']) { $sticky3[$val['tid']] = $val; } } } else { // 栏目/上级频道/全局置顶 foreach ($arrlist as $val) { if ($forum['fid'] == $val['fid'] && 1 == $val['sticky']) { $sticky1[$val['tid']] = $val; } elseif (in_array($val['fid'], $fids) && 2 == $val['sticky']) { $sticky2[$val['tid']] = $val; } elseif (3 == $val['sticky']) { $sticky3[$val['tid']] = $val; } } } $sticky3 = empty($sticky3) ? array() : array_multisort_key($sticky3, 'create_date', FALSE, 'tid'); $sticky2 = empty($sticky2) ? array() : array_multisort_key($sticky2, 'create_date', FALSE, 'tid'); $sticky1 = empty($sticky1) ? array() : array_multisort_key($sticky1, 'create_date', FALSE, 'tid'); $arr = $sticky3 + $sticky2 + $sticky1; return $arr; } // 全部置顶缓存 function sticky_thread_find_cache() { global $conf; $key = 'sticky_thread_list'; static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,跨进程需要再加一层缓存:redis/memcached/xcache/apc if (isset($cache[$key])) return $cache[$key]; if ('mysql' == $conf['cache']['type']) { $arr = sticky_thread__find(array(), array('tid' => -1), 1, 2000); } else { $arr = cache_get($key); if (NULL === $arr) { $arr = sticky_thread__find(array(), array('tid' => -1), 1, 2000); $arr AND cache_set($key, $arr, 1800); } } $cache[$key] = $arr ? $arr : NULL; return $cache[$key]; } ?>密码

用Python脚本能获取Wifi密码么?能。

注意,本文不是破解 WIFI 密码,当然你把程序发给别人再获取对方密码,那是社会工程学。 文章目录⛳️ 实战场景与 subprocess 模块介绍⛳️ Python 获取本地

7月前990

解决浏览器自动弹出账号和密码问题

文章目录场景需求试错解决完整代码场景 当我进入此页面得时候,输入框自动补全了账号和密码,而且输入框获取焦点时会有账号和密码提示需求 从账号安全角度来说,不希望用户每次

7月前860

解决浏览器自动填充账号密码行为

这东西真的不是程序员的问题,但是没办法拿着别人的给的钱就必须解决。如果你很急,就直接跳到最后一个看解决办法。首先为什么会出现这种情况本人实验了三个浏览器360浏览器、火狐浏览器、谷歌浏览器&

7月前710

360浏览器保存密码导出_一键窃取所有账号密码,我有点慌...

粉丝福利:今天继续从留言区抽5个小伙伴赠送网盘超级会员或30元现金红包! 身处于互联网时代,几乎没有啥隐私可言,可能你的个人信息都会在不经意间被泄露出去,其实也不用太过慌张,毕竟别人要你的那些信息也没太大作用,所以一般来说我们都不会感受到。

7月前830

Wireshark抓明文账号和密码

Wireshark抓包,打开wireshark选择WLAN,双击进入抓包。我使用4399的登陆过程作为案例,注册好后登录4399.然后可以看见wireshark开始工作&am

7月前910

关于找回电脑删除的文件的密码,已破解…

经常使用电脑的我们,难免误删掉一些数据是比较不少见的,重要的是要怎么找回电脑删除的文件。那么当我们删除主要是什么原因导致的呢?一般是什么情况下导致的误删呢&#xff1

7月前670

linux系统设置root初始化密码

一个新的linux系统是没有root密码的,需要设置root默认密码。安装好Linux之后,打开终端,输入su命令,会出现如下情况userdomain:

7月前1350

windows远程连接ubuntu-(密码登录、密钥登录、免密登录)

入坑前的必备小知识: 什么是公钥登录? 所谓"公钥登录",就是用户将自己的公钥储存在远程主机上。登录的时候,远程主机会向用户发送一段随机字符串,用户用自己的私钥加密后,再发回来。远程主机用事先储存的公钥进行解

7月前740

纯净版xp系统在局域网共享需要密码如何解决

纯净版xp系统在局域网共享需要密码怎么办?这是近来不少朋友都向小编反馈的问题。他们表示每次共享者更改密码后其他人都需要再重新输入密码,感觉十分的麻烦。下面是系统城小编给大家整理的一些有关XP系统局

7月前1090