Jump to content

guyfromfl

Members
  • Posts

    286
  • Joined

  • Last visited

    Never

Everything posted by guyfromfl

  1. They say this can be from refrencing a null pointer, but i dont see how?
  2. I have a db class that contains several db functions. The biggie is $db->query($sql) function. EVERYTHING that goes to the database goes through this function, and I want to add some security... I have a another function in the db class, checkIp($ip) that checks to see if the ip is in the block list or not. Whenever I update the code (from the simple $result = mysql_query()... and return $result to have the if..else statement, I get a signal Segmentation fault... Any ideas? class dblib { function query($sql) { if ($this->checkIp($_SERVER['REMOTE_ADDR'])) { //die("GH"); // For testing... $result = mysql_query($sql) or die("Database error: " . mysql_error() . "<br /><br /><h2>SQL</h2><p>$sql</p>"); return $result; } else { die("<h1>Banned</h1>"); } } function checkIp($ip) { $sql = "SELECT * FROM block WHERE ip='$ip' LIMIT 1 "; $result = $this->query($sql); if (mysql_num_rows($result) == 0) return true; else return false; } }
  3. E, yea man I wish I could but the CSV's come from vendors and customers, so I'm kinda tied there. Thanks for the input!
  4. I am trying to protect my queries to check the user's ip address to make sure they are not banned... When I comment out the if statement in $db->query the error goes away... The checkIp function works in other instances, I am just trying to call it so nobody can inject things by trying to go around the actual pages... my db function class looks like this: class dblib { function query($sql) { if ($this->checkIp($_SERVER['REMOTE_ADDR']) == true) { die("GH".$ip); // Used to see if I can get that far... $result = mysql_query($sql) or die("Database error: " . mysql_error() . "<br /><br /><h2>SQL</h2><p>$sql</p>"); return $result; } else { die("<h1>Banned</h1>"); } } /// .......some other functions function checkIp($ip) { $sql = "SELECT * FROM block WHERE ip='$ip' LIMIT 1 "; $result = $this->query($sql); if (mysql_num_rows($result) == 0) return true; else return false; }
  5. A static size was set. I guess if the child text of the set size is larger than the container it will not show at all...
  6. I am trying to understand jQuery. I copied the code from http://jqueryui.com/demos/dialog/#modal-confirmation I can get the dialog to appear correctly, and the background gray out (the 2 jquery js files (jquery and jquery-ui) are in the corect order) but the actual test of the box does not appear. I get the orange title bar and buttons, but nothing in the actual message. Any ideas?
  7. Yea thats what I was affraid of... This is another one of those "trying to make it so computer idiots can use it type of thing" The script detects if it is a CSV or XLS file and works appropriately. My next option was to make the script "smarter" by validating the type of data and putting it in the correct element accordingly. Sounds like the only somewhat doable way to get around this problem. Thanks for the input.
  8. Man I hate it when I do that...I found the problem after I posted. I needed to join on another table to search for the descriptionOther info... Sorry guys.
  9. I have written the database software for my work that tracks return authorizations for warranty repair. The "framework" was originally set up so the user could select the product from a list of generic descriptions for the ra item. I later added a feature that integrates the customer's warranty registrations into his profile, and the user can select from a drop down box of products only linked to that customer. Now when I list all of the customer's repairs, the SOME of the ones that were entered with the registered products method do not show up. I know this is a huge question for you guys because its a pretty complex schema but here is the sql to list the customer's repairs. descriptionOther is what links the registration... Select repairs.ra.id, customers.dealerName, customers.lName, customers.fName, repairs.ra.openDate, repairs.ra.recDate, repairs.ra.shipDate, users.firstName As Owner, engines.Description, repairs.raitem.descriptionOther, engines.Brand From repairs.ra Left Join customers On repairs.ra.customer = customers.custId Left Join users On users.id = repairs.ra.openBy Left Join repairs.raitem On repairs.ra.id = repairs.raitem.raID Inner Join engines On repairs.raitem.description = engines.engineId Where repairs.ra.customer = 4473 Please ask for any clearification. I am leaving this job at the end of February and need to make sure this program is bullet proof. Thanks!
  10. I am having trouble parsing data that is separated by comas in an XLS file. The upload and parsing scripts work beautifully, but the problem I am having is the data is read in from one cell (all 5 fields for the row are in column A) I am exploding it by , but some of the cells contain comas. For example a cell might contain "jim,jones,12345678,jim@jones.com,More, Data,192.168.1.1" but the next one might be "Dave,Thomas,98765432,dave@wendys.com,something else, 255.255.255.0" The problem I am having is More, Data should be one cell. Not all position 4 will have a , so I can't just add it back because the IP address would be appended to more... Any ideas? I hope thats clear enough...
  11. oh ok, i was quickly skimming and over looked the dir handle anyway it looks good to me too. almost what I have. Try commenting out the echo with the list in it and just print $file. what comes out. Stupid check, how many files are in the /results/2011/Girls dir
  12. damn, thats sexy. I'm out of here in 10 minutes, so I'll build a class tomorrow and let you know how it goes. Thanks!
  13. You might need this /** * public function getExt($file) * * Returns a file's extention. * * @param string file to parse extention * @return string file's extention */ public function getExt($file) { return pathinfo($file, PATHINFO_EXTENSION); }
  14. It returns an array where you can just foreach through and print the li's in there
  15. Out of curiosity why do you have 2 handles?? I am working on a file system class for a project here at work, this will get all the files from the directory passed: public function loadFiles($directory, $wantedExts) { /** * @var array $fileList a list of files in the directory */ $fileList = array(); $extension = explode(",", $wantedExts); echo count($extension); print_r ($extension); /* * Check to see if the current file in the directory is of the correct type. * * This method excludes . and .. listings to make sure they are not recursive and * files contained wihtin the directory. * * If it is what we want, push it on the $fileList array. * * @TODO: * * Accept multiple file names, like "csv,xls" */ // Check to see if the directory is valid and accessible if ($handle = opendir($directory)) { // Read the files in the directory while (false !== ($file = readdir($handle))) { /* * Not a directory or other level of the tree */ /* if ($file != "." && $file != ".." && $this->checkExt($file, $extention)) { array_push($fileList, $file); } */ if ($file != "." && $file != "..") { /* if (!empty($extention) && $this->checkExt($file, $extension)) { */echo $this->getExt($file); if (isset($extension) && (count($extension) > 0) && in_array($this->getExt($file), $extension, FALSE)) { array_push($fileList, $file); } else { /* * Get all files */ array_push($fileList, $file); } } } } else { die ("<div class='error'>Invalid directory!</div>"); } unset($extension); return $fileList; }
  16. What if I exploded $$array_of_wanted_exts and searched the extensions in that list?
  17. I have a script that works perfectly, for one type of file extension. What I want to do now is be able to list all files in a set of file types. I want to pass the argument to the fileSystem class's loadFiles method like this: $some_var = $fileSystem->loadFiles(DATA_DIRECTORY, "csv,xls,etc"); Then in the loadFiles method it reads the dir for each file, then test its extension. If they are of the right type, then push it on the returned array. Now I am having problems testing if the file's extension is in the array. If I use if (strpos(getExt($file), $array_of_wanted_exts))... php would match php3.. Does anybody have a better method?
  18. Yea, it was staring me in the face... I was coming at it in a different way, thanks for pointing out the obvious for me!
  19. I am writing a script that can handle either csv or xls files. Once the data is parsed for either type it goes into an array $data and all the same operations are done on it. Right now, it is only set up to handle a csv file. This is the code I have right now: //Load the CSV files in the UPLOAD_PATH directory $fileList = $fs->loadFiles(UPLOAD_PATH, "csv"); // Loop through fileList array to processes each file foreach($fileList as $filename) { // Attempt to open the next file in the list and process it. if (($handle = fopen(UPLOAD_PATH.$filename, "r")) != FALSE) { // Create the input array while(($data = fgetcsv($handle, 0, ",")) != FALSE) { // ... do the magic How do I add another set of instructions to goto the parseXLS function that performs basically what fgetcsv does? I think in this case a try...catch statement would be too loose, and wouldnt be the best way. What I would LIKE to do is if (a csv file) { while(($data = fgetscv($handle, 0, ",")) != FALSE) { } else if (an xls file) { while ($data = parseXLS()) { } // Do the magic } // end of while I know this won't work but i need to do something along those lines. Any ideas?
  20. I don't think you have something configured correctly then. the phpinfo() function should spit out a couple tables with the server info in it.
  21. write this script: phpinf.php <?php phpinfo(); ?> what does it say?
  22. Scope *** oops sorry about that didn't mean to submit just that...here's the rest When you declare the variables at the top of the class you are preparing them to be used anywhere in the class. In the function declaration you are setting them as if they were local variables being passed for that function.
  23. Ha, thats awsome. Idk why I didn't see one mention of that function, and why I wasn't even thinking about it. Thanks!
  24. Are you trying to actually get the hash from youtube or are you trying to figure out the variable you are passing in your project? Like at youtube their code might look something like this: $video = $_GET['v']; echo $video; if you are trying to get the string after v= in the url you would need something like: strstr($url, 'v=')
×
×
  • 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.