Jump to content

weee

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

weee's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello Everyone, I am having issues where people are submitting null characters on my website (I.e. %00). Currently, I check if their is a value by using the empty function, and I also am checking if the value after running the trim command is =="". How can I check for these special characters to make sure that whatever they are submitting actually contains some sort of legitimate value? Thanks!
  2. Hello Everyone, I seem to have stumbled upon something that looks like it is next to impossible in PHP; zipping files/folders on demand in php So, after doing some extensive google searching, I have found various functions; some work only zipping files, other have no comments, some just don't work at all, etc. After looking at multiple projects, I have finally compiled something that works and has some sort of comments on what the heck is going on. <?php class zipfile { /** * Array to store compressed data * * @var array $datasec */ var $datasec = array(); /** * Central directory * * @var array $ctrl_dir */ var $ctrl_dir = array(); /** * End of central directory record * * @var string $eof_ctrl_dir */ var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; /** * Last offset position * * @var integer $old_offset */ var $old_offset = 0; /** * Add a directory * * @var string $name */ function add_dir($name) { $name = str_replace("", "/", $name); $fr = "\x50\x4b\x03\x04"; $fr .= "\x0a\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00"; $fr .= "\x00\x00\x00\x00"; $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("V",0); $fr .= pack("v", strlen($name) ); $fr .= pack("v", 0 ); $fr .= $name; $fr .= pack("V", 0); $fr .= pack("V", 0); $fr .= pack("V", 0); $this -> datasec[] = $fr; $new_offset = strlen(implode("", $this->datasec)); $cdrec = "\x50\x4b\x01\x02"; $cdrec .="\x00\x00"; $cdrec .="\x0a\x00"; $cdrec .="\x00\x00"; $cdrec .="\x00\x00"; $cdrec .="\x00\x00\x00\x00"; $cdrec .= pack("V",0); $cdrec .= pack("V",0); $cdrec .= pack("V",0); $cdrec .= pack("v", strlen($name) ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("V", 16 ); $cdrec .= pack("V", $this -> old_offset ); $cdrec .= $name; $this -> ctrl_dir[] = $cdrec; $this -> old_offset = $new_offset; } /** * Converts an Unix timestamp to a four byte DOS date and time format (date * in high two bytes, time in low two bytes allowing magnitude comparison). * * @param integer the current Unix timestamp * * @return integer the current date in a four byte DOS format * * @access private */ function unix2DosTime($unixtime = 0) { $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); if ($timearray['year'] < 1980) { $timearray['year'] = 1980; $timearray['mon'] = 1; $timearray['mday'] = 1; $timearray['hours'] = 0; $timearray['minutes'] = 0; $timearray['seconds'] = 0; } // end if return (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); } // end of the 'unix2DosTime()' method /** * Adds "file" to archive * * @param string file contents * @param string name of the file in the archive (may contains the path) * * @access public */ function add_file($data, $name) { // Read the file $fp = fopen($data,"r"); $data = fread($fp,filesize($data)); fclose($fp); // Clean the file name $name = str_replace("", "/", $name); $dtime = dechex($this->unix2DosTime(0)); $hexdtime = '\x' . $dtime[6] . $dtime[7] . '\x' . $dtime[4] . $dtime[5] . '\x' . $dtime[2] . $dtime[3] . '\x' . $dtime[0] . $dtime[1]; eval('$hexdtime = "' . $hexdtime . '";'); $fr = "\x50\x4b\x03\x04"; $fr .= "\x14\x00"; // ver needed to extract $fr .= "\x00\x00"; // gen purpose bit flag $fr .= "\x08\x00"; // compression method $fr .= $hexdtime; // last mod time and date // "local file header" segment $unc_len = strlen($data); $crc = crc32($data); $zdata = gzcompress($data); $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug $c_len = strlen($zdata); $fr .= pack('V', $crc); // crc32 $fr .= pack('V', $c_len); // compressed filesize $fr .= pack('V', $unc_len); // uncompressed filesize $fr .= pack('v', strlen($name)); // length of filename $fr .= pack('v', 0); // extra field length $fr .= $name; // "file data" segment $fr .= $zdata; // add this entry to array $this -> datasec[] = $fr; // now add to central directory record $new_offset = strlen(implode("", $this->datasec)); $cdrec = "\x50\x4b\x01\x02"; $cdrec .="\x00\x00"; $cdrec .="\x14\x00"; $cdrec .="\x00\x00"; $cdrec .="\x08\x00"; $cdrec .="\x00\x00\x00\x00"; $cdrec .= pack("V",$crc); $cdrec .= pack("V",$c_len); $cdrec .= pack("V",$unc_len); $cdrec .= pack("v", strlen($name) ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("v", 0 ); $cdrec .= pack("V", 32 ); $cdrec .= pack("V", $this -> old_offset ); $this -> old_offset = $new_offset; $cdrec .= $name; $this -> ctrl_dir[] = $cdrec; } /** * Dumps out file * * @return string the zipped file * * @access public */ function file() { $data = implode('', $this -> datasec); $ctrldir = implode('', $this -> ctrl_dir); return $data . $ctrldir . $this -> eof_ctrl_dir . pack('v', sizeof($this -> ctrl_dir)) . // total # of entries "on this disk" pack('v', sizeof($this -> ctrl_dir)) . // total # of entries overall pack('V', strlen($ctrldir)) . // size of central dir pack('V', strlen($data)) . // offset to start of central dir "\x00\x00"; // .zip file comment length } } // Test this class $zipTest = new zipfile(); $zipTest->add_dir("images/"); $zipTest->add_file("images/test.jpg", "test.jpg"); $zipTest->add_file("images/test2.jpg", "images/test2.jpg"); // Return Zip File to Browser Header("Content-type: application/octet-stream"); Header ("Content-disposition: attachment; filename=zipTest.zip"); echo $zipTest->file(); ?> On windows and linux, this class works flawlessly. On a Mac, this works with the stuffit program, but the default archive program does not like the zips if it contains a directory. If you comment out $zipTest->add_dir("images/");, the archive will work great on a Mac as well. Could someone help me get this class to create a working directory on a Mac as well? I am at a point where I would be willing to pay for your time if you can help me get this working (via paypal of course). Thanks in advance! weeee
  3. Please bump? Does anyone know if this is even possible? Thanks! weee
  4. May I bump?
  5. RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteRule ^contact/?$ index.php?act=contact [L] I have a few of these where they map to some static pages. So this would be the equivalent http://www.mywebsite.com/contact to http://www.mywebsite.com/index.php?action=contact. Thanks! weee
  6. Is it possible to use "seo urls" under https? It seems like all of my links that use mod_rewrite under SSL no longer work... Thanks! weee
  7. Basically I am trying to join a table that has all of the results (my left table) with a table that may have results or may not (my right table). So I want every row to be returned on my left table regardless if the right table does not have a sufficient row to join (Ie. return back null for not finding anything).
  8. My scenario is that I have a value=NULL and that is resulting in 0 rows on my join, rather than replying back as onn on my second table.
  9. NULL!==NULL???? How not? Even if I can get my join to return 0 I would be fine, but right now it is dropping the entire row rather than return something back which is the problem. This keeps the row in tact regardless if table2 has the value or not.
  10. Hello everyone, I am trying to rotate an image, but when I run my script I get: Fatal error: Call to undefined function imagerotate() in test.php on line 15 When I run phpinfo(), it shows GD support is enabled. Anyone have any ideas on how to get this to work? Thanks! weee
  11. Right now the only way I can get my queries to return NULL values is if I do something like this: SELECT table1.*, (SELECT otherValue2 FROM table2 WHERE ID=table1.ID) as otherValue2 FROM table1 WHERE table1.anotherID=2
  12. Hello everyone, I am trying to force mySQL to return null values rather than no rows on my join. So here is my scenario Table 1 ID | NAME | VALUE | AnotherID 1 | blah | 25 | 2 2 | z | 36 | 2 3 | a | 1 | 3 4 | b | 2 | 2 Table 2 ID2 | ID | otherValue | OtherValue2 1 | 2 | b | 4 Here would be my sql code SELECT table1.*, table2.otherValue, table2.otherValue2 FROM table1 LEFT JOIN table2 ON table2.ID=table1.ID WHERE table1.anotherID=2 Now I would like my result to look like the result below but instead I get 0 rows. ID | NAME | VALUE | AnotherID | otherValue | otherValue2 1 | blah | 25 | 2 | NULL | NULL 2 | z | 36 | 2 | b |4 4 | b | 2 | 2 | NULL | NULL How can I do this? Thank you! weee
  13. The only sensitive information on my site is the user login lol How do sites like youtube and yahoo keep users logged in securely without https than?
  14. Hello, I am trying to implement a remember me feature on my site, but am having problems doing so securely. I would like the cookies that remember your info to be sent securely over ssl, but the problem is all of my pages are http. I do not want to force everyone to be https because it is not needed. Is there a way to tell php to check for the cookies via ssl even though the page request was http? Thank you! weee
  15. public function login($username, $password) changed to: static public function login($username, $password) would make it static.
×
×
  • 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.