strpos

PHP strpos not working

≡放荡痞女 提交于 2019-12-11 01:44:35
问题 I've always had problems with strpos, I understand the num v. boolean issue, but I can NOT get this working. The $cur_key value is something like "page=>name"... $pos = strpos($cur_key, "=>"); if ($pos !== false) { $mod = explode("=>",$cur_key); $path = $mod[0]; $param = $mod[1]; }else{ $path = $cur_key; } If it's in there it should split it into the two values but no matter what I try it's always just returning the original value... 回答1: $mod = explode('=>',$cur_key); $path=$mod[0]; if

Warning: strpos() expects parameter 1 to be string, resource

旧城冷巷雨未停 提交于 2019-12-10 19:12:14
问题 I recently migrated a PHP site to my server and after migration I receive this error message. As I'm not really familiar with PHP, I'd really appreciate any help. Thanks. Warning: strpos() expects parameter 1 to be string, resource given in .../public_html/store /product_list.php on line 121 Line 121 is as follows... $exists = (strpos($handle, "Resource id") !== false) ? true : false; Here is the rest of the code on the top of the page for relevance. <?php session_start(); include_once("..

function to check array strpos and return an array

不打扰是莪最后的温柔 提交于 2019-12-10 18:09:31
问题 hello i would like to create a function that checks if an etry contains some words. for my login-script i would like to create a function that checks if the $_POST has some keywords in it. therfor i have thought to create an array that contains the words i'm looking for like that: function value_check($a, $b){ $haystack = array ($a, $b) $words = array ("abc", "def"); if(strpos($haystack, $words) === true) { return ($a or $b, or both where strpos === true); } return false; } and i would like

How to find position of a character in a string in PHP

十年热恋 提交于 2019-12-10 14:43:58
问题 How to find positions of a character in a string or sentence in php $char = 'i'; $string = 'elvis williams'; $result = '3rd ,7th and 10th'. I tried strpos..but no use.. 回答1: This will give you the position of $char in $string: $pos = strpos($string, $char); If you want the position of all occurences of $char in string: $positions = array(); $pos = -1; while (($pos = strpos($string, $char, $pos+1)) !== false) { $positions[] = $pos; } $result = implode(', ', $positions); print_r($result); Test

PHPWIND V8.7会员回复帖功能限制会员不能发表带有超链接地址的帖子的BUG

孤者浪人 提交于 2019-12-10 09:10:50
会员在论坛发链接帖子,无非就是给自己网站打广告。为了论坛人气,适当的广告互动是可以的,为了方便的控制好,我们可以设定一个预定值,只有达到发 帖数量后,才可以发带有超链接的帖子,这样论坛的总帖子数量和用户的一些特殊要求,两全其美。那么,我们的phpwind是否可以实现类?如何可以实现, 如何设置?这个功能,我们可以在phpwind后台直接设置,但是无忧主机小编在测试中,发现了一个bug,但是设置这项 选项后会员回复帖子会提示:你的发贴数未到x(帖子的数量),不能发表带有链接地址的帖子。而且已经在官方找到了解决方案,并确定是这是一个BUG,小编 现在分享一下这个bug的解决方案,让站长遇到同样问题少走弯路。 一、phpwind后台操作路径 Phpwind管理后台—>全局—>会员相关—>链接帖发帖限制 二、解决会员回复帖子提示:您的发帖数未到x(帖子的数量),不能发表带有链接地址的帖子方案 文件目录为:lib/forum/post.class.php将文件下载至本地 文本编辑器打开:post.class.php(修改前备份好原文件) 查找:(大约在660-669行) function urlCheck($str) { global $db_bbsurl; if (strpos($str,'[/URL]') !== false || strpos($str,'[/url]') !==

Search String and Return Line PHP

♀尐吖头ヾ 提交于 2019-12-09 00:47:23
问题 I'm trying to search a PHP file for a string and when that string is found I want to return the whole LINE that the string is on. Here is my example code. I'm thinking I would have to use explode but cannot figure that out. $searchterm = $_GET['q']; $homepage = file_get_contents('forms.php'); if(strpos($homepage, "$searchterm") !== false) { echo "FOUND"; //OUTPUT THE LINE }else{ echo "NOTFOUND"; } 回答1: Just read the whole file as array of lines using file function. function getLineWithString(

PHP: How to Properly Use Strpos() to Find a Word in a String

浪尽此生 提交于 2019-12-08 13:58:00
问题 If one is experienced in PHP, then one knows how to find whole words in a string and their position using a regex and preg_match() or preg_match_all. But, if you're looking instead for a lighter solution, you may be tempted to try with strpos(). The question emerges as to how one can use this function without it detecting substrings contained in other words. For example, how to detect "any" but not those characters occurring in "company"? Consider a string like the following: "Will *any*

Check if string contains one of several words

依然范特西╮ 提交于 2019-12-07 08:55:37
问题 I am trying to make a word filter in php, and I have come across a previous Stackoverlow post that mentions the following to check to see if a string contains certain words. What I want to do is adapt this so that it checks for various different words in one go, without having to repeat the code over and over. $a = 'How are you ?'; if (strpos($a,'are') !== false) { echo 'true'; } Will it work if I mod the code to the following ?...... $a = 'How are you ?'; if (strpos($a,'are' OR $a,'you' OR

CTF gopher协议

不想你离开。 提交于 2019-12-07 01:47:35
0x01 例题 这儿举例安恒的一道月题 tips:利用ssrf,gopher打内网 0x02 贴出代码 <?php highlight_file ( __FILE__ ) ; $x = $_GET [ 'x' ] ; $pos = strpos ( $x , "php" ) ; if ( $pos ) { exit ( "denied" ) ; } $ch = curl_init ( ) ; curl_setopt ( $ch , CURLOPT_URL , " $x " ) ; curl_setopt ( $ch , CURLOPT_RETURNTRANSFER , true ) ; $result = curl_exec ( $ch ) ; echo $result ; 0x03分析过程 首先 x 我们可以控制, x可利用的协议有 gopher 、 dict 、 http 、 https 、 file 等 file 协议可以用于查看文件 dict 协议可以用于刺探端口 gopher 协议支持 GET&POST 请求,常用于攻击内网 ftp 、 redis 、 telnet 、 smtp 等服务,还可以利用 gopher 协议访问 redis 反弹 shell 首先我们利用file读取文件 先上脚本扫描一下目录,得到 flag.php 。 一般我们还可以读取 /etc/hosts

php端检测是否移动设备的完整代码

南笙酒味 提交于 2019-12-06 02:12:15
做网页时,需要得到当前打开网页页面的设备是PC的浏览器,还是移动设备的浏览器,再针对不同设备,让页面显示合适内容; 针对这个需求场景,个人认为有三种方法可以实现: 方法一: 通过css ; 方法二,通过js; 方法三 通过 php端; 这三种方法按业务需求,进行采用,会有不一样的效果; css 通过 @media 属性 ,设置不一样屏幕尺寸 显示不一样的页面;达到页面匹配不同尺寸的效果; 通过js 判断设备是移动设备,pc设备、微信客户端等,再做对应的跳转到合适的业务页面展示给客户端; 方式三,通过php端判断 访问的设备是 pc还是移动设备; 后端返回 不一样的业务内容; 个人觉得方式三 适合复杂的,业务需求。 下面就 提供一个 php端 判断设备的代码吧。 /** * 是否移动端访问访问 */ public function _is_mobile() { if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) { // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 return true; } elseif (isset ($_SERVER['HTTP_USER_AGENT'])) { // 判断手机发送的客户端标志,兼容性有待提高 $clientkeywords = [ 'nokia', 'sony', 'ericsson',