Jump to content

Maverickb7

Members
  • Posts

    112
  • Joined

  • Last visited

    Never

Everything posted by Maverickb7

  1. How would I go about doing that? I did a quick google search and haven't been able to find any examples that would push me in the right direction.
  2. I was wondering if someone could tell me the easiest way to obtaining the page title of a specific url? I've tried to use fopen and those functions but I got the below error.
  3. ok, one more question. =( does glob() have to use a path or can it use a URL as well?
  4. Yes, that helped me monk.e.boy. Thanks. For some reason I tried that before and it didn't want to work for me but this time around it worked so thanks.
  5. I'm not saying anything about your code. I didn't want something re-written for me. I was trying to find a way to modify the code I had created above to do what I was asking. I just need away to tell that code to look in X directory using a variable. I'm sure its only like 2 seconds of work for someone who knows what they are doing. I'm still new to all of this so any help would be appreciated.
  6. I just need some way to tell the code what directory to look in using a variable. Could you help me?
  7. Thanks, I'll take a look at your code. But do you know of anyway I could edit the code I created to do this? I just need some way to tell the code what directory to look in using a variable. Could you help me?
  8. isn't glob and opendir two different methods? how would I include $path into the code i've already made?
  9. hello--i'm trying to create a script that will read files from various directories on my site. I've come up with some code that does what I want but I can't figure out how to specific a directory through a variable. foreach (glob("*.txt") as $filename) { $filesize = filesize($filename); $filesize = humansize($filesize); echo $filename." - ".$filesize; } I've toned it down a bit so its easier to read. But basically at the moment the script only reads the directory its being run from. I want the directory path stored in a variable and included somehow... anyone know?
  10. Any help would be appreciated. I was working on this a couple of months ago but its been pretty busy in my life so I've lost track of things. Maybe someone could help me out?
  11. here is the entire code. if anyone could help me that would be create. i've been trying to get this to work for the last couple of weeks with no luck. <html> <head> <title>The Spot</title> <link rel="stylesheet" type="text/css" href="../spot/css.php?theme=2"> </head> <body> <? // End of config area error_reporting (0); function pathurlencode($uri) { $uri = urlencode($uri); $uri = str_replace('%3A', ':', $uri); $uri = str_replace('%2F', '/', $uri); $uri = str_replace('%26', '&', $uri); $uri = str_replace('%40', '@', $uri); $uri = str_replace('%3A', ':', $uri); $uri = str_replace('%3F', '?', $uri); $uri = str_replace('%3D', '=', $uri); $uri = str_replace('%5B', '[', $uri); $uri = str_replace('%5D', ']', $uri); return $uri; } // From php.net function getfilesize($bytes) { if ($bytes >= 1099511627776) { $return = round($bytes / 1024 / 1024 / 1024 / 1024, 2); $suffix = "TB"; } elseif ($bytes >= 1073741824) { $return = round($bytes / 1024 / 1024 / 1024, 2); $suffix = "GB"; } elseif ($bytes >= 1048576) { $return = round($bytes / 1024 / 1024, 2); $suffix = "MB"; } elseif ($bytes >= 1024) { $return = round($bytes / 1024, 2); $suffix = "KB"; } else { $return = $bytes; $suffix = "Byte"; } if ($return == 1) { $return .= " " . $suffix; } else { $return .= " " . $suffix; } return $return; } function Parse($filename) { require_once("BDecode.php") ; require_once("BEncode.php") ; global $seedsandpeers; $torrent = explode(".", $filename); $fileend = end($torrent); $fileend = strtolower($fileend); if ( $fileend == "rar" ) { $stream = @file_get_contents("./files/$filename"); if ($stream == FALSE) { echo "$filename cannot be opened" ; } if(!isset($stream)){ echo "Error in Opening file." ; }else{ $array = BDecode($stream); if ($array === FALSE){ echo "Error in file. Not valid BEncoded Data." ; }else{ if(array_key_exists("info", $array) === FALSE){ echo "Error in file. Not a valid files file." ; }else{ echo "<tr><td><span class=\"smalltext\">".$filename."</span></td>" ; $infovariable = $array["info"]; if (isset($infovariable["files"])) { foreach ($infovariable["files"] as $file) { $multitorrentsize = $file['length']; $filessize += $file['length']; } echo "<td align=\"right\"><span class=\"smalltext\">"; echo getfilesize($filessize); echo "</span></td></tr>"; } else { // Calculates File size in KB and rounds to 2 decimal places echo "<td align=\"right\"><span class=\"smalltext\">"; $filessize = $infovariable['length']; echo getfilesize($filessize); echo "</span></td></tr>"; } } } } } } echo "<center><table cellspacing=\"0\" cellpadding=\"2\" border=\"1\" width=\"500\">"; echo "<tr><td><span class=\"smalltext\"><b>Title:</b></span></fd><td align=\"center\"><span class=\"smalltext\"><b>Size</b></span></td></tr>"; $dirpath = "./files"; $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { if (!is_dir("$dirpath/$file")) { $fileend = substr($file, -3); $fileend = strtolower($fileend); if ( $fileend == ".rar" ) { if (isset($file)) { Parse($file); } else { echo "No file name has been specified. Please Specify One."; } } } } closedir($dh); echo "</table></center>"; ?> </body> </html>
  12. Hello-- I'm trying to code a simple script that will allow me to list all files within a directory in order by letter. I'm using the below code and was wondering if anyone knew how I could modify it to do this? Thanks in advance!! $dirpath = "./files"; $dh = opendir($dirpath); while (false !== ($file = readdir($dh))) { if (!is_dir("$dirpath/$file")) { $fileend = substr($file, -; $fileend = strtolower($fileend); if ( $fileend == ".rar" ) { if (isset($file)) { Parse($file); } else { echo "No file name has been specified. Please Specify One."; } } } } closedir($dh); does anyone know what I would have to add to have this done?
  13. yes. I'm trying to display image files.
  14. hello, I was wondering if someone could put me in the direction of some code that would take all files within a certain directory and put it into an array. Does anyone know where I can find this.. I'm trying to find some good examples.
  15. ok i'm useless.. can someone give me an example of how to do this.. i still can't figure it out by reading those pages.
  16. how would I use that to skip the first two items in an array? I tried to look it up on the net through google but it didn't really bring up any results that explained what I wanted.
  17. How can I skip the first two items in an array. I'm trying to display a bunch of images within a directory by grabbing all the file names with php. Before the image files it shows . and .. so i'm wondering how I can remove them.
  18. Alright I did a little messing around and I seemed to get things working after using the switch function. :)
  19. Still doesn't seem to work for me. After I hit fresh it just reloads the main and no changes were made. :S
  20. I tried putting this into play but it doesn't seem to work. The code I'm using is below. I have one other file included that is not shown.. it has the database information. [code]<?php include("/home/templates/global_header.php"); $site_name = $_POST['site_name']; $site_url = $_POST['site_url']; if (isset($_POST['submit'])) { $connect = mysql_connect($DBhost, $DBuser, $DBpass); mysql_select_db($DBname,$connect) or die ("Could not select database"); mysql_query($connect); $q = "SELECT * FROM settings"; $r = mysql_query($q); $row = mysql_fetch_array($r); $site_name = $row['site_name']; $site_url = $row['site_url']; $query = "UPDATE site_settings SET site_url = '$site_url', site_name = '$site_name'"; mysql_query($query); echo "<center><h2>Thank you,<br>Your settings have been updated.</h2></center>"; echo "<meta http-equiv=Refresh content=2;url=settings.php>"; } else { $connect = mysql_connect($DBhost, $DBuser, $DBpass); mysql_select_db($DBname,$connect) or die ("Could not select database"); mysql_query($connect); $q = "SELECT * FROM site_settings"; $r = mysql_query($q); $row = mysql_fetch_array($r); $site_name = $row['site_name']; $site_url = $row['site_url']; echo "<form action = '{$_SERVER['PHP_SELF']}' method = 'post'>"; ?> <span class="largetext">Modify Settings</span><br> <span class="smalltext">Customize the settings below to your liking.</span><br> <br> <table cellspacing="0" cellpadding="2" width="100%" align="center"> <tr><td><span class="smalltext"><b>Site Name:</b></span></td><td><input class="textfield" type="text" size="52" name="site_name" value="<? echo $site_name; ?>"></td></tr> <tr><td><span class="smalltext"><b>Site URL:</b></span></td><td><input class="textfield" type="text" size="52" name="site_url" value="<? echo $site_url; ?>"></td></tr> <tr><td colspan="2" align="center"><input type='hidden' name='zv_settings' value='Website_Settings' /><input class="submit" type="Submit" value="submit"></td></tr> </table></form> <?php } include("/home/templates/global_footer.php"); ?>[/code]
  21. Hello, I'm creating a CMS and I'm trying to refresh my memory as I haven't coded php for a while. Anyways, I've created a settings page that holds form that pulls settings from my database and allows me to edit them. Now when I click submit i want it to update the database with the updated information. I know how to do this using two pages, but how would i go about doing this within the same page?
×
×
  • 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.