PHP - Close Window If Referer Not Valid
I need to close a window if referer not valid, but it cannot be in HTML, needs to be php. This is what I have so far:
Code: [Select] if (ereg("http://www.mysite.com/test.php", $_SERVER['HTTP_REFERER']) != true){ header('Location: ?????????'); exit; } I get a header already sent message if I use a URL. I need it to close the window after 3 seconds. Any ideas? Similar TutorialsThis topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=355464.0 Hello dear friends, if i want only to get visitors from certain website (referer) say 7777777site.com so can someone rewrite that code for me please // that code to get referer right ! $r = $_SERVER['HTTP_REFERER']; // the only site i accept $sto = "7777777site.com" // now to compare it if ($r == $sto ) { echo "goood"; } else { echo "bad"; } i've tired this and totally wrong .. - it didn't works - i found if someone comes for example from 7777777site.com/vb/index.php it will consider it bad however it should be accepted referer so can someone please help me how to write such code ? Im working on an issue that keeps sending the user to logge_in.php and never to post_new.php even if it is the referer. Here is the code I have wrote so far: Code: [Select] if($_SERVER['HTTP_REFERER'] =="post_new.php"){ $referer = "post_new.php"; }elseif($_SERVER['HTTP_REFERER'] =="logged_in.php"){ $referer = "logged_in.php"; } header("Location: ".$referer." "); exit(); } Thanks in advance! I have htaccess file from which I am calling htpasswd. Currently its ask for authentication from everyone. I want it IP based or Domain based so that a user requesting from specific IP may not have to go through http authentication. Some domain calling the web pages in background like paypal OR google checkout can access the page without http authentication. Is it possible ? content of htaccess file is given below. AuthUserFile /var/www/web/.htpasswd AuthName "Authorization Required" AuthType Basic <Limit GET POST> require user username </Limit> Hoping someone can help. I have a file, say bounce.php that uses php url ramdomizer, like this: <?php $urls = array("link1", "link2"); $url = $urls[array_rand($urls)]; header("Location: http://$url"); ?> What I want is to only allow that code to execute if the user is coming from another php page on the same sever/folder. So like this.... So bounce.php will check where the traffic is coming from.....if traffic is coming from page1.php (file on same server) then it will allow URL REDIRECT CODE to execute, if traffic is coming from another source, such as google.com, or from no referel, then person is sent to another site, say msn.com. now i use this code to show where the visitors came from to my site. <?php $referer=$_SERVER['HTTP_REFERER']; echo $referer; ?> now, i want to show the 5 latest vistors referer's site url on my site ? Scenario :
I would like to open the main program window and at the same time, if a condition is met, open a second - popup window to alert the user of previous information stored in the database.
This is an easy exercise if I use a hyperlink to open th second (popup) window but this is not the process required .
Can someone point me in the right direction ?
Cheers and thanks
$ARR[$i] == $NEEDLE ? $Count++ : $Count I am using it in: private function _countIf($ARR, $NEEDLE){ $Count = 0; for($i = 0; $i < count($ARR); i++){ $ARR[$i] == $NEEDLE ? $Count++ : $Count } return $Count; }Edited March 25, 2019 by Karaethon With the following code i can create an xml file. Code: [Select] <?php $myXML = new SimpleXMLElement("<myroot></myroot>"); $title= $myXML->addChild('title'); $title->addAttribute('number','12'); $titleName= $title->addChild('titleName', 'title1'); $titleLink= $title->addChild('titleLink', 'link1'); Header('Content-type: text/xml'); echo $myXML->asXML(); ?> But when i check the validity of xml file http://www.validome.org/xml/validate/ This error occurs: Can not find declaration of element 'myroot'. I suppose that the problem is missing of !DOCTYPE and !ELEMENT lines. How can i create valid XML documents with PHP automatically?? Is it possible to make it without writing doctype and element types for the whole element types of xml by hand $title, $titleName and $titleLink Thank you Hello! First... I'm sorry about my english skills.. Seems that with my own language I don't get a correct or good answer So.. I have a site where visitors can put there favorite links to other sites and show them to others. My problem is multiple urls to same locations in sites-table. example: http://google.com http://google.com/ http://www.google.com http://www.google.com/ http://www.google.com/index.php (?) they all lead to same... is there any light and powerfull way to check these? I'm trying to use query with "like" but it only works if there is exactly same url. I use fopen to check that url really exicst.. table: Sites (basic information for link) -id -url -title +some meta tags if found -timestamp I'm not asking to do me this code. But if someone can tell me just what functions and others I'm looking for and what I need for this... My coal is to keep sites-table as clean as it can be. If visitor adds a url that is already in sites-table only thing that happens is updating timestamp. Thank you all for helping me! -Roosterr Hi, I am trying to create a mobile version of my already uploaded file using below code but getting this error imagecreatefrompng(): is not a valid PNG file Here is the code: if (move_uploaded_file($_FILES['photo']['tmp_name'], $uploadedFile)) { $resource = imagecreatefrompng($uploadedFile); $small_file = imagescale($resource , 500, 400); $small_file = imagepng($small_file); $newSmallFile = "mobile-" . $gallery_uuid . '.png'; $uploadedSmallFile = $uploaddir . $newSmallFile; echo $uploadedSmallFile; if (move_uploaded_file($small_file, $uploadedSmallFile)) { } else { echo json_encode("error"); } } else { echo json_encode("error"); }
Kindly help..
Thanks, Jassim Edited July 29 by requinix removing link I have this code which performs a mysql query. However is there a way I can check to see if the set it returns is empty. If it is empty I will then change the sql statement. Thanks $announcement_sql = "select * where annnouncement_for like \"%" . $_POST['for_search'] . "%\" and announcement_verification=\"1\" order by announcement_number desc limit 0, 15"; I always use my queries like below mysql_query("SELECT id FROM someTable", $cn); but some times i see in my error_log says: mysql_fetch_array(): supplied argument is not a valid MySQL result resource. Why is this happening? I mean, there is no problem with my sites and all they are working as they should be but why php generates this error? HI,
I am triying to check a domain is valid or not using PHP. If the domian is not a valid one the name shoud be empty string.
So I tried using preg_match() and preg_replace(). But I couldn't get it to work.
This is my code sofar -
if (preg_match ('/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/', $domain)) { $mydomain = $domain; } else { $mydomain = preg_replace("/^((?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{2,6}$/", "", $domain); }When I am tring using valid and invalid domain name its always going to else part. Eg: example.com example.t.t.c Hope somebody may help me out. Thank you. What is wrong? Warning: mysql_select_db(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 41 Warning: mysql_query(): supplied resource is not a valid MySQL-Link resource in /home/rweekly/public_html/2012/view_arguments.php on line 43 Code: [Select] mysql_select_db($database_news, $news); $query_news = "SELECT * FROM news WHERE id = '$id'"; $news = mysql_query($query_news, $news) or die(mysql_error()); $row_news = mysql_fetch_assoc($news); $totalRows_news = mysql_num_rows($news); mysql_select_db($database_news, $news); $query_arguments = "SELECT * FROM argue WHERE pid = '$id'"; $arguments = mysql_query($query_arguments, $news) or die(mysql_error()); $row_arguments = mysql_fetch_assoc($arguments); $totalRows_arguments = mysql_num_rows($arguments); Okay, I have a table with two columns..'annoyed' and 'ignored'. I poulated 'annoyed' with Bob and 'ignored' with Sally. I ran the following test due to problems I was having in my main script and I get the old MySQL "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/testing_ig.php on line 16 Here is the code: <?php $DBhost = "localhost"; $DBuser = "xxxxx"; $DBpass = "xxxxx"; $DBName = "xxxxx"; $table = "ignore"; mysql_connect($DBhost,$DBuser,$DBpass) or die(); @mysql_select_db("$DBName") or die(); $ignorequery = "SELECT * FROM $table WHERE annoyed='Bob' AND ignored='Sally'"; $checkignore = mysql_query($ignorequery); $ifignored = mysql_num_rows($checkignore); //<--- This is line 16 if ($ifignored >= 1) { echo "exists"; } else { echo "doesn't exist"; } ?> I must be really tired because I'm not seeing the problem...? I'm trying to list all the tables in my database. I got this code pretty much "word" for word from the example at php.net, but I get: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\wamp\www\test\test-in.php on line 67 <?php $db= $_POST['db']; $sql= "SHOW TABLES FROM $db"; $result=mysql_query($sql); while ($tblarray = mysql_fetch_row($result)){ ?><a href="?tablename=<?php echo $tblarray[0];?>"><?php echo $tblarray[0];?></a><?php } ?> I'm wondering what makes a pop-up login window run differently than inside a webpage. I can't seem to get my login system to bring the user back to the page (brings them to a page can't be found) when clicking a form submit button when it is included in the webpage. But if your in the popup page that I'm trying to include, it works no problem so I was wondering if it changes anything. Or if there is some sort of work around (such as embedding a popup window into the webpage). Thanks a lot! Hey guy's, have been stuck at this hurdle for a little whole now and I can't seem to find the right solution and would very much appreciate anyones help on this. Ok, so I have a table of votes and each time a user votes, they're added to this table. Now, I have a 'pool' table which will display certain items. What I'm trying to do is display the 'pool' items, but if this specific user has already voted on this particular item, then I want it to skip the item in the 'pool' and go to the next item, until the argument of has that user voted is false. The current code I'm pasting will obviously not work, it isn't even in the right position, but I've separated it so that you can hopefully understand what I'm trying to do in order to help. Below is the code I use to check if a user has already voted on a particular photo: <?php $result=mysql_query("SELECT * FROM votes WHERE vVoter='$_SESSION[userID]' AND vPhoto='$_SESSION[currentphoto]'"); $rowCheck = mysql_num_rows($result); $alreadyv = 0; if($rowCheck > 0){ $alreadyv = 1; //user has already voted on this photo, need to use this info to be able to skip it in the 'pool' } else { //do nothing } ?> totalVoted is basically how many times a user has voted, so that people who vote more, get more votes: <?php $result=mysql_query("SELECT * FROM pool ORDER BY totalVoted DESC LIMIT 1"); $rowCheck = mysql_num_rows($result); if($rowCheck > 0){ while($row = mysql_fetch_array($result)){ $photoid = $row['photoInPool']; $result2=mysql_query("SELECT * FROM photos WHERE pID='$photoid'"); $rowCheck2 = mysql_num_rows($result2); if($rowCheck2 > 0){ while($row2 = mysql_fetch_array($result2)){ if($alreadyv == 1) { //I NEED THIS TO SHOW THE NEXT PHOTO IN THE ARRAY, HOWEVER, IF THEY HAVE ALREADY VOTED ON THE NEXT PHOTO, IT WILL STILL DISPLAY IT, THIS IS MY PROBLEM I NEED HELP WITH PLEASE } elseif ($alreadyv != 1) { $fname = $row2['pFileName']; } } } $_SESSION[currentphoto] = $row['photoInPool']; echo "<center><img src='user_images/$fname'></center>"; } } ?> I hope I've explained this well enough and hope somebody can help. Many thanks in advance Hi there, I was thinking of using this following check system to see if a user has entered a good valid value for a categories selection, but it is just is_numeric, here's my line of single code for this: Code: [Select] if(!array_key_exists('category', $_GET) || trim(is_numeric($_GET['category'])) == '') Is there anything better that I can be using than is_numeric()? I mean this would allow 2.22 which for the categories selection, would not be valid, I will only be allowing integer values, I mean it would potentially come up with no category selected but that wouldn't be very good would it? It could be applied to a blog I am doing aswell, any guidance on such an improvement on this function would very much be appreciated, Jeremy. |