Jump to content

DaveLinger

Members
  • Posts

    268
  • Joined

  • Last visited

    Never

Everything posted by DaveLinger

  1. Basically the php code finds subfolders in a "screenshots" directory of a game's directory, then lists each subdir it finds. Currently they're not sorted in terms of what order they're being printed. $dirpath = "games/{$gameid}/screens/"; $dir = opendir($dirpath); while (($filename = readdir($dir)) !== false){ if($filename != "" && $filename != "." && $filename != ".."){ if(strpos($filename, ".") === false){ echo "<div class=\"category\"><a href=\"game.php?id={$gameid}&page=screenshots&cat={$filename}\">{$filename}</a></div>"; } } }
  2. oops must of missed that this are the words I've found.. idealization idealizations linearization illegalization indefatigation liberalisation liberalization mineralization interlamination internalization liberalizations InterApplication deliberalization demineralization interapplication semihepatization sentimentalization trade-liberalization the dictionary was taken from here : ftp://ftp.ox.ac.uk/pub/wordlists/american/ this is the code I used.. in case anyone cares.. #!C:\strawberry\perl\bin #i read the dir , because it contained more than one file opendir DIR,"dex"; while ($line =readdir(DIR)){ if ($line ne /.+/){ push @array,$line; #I remember all file names in @array } } #i remove first two values of the array which are "." and ".." shift(@array); shift(@array); open TOTAL ,">dex.txt"; #checking everyfile.. foreach $val (@array){ open F,"<","dex/".$val; while ($line=<F>){ if ($line =~ /[bcdfghjklmnpqrstxyz]*i[bcdfghjklmnpqrstxyz]*e[bcdfghjklmnpqrstxyz]*a[bcdfghjklmnpqrstxyz]*i[bcdfghjklmnpqrstxyz]*a[bcdfghjklmnpqrstxyz]*i[bcdfghjklmnpqrstxyz]*o[bcdfghjklmnpqrstxyz]*/i){ print TOTAL $line,"\n"; } } close F; } awesome! Thanks! However: deliberalization demineralization semihepatization sentimentalization trade-liberalization Do not qualify
  3. I have no experience with perl, but from what I can see, there's nothing in the script preventing extra vowels from being present. Is that true or am I reading it wrong?
  4. So I was having a discussion with a friend of mine about a song called I-E-A-I-A-I-O. I read somewhere that one proposed meaning of the title is that it represents the vowels in the word I-D-E-A-L-I-Z-A-T-I-O-N. He said that it doesn't matter cause probably lots of words meet the criteria. I, however, think that VERY few words meet the criteria of having this specific 7-character vowel combination IN ORDER with no extra vowels at all. So... I want to know now! Haha. So first, does anyone know of any database or xls or text file that I can try this with? The less abridged the better. Second, how would I go about it? There can be any number of characters between the vowels, but none of those characters can be vowels - and they have to be in order, and there can't be any extra vowels.
  5. Whoops, nevermind, I found the error. It was looking for directories again, instead of files. (was looking for files without a "." in their name)
  6. Ah, indeed. Good call. That fixed that. But apparently it's also not listing the files in each category, as if the folder is empty. My new code: echo "<div class=\"box\"> <div class=\"box1\"><h2>Map Categories</h2></div> <div class=\"box2\">"; $dirpath = "games/{$gameid}/maps/"; $dir = opendir($dirpath); while (($filename = readdir($dir)) !== false){ if($filename != "" && $filename != "." && $filename != ".."){ if(strpos($filename, ".") === false){ echo "<a href=\"#{$filename}\">{$filename}</a> "; } } } echo "</div></div><br />"; $dirpath = "games/{$gameid}/maps/"; $dir = opendir($dirpath); while (($filename = readdir($dir)) !== false){ if($filename != "" && $filename != "." && $filename != ".."){ if(strpos($filename, ".") === false){ echo "<div class=\"box\"> <div class=\"box1\"><h2>{$filename}</h2><a name=\"{$filename}\"></a></div> <div class=\"box2\"> <ul>"; $dirpath1 = "games/{$gameid}/maps/{$filename}/"; $dir1 = opendir($dirpath1); while (($filename1 = readdir($dir1)) !== false){ if($filename1 != "" && $filename1 != "." && $filename1 != ".."){ if(strpos($filename1, ".") === false){ echo "<li><a href=\"{$filename1}\">{$filename1}</a></li>"; } } } echo "</ul> </div></div><br />"; } } }
  7. So what I'm trying to do is scan a directory "maps" for subdirectories (which will be used as categories). At the top of the page, I want to list the "categories", with anchor links/bookmark links (#these) to the part of the page (below) that lists that category's contents. I've got it all working EXCEPT that it only lists the contents of the FIRST category, then stops. echo "<div class=\"box\"> <div class=\"box1\"><h2>Map Categories</h2></div> <div class=\"box2\">"; $dirpath = "games/{$gameid}/maps/"; $dir = opendir($dirpath); while (($filename = readdir($dir)) !== false){ if($filename != "" && $filename != "." && $filename != ".."){ if(strpos($filename, ".") === false){ echo "<a href=\"#{$filename}\">{$filename}</a> "; } } } echo "</div></div><br />"; $dirpath = "games/{$gameid}/maps/"; $dir = opendir($dirpath); while (($filename = readdir($dir)) !== false){ if($filename != "" && $filename != "." && $filename != ".."){ if(strpos($filename, ".") === false){ echo "<div class=\"box\"> <div class=\"box1\"><h2>{$filename}</h2><a name=\"{$filename}\"></a></div> <div class=\"box2\"> <ul>"; $dirpath = "games/{$gameid}/maps/{$filename}/"; $dir = opendir($dirpath); while (($filename1 = readdir($dir)) !== false){ if($filename1 != "" && $filename1 != "." && $filename1 != ".."){ if(strpos($filename1, ".") === false){ echo "<li><a href=\"{$filename1}\">{$filename1}</a></li>"; } } } echo "</ul> </div></div>"; } } } Example output: <div class="box1"><h2>Map Categories</h2></div> <div class="box2"><a href="#World 8">World 8</a> <a href="#World 2">World 2</a> <a href="#Miscellaneous">Miscellaneous</a> <a href="#World 1">World 1</a> </div></div><br /><div class="box"> <div class="box1"><h2>World 8</h2><a name="World 8"></a></div> <div class="box2"> <ul></ul> </div></div>
  8. So basically on this website I'm building, I have a bunch of mp3 files that I want people to be able to listen to using a flash mp3 player on the site, and I want them to be able to (I suppose) save the files to their hard drives, but NOT be able to link directly to the mp3 from other websites. So here's my code: <?php $gid = $_GET['g']; //game ID number. Each game has its own music directory. $file = $_GET['f']; //filename minus the .mp3 $yoursite = "www.xxx.com"; $yoursite2 = "xxx.com"; $referer = $_SERVER['HTTP_REFERER']; if ($referer == "") { $domain = $yoursite; } else { $domain = parse_url($referer); } if($domain['host'] == $yoursite || $domain['host'] == $yoursite2) { $location = "/games/".$gid."/music/".$file.".mp3"; header("Location: $location"); } else { header("Location: http://www.xxx.com"); } ?> But the problem with this is that, assuming they ARE on the site, it just gives them the direct URL to the file. How can I set it so that rather than essentially redirecting to the mp3 file, the php file actually outputs the contents of the mp3 file? For example they could save the php file to their hard drive and rename it to mp3 and it would play. I think I've seen this done before.
  9. I'm getting this error: PHP Fatal error: Call to undefined function mime_content_type()
  10. Thanks for your help, fanfavorite. Correct me if I'm wrong, but this code does not read or use the actual filename extension at all, right? It actually uses the mimetype - and wouldn't that mean that it would echo, for example, "audio/mpeg3" instead of "mp3"?
  11. How can I list all of the, say, mp3 and wav files in a directory and display some of their stats? I'd like something like this as a result: /// 3 items found "A song about soccer" - 1.85MB mp3 "Basketball is cool" - 2.10MB wav "Cool song" - 1.11MB mp3 /// I understand that the filesize will probably be in bytes, but that's not a big deal and isn't really important right now. I'd also like to know if it's possible to read any metadata from the files, like creation date, modified date, etc.
  12. My final code (for others' reference): $totalrows = mysql_num_rows($result); if($totalrows >0){ for($i = 1;$row = mysql_fetch_row($result);$i++){ echo "<td><a href=\"game.php?id={$row[0]}\"><img src=\"images/games/thumbs/{$row[0]}_t.png\" alt=\"{$row[2]}\"><br />{$row[2]}</a></td>"; if($i%3 == 0 && $i != $totalrows){echo "</tr><tr>";} if($i == $totalrows && $i%3 != 0){ $i1 = $i+1; if($i1%3 == 0){echo "<td> </td>";} $i2 = $i+2; if($i2%3 == 0){echo "<td> </td><td> </td>";} } } }else{ echo "<p>No results found!</p>"; } As you can see I made it add enough blank cells after the last row to even out the table.
  13. How would I make it so that if it's the last result, it does NOT do this? I can close the tr and the table outside of the loop, but it's no good if it opens a new tr that I'll just have to immediately close at the end.
  14. So basically I'm writing a quick-and-dirty script to read all of the items from a database, and display them in a table. I think the easiest way to accomplish this is to display each result, then check if the result number plus one divided by 3 is a whole number (for a 3 column table), and if it is, echo </tr><tr>. So here's what I'm thinking (looping per result of course). I'm adding one to the result number so that 0 becomes 1, and so on. echo "<td>this is some database info</td>"; $newresultnumber = $resultnumber+1; if($newresultnumber ??? is a whole number ???){echo "</tr><tr>";} ^^loop So what can I do to make this work?
  15. The only way you can guarantee expert replies is if you only ask php experts, but you've asked a public forum.
  16. Well the square brackets were there in the Google example code, so I assumed that it was correct. Anyway, it works great now. You're the man! You're officially now on my Christmas card list.
  17. well since GET is taken from the url, someone, for example, could make the url file.php?from_mail=null)fopen(C:/windows/php.ini); or other malicious code.
  18. Thanks a ton for your help, and your code DOES seem to work, but it's not what I need - I don't want to echo every column's value, the result literally must be exactly this format for Google Maps to take it: {name: '$owner', id: '$id', location: '$location', year: '$year', model: '$model', texid: '$texid', texusername: '$texusername', lat: '$lat', lng: '$lon'}, take a look at the result of your code: http://registry.davelinger.com/ (in the head) it appears to be adding in extra data and echoing stuff twice ??? With your code, it was also echoing the person's md5'd password, as well as their email and such, which obviously should not be echoed.
  19. Please excuse my lack of php skills, but I'm not familiar with either rtrim or implode, would you mind integrating one of you solutions into my code? Sorry =/
  20. Shouldn't this work? $query="SELECT * FROM registry WHERE lat <> '' ORDER BY id ASC"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $owner = $row["owner"]; $year = $row["year"]; $texusername = $row["texusername"]; $texid = $row["texid"]; $location = $row["location"]; $lat = $row["lat"]; $lon = $row["lon"]; if ($row < $count-1) { echo "{name: '$owner', id: '$id', location: '$location', year: '$year', model: '$model', texid: '$texid', texusername: '$texusername', lat: '$lat', lng: '$lon'},"; } if ($row == $count-1){ echo "{name: '$owner', id: '$id', location: '$location', year: '$year', model: '$model', texid: '$texid', texusername: '$texusername', lat: '$lat', lng: '$lon'}"; } } if I echo $count, I get 3, which is right - because the first row is #0, I subtract one from the count to match it up. However it still echoes nothing. Here's my complete code: <?php if (!$link = mysql_connect(x, x, x)) { echo 'Could not connect to mysql'; exit; } if (!mysql_select_db(x, $link)) { echo 'Could not select database'; exit; } $query="SELECT * FROM registry WHERE lat <> '' ORDER BY id ASC"; $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); $count = mysql_num_rows($result); while ($row = mysql_fetch_array($result)) { $id = $row["id"]; $owner = $row["owner"]; $year = $row["year"]; $texusername = $row["texusername"]; $texid = $row["texid"]; $location = $row["location"]; $lat = $row["lat"]; $lon = $row["lon"]; if ($row < $count-1) { echo "{name: '$owner', id: '$id', location: '$location', year: '$year', model: '$model', texid: '$texid', texusername: '$texusername', lat: '$lat', lng: '$lon'},"; } if ($row == $count-1){ echo "{name: '$owner', id: '$id', location: '$location', year: '$year', model: '$model', texid: '$texid', texusername: '$texusername', lat: '$lat', lng: '$lon'}"; } } ?>
  21. $query = "INSERT INTO videos (embed_html, description, date) VALUES ('$embedHTML', '$description', NOW())";
  22. Again, that won't work because it retrieves all of the rows (34 rows total), but I only want to echo the rows which have LAT set, which, in this case, is 3. echoes nothing =/
×
×
  • 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.