Search the Community
Showing results for tags 'remove'.
-
This is so strange. I have this bit of code that removes the .php extension from pages so that I can visit any page without typing .php at the end. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*)$ $1.php [L] The above code has always worked for me before. But for some reason today it stopped working on localhost and the live server(ipage hosting). Do you know why that might be?
-
Trying to figure out how, when I press my logout button, do I get my page to go back to it's original page without the ?variable=something at the end: header('Location: '.$_SERVER['PHP_SELF'].'?activationsent=1'); I own this site: http://www.golden-wand.com/phpfreaks.txt
-
Here is my code which i use to recieve uploaded files. $filepath = $_SERVER['DOCUMENT_ROOT'] . "file/"; $fileunzippath = $filepath."unzipped/"; $exclude_list = array(".", "..", "...", "index.php", ".php", ".htaccess"); if($_FILES["zip_file"]["name"]) { $filename = $_FILES["zip_file"]["name"]; $source = $_FILES["zip_file"]["tmp_name"]; $type = $_FILES["zip_file"]["type"]; $name = explode(".", $filename); $accepted_types = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/x-compressed'); foreach($accepted_types as $mime_type) { if($mime_type == $type) { $okay = true; break; } } $continue = strtolower($name[1]) == 'zip' ? true : false; if(!$continue) { $message = "The file you are trying to upload is not a .zip file. Please try again."; } $string = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $filename); $clean_name = strtr($string, array('Š' => 'S','Ž' => 'Z','š' => 's','ž' => 'z','Ÿ' => 'Y','À' => 'A','Á' => 'A','Â' => 'A','Ã' => 'A','Ä' => 'A','Å' => 'A','Ç' => 'C','È' => 'E','É' => 'E','Ê' => 'E','Ë' => 'E','Ì' => 'I','Í' => 'I','Î' => 'I','Ï' => 'I','Ñ' => 'N','Ò' => 'O','Ó' => 'O','Ô' => 'O','Õ' => 'O','Ö' => 'O','Ø' => 'O','Ù' => 'U','Ú' => 'U','Û' => 'U','Ü' => 'U','Ý' => 'Y','à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a','å' => 'a','ç' => 'c','è' => 'e','é' => 'e','ê' => 'e','ë' => 'e','ì' => 'i','í' => 'i','î' => 'i','ï' => 'i','ñ' => 'n','ò' => 'o','ó' => 'o','ô' => 'o','õ' => 'o','ö' => 'o','ø' => 'o','ù' => 'u','ú' => 'u','û' => 'u','ü' => 'u','ý' => 'y','ÿ' => 'y')); $clean_name = strtr($clean_name, array('Þ' => 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh', 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE', 'æ' => 'ae', 'µ' => 'u')); $clean_name = preg_replace(array('/\s/', '/\.[\.]+/', '/[^\w_\.\-]/'), array('_', '.', ''), $clean_name); $target_path = $filepath.$clean_name; // change this to the correct site path if(move_uploaded_file($source, $target_path)) { echo "Source: ".$source."<br/>"; echo "Type: ".$type."<br/>"; echo "Filename: ".$filename."<br/>"; $zip = new ZipArchive(); $x = $zip->open($target_path); if ($x === true) { $zip->extractTo($fileunzippath.$clean_name); // change this to the correct site path $zip->close(); $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } } $message = "Your .zip file was uploaded and unpacked."; } else { $message = "There was a problem with the upload. Please try again."; } } Specifically i want to highlight this part: $exclude_list; $dir_path = $_SERVER['DOCUMENT_ROOT']; $dir_path .= "/file/unzipped/"; $directories = array_diff(scandir($fileunzippath.$clean_name), $exclude_list); foreach($directories as $entry) { if(is_dir($dir_path.$entry)) { if($entry != 'part0' || $entry !='part1') { rmdir($entry); } } } When I upload a zip file containing 2 directories(one called 'part0', and one called 'bad'), they get unzipped correctly and it gives no errors, however the fake directories(not called part0 or part1) I put in there are still there. Any Help?
-
Hi, I have a little snipplet I am posting here, I am not very experienced with PHP but thought I would ask some of you for help. I have to modify a program and a very small part of it is to remove lines where values are being set to blank or '' null values. Here is the little code snipplet: echo "\t\tfor(index=0; index < $maxclothrows; index++)\n"; echo "\t\t{\n"; echo "\t\t\tdocument.pickDivision.cloth.options[index].text = '';\n"; echo "\t\t\tdocument.pickDivision.cloth.options[index].value = '';\n"; echo "\t\t}\n\n"; This above code is used to set some values to ' ', but then after I would like those blank values removed rather then showing up in the list because when I scroll down you have a whole bunch of blank lines. How can I remove these completely? Maybe: echo "\t\t\if(document.pickDivision.cloth.options[index].text = '') {...some code here to remove this blank line} I read about regex or some str_replace, but am not sure how to use it. This program is around 3000 lines of code, so don't think I can attach the file. Any help would be greatly appreciated!
-
Theres this script floating around the web that replaces special characters with dashes but instead I would like specifically punctuation to NOT be replaced with anything but to just be removed... no white space, no dash. example: today's weather is hot! good:: todays-weather-is-hot bad: today-s-weather-is-hot- This script replaces does that bad example... how to make it do the good?: function secUrl($string){ $string = strtolower($string); $string = preg_replace('/[^a-zA-Z0-9]/i','-',$string); $string = preg_replace("/(-){2,}/",'$1',$string); return $string; }
-
So, my host's mod_rewrite seems to be messed up or something is wrong with their software. I'm not really sure and the host refuses to fix it or give me my money back so I'm stuck with it. Anyway, so I'm saying, mod_rewrite doesn't work. How would I mod the script so that it does not need to depend on mod_rewrite? A general answer will probably do fine. Do I just go through every single page and the ones that have a link, I link it to the .php page and not the mod_rewrite one? Sorry, I'm a little confused.