jakebur01
Members-
Posts
885 -
Joined
-
Last visited
Everything posted by jakebur01
-
I was hoping it would be easy. Something I could stick in the code where if $fList[$1]==car then it will not display that directory. if(@ftp_chdir($conn, $fList[$i])) { @ftp_cdup($conn); ?> <img src='http://www.orosandrei.ro/images/folder.gif'> <a href='scan.php?command=listFiles&currDir=<?php echo $fList[$i]; ?>'> <?php echo $trimFile; ?> </a> <br> <?php } else { ?> <img src='http://www.orosandrei.ro/images/file.gif'> <a href='scan.php?command=getFile&currFile=<?php echo $fList[$i]; ?>&currDir=<?php echo $currDir; ?>'> <?php echo $trimFile; ?> </a> <br> <?php } Thanks, Jake
-
How could I get the following function to exclude the directory named "car" when it is listing them out? function ShowFiles() { $conn = DoConn(); $currDir = ""; // Get the name of the current directory if(isset($_GET["currDir"])) $currDir = $_GET["currDir"]; else $currDir = ftp_pwd($conn); // Retrieve a list of files and directories // and display the appropriate icon for each $fList = @ftp_nlist($conn, $currDir); // We will work out the parent directory $parentDir = strrev($currDir); $parentDir = ereg_replace("^[a-zA-Z0-9\-]*/", "", $parentDir); $parentDir = strrev($parentDir); ?> <a href="javascript:history.go(-1)"> <img src='http://www.orosandrei.ro/images/back.gif'> </a> <br> <?php for($i = 0; $i < sizeof($fList); $i++) { // We will remove the parent directory (if any) // from the name of the file that gets displayed $trimFile = ereg_replace("^$currDir", "", $fList[$i]); // Remove any forward slash at front of name $trimFile = ereg_replace("^/", "", $trimFile); if(@ftp_chdir($conn, $fList[$i])) { @ftp_cdup($conn); ?> <img src='http://www.orosandrei.ro/images/folder.gif'> <a href='scan.php?command=listFiles&currDir=<?php echo $fList[$i]; ?>'> <?php echo $trimFile; ?> </a> <br> <?php } else { ?> <img src='http://www.orosandrei.ro/images/file.gif'> <a href='scan.php?command=getFile&currFile=<?php echo $fList[$i]; ?>&currDir=<?php echo $currDir; ?>'> <?php echo $trimFile; ?> </a> <br> <?php } } }
-
I am having trouble converting the functions in this class into ftp functions. function getFiles($path) { $files = array(); $fileNames = array(); $i = 0; // build if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if (($file == ".") || ($file == "..")) continue; $fullpath = $path . "/" . $file; //$fkey = strtolower($file); $fkey = $file; while (array_key_exists($fkey,$fileNames)) $fkey .= " "; $a = stat($fullpath); $files[$fkey]['size'] = $a['size']; if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-"; else if ($a['size'] > 1024 && $a['size'] <= 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K"; else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb"; else $files[$fkey]['sizetext'] = $a['size'] . " bytes"; $files[$fkey]['name'] = $file; $e = strip_ext($file); // $e is the extension - for example, .gif $files[$fkey]['type'] = filetype($fullpath); // file, dir, etc $k=$e.$file; // we use this string for sorting the array elements by extension and filename; $fileNames[$i++] = $k; } closedir($dh); } else die ("Cannot open directory: $path"); } else die ("Path is not a directory: $path"); sort($fileNames,SORT_STRING); // sorting $sortedFiles = array(); $i = 0; foreach($fileNames as $f) { $f = substr($f, 4, strlen($f)-4); // we remove the extension we added in front of the filename for sorting if($files[$f]['name'] !='') $sortedFiles[$i++] = $files[$f]; }// ends the foreach where we build the final sorted array return $sortedFiles; }
-
Is there anyone that can help me get started with this? I want to implement ftp functions from here: $ftp_server = 'myip'; $ftp_port = '21'; $conn = ftp_connect($ftp_server,$ftp_port); $ftpUser = "myuser"; $ftpPass = "mypass"; set_time_limit(160); $login = ftp_login($conn, $ftpUser, $ftpPass) or die("Login credentials were rejected"); $workingDir = ftp_pwd($conn); echo "Files for directory: $workingDir<br><br>"; $fList = @ftp_nlist($conn, $workingDir); if(is_array($fList)) { for($i = 0; $i < sizeof($fList); $i++) { echo $fList[$i] . "<br>"; } } else { echo "$workingDir contains no files."; } ftp_quit($conn); into this code: $host = "./"; // the folder where index.php is located // path for folder, file, buttons(back and home) images $img_back="http://www.orosandrei.ro/images/back.gif"; $img_folder="http://www.orosandrei.ro/images/folder.gif"; $img_file="http://www.orosandrei.ro/images/file.gif"; $img_home="http://www.orosandrei.ro/images/home.gif"; // end of install variables // returns the extension of a file function strip_ext($name) { $ext = substr($name, strlen($ext)-4, 4); if(strpos($ext,'.') === false) // if we have a folder element { return " "; // we return a string of space characters for later sort, // so that the folder items remain on the first positions } return $ext; // if we have a file we return the extension - .gif, .jpg, etc. } // returns the files from the $path and returns them in an array function getFiles($path) { $files = array(); $fileNames = array(); $i = 0; // build if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if (($file == ".") || ($file == "..")) continue; $fullpath = $path . "/" . $file; //$fkey = strtolower($file); $fkey = $file; while (array_key_exists($fkey,$fileNames)) $fkey .= " "; $a = stat($fullpath); $files[$fkey]['size'] = $a['size']; if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-"; else if ($a['size'] > 1024 && $a['size'] <= 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K"; else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb"; else $files[$fkey]['sizetext'] = $a['size'] . " bytes"; $files[$fkey]['name'] = $file; $e = strip_ext($file); // $e is the extension - for example, .gif $files[$fkey]['type'] = filetype($fullpath); // file, dir, etc $k=$e.$file; // we use this string for sorting the array elements by extension and filename; $fileNames[$i++] = $k; } closedir($dh); } else die ("Cannot open directory: $path"); } else die ("Path is not a directory: $path"); sort($fileNames,SORT_STRING); // sorting $sortedFiles = array(); $i = 0; foreach($fileNames as $f) { $f = substr($f, 4, strlen($f)-4); // we remove the extension we added in front of the filename for sorting if($files[$f]['name'] !='') $sortedFiles[$i++] = $files[$f]; }// ends the foreach where we build the final sorted array return $sortedFiles; } // folder navigation code $startdir = "./"; if(isset($_GET['dir'])) { $prev = $_GET['dir']; $folder = $_GET['dir']; echo "<a href=\"javascript:history.go(-1)\"><img src=\"$img_back\"></a> <a href=\"$host\"><img src=\"$img_home\"></a> <br/><br/>"; } else { $folder = $startdir; $prev='';} // end folder navigation code $files = getFiles($folder); foreach ($files as $file) { if(strip_ext($file[name])!='.php'){ $image = $img_file; if($file[type]=='dir') { $image = $img_folder; $cmd='?dir='.$prev.$file[name].'/'; }// if the element is a directory else $cmd=$prev.$file[name]; echo "<a href=\"$cmd\" title=\"$file[type], $file[sizetext]\"><img src=\"$image\" /> $file[name]</a> <br/>"; }//if strip_ext }//foreach
-
I have been playing with this. How could I tie this ftp connection: $ftp_server = 'myip'; $ftp_port = '21'; $conn = ftp_connect($ftp_server,$ftp_port); $ftpUser = "myuser"; $ftpPass = "mypass"; set_time_limit(160); $login = ftp_login($conn, $ftpUser, $ftpPass) or die("Login credentials were rejected"); $workingDir = ftp_pwd($conn); echo "Files for directory: $workingDir<br><br>"; $fList = @ftp_nlist($conn, $workingDir); if(is_array($fList)) { for($i = 0; $i < sizeof($fList); $i++) { echo $fList[$i] . "<br>"; } } else { echo "$workingDir contains no files."; } ftp_quit($conn); Into this cool script? $host = "./"; // the folder where index.php is located // path for folder, file, buttons(back and home) images $img_back="http://www.orosandrei.ro/images/back.gif"; $img_folder="http://www.orosandrei.ro/images/folder.gif"; $img_file="http://www.orosandrei.ro/images/file.gif"; $img_home="http://www.orosandrei.ro/images/home.gif"; // end of install variables // returns the extension of a file function strip_ext($name) { $ext = substr($name, strlen($ext)-4, 4); if(strpos($ext,'.') === false) // if we have a folder element { return " "; // we return a string of space characters for later sort, // so that the folder items remain on the first positions } return $ext; // if we have a file we return the extension - .gif, .jpg, etc. } // returns the files from the $path and returns them in an array function getFiles($path) { $files = array(); $fileNames = array(); $i = 0; // build if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if (($file == ".") || ($file == "..")) continue; $fullpath = $path . "/" . $file; //$fkey = strtolower($file); $fkey = $file; while (array_key_exists($fkey,$fileNames)) $fkey .= " "; $a = stat($fullpath); $files[$fkey]['size'] = $a['size']; if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-"; else if ($a['size'] > 1024 && $a['size'] <= 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K"; else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb"; else $files[$fkey]['sizetext'] = $a['size'] . " bytes"; $files[$fkey]['name'] = $file; $e = strip_ext($file); // $e is the extension - for example, .gif $files[$fkey]['type'] = filetype($fullpath); // file, dir, etc $k=$e.$file; // we use this string for sorting the array elements by extension and filename; $fileNames[$i++] = $k; } closedir($dh); } else die ("Cannot open directory: $path"); } else die ("Path is not a directory: $path"); sort($fileNames,SORT_STRING); // sorting $sortedFiles = array(); $i = 0; foreach($fileNames as $f) { $f = substr($f, 4, strlen($f)-4); // we remove the extension we added in front of the filename for sorting if($files[$f]['name'] !='') $sortedFiles[$i++] = $files[$f]; }// ends the foreach where we build the final sorted array return $sortedFiles; } // folder navigation code $startdir = "./"; if(isset($_GET['dir'])) { $prev = $_GET['dir']; $folder = $_GET['dir']; echo "<a href=\"javascript:history.go(-1)\"><img src=\"$img_back\"></a> <a href=\"$host\"><img src=\"$img_home\"></a> <br/><br/>"; } else { $folder = $startdir; $prev='';} // end folder navigation code $files = getFiles($folder); foreach ($files as $file) { if(strip_ext($file[name])!='.php'){ $image = $img_file; if($file[type]=='dir') { $image = $img_folder; $cmd='?dir='.$prev.$file[name].'/'; }// if the element is a directory else $cmd=$prev.$file[name]; echo "<a href=\"$cmd\" title=\"$file[type], $file[sizetext]\"><img src=\"$image\" /> $file[name]</a> <br/>"; }//if strip_ext }//foreach
-
I am not wanting to include a php script on a remote server. I am wanting run a php script on server A that will view files in a directory on server B. Using a command like opendir() , etc.
-
Are there any permissions I could change or anything I can do to make the code below access files on a remote server? Example: If I could some how make the line work with $startdir = "http://mysite.com/downloads/"; located on my remote server rather than having to use the local folder $startdir = "./"; which is on the local server. $host = "./"; // the folder where index.php is located // path for folder, file, buttons(back and home) images $img_back="http://www.orosandrei.ro/images/back.gif"; $img_folder="http://www.orosandrei.ro/images/folder.gif"; $img_file="http://www.orosandrei.ro/images/file.gif"; $img_home="http://www.orosandrei.ro/images/home.gif"; // end of install variables // returns the extension of a file function strip_ext($name) { $ext = substr($name, strlen($ext)-4, 4); if(strpos($ext,'.') === false) // if we have a folder element { return " "; // we return a string of space characters for later sort, // so that the folder items remain on the first positions } return $ext; // if we have a file we return the extension - .gif, .jpg, etc. } // returns the files from the $path and returns them in an array function getFiles($path) { $files = array(); $fileNames = array(); $i = 0; // build if (is_dir($path)) { if ($dh = opendir($path)) { while (($file = readdir($dh)) !== false) { if (($file == ".") || ($file == "..")) continue; $fullpath = $path . "/" . $file; //$fkey = strtolower($file); $fkey = $file; while (array_key_exists($fkey,$fileNames)) $fkey .= " "; $a = stat($fullpath); $files[$fkey]['size'] = $a['size']; if ($a['size'] == 0) $files[$fkey]['sizetext'] = "-"; else if ($a['size'] > 1024 && $a['size'] <= 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/1024*100)/100) . " K"; else if ($a['size'] > 1024*1024) $files[$fkey]['sizetext'] = (ceil($a['size']/(1024*1024)*100)/100) . " Mb"; else $files[$fkey]['sizetext'] = $a['size'] . " bytes"; $files[$fkey]['name'] = $file; $e = strip_ext($file); // $e is the extension - for example, .gif $files[$fkey]['type'] = filetype($fullpath); // file, dir, etc $k=$e.$file; // we use this string for sorting the array elements by extension and filename; $fileNames[$i++] = $k; } closedir($dh); } else die ("Cannot open directory: $path"); } else die ("Path is not a directory: $path"); sort($fileNames,SORT_STRING); // sorting $sortedFiles = array(); $i = 0; foreach($fileNames as $f) { $f = substr($f, 4, strlen($f)-4); // we remove the extension we added in front of the filename for sorting if($files[$f]['name'] !='') $sortedFiles[$i++] = $files[$f]; }// ends the foreach where we build the final sorted array return $sortedFiles; } // folder navigation code $startdir = "./"; if(isset($_GET['dir'])) { $prev = $_GET['dir']; $folder = $_GET['dir']; echo "<a href=\"javascript:history.go(-1)\"><img src=\"$img_back\"></a> <a href=\"$host\"><img src=\"$img_home\"></a> <br/><br/>"; } else { $folder = $startdir; $prev='';} // end folder navigation code $files = getFiles($folder); foreach ($files as $file) { if(strip_ext($file[name])!='.php'){ $image = $img_file; if($file[type]=='dir') { $image = $img_folder; $cmd='?dir='.$prev.$file[name].'/'; }// if the element is a directory else $cmd=$prev.$file[name]; echo "<a href=\"$cmd\" title=\"$file[type], $file[sizetext]\"><img src=\"$image\" /> $file[name]</a> <br/>"; }//if strip_ext }//foreach
-
By setup, do you mean permissions in iis?
-
Is it possible to list files in a directory across the web rather than on the local server. I am having trouble getting the code below to work. code: <?php /* ABOUT: This snippet will list all the files in the directory of your choice, truncate the file extension, capitalize the first letter and put it all in a drop down menu. The script will not list subdirectories so all you see are the files in your directory. Feel free to use or modify to your liking. USAGE: Change the $dirpath variable the directory you want to list. AUTHOR: Written by shockingbird Visit www.glomer.net for more information tate at tatenations dot com for any questions */ echo "<form>"; //Looks into the directory and returns the files, no subdirectories echo "<select name='yourfiles'>"; //The path to the style directory $dirpath = "http://mysite.com/downloads/"; $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { //Don't list subdirectories if (!is_dir("$dirpath/$file")) { //Truncate the file extension and capitalize the first letter echo "<option value='$file'>" . htmlspecialchars(ucfirst(preg_replace('/\..*$/', '', $file))) . '</option>'; } } closedir($dh); //Close Select echo "</select>"; echo "</form>"; ?> error: PHP Warning: opendir(http://mysite.com/downloads/) [function.opendir]: failed to open dir: not implemented in C:\Inetpub\Websites\mysite.com\scan.php on line 25 PHP Warning: readdir(): supplied argument is not a valid Directory resource in C:\Inetpub\Websites\mysite.com\scan.php on line 26 PHP Warning: closedir(): supplied argument is not a valid Directory resource in C:\Inetpub\Websites\mysite.com\scan.php on line 33
-
thank you....
-
How do I read a list of files in a directory with php? example if I want to see all the excel, pdfs, etc in http://testsite.com/downloads/ I am creating a backend for a dealer downloads page. I want to be able to select the file and store the url to it in a database. Then, display the download files on our downloads page. Thanks, Jake
-
I only need the session on the homepage. Which is the only page accessible by google.
-
PHP Version 5.2.2 Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 Off Off session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 1000 1000 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.hash_bits_per_character 5 5 session.hash_function 0 0 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path no value no value session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid 1 1 Would it be ok if I use the following below before SESSION_START(); ? ini_set('session.use_trans_sid', false); ini_set("url_rewriter.tags",""); Is this going to hurt me in any way?
-
I did some research. Someone suggested this: ini_set('session.use_trans_sid', false); won't help, but ini_set("url_rewriter.tags",""); does Would ini_set("url_rewriter.tags",""); be a good thing for me to use? And will it hurt me or my customers in any way?
-
It has to be common for people who have worked with e commerce sites. How do they display the cart quantities and cart items without having session id's in their links?
-
I am trying to display different content for the user on the homepage if they are logged in. After they logged in I set $_SESSION['valid_user'] , $_SESSION['zip'], etc. On the homepage I have session_start(); at the top and I have sections on the page that checked to see if you are logged in.... if you are, then it displays info based on you account. My problem is that I do not want session_id's appended onto all of my links. How can I do what I need to do on the homepage and not have session id's in my links? Thanks, Jake
-
i tried this if statement and still could not make it happen. $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' limit 8", $db); while ($myrow = mysql_fetch_array($result)) { $MeetingId = $myrow["MeetingId"]; $Type = $myrow["Type"]; $Username = $myrow["Username"]; $Club = $myrow["Club"]; $Topic = $myrow["Topic"]; $Starttime = $myrow["Starttime"]; $Endtime = $myrow["Endtime"]; $Starttime= date('Y-m-d H:i', $Starttime); $if1=date('Y-m-d', $Starttime); $if2=date('Y-m-d'); if ($if1==$if2) { echo "<small><b>$Starttime</b></small> - $Type<br /><b>$Club</b><br /><a href=\"test7.php?meeting=$MeetingId\"><small>$Topic</small></a><br /><small>$Username</small><br /><br />"; } else { //echo "There are not yet any meetings scheduled for today."; } }
-
I tried this I still had no action. $datet=date(); $time=time(); $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' AND FROM_UNIXTIME(Starttime) = '$datet' limit 8", $db);
-
this one works fine for pulling all of the meetings that have not yet ended $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' ORDER BY MeetingId desc limit 10", $db); but I need to pull only todays meetings and on another page pull only the meetings for the month Starttime is a unix timestamp of the meeting starting time and Endtime is the unix timestamp of the Meeting end time.
-
I am having trouble. $datet=date(); $time=time(); $db = mysql_connect("#", "#", "#"); mysql_select_db("#", $db); $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' AND `Starttime` = '$datet' ORDER BY 'Starttime' desc limit 8", $db);
-
this what it is like when it is inserted $Month=$_POST["Month"]; $Day=$_POST["Day"]; $Hour=$_POST["Hour"]; $Club=$_POST["Club"]; $Topic=$_POST["Topic"]; $Type=$_POST["Type"]; $Year=$_POST["Year"]; $Starttime = mktime($Hour, 0, 0, $Month, $Day, $Year);
-
I have a table full of events. Each event has a timestamp date on the same row. I am wanting to pull only the events that are scheduled for today and sort them. I also want on another page to pull all of the events for the month and sort them.
-
How could I set it up to where these little profile images will go across the page and wrap to the next line. I tried putting them into table, but they stacked on top of each other. I want them side by side.
-
I was thinking that I might could start the session, create a variable out of the session I need, reset the session, and then end it before the rest of the page loads.
-
Is there any way I could use the session just for that section of code then kill it?