Jump to content

sayedsohail

Members
  • Posts

    468
  • Joined

  • Last visited

    Never

Everything posted by sayedsohail

  1. Hi everyone, function below just display files and folder but no the supplied path ie., http://localhost/xyz/ it just display files and folders where this script is saved not the supplied path. Can someone please have a look at it. Thanks, <?php function showContent($path){ if ($handle = opendir($path)) { $up = substr($path, 0, (strrpos(dirname($path."/."),"/"))); echo "<tr><td colspan='3'>"; echo "<a href='".$_SERVER['PHP_SELF']."?path=$up'>Up one level</a>"; echo "</td></tr>"; while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $fName = $file; $file = $path.'/'.$file; if(is_file($file)) { echo "<tr><td> -F- <a href='".$file."'>".$fName."</a></td>" ."<td align='right'>".date ('d-m-Y H:i:s', filemtime($file))."</td>" ."<td align='right'>".filesize($file)." bytes</td></tr>"; } elseif (is_dir($file)) { print "<tr><td colspan='3'> -D- <a href='".$_SERVER['PHP_SELF']."?path=$file'>$fName</a></td></tr>"; } } } closedir($handle); } } ?> <table width="100%" border='1'> <?php $actpath ="http://localhost/"; showContent("$actpath"); ?> </table>
  2. Hi everyone, Is this the right way to extract and store the session variable value? $memid =mysql_real_escape_string($_SESSION['SESS_MID']));
  3. I found a class that does the job, also look at the settings i described in the thread: Sohail http://www.vulgarisoip.com/2006/10/13/update-send-email-with-php-and-gmail-hosted-for-your-domain/#comment-3211
  4. Million thanks for the help, Is there anyway, i could add funtionality to browse the subdirectories and a back button to parent directory? Something like this, but this one is not showing anything: <?php # Original PHP code by Chirp Internet: www.chirp.com.au # Please acknowledge use of this code by including this header. function getFileList($dir, $recurse=false) { # array to hold return value $retval = array(); # add trailing slash if missing if(substr($dir, -1) != "/") $dir .= "/"; # open pointer to directory and read list of files $d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading"); while(false !== ($entry = $d->read())) { # skip hidden files if($entry[0] == ".") continue; if(is_dir("$dir$entry")) { $retval[] = array( "name" => "$dir$entry/", "type" => filetype("$dir$entry"), "size" => 0, "lastmod" => filemtime("$dir$entry") ); if($recurse && is_readable("$dir$entry/")) { $retval = array_merge($retval, getFileList("$dir$entry/", true)); } } elseif(is_readable("$dir$entry")) { $retval[] = array( "name" => "$dir$entry", "type" => mime_content_type("$dir$entry"), "size" => filesize("$dir$entry"), "lastmod" => filemtime("$dir$entry") ); } } $d->close(); return $retval; } # include subdirectories $dirlist = getFileList("./", true); echo "<table>\n"; echo "<tr><th>Name</th><th>Type</th><th>Size</th><th>Last Mod.</th></tr>\n"; foreach($dirlist as $file) { echo "<tr>\n"; echo "<td>{$file['name']}</td>\n"; echo "<td>{$file['type']}</td>\n"; echo "<td>{$file['size']}</td>\n"; echo "<td>" . date("r", $file['lastmod']) . "</td>\n"; echo "</tr>\n"; } echo "</table>\n\n"; ?>
  5. Revised version1.1, i removed the download option now it displays the files and subdirectories, can someone help in adding a download button, where user can click the download link and the file starts downloading. <?php $dh = opendir('./'); $i=1; echo "<table><tr><th>ID</th>Download</th><th>File Name</th><th>Type</th></tr>"; while ($file = readdir($dh)) { echo "<tr><th>$i</th><th></th><th>".$file."</th><th></th></tr>"; $i++; } echo "</table>"; closedir($dh); ?>
  6. Hi everyone, My first version of simple code, display files and directories but when i tried only to display pdf files and subdirectories inside the given path, with pagination and downloadable option, everything went wrong. ID Download File Name Type 1 CLICKABLE IMAGE XYZ PDF <?php header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="$file"'); $dh = opendir('/usr/local/apache2/htdocs/'); $i=1; echo "<table><tr><th>ID</th>Download</th><th>File Name</th><th>Type</th></tr>"; while ($file = readdir($dh)) { echo "<tr><th>i++</th><th>".readfile('$file')." </th><th>".$file."</th><th></th></tr>"; $i++; } echo "</table>"; closedir($dh); ?>
  7. require("./file_man/functions/index/top.x");
  8. use phpmailer or royalmail lol.
  9. Thanks madtechie, can you please explain how it works, please. specially the /si bit is something new for me. and how do i take only the first occurance of letters from the full company ie., cat's co ltd to $file_name='cats'; $file_name="Cat's Company Ltd."; tosomethign like this using preg_replace or preg_split, i am not sure could i achieve this. $file_name ="cats";
  10. million thanks, The directory i am creating is basically the name of the client i.e, ABC Ltd or XYZBCDD Co. or Cat's Co., here i wish to abstract only the alphabets and only the first bit i.e., ABC and XYZBCDD and Cats replacing the other characters exists inside the first bit as you notice Cats in place of Cat's Co. I am not sure if str_replace could do all that work. $file_name=$_GET['client_name']; $file_name = str_replace("'","",$file_name); or substr($file_name,strpos($file_name,$pattern)+strlen($pattern)); or $str = preg_replace('/.'*?/', $file_name); Can you please suggest something here.
  11. I was told using umask(0), is better before making any directories or writting files, can someone please explain little bit about umask(0), please. Thanks, $oldumask = umask(0); $mode = 0777; if (!is_dir($path) && !mkdir($path, $mode)) {mkdir( "$uname" , 0777); } umask($oldumask);
  12. yes i am trying to add this code now, not sure this is the right way. $mode = 0777; if (!is_dir($path) && !mkdir($path, $mode)) {mkdir( "$uname" , 0777); }
  13. I slightly changed the first three lines and it worked? $uname = "tmp1"; $path = 'pdf/'.$uname.'/'; $filename = "$path" ."doc1.doc";
  14. This is simple code, but its not working? no errors, although i removed the session in my second try. ? <?php //session_start(); //$uname = $_SESSION['sess_uname']; $uname = "tmp1"; $path= 'pdf/'.$uname.'/' $filename = '/'.$path.'/doc1.doc'; if (file_exists($path)) { echo " The Directory $path exists"; } else { echo "The directory $path does not exist"; } if (file_exists($filename)) { echo "The file $filename exists"; } else { echo "The file $filename does not exist"; } ?>
  15. is there anything such as directory exists?, can you please help with a little bit of code.
  16. Hi everyone, I just saw an interesting thread, for uploading files - but my problem is just to add a directory for each user, the user name are stored in session variable sess_uname? I am not sure how do i check if the directory is already exists for the logged user. if directory exists than i i just want to move the file to that directory otherwise create directory with the name as sess_uname and store the file. Can anyone please help in this regard. Thanks <?php //This is the directory where images will be saved $path = '../images/'; //This gets all the other information from the form $name=$_POST['name']; $suburb=$_POST['suburb']; $price=$_POST['price']; $content=$_POST['content']; $uploadFile0=($_FILES['uploadFile0']['name']); $uploadFile1=($_FILES['uploadFile1']['name']); $uploadFile2=($_FILES['uploadFile2']['name']); $uploadFile3=($_FILES['uploadFile3']['name']); $uploadFile4=($_FILES['uploadFile4']['name']); $uploadFile5=($_FILES['uploadFile5']['name']); $uploadFile6=($_FILES['uploadFile6']['name']); $uploadFile7=($_FILES['uploadFile7']['name']); $uploadFile8=($_FILES['uploadFile8']['name']); // Connects to your Database mysql_connect("localhost", "root", "10000") or die(mysql_error()) ; mysql_select_db("docs") or die(mysql_error()) ; // Check the extension is valid if (preg_match('/\.(jpg|jpeg|gif|png)$/i', $_FILES['uploadFile'. $x]['name'])){ //Writes the information to the database mysql_query("INSERT INTO `employees` VALUES ('$name', '$suburb', '$price', '$content', '$uploadFile0', '$uploadFile1', '$uploadFile2', '$uploadFile3', '$uploadFile4', '$uploadFile5', '$uploadFile6', '$uploadFile7', '$uploadFile8')") ; $uploadNeed = $_POST['uploadNeed']; // start for loop for($x=0;$x<$uploadNeed;$x++){ $file_name = $_FILES['uploadFile'. $x]['name']; // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); $copy = move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $path . $file_name); } else { // Add your error code here echo "Sorry, file must be of type .jpg .jpeg .gif or .png\n"; } // check if successfully copied if($copy){ print "<meta http-equiv=\"refresh\" content=\"0;URL=property_added_successfully.php\">"; } else{ echo "$file_name | could not be uploaded!<br>"; } } // end of loop ?>
  17. I am using phpmailer it does wonders with small tweakining. It is a best mailer class and very easy to integrate and use.
  18. You need to capture the post values from the form, add this two lines inside your code above the $hostname etc, and there is not need to escape etc, its all stupid for the beginners - your original code is quite enough to do the job. Although there are lots of improvement can be done for advance level users. but this two lines should do the job for you to get the immediate results. $search = $_GET['q']; $metode = $_GET['metode']; $hostname = "localhost"; $username = "acdcalliance"; $password = "testpass22"; $usertable = "members"; $dbName = "acdc-alliance_com-mdb"; // Secondly its recommended to check the post/get values against sql injection for security reasons. Anyway this is keep you going. best of luck.
  19. Move the following lines under the mysql connect statement i.e, mysql_connect("localhost","adder","clifford"); mysql_select_db("real") or die("Unable to select database"); $targetb = mysql_real_escape_string($targetb); $type = mysql_real_escape_string($_POST['Type']); This should solve your problem. good luck.
  20. apologize if i am wrong, can you just echo the post values i.e, echo "$titleedit - $lengthedit ..... the rest of post values and specially don't forget $theedit"; can you please tell me if it prints the post values. i will wait for your confirmation and lets solve this issues now? Do remember to comment the update statement for time being. /*$sql = "UPDATE excursions SET exc_title='$titleedit', exc_length='$lengthedit', exc_price='$priceedit', exc_desc='$descedit' WHERE exc_id=$theedit"; mysql_query("$sql") or die(mysql_error()); echo "Excursion Updated<br><br>";*/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.