PHP - How To Reliably Determine If Server Is Apache?
How to reliably determine if server is Apache using PHP?
For example isApache() function? Similar TutorialsWhen I upload new files, their file name is stored into my database. I have been told that a couple of the file downloads weren't working. Upon further investigation I figured out that the file the person wanted to download was nowhere to be seen in my downloads directory. How can I determine if a file exists in my directory? I assume I can somehow use the location that is stored inside my database (ex: myfile.pdf) and compare that with what's in the folder. I implemented google's reCAPTCHA V2 on http:// on the remote apache shared server and it worked 100%. I then changed the protocol to my shared server SSL using the same PHP script as the non-SSL script. The older version of reCaptcha had an SSL 'false' to 'true' SSL parameter, whereas I can't find one for V2. I had to use htaccess to redirect the example.com to the shared SSL server https://serverid.net/example/ which works perfectly without recCAPTCHA. I incorporated reCAPTCHA V2 and the error message where the reCAPTCHA image should be shows "ERROR: Invalid domain for site key". This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=333987.0 So, I'm trying to read a file from a different filepath than the current working directory.
I have some simple PHP like this :
<?php $input_map = "readfile.php"; $map_contents = file_get_contents($input_map); echo $map_contents."<br />\n"; ?>And this'll work fine because it's in the same directory but if I try to set $input_map = "/home/...", the browser will return an empty string. This script will work from the command line though. So how do I get file_get_contents() to read from the server's file structure instead of just the working directory? Edit : For example, this will not work through the browser : <?php $input_map = "/home/..."; $map_contents = file_get_contents($input_map); echo $map_contents."<br />\n"; var_dump($map_contents); ?> Edited by MutantJohn, 21 January 2015 - 06:35 PM. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=351056.0 I know there has got to be some server config somewhere. But I have a site with about 8000 users. And 20% or so can never receive "forgot email" passwords. A lot of them checked their junk and its not there, it just never gets delivered. But for a lot of people it works fine. So... How can i get PHP mail() to work better. Right now im using swift mailer with this code Code: [Select] function email($to,$subject,$body,$from="") { require_once 'packages/swift/swift_required.php'; $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'); $mailer = Swift_Mailer::newInstance($transport); $message = Swift_Message::newInstance($subject); $message->setFrom($from); $headers = $message->getHeaders(); if (!$headers->has('Reply-To')) { $headers->addTextHeader('Reply-To',$from); } if(!is_array($to)) $to = array($to); $message->setTo($to); $message->setBody($body,'text/html'); $result = $mailer->batchSend($message); $toString = implode(",",$to); $this->_log("EMAIL to $toString - $body - $result"); return $result; } What have you guys used for this kind of thing? Is there some server config everyone should do? Thanks! All, I have a zip code and for example the zip code is 01101. How can I determine if the first character in this is a zero? Thanks in advance. I have a Unique Constraint setup on (emailAddress and pin) to allow multiple email addresses be the same and multiple pins but not the same emailAddress and pin value together (unique(emailAddress, pin)) Anyway, I am trying to generate a pin through a random seed, but I can't get my code to work properly to test if the combination already exists. Here is the chunk that does not work: Code: [Select] $tries = 0; $foundRows=0; do { $pin=null; $tries++; $pin = str_pad(rand(0,9), 4, "0", STR_PAD_LEFT); $stmt = $dbh->prepare("SELECT COUNT(*) FROM ajax WHERE emailAddress=:email AND pin=:pin LIMIT 1"); if ($stmt->bindParam(':email', $email, PDO::PARAM_STR) && $stmt->bindParam(':pin', $pin, PDO::PARAM_INT)) { $stmt->execute(); $foundRows = $dbh->query("SELECT FOUND_ROWS()")->fetchColumn(); echo "<br />$foundRows<br />"; } else { die ("<p>Could not bind to data verification</p>"); } } while ($foundRows > 0); This is always returning $foundRows=0 so always exiting the loop, and giving me a constraint error. Any ideas? Maybe a better way to do this? Am currently using this code, and actually thinking about it should split the query to an include in order to allow for other database drivers, on the chance we may decide to ditch the old MySQL. But I digress from the question. Code: [Select] include($lib."dbconfig.php"); $q = 'SELECT * FROM file WHERE this = "'.$that'"; $result = mysql_query($q); if (mysql_num_rows($result) > 0) If the query doesn't pick up a row I'm getting this error yo, Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\webpages\*\*\admin.php on line 553 So what would be a better way of testing if the query was successful? My uploader allows the following file formats: jpg gif png I tested that if someone was to name a file configure.php.jpg, my uploader allows it to upload I want to do a check to see if the user has 2 extensions, and if so it will not allow them to upload. I was thinking of just checking if the file name has two "." (dots) in the name. What function could I use to do this? Or .. is there a better way? I have a table that I must be populated based on a check box selection. The maximum selection is 5, however, there are more then 10 choices. For example: Here is a choice of 10 different (checkbox) options that the user can select from: 1. Coke 2. Root Beer 3. Pepsi 4. Dr. Pepper 5. Sprite 6. 7up 7. Cream Soda 8. Club Soda 9. Water 10. Milk I've already managed to limit the users selection to only 5. My issue is determining which of the checkboxese were actually selected so that I can correctly place them in my database. The first thing to do is create variables from all the checkboxes: $coke = $_POST['coke']; $rootbeer = $_POST['rootbeer']; $pepsi = $_POST['pepsi']; $drpepper = $_POST['drpepper']; etc. etc. Now that I have all 10 selections as variables from a submitted form how can I determine which ones are empty (or which ones have values) so that I can then save them to the database respectively? I am pulling records from a mysql db. Example Output: Team A= Our Team Team b = An opponent team Team A score = 7 Team B score = 8 Team A = Our Team Team b = Another Opponent Team A score = 3 Team B score = 1 What I need now is to add ONE more output, which is whether this is a "WIN" or a "LOSS". Should I add a field into the table that calc's this? If so, how? Please be specific. Or, should I use php to compare Team A score vs Team B score PER every record and then insert this new variable into the output. If so, how do I create a new variable value for every single output in the table? I know ultimately that this is a IF THEN type of calc, but can't quite figure out how specifically. Please be specific. Thanks This may sound funny, but I'm not sure what I was trying to get this code to do... Code: [Select] <!-- Find Current Page Name --> <?php $page = basename($_SERVER['REQUEST_URI']); echo '<p>$page = ' . $page . '</p>'; // if ($page == '') { if (($page == '/')||($page == '')||($page == 'index.php')){ $page = "index.php"; echo '<p>You are on the Home Page.</p>'; }else{ echo '<p>You are on Some Other Page.</p>'; } What I mean by that is I'm not understanding why I chose... Code: [Select] if ($page == '') { and then... Code: [Select] if (($page == '/')||($page == '')){ and then... Code: [Select] if (($page == '/')||($page == '')||($page == 'index.php')){ Why would I get those different results from basename($_SERVER['REQUEST_URI'])?? And what should I expect locally on my Laptop with a Virtual Host set up (e.g. "http://local.debbie/index.php") versus using a Test Site (e.g. "http://www.doubledee.byethost2.com/") versus a real site (e.g. "www.debbie.com")?! Hope I'm making some sense here... Debbie So far, my company has been using Apache (Linux)-based web hosts for our hosting needs. Ever since the Heartbleed bug was found in OpenSSL, which is common to open source software, including Apache HTTP Server, I was wondering if Microsoft's IIS was any more secure than Apache. Opinions?
My arguement is that although IIS is a closed-source system, it is also a widely targeted platform (Windows) so that may be of concern. My argument for Apache is that it is open source, so exploits can be implemented using the source code as well, which is available for free download.
So, the question really is which HTTP server platform is more secure?
Hi, Competitors vs. against each other and are recorded in a database. Each participant equally has 4 matches each, as you can see in the attatchment following the points gained in their played matches. I want to be able to determine the qualified participants according to either their "points" or "wins/losses". If two competitors have the same points, then I have already made a solution that another match must be generated for the two participants with the same points and draws can not be submitted which means the points will always be different for each team. I want to pick out half of participants 8/16 (screenshot below) with highest points which will be the qualifiers, or pick out half participants 8/16 with best match stats according to wins/losses. Any help I would be very grateful, thanks. Hi, I'm making an attempt to build a small cms based site. I have read in a lot of places it is best to use the id of a table row to fetch contents, but being as I am using url rewrite in frontend, it won't be showing query strings, so I thought I would ask if anyone saw any potential problems if I did the following. Page table looks like this: Pages - id - name - content In backend, the user has a form to name the page and use ckeditor to add rich content. I will use php to ensure that the name is alphanumeric and use strtolower & str_replace to ensure that My First HTML Page is sent to mysql as my-first-html-page and also check that a row with this name does not already exist. So on front end this page url will be mywebsite.com/my-first-html-page So to output the content I strip out the domain & / so I'm left with the name as entered in the db. $url = $_SERVER['REQUEST_URI']; $url = str_replace ('/','',$url); Then in my function to output content I will use WHERE name = $url I have this function, but it doesnt work. Basically the list outputs a list of news features, and puts a line under neath each article to seperate them. However once the last article has been reached, I don't want the break to be shown. this is my code, any help would be appreciated as i am really struggling on this. Just need to determine the last item in the array, and stop the <hr split> from being output. function newsFeature(){ $event = "SELECT imgname, title, content, pkID from news ORDER BY date, time DESC LIMIT 5"; $event_page = query($event); $count = numRows($event_page); while ($row = mysql_fetch_assoc($event_page)) { $rowcount = $count; $para = substr($row['content'] , 0,100); $result .= '<article>'; $result .= '<a href="news-article.php?pkID=' . $row['pkID'] . '"><img src="uploads/thumbs/' . $row['imgname'] . '" alt="" width=116 height=83/ ></a>'; $result .= '<h2><a href="news-article.php?pkID=' . $row['pkID'] . '">' . $row['title'] . '</a></h2>'; $result .= '<p>' . $para . '...</p>'; $result .= '<p><a class="read-more" href="news-article.php?pkID=' . $row['pkID'] . '">Read more<span></span></a></p>'; $result .= '</article>'; if($row != end($row[])){ $result .= '<hr class="split">'; } } return $result; } I can determine which radio button is selected for each file upload prompt because I have a name and a value. So the array name=image can have one of three values for each file upload prompt. Is there a way to determine which of the three file upload prompts was loaded (clicking browse & select image) with an image and which was not? There doesn't seem to be a value like there is with radio buttons. I want to be able to replace an already uploaded image with another. Thanks. <input type='radio' name='image[image0]' value='keep' checked='checked'/> <input type='radio' name='image[image0]' value='delete' /> <input type='radio' name='image[image0]' value='replace' /> <input type="file" name="image[]" /> <input type='radio' name='image[image1]' value='keep' checked='checked'/> <input type='radio' name='image[image1]' value='delete' /> <input type='radio' name='image[image1]' value='replace' /> <input type="file" name="image[]" /> <input type='radio' name='image[image2]' value='keep' checked='checked'/> <input type='radio' name='image[image2]' value='delete' /> <input type='radio' name='image[image2]' value='replace' /> <input type="file" name="image[]" /> if (isset($_POST['submitted']) && ($image = $_POST['image'])) { foreach($image as $imageKey => $imageValue) { if ($imageValue == 'keep') { do this } } } I'm trying to run a process using shell_exec, however the program i'm trying to run must communicate with a process that is not a system process, and everytime i run it, it fails, does anyone know how to make a apache server run active windows not in the system process? hey guys i have apache installed but im sure my .htaccess file isnt being read...is there something in the config file i have to do please?...thank you |