PHP - Path After A .php Extension
Hey guys! I just joined this forum today, and I'm wondering about something...
I see a lot of sites, and in the code of the site, style sheets and javascript includes are references in a manner similar to this... "href='http://www.somesite.com/css/css.php/someDirectory/style.css'" How is this done? The path following the "css.php" is what confuses me. Thanks for any information you have! Similar TutorialsHi! So I'm working for someone, and they want me to fix this error in a PHP file.. Here is the code: <?php include_once('config.php'); $online = mysql_query("SELECT * FROM bots WHERE status LIKE 'Online'"); $offline = mysql_query("SELECT * FROM bots WHERE status LIKE 'Offline'"); $dead = mysql_query("SELECT * FROM bots WHERE status LIKE 'Dead'"); $admintrue = mysql_query("SELECT * FROM bots WHERE admin LIKE 'True'"); $adminfalse = mysql_query("SELECT * FROM bots WHERE admin LIKE 'False'"); $windows8 = mysql_query("SELECT * FROM bots WHERE so LIKE '%8%'"); $windows7 = mysql_query("SELECT * FROM bots WHERE so LIKE '%7%'"); $windowsvista = mysql_query("SELECT * FROM bots WHERE so LIKE '%vista%'"); $windowsxp = mysql_query("SELECT * FROM bots WHERE so LIKE '%xp%'"); $unknown = mysql_query("SELECT * FROM bots WHERE so LIKE 'Unknown'"); $totalbots = mysql_num_rows(mysql_query("SELECT * FROM bots")); $onlinecount = 0; $offlinecount = 0; $deadcount = 0; $admintruecount = 0; $adminfalsecount = 0; $windows8count = 0; $windows7count = 0; $windowsvistacount = 0; $windowsxpcount = 0; $unknowncount = 0; while($row = mysql_fetch_array($online)){ $onlinecount++; } while($row = mysql_fetch_array($offline)){ $offlinecount++; } while($row = mysql_fetch_array($dead)){ $deadcount++; } while($row = mysql_fetch_array($admintrue)){ $admintruecount++; } while($row = mysql_fetch_array($adminfalse)){ $adminfalsecount++; } while($row = mysql_fetch_array($windows8)){ $windows8count++; } while($row = mysql_fetch_array($windows7)){ $windows7count++; } while($row = mysql_fetch_array($windowsvista)){ $windowsvistacount++; } while($row = mysql_fetch_array($windowsxp)){ $windowsxpcount++; } while($row = mysql_fetch_array($unknown)){ $unknowncount++; } $statustotal = $onlinecount + $offlinecount + $deadcount; $admintotal = $admintruecount + $adminfalsecount; $sototal = $windows7count + $windowsvistacount + $windowsxpcount + $unknowncount; ?> Can anyone tell me the error here, can how to fix it? Hi all. i have problems with making a questionnaire. i have done a single questions but i have no idea how to add them al ltogether so they work as switch function. i`ve attached one of the questions. could anyone suggest how i make answers into a list rather than just a line of options? Hi there, trying to use PCNTL. I've recompiled PHP with --enable-pcntl in configure as described in PHP manual, but when I call pcntl_fork() I receive back " Fatal error: Call to undefined function pcntl_fork() ". What am I missing??? Thanks in advance Muflo How do I know if Filter extension is on with my webhost? Or does it always work with PHP5? If I cannot use it, can someone recommend a good regex to validate EMAIL addresses?? Thanks, Debbie Hi all, I just managed to make a little mod_rewrite rule which manages to interpret url's without the extension and calls the right file with the extension (ie. /articles calls articles.php) . But now i am left with another question which i am almost certain has nothing to do with mod_rewrite, but rather with a php trick. In case someone enters on my site www.mydomain.com/laalalalala.php How do i get rid of that last part(the extension for example)? Do i maybe have to get the GET['var'] and run it through a regex and reload the page with the stripped version? That was all i could think off but it sound so complicated. if anyone has an idea i would love to hear it cheers! P.s.s if anyone want's that rewrite rule, let me know. I saw quite some people on the internet looking for it PHP v. 5.3.8 What is libxml extension and how would I know if it's enabled? My book told me Note To take advantage of SimpleXML, make sure PHP's libxml extension is enabled. Just started working with PHP and wrote a PHP extension in C. Got it working with hard coded variables and started to work on feeding it 3 string arguments as input. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &acct, &acct_len,&userid, &userid_len, &passwd, &passwd_len) == FAILURE) { RETURN_NULL(); } When I execute the extension with 3 arguments I always get the following. Code: [Select] [XXX@XXXVIPH01 smxauth]$ php -r "smxauth('myacct','nobody','password');" PHP Warning: smxauth() expects exactly 1 parameter, 3 given in Command line code on line 1 I thought the "sss" would dictate the number of args expected but it doesn't seem to work that way (for me at least). Using php-5.1.6 Any thoughts? Thanks Tim I have a variable that holds the name of a File... Code: [Select] $origFileName = $_FILES['userPhoto']['name']; What is the best way to just get the File Name from this? Debbie Hello guys, i need to create a code for making connections with SSL servers (particularly SMTPS and POP3S) and i know about the existence of OpenSSL extension. However, i'm in doubt about a basic issue: 1. Is this extension useful for creating SSL clients or SSL servers? I'm not a SSL expert, so maybe i'm misunderstanding something; i hope you can help me. Kind regards. Hi Guys, I am having some issues in trying to return a file extension in a php upload script, here is what I am trying to do, no extension is added when a file is uploaded. $p_id = $row['p_id']; $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; $filename = $HTTP_POST_FILES['Filedata']['name']; $ext = end(explode('.', $filename)); $nfilename = $p_id . $ext; $targetFile = str_replace('//','/',$targetPath) . $nfilename; Hi folks, just upgrading one of my sites with a new script which i thought i had working, well it did at least on my local server. Its an image upload script. It fails at the get image extension part, which when echoed out is blank. Which is why its failing. Can anyone see what i have missed? if($_POST){ $image =$_FILES["image"]["name"]; $img = $_FILES['image']['tmp_name']; $size = filesize($_FILES["image"]["tmp_name"]); $maxsize= 400; if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>409600){ echo 'Upload FAILED, file is too large !'; exit(); } if ($size > $maxsize*1024){ echo "File too big"; exit(); } else { if(file_exists($existingimage)){ unlink($existingimage); } function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $extension = getExtension($image); $extension = strtolower($extension); if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif")) { echo "The extension is:" . $extension ." "; echo'Unknown Image extension'; exit(); } Ive ended the script here at the part where it fails to reduce the amount of uneeded code to sift through. It fails no matter what type of image is used to upload. Hello freaks, I am using the FPDF class to generate PDF's on the fly, and I needed a way to generate multiline (flowing) text with specific widths. I found this FPDF extension function from FPDF's website, but can't seem to call it properly. I recieve an undefined function error! The function with in my script is as follows: Code: [Select] <?php include_once "fpdf16/fpdf.php"; class PDF extends FPDF { function WordWrap(&$text, $maxwidth) { $text = trim($text); if ($text==='') return 0; $space = $this->GetStringWidth(' '); $lines = explode("\n", $text); $text = ''; $count = 0; foreach ($lines as $line) { $words = preg_split('/ +/', $line); $width = 0; foreach ($words as $word) { $wordwidth = $this->GetStringWidth($word); if ($wordwidth > $maxwidth) { // Word is too long, we cut it for($i=0; $i<strlen($word); $i++) { $wordwidth = $this->GetStringWidth(substr($word, $i, 1)); if($width + $wordwidth <= $maxwidth) { $width += $wordwidth; $text .= substr($word, $i, 1); } else { $width = $wordwidth; $text = rtrim($text)."\n".substr($word, $i, 1); $count++; } } } elseif($width + $wordwidth <= $maxwidth) { $width += $wordwidth + $space; $text .= $word.' '; } else { $width = $wordwidth + $space; $text = rtrim($text)."\n".$word.' '; $count++; } } $text = rtrim($text)."\n"; $count++; } $text = rtrim($text); return $count; } } ?> My call to this function with in my script is as follows: Code: [Select] <?php $text = $useDesc1; $pdf -> WordWrap($text, $useDescTextWidth); $pdf -> Write(10, $text); ?> Does anyone have a reccommendations as to why this is happening? Thanks in advance. Hello, I'm currently using this to block certain emails: $blacklisted = Array("email@email.com", "email2@email.com", "email3@email.com"); in with: if( !in_array( strtolower($email), $blacklisted ) ) { Ok, What I want to do, is be able to specify a domain extension such as '*@email.com' So anything with 'something'@email.com is blocked. I still wish to keep manual email address's in place aswell. Many thanks James I have a website that I did for my uncle and now, the requirements are going beyond my html knowledge and into the realm of server scripting. My issue is that I need to loop through all the images in a given folder and subfolders and preload them into the html so that the user can view them within a slide show. There are currently 6 subfolders with over 20 pics in each and there are more pics to come and different folders to add. I have a media page with the first picture within each category (subfolder) displayed as an eye catcher to the category. once the user clicks on the image, the slide show will start in a popup. The problem is that with js, I have to list out every image since it cannot look through a directory listing. I would like to simply call a server side script that will create an array of the images and preload them so that when the slide show is ran, the appropriate images will show. I am found numerous scripts for preloading images, written in php, but I am unsure how to implement them and keep a html extension for my pages. As the site is written entirely in html and javascript, I would like to keep the html extentions if possible. As this is my first site, I am sure that server side scripting will become a bigger role, but baby steps are what I need right now. In addition, if anyone has a good site for learning the server scripting world, I would greatly appreciate the reference. Hello, I was wondering how you can find out the extension of the image (so .gif, or .jpg). Because i need to make an image uploader thingy, and i want to change the name of the picture to some random string, but keep the extension the same. My friend said i could do it in regex but i have no idea.. Thanks Jragon. I have an array that has data in it and its being sorted like this: Code: [Select] Source 1 (zip): filename.zip Source 1 (jpg): filename.jpg Source 1 (png): filename.png Source 2 (zip): filename.zip Source 2 (jpg): filename.jpg Source 2 (png): filename.png Source 3 (zip): filename.zip Source 3 (jpg): filename.jpg Source 3 (png): filename.png Id like the data to be sorted like this instead, but i dont know how to get it to sort this way: Code: [Select] Source 1 (zip): filename.zip Source 2 (zip): filename.zip Source 3 (zip): filename.zip Source 1 (jpg): filename.jpg Source 2 (jpg): filename.jpg Source 3 (jpg): filename.jpg Source 1 (png): filename.png Source 2 (png): filename.png Source 3 (png): filename.png Here's my code: any help is appreciated. thanks. for ($i = 1; $i <= 5; $i++) { $src[$i] = 'Source '.$i.' ('.$ext.'): '.$filename.''; array_multisort($src, SORT_ASC, SORT_STRING); } Hi first post here and very new to php. I built a form so that a data entry perosn can "build" new pages for our companies website. I pretty much have the basics of the form and the action page coded correctly, however my issue is that I need this final page where the form inputs are posted too to be an html document. I read some about the str_replace() function, but I'm not understanding how I could use that to replace the file extension of a page. Maybe I'm going about this all wrong. I also read that one can edit the htaccess folder to allow an html file to run php script. Not sure which way would be the best. One thing to mention though, is this application would be run locally to our back up files which is then scheduled to be uploaded to the remote server very night. Any help or suggestions would be greatly appreciated. Hi everyone, Sorry not sure if this is a php or html problem. Im using php and a html form to upload images to my site, i have made it so that jpg, jpeg, gif and png images can be uploaded. The problem im having is displaying the image. Code: [Select] <img src="images/<?php echo $name ?>.jpg" /> That works fine if a jpg was uploaded, but what if a png or a gif was uploaded? The $name is going to be unique, there will not be more than one image with the same name, so what do i have to do to display the image regardless of what the extension is? Thanks Hi, how do I extract just file extension? eg: $file="hello.xml"; $fileExt=??? print $fileExt; Any help much appreciated! so im trying this
$file is not a .txt file
if ($file != "." && $file != ".." && !is_dir("uploads/$fuser/$file") && (pathinfo("uploads/$fuser/$file", PATHINFO_FILENAME)!= "txt")
i tried this but doesnt work
|