Jump to content

tiki

Members
  • Posts

    45
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

tiki's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeah I was thinking of doing it that way. It works perfectly, except if you place code tags within the code tags, but theres nothing we can do about that. Thanks a lot for the help!
  2. Thats not the problem. For example: [ b]bold1[/ b] [ code][ b]bold2[/ b][/ code] I only want bold1 to turn bold, bold2 would not be converted at all since its within the code tags.
  3. Anyone know if this is even possible?
  4. I havent even begun how to do this part, since im completely lost. Im really good at regex, just never done something like this. Im assuming it will be a preg_match_all. But heres a snippet of the code, that this needs to be applied to: private $markup = array( '/\[b\](.*?)\[\/b\]/is' => '<strong>$1</strong>', '/\[i\](.*?)\[\/i\]/is' => '<em>$1</em>', '/\[u\](.*?)\[\/u\]/is' => '<span style="text-decoration: underline">$1</span>', '/\[align=(left|center|right)\](.*?)\[\/align\]/is' => '<div style="text-align: $1">$2</div>', '/\{6}|[a-z]+)\](.*?)\[\/color\]/is' => '<span style="color: $1">$2</span>', '/\(.*?)\[\/font\]/is' => '<span style="font-family: \'$1\', sans-serif;">$2</span>', '/\[h([1-6]{1})\](.*?)\[\/h([1-6]{1})\]/is' => '<h$1>$2</h$3>', '/\{1})?[0-9]{1})\](.*?)\[\/size\]/is' => '<span style="font-size: $1px">$2</span>', '/\[code\](.*?)\[\/code\]/is' => '<pre>$1</pre>', '/\[sub\](.*?)\[\/sub\]/is' => '<sub>$1</sub>', '/\[sup\](.*?)\[\/sup\]/is' => '<sup>$1</sup>' ); // Later in the code $string = preg_replace(array_keys($this->markup), $this->markup, $string);
  5. So I have this BB code parsing class I wrote that works perfectly. Just one thing I cant figure out. I want all tags ([ b], etc) to be parsed EXCEPT if they are within [ code] tags. Any help would be greatly appreciated.
  6. Ok so I have this class that uploads and images and resizes. It all works perfectly, but now I need to "crop" the image if the $maxHeight is set but I cant seem to get it working correctly. So if $maxHeight is null it just resizes the image depending on the $maxWidth. Secondly if $maxHeight is set, it will resize the image to the $maxWidth but also crop the height at $maxHeight. Cant figure out the correct coordinates, any help would be awesome. /** * Uploads to tmp and resizes an image * @param array $file * @param int $maxWidth * @param int $maxHeight * @param int $quality * @return void */ function resize($file, $maxWidth, $maxHeight = NULL, $quality = 75) { $image = $this->upload($file); if ($image) { // Capture the original size of the uploaded image list($width, $height) = getimagesize($image); // Figure out the new image dimensions if ($width <= $maxWidth) { return $image; } else { $newWidth = $maxWidth; if (isset($maxHeight)) { $newHeight = $maxHeight; } else { $newHeight = ($height / $width) * $maxWidth; } } $path = $this->temp . $maxWidth .'_'. $file['name']; // Create an image to work with switch ($file['type']) { case 'image/gif': $src = imagecreatefromgif($image); break; case 'image/png': $src = imagecreatefrompng($image); break; case 'image/jpg': case 'image/jpeg': $src = imagecreatefromjpeg($image); break; default: trigger_error('Unsupported filetype!', E_USER_WARNING); break; } $tmp = imagecreatetruecolor($newWidth, $newHeight); // If gif,png allow transparencies if ($file['type'] == 'image/gif' || $file['type'] == 'image/png') { imagealphablending($tmp, false); imagesavealpha($tmp, true); $transparent = imagecolorallocatealpha($tmp, 255, 255, 255, 127); imagefilledrectangle($tmp, 0, 0, $newWidth, $newHeight, $transparent); } // Lets take our source and apply it to the temporary file and resize imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); // Now write the resized image to the server switch ($file['type']) { case 'image/gif': imagegif($tmp, $path); break; case 'image/png': imagepng($tmp, $path); break; case 'image/jpg': case 'image/jpeg': imagejpeg($tmp, $path, $quality); break; default: trigger_error('Image resize has failed!', E_USER_WARNING); break; } // Clear memory imagedestroy($src); imagedestroy($tmp); unlink($image); return $path; } return false; }
  7. Yes but ive also read and spoke to many people that date/time based column types are slow and do not scale well for large applications.
  8. Make your date field an INT and store dates as a unix timestamp (e.g., time()). Then you simply just do a strtotime (http://us2.php.net/strtotime) and do a backwards date. $pastDate = strtotime("-5 days"); SELECT * FROM 'mytable' WHERE date > '$pastDate '
  9. Well how am I supposed to do the read/unread thing? If I can combine the read/unread with the last login, then ill do it that way. If I cannot, then id probably have to do something like you said.
  10. Ok I know my way around PHP fairly well, but on this im quite stumped on the best approach. I recently built my own forum system that has shared users, forums, messages, etc across two sites. http://www.sc2armory.com/forums/ (sc2a) http://www.d3armory.com/forums/ (d3a) Notice at the bottom they both have the same forums, and then different forums per domain. They also share the same user base, which all works out perfectly. The problem im having is this: - When a user logs in (with cookie or without) it updates a last login and current login time. Last login time is used to determine the "users online" as well as grab all topics with new posts since their last login time. - This all works fine, but if I go to sc2a and view new posts it works (but updates the last login time). And then if I go to d3a and view new posts, there isnt any because I just checked on sc2a and the times have been updated. So I can only view one site or the other. I know I can easily fix this by storing session data in the database that routes to each domain per user, thats simple... but. - I also want to be able to make it so when a user views a thread, it marks it as read. This is the part I am confused on, how do I do this? Do I store all topics ids since last visit in an array in the session/db? Then remove an id if they have read it? Or is there another way to do this? -------------- If you dont want to read above: - How do I mark topics as read/unread and keep consistency since last visit, per domain?
  11. Can someone point me in the right direction for this?
  12. if (isset($_POST["submit"])) { // if submitted do stuff here } else { // didnt submit }
  13. So I must have lets say a blank gif file on the server somewere and output the image functions to that image?
  14. I have a form checking class I wrote and im currently writing a method that creates a captcha image, but im relatively new to the image library. Every way ive seen a captcha made it uses a seperate file, is it possible to create the image using a method. Heres my current method, its entirely a work in progress. public function captcha($height, $width, $bgColor = "", $textColor = "", $options = "") { header ("Expires: Sat, 10 Dec 1983 07:00:00 GMT"); header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header ("Pragma: no-cache"); // HTTP/1.0 header ("Content-type: image/gif"); // If no bg color / text color / options set if (!is_array($bgColor)) { $bgColor = array( "red" => 0, "blue" => 0, "green" => 0 ); } if (!is_array($textColor)) { $textColor = array( "red" => 255, "blue" => 255, "green" => 255 ); } if (!is_array($options)) { $options = array( "font" => 1, "x" => 5, "y" => 5 ); } // Create the image $image = imagecreate($width, $height); $image_bg = imagecolorallocate($image, $bgColor["red"], $bgColor["green"], $bgColor["blue"]); $image_text = imagecolorallocate($image, $textColor["red"], $textColor["green"], $textColor["blue"]); imagestring($image, $options["font"], $options["x"], $options["y"], $this->pass, $image_text); imagegif($image); }
×
×
  • 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.