Jump to content

simcoweb

Members
  • Posts

    1,104
  • Joined

  • Last visited

Everything posted by simcoweb

  1. Hmmm...ok, if i'm understanding correctly this 'management console' has somewhat of a broken page where the form displays where it shouldn't? And you want to move it to where it should display?
  2. That example you showed: <td>".$Body."<strong>Name</strong></font></td><td><input type=\"text\" name=\"name\" value=\"".$row['2']."\"></td> is for dynamically populating a form's fields. Not just displaying a form. Barand showed you how to display the form within your <?php ?> tags but not how to dynamically populate the fields. Is that what you're looking for?
  3. You don't want to insert the actual image into the table. Just the name of the image OR the full path to it OR the url to it.
  4. Did you wrap it in <html><head> tags?
  5. It may be that your code is failing elsewhere. Possibly this part in the phpscript2.php file: <?= $CityName ?> Try this instead: <?php echo $CityName; ?>
  6. Basically you would use the 'include' or 'require' method: include 'image.class.php'; Then you would simply use the many functions listed in the class file in your page scripting. The class file is a collection of functions that you can reference and use throughout your pages.
  7. LOL...well this isn't a script repository. It's a help center for people learning and writing their own scripts. If you want something already done then head over to www.hotscripts.com and cruise through their PHP catalog and see what gaming scripts may work for you. If you want to write your own then you'll need to come to the realization that there's a lot more to it than what i've just outlined.
  8. I'm so confused. Let's see if I have this right: 1. someone comes to your site to report a match/challenge 2. when they report the match a random password is generated..which they have to 'remember' for later when they report the win/lose 3. they go beat the crap out of each other and report the win/lose back at the site 4. before they can report it, they have to enter that password 5. that password they enter is matched against one in the database associated with that match to allow the winner to be posted 6. that password is then deleted/nullified/x-nayed from the database so it can't be used again. Is this right?
  9. Here's a great image class file that has a lot of what you're looking for. You could modify it to further fit your needs. <?php /** * A class providing a set of methods for doing basic transformation to an image like resizing, rotating and flipping * * The code is approx 18Kb in size but still heavily documented so you can easily understand every aspect of it * * * */ error_reporting(E_ALL); class imageTransform { /** * Path and name of image file to transform * * @var string */ var $sourceFile = ""; /** * Path and name of transformed image file * * @var string */ var $targetFile = ""; /** * Available only for the {@link resize} method * * Width, in pixels, to resize the image to * * the property will not be taken into account if is set to -1 * * default is -1 * * @var integer */ var $resizeToWidth = -1; /** * Available only for the {@link resize} method * * Height, in pixels, to resize the image to * * the property will not be taken into account if is set to -1 * * default is -1 * * @var integer */ var $resizeToHeight = -1; /** * Available only for the {@link resize} method * * while resizing, image will keep it's aspect ratio if this property is set to TRUE, and only one of the * {@link resizeToWidth} or {@link resizeToHeight} properties is set. if set to TRUE, and both * {@link resizeToWidth} or {@link resizeToHeight} properties are set, the image will be resized to maximum width/height * so that neither one of them will exceed given width/height while keeping the aspect ratio * * default is TRUE * * @var boolean */ var $maintainAspectRatio = true; /** * Available only for the {@link resize} method * * image is resized only if image width/height is smaller than the values of * {@link resizeToWidth}/{@link resizeToHeight} properties * * @var boolean */ var $resizeIfSmaller = true; /** * Available only for the {@link resize} method * * image is resized only if image width/height is greater than the values of * {@link resizeToWidth}/{@link resizeToHeight} properties * * @var boolean */ var $resizeIfGreater = true; /** * Available only for the {@link resize} method and only if the {@link targetFile}'s extension is jpg/jpeg * * output quality of image (better quality means bigger file size). * * range is 0 - 100 * * default is 65 * * @var integer */ var $jpegOutputQuality = 65; /** * what rights should the transformed file have * * by default a file created by a script will have the script as owner and you would not be able to edit, modify * or delete the file. better is to leave this setting as it is * * @var string */ var $chmodValue = "0650"; /** * in case of an error read this property's value to find out what went wrong * * possible error values are: * * - 1: source file could not be found * - 2: source file can not be read * - 3: could not write target file * - 4: unsupported source file * - 5: unsupported target file * - 6: available version of GD does not support target file extension * * @var integer */ var $error = 0; /** * returns an image identifier representing the image obtained from sourceFile and the image's width and height * * @access private */ function create_image_from_source_file() { // performs some error checking first // if source file does not exists if (!file_exists($this->sourceFile)) { // save the error level and stop the execution of the script $this->error = 1; return false; // if source file is not readable } elseif (!is_readable($this->sourceFile)) { // save the error level and stop the execution of the script $this->error = 2; return false; // if target file is same as source file and source file is not writable } elseif ($this->targetFile == $this->sourceFile && !is_writable($this->sourceFile)) { // save the error level and stop the execution of the script $this->error = 3; return false; // get source file width, height and type // and if founds a not-supported file type } elseif (!list($sourceImageWidth, $sourceImageHeight, $sourceImageType) = getimagesize($this->sourceFile)) { // save the error level and stop the execution of the script $this->error = 4; return false; // if no errors so far } else { // creates an image from file using extension dependant function // checks for file extension switch ($sourceImageType) { // if gif case 1: // the following part gets the transparency color for a gif file // this code is from the PHP manual and is written by // fred at webblake dot net and webmaster at webnetwizard dotco dotuk, thanks! $fp = fopen($this->sourceFile, "rb"); $result = fread($fp, 13); $colorFlag = ord(substr($result,10,1)) >> 7; $background = ord(substr($result,11)); if ($colorFlag) { $tableSizeNeeded = ($background + 1) * 3; $result = fread($fp, $tableSizeNeeded); $this->transparentColorRed = ord(substr($result, $background * 3, 1)); $this->transparentColorGreen = ord(substr($result, $background * 3 + 1, 1)); $this->transparentColorBlue = ord(substr($result, $background * 3 + 2, 1)); } fclose($fp); // -- here ends the code related to transparency handling // creates an image from file $sourceImageIdentifier = @imagecreatefromgif($this->sourceFile); break; // if jpg case 2: // creates an image from file $sourceImageIdentifier = @imagecreatefromjpeg($this->sourceFile); break; // if png case 3: // creates an image from file $sourceImageIdentifier = @imagecreatefrompng($this->sourceFile); break; default: // if file has an unsupported extension // note that we call this if the file is not gif, jpg or png even though the getimagesize function // handles more image types $this->error = 4; return false; } } // returns an image identifier representing the image obtained from sourceFile and the image's width and height return array($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight); } /** * Creates a target image identifier * * @access private */ function create_target_image_identifier($width, $height) { // creates a blank image $targetImageIdentifier = imagecreatetruecolor($width, $height); // if we have transparency in the image if (isset($this->transparentColorRed) && isset($this->transparentColorGreen) && isset($this->transparentColorBlue)) { $transparent = imagecolorallocate($targetImageIdentifier, $this->transparentColorRed, $this->transparentColorGreen, $this->transparentColorBlue); imagefilledrectangle($targetImageIdentifier, 0, 0, $width, $height, $transparent); imagecolortransparent($targetImageIdentifier, $transparent); } // return target image identifier return $targetImageIdentifier; } /** * creates a new image from a given image identifier * * @access private */ function output_target_image($targetImageIdentifier) { // get target file extension $targetFileExtension = strtolower(substr($this->targetFile, strrpos($this->targetFile, ".") + 1)); // image saving process goes according to required extension switch ($targetFileExtension) { // if gif case "gif": // if gd support for this file type is not available if (!function_exists("imagegif")) { // save the error level and stop the execution of the script $this->error = 6; return false; // if, for some reason, file could not be created } elseif (@!imagegif($targetImageIdentifier, $this->targetFile)) { // save the error level and stop the execution of the script $this->error = 3; return false; } break; // if jpg case "jpg": case "jpeg": // if gd support for this file type is not available if (!function_exists("imagejpeg")) { // save the error level and stop the execution of the script $this->error = 6; return false; // if, for some reason, file could not be created } elseif (@!imagejpeg($targetImageIdentifier, $this->targetFile, $this->jpegOutputQuality)) { // save the error level and stop the execution of the script $this->error = 3; return false; } break; case "png": // if gd support for this file type is not available if (!function_exists("imagepng")) { // save the error level and stop the execution of the script $this->error = 6; return false; // if, for some reason, file could not be created } elseif (@!imagepng($targetImageIdentifier, $this->targetFile)) { // save the error level and stop the execution of the script $this->error = 3; return false; } // if not a supported file extension default: // save the error level and stop the execution of the script $this->error = 5; return false; } // if file was created successfully // chmod the file chmod($this->targetFile, $this->chmodValue); // and return true return true; } /** * Resizes the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile} * while following user specified properties * * @return boolean TRUE on success, FALSE on error. * If FALSE is returned, check the {@link error} property to see what went wrong */ function resize() { // creates an image from sourceFile list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight) = $this->create_image_from_source_file(); // if aspect ratio needs to be maintained if ($this->maintainAspectRatio) { // calculates image's aspect ratio $aspectRatio = $sourceImageWidth <= $sourceImageHeight ? $sourceImageHeight / $sourceImageWidth : $sourceImageWidth / $sourceImageHeight; $targetImageWidth = $sourceImageWidth; $targetImageHeight = $sourceImageHeight; // if width of image is greater than resizeToWidth property and resizeIfGreater property is TRUE // or width of image is smaller than resizeToWidth property and resizeIfSmaller property is TRUE if ( ($this->resizeToWidth >= 0 && $targetImageWidth > $this->resizeToWidth && $this->resizeIfGreater) || ($this->resizeToWidth >= 0 && $targetImageWidth < $this->resizeToWidth && $this->resizeIfSmaller) ) { // set the width of target image $targetImageWidth = $this->resizeToWidth; // set the height of target image so that the image will keep its aspect ratio $targetImageHeight = $sourceImageWidth <= $sourceImageHeight ? $targetImageWidth * $aspectRatio : $targetImageWidth / $aspectRatio; } // if height of image is greater than resizeToHeight property and resizeIfGreater property is TRUE // or height of image is smaller than resizeToHeight property and resizeIfSmaller property is TRUE if ( ($this->resizeToHeight >= 0 && $targetImageHeight > $this->resizeToHeight && $this->resizeIfGreater) || ($this->resizeToHeight >= 0 && $targetImageHeight < $this->resizeToHeight && $this->resizeIfSmaller) ) { // set the width of target image $targetImageHeight = $this->resizeToHeight; // set the width of target image so that the image will keep its aspect ratio $targetImageWidth = $sourceImageWidth <= $sourceImageHeight ? $targetImageHeight / $aspectRatio : $targetImageHeight * $aspectRatio; } // if aspect ratio does not need to be maintained } else { $targetImageWidth = ($this->resizeToWidth >= 0 ? $this->resizeToWidth : $sourceImageWidth); $targetImageHeight = ($this->resizeToHeight >= 0 ? $this->resizeToHeight : $sourceImageHeight); } // prepares the target image $targetImageIdentifier = $this->create_target_image_identifier($targetImageWidth, $targetImageHeight); // resizes image imagecopyresized($targetImageIdentifier, $sourceImageIdentifier, 0, 0, 0, 0, $targetImageWidth, $targetImageHeight, $sourceImageWidth, $sourceImageHeight); // writes image return $this->output_target_image($targetImageIdentifier); } /** * Flips horizontally the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile} * * @return boolean TRUE on success, FALSE on error. * If FALSE is returned, check the {@link error} property to see what went wrong */ function flip_horizontal() { // creates an image from sourceFile list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight) = $this->create_image_from_source_file(); // prepares the target image $targetImageIdentifier = $this->create_target_image_identifier($sourceImageWidth, $sourceImageHeight); // flips image horizontally for ($x = 0; $x < $sourceImageWidth; $x++) { imagecopy($targetImageIdentifier, $sourceImageIdentifier, $x, 0, $sourceImageWidth - $x - 1, 0, 1, $sourceImageHeight); } // writes image return $this->output_target_image($targetImageIdentifier); } /** * Flips vertically the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile} * * @return boolean TRUE on success, FALSE on error. * If FALSE is returned, check the {@link error} property to see what went wrong */ function flip_vertical() { // creates an image from sourceFile list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight) = $this->create_image_from_source_file(); // prepares the target image $targetImageIdentifier = $this->create_target_image_identifier($sourceImageWidth, $sourceImageHeight); // flips image vertically for ($y = 0; $y < $sourceImageHeight; $y++) { imagecopy($targetImageIdentifier, $sourceImageIdentifier, 0, $y, 0, $sourceImageHeight - $y - 1, $sourceImageWidth, 1); } // writes image return $this->output_target_image($targetImageIdentifier); } /** * Rotates the image given as {@link sourceFile} and outputs the resulted image as {@link targetFile} * * this method implements PHP's imagerotate method which is buggy. * an improved version of this method should be available soon * * @param double $angle angle to rotate the image by * @param mixed $bgColor the color of the uncovered zone after the rotation * * @return boolean TRUE on success, FALSE on error. * If FALSE is returned, check the {@link error} property to see what went wrong */ function rotate($angle, $bgColor) { // creates an image from sourceFile list($sourceImageIdentifier, $sourceImageWidth, $sourceImageHeight) = $this->create_image_from_source_file(); // rotates image $targetImageIdentifier = imagerotate($sourceImageIdentifier, $angle, $bgColor); // writes image return $this->output_target_image($targetImageIdentifier); } }
  10. This code worked great for me. You can set the # of columns as well. I used it to display 2 columns of subcategories in table cells pulling from the MySQL database. // run query $sql = "SELECT * FROM subcategories WHERE cat_id='2'"; $results = mysql_query($sql) or die(mysql_error()); // display results $totalColumns = 2; $i = 1; echo "<table border='0' cellpadding='2'>"; while ($row = mysql_fetch_array($results)){ if ($i == 1) echo "<tr>"; echo "<td>"; echo "<a href='getcat.php?subcat_id=". $row['subcat_id'] . "'>" . $row['subcat_name'] . "</a>"; echo "</td>"; if ($i == $totalColumns) { echo "</tr>"; $i = 0; } $i++; } echo "</table>";
  11. Question: Why wouldn't you let the users choose their own password(s)? If i'm understanding correctly in what you're doing, you'll wind up with a gazillion passwords. Who is going to remember those?
  12. There are several 'date' styles and commands in PHP. You could have it say: January 1, 2007 Friday 11:30am for example. What code is creating those values that are being inserted? Can you post that please?
  13. That still doesn't ask a question. Your first post was a statement. The Zip file is in .cfm. We can't help you unless you post some PHP code you need help with.
  14. Thorpe, would that then produce something like: index.php index.php?aboutus index.php?blahblah index.php?yadayada Where it's basically dynamically generating the text in the content area depending upon what link is clicked? I've been wanting to learn this method.
  15. Yeah, i've downloaded videos like Saving Private Ryan that were less than 800mb's!
  16. Make sure your permissions are correct also.
  17. You could use something like this. It's difficult to just 'give' you a turnkey snippet since your HTML, folder setup, etc. needs to be factored in. This snippet also includes a sample upload form at the bottom, validates the file type, size, etc. and places it in the proper folder you designate. if(isset($_POST['upload']) { $ServerRoot = $_SERVER['DOCUMENT_ROOT']; // Grabs the home directory of your hosting. $Directory = 'uploads/'; // Folder that will be uploaded to relative to the public_html. $MaxFileSize = '10240'; // Maximum file size allowed. $AllowedFiles = array(jpg,gif,png,psd,zip,rar,bmp); // The allowed file extensions $FileExtension = $_FILES['file']['type']; $FileSize = $_FILES['file']['size']; $FileName = $_FILES['file']['name']; if($FileSize > $MaxFileSize) { echo 'Your file is too big!'; exit; } if(!in_array($FileType) { echo 'You are not allowed to upload that file type!'; exit; } $UploadFile = move_uploaded_file($_FILES['file']['tmp_name'], $ServerRoot$Directory); if($UploadFile !== TRUE) { echo 'Problem uploading!'; exit; } echo "File uploaded successfully: http://www.your-domain/'.$Directory$_FILES['file']['name']."; } else { echo " <form name='upload' encrypte='multipart/form-data' action="'.$_SERVER['PHP_SELF'].'" method='post'> "; echo "<input type='upload' name='file' size='30' />"; } ?><form enctype="multipart/form-data" action="upload.php" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000" /> Choose a file to upload: <input name="uploaded_file" type="file" /> <input type="submit" value="Upload" /> </form>
  18. There's a file upload tutorial in the PHP Freaks tutorial section. Check that out first.
  19. I don't see where you've actually 'executed' the command. You've basically populated a bunch of variables. Is there more code that actually summons the $makeCopy?
  20. I don't understand. Can you clarify what you're looking for there?
  21. Try this: ####################### # Create an Advanced # Textbox # function createTextBoxAdv($text, $name, $size, $onBlur, $onClick, $onFoc) { if(isset($onBlur)){ $addThis += "onblur=".$onBlur." "; } if(isset($onClick)){ $addThis += "onclick=".$onClick." "; } if(isset($onFoc)){ $addThis += "onfocus=".$onFoc." "; } echo $onFoc; print "<label>".$text."</label><input type=\"text\" size=\"".$size."\" name=\"".$name."\" ".$addThis." />\n"; }
  22. You could, as well, use something that makes sure the form was actually submitted: if (isset($_POST['submit'])){ // all your code here } else { header("Location: form.php"); }
  23. Basically the page has some javascript in it that tells it to refresh every 60 seconds and when it does the .asp code in the page runs a query to that entity and displays the results. You could do the same thing in PHP as well. You'd just have to have the source that supplies the information.
×
×
  • 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.