jomla Posted January 29, 2017 Share Posted January 29, 2017 Hi at all, I have to intercept search engines and my visits not to insert in the log files of my visits and countless search engine visits. I therefore made this function but it is not working and search engines continue to pass. Where is the mistake? Thank you very much <php code> function write_log() {if (!(isset($_SESSION['me']))||($_SESSION['me']!=="pippo") || (preg_match('/bot|bingbot|bing|robot|crawl|slurp|spider|yahoo|se arch/i', $_SERVER['HTTP_USER_AGENT'])==0)){return true;}else{return false;}}if(write_log()===true){require_once("log.php");} </php code> I therefore I made this function but it is not working and search engines continue to pass. Where is the mistake? Thank you Link to comment Share on other sites More sharing options...
justsomeguy Posted January 30, 2017 Share Posted January 30, 2017 Well, what are you testing for? You're saying if a certain session value is not set, or is set to a different value than "pippo", or if it doesn't match that regular expression, then you want to do the logging. First off, why are you saying to do the logging if the session isn't set? Do you know that all bots will send cookies back and forth to keep a session going? Link to comment Share on other sites More sharing options...
jomla Posted January 30, 2017 Author Share Posted January 30, 2017 The session variable "me" represent my person that I am visiting my web site and its value with which I enter is "foo". So if the session variable $ _SESSION ['me'] !== 'foo' it can be inserted into file.log visitors because visitor I am not me. But I do not want even the search engines are put into visitors file.log so I added the second part of the function but some think do not work The session variable "me" I am visiting my site and its value with which I enter is "foo". So if the session variable $ _SESSION [ 'I'] == 'foo' and I must not be inserted into file.log visitors. But I do not want even the search engines are put in the logo file so I added the second part of the function Link to comment Share on other sites More sharing options...
justsomeguy Posted January 30, 2017 Share Posted January 30, 2017 Maybe you need AND instead of OR. You're telling it to use the log if $_SESSION['me'] is not set, OR $_SESSION['me'] is not "pippo", OR that regular expression doesn't match. If any one of those things is true, then you use the log. It sounds like you need to be more specific instead of just listing everything separated by OR, because adding more conditions to that if statement using OR only makes it use logging for more cases, not fewer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now