Jump to content

itsureboy

Members
  • Posts

    51
  • Joined

  • Last visited

Everything posted by itsureboy

  1. I know I was trying to use imagejpg(); but couldn't get it to work. Heres the amazon s3 code thats works alone: if (!class_exists('S3'))require_once('S3.php'); //AWS access info if (!defined('awsAccessKey')) define('awsAccessKey', 'BLAHBLAH'); if (!defined('awsSecretKey')) define('awsSecretKey', 'BLAHBLAH'); //instantiate the class $s3 = new S3(awsAccessKey, awsSecretKey); $fileName = $_FILES['theFile']['name']; $temp_file_name = $_FILES['theFile']['tmp_name']; $fileSize = $_FILES['theFile']['size']; $fileExt = substr($fileName, strrpos($fileName, '.') + 1); $fileExt = strtolower($fileExt); $custompostid = rand(1000000,9999999); $imageName = $custompostid.".".$fileExt.""; //move the file if ($s3->putObjectFile($temp_file_name, "BUCKETNAME", $image, S3::ACL_PUBLIC_READ, array(), $imageType)) { //success } else{ //error } But before the putObjectFile above , is where I want to implement this: $temp_file_name = $_FILES['theFile']['tmp_name']; $image = $temp_file_name; // creating png image of watermark $watermark = imagecreatefrompng('watermark.png'); // getting dimensions of watermark image $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // creting jpg from original image $image = imagecreatefromjpeg($temp_file_name); //something went wrong if ($image === false) { return false; } // getting the dimensions of original image $size = getimagesize($image_path); // placing the watermark 5px from bottom and right $dest_x = $size[0] - $watermark_width - 10; $dest_y = $size[1] - $watermark_height - 10; // blending the images together imagealphablending($image, true); imagealphablending($watermark, true); // creating the new image imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); //HERE I NEED A $temp_file_name TO BE THE UPDATED FILE WITH THE WATERMARK TO PASS TO THE S3 FUNCTION. // destroying and freeing memory imagedestroy($image); imagedestroy($watermark); I just need to link the variable to the function above and then output that variable again updated to pass it to S3 putObjectFile. Hope I didn't confuse you too much.
  2. I have a script that uploads files uploaded through my website directly to my Amazon s3 bucket. This never saves the file permanetly to my server, just as a temp_file_location This works perfect alone. However, I am trying to now add a watermark to the image before passing the temp_file_location to the s3 function to upload. My question is, how can I use the code below, with the temp_file and then return a new temp_file (which is the watermarked version) Here is just the code for the watermarker, I need this to start with the temp_file and leave me with a new temp_file_location: $temp_file_name = $_FILES['theFile']['tmp_name']; $image = $temp_file_name; // creating png image of watermark $watermark = imagecreatefrompng('watermark.png'); // getting dimensions of watermark image $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); // creting jpg from original image $image = imagecreatefromjpeg($temp_file_name); //something went wrong if ($image === false) { return false; } // getting the dimensions of original image $size = getimagesize($image_path); // placing the watermark 5px from bottom and right $dest_x = $size[0] - $watermark_width - 10; $dest_y = $size[1] - $watermark_height - 10; // blending the images together imagealphablending($image, true); imagealphablending($watermark, true); // creating the new image imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); //HERE I NEED A $temp_file_name TO BE THE UPDATED FILE WITH THE WATERMARK TO PASS TO THE S3 FUNCTION. // destroying and freeing memory imagedestroy($image); imagedestroy($watermark); Any ideas?? Thanks ahead!!
  3. I'm having a problem and need an answer to why its happening and how to prevent it. Scenario: I begin load my home page which starts with a session_start(); .... Before it FULLY completes loading I try to navigate to another page and BOOM, that page will not load and any other page that begins with session_start(); will not load unless I close and restart the entire browser or wait about 10 minutes.... I will note my website makes ajax calls every 5 seconds or so, but I use setTimeout for them. Any help??? Thanks ahead!
  4. Any insight? =\ In a day or two I may be completely bald...
  5. Hey, I am having a problem with one of my applications... I have a homepage that loads and makes AJAX calls. I have three calls that are in intervals of about 5,7, and 10 seconds (I use setTimeout though).... However, every now and then my script hangs on session_start(); (I know its this because I can load up any other pages that do not contain it)... After that happens I can't open up ANY page with session_start(); ... Until what it seems like the session expires and you have to re-login. Anyone know what can be causing this... I use session_write_close(); to the point where its as fast as it can close it, a reopen it to save anything quickly and reclose. (don't have it open in loops and things like that that may take time).... Any Help? ???? Driving me nuts!! Thanks ahead!!
  6. Hey, I need a simple bit of code to do the following: I am trying to strip out a username in a string. This string will distinguish the username because the string will contain a * right before the username. For example: $string = "blah blah *username blah blah blah" The username can only contain numbers and letters. no spaces. And from that string all I want is the username, for example: $string = username (which will vary of course) Hope this makes sense, made it as clear as I possibly could. Thanks ahead! :confused:
  7. I need some simple code that would take a URL and convert it to its utmost proper form which would be for example, http://www.site.com So if a user submits the URL short without the http://, or www. the code would add it accordingly. Any help. Thanks ahead.
  8. Oh, sorry, didn't notice, I've been doing so much PHP its all i see.. But thanks, that looks like it'll work! let me test it out. thanks alot!
  9. Thanks... But the problem with using that is that it will simply just count the rows of a specific user. I need to count the rows of all users and then select the id of the one with the highest count.
  10. Okay, so what I'm trying to do is to calculate the number activities (rows) users have made in a table I call, lets say, ACTIVITIES in the last 24hrs. I then want to select the ID of the user that has had the most activity in the last 24hrs, however without selecting all of his activities and each of those rows information, because the table activities is mainly for the purpose of determining the most active user (by the amount of rows selected with his matching userid/ sort of a mode type thing) and select their userid based on that. Can anybody tell me a way or what I can use to accomplish this? Or it its even possible? I don't need help with any timing or anything like that, just a way. Hope this makes sense, kinda rushed through it, a little frustrated. Thanks ahead.....
  11. Is it possible to display data from two different tables with different data types, and order them by a certain field in sync - (using date based on my example below). Kind of like a news feed. For some reason this doesn't come simple to thought. Maybe it's just me, but it seems really complicated, unless there's an easier way with PHP. For example, lets say I have these two tables. Table 1 Below: Table 2 Below: ---------------------------- ---------------------------- ID | COMMENT | DATE | ID | PICTURE | DATE | ---------------------------- ---------------------------- AND order them based on the DATE uploaded/posted: COMMENT ----------- COMMENT ---------- PICTURE ---------- COMMENT ---------- PICTURE ---------- PICTURE (for example) Hope this isn't to confusing, because I sure am confused after trying to figure out ways of going about doing this. *****I don't need exact code, just a method.
  12. It worked! You don't know how thankful I am. =) THANK YOU!!!!!!!!!!!!!!
  13. I'm new to PHP and everything, so I was wondering. Is it possible to assign a WHILE loop to a variable. I am trying this, just in case it is even possible. $query = while($row = mysql_fetch_array($result)){ echo ' OR commenterid = '.$row['friendid'].' '; }; And get the error: Parse error: syntax error, unexpected T_WHILE Thanks ahead, Chris
  14. I recently changed my dynamic urls to static urls using mod_rewrite. I was just wondering do search engines spiders pick up and update my urls when i use a 301 redirect using php?....I would use mod_rewrite but i added one more variable to some of the urls so it would be way easier with php but only if the spiders pick up the new urls.. Anyone? ??? Thanks.....
  15. I recently changed my dynamic urls to static urls. I was just wondering do search engines pick up and update my urls when i redirect using php?....I would use mod_rewrite but i added one more variable to the urls so it would be easier with php.. Thanks......
  16. I think its adding more than 1 views because i have anothor query. Is this the reason? How can i avoid it adding more than 1 without having to remove other query?
  17. Is there anyway i can do this? Basically i have a rating system and I dont want users to be able to vote more than once on any given row by ID so i store sessions. However since i cant do what i want they can only vote once on 1 ID and no other. What i want to do is explained below.... $_SESSION['\\change according to the value of $id'] = $id; can i put $id in between the session brackets? or any other way to do what i want? hope this makes sense...thanks.....
  18. I tried the code you posted it did the same thing. From 0 added 1 then when reloaded added 4(5) then 4 again (9) and so forth i dont no why.
  19. Wow sorry totally wrong code.... here it is: <?php include 'dbconnect.php'; mysql_query("SELECT views FROM table WHERE id = '$id'"); $newviews = $views + 1; mysql_query("UPDATE table SET views='$newviews' WHERE id = '$id'") ?>
  20. lol.... Was just removing some code for the example and somehow that stayed there.
  21. I have a simple counter that updates a row by 1 each time the page is loaded. However, when its on zero and its first executed it adds one then every other time after that for some reason adds 4 and sometimes something different. I just want it to update by 1 each time its reloaded. Here is the code: <?php include 'dbconnect.php'; $id = $id; $query = "SELECT views FROM table WHERE id = '$id' LIMIT 1"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) { $views = $row[0]; $newviews = 0; } mysql_query("UPDATE table SET views='$newviews' WHERE id = '$id'") ?> Thanks.....
  22. Really.... That is kinda apparent. I just always used it like that on another server and it worked. Lemme give it a try.Thanks....
  23. OK so i have an upload form on my website connected to the upload.php file. Everytime i upload i get this error and it doesnt insert into the table: Warning: mysql_insert_id() [function.mysql-insert-id]: A link to the server could not be established in /home/ls/public_html/lauploadcl.php on line 19 I dont know whats going wrong.... Here is the code: <?php $id = mysql_insert_id(); $category = $_POST['category']; $subcategory = $_POST['subcategory']; $title = $_POST['title']; $preview= $_POST['preview']; $code = $_POST['code']; $background = $_POST['background']; $contact = $_POST['contact']; $extbanner = $_POST['extbanner']; $extwidth = $_POST['extwidth']; $extheight = $_POST['extheight']; $author = $_POST['author']; $description = $_POST['description']; $date = $_POST['date']; $ip = $_POST['ip']; $dbhost = 'localhost'; $dbuser = 'ex'; $dbpass = 'ex'; $dbname = 'ex'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname) or die(mysql_error()); mysql_query("INSERT INTO `layouts` VALUES ('$id', '$category', '$subcategory', '$title', '$preview', '$code', '$background', '$contact', '$extbanner', '$extwidth', '$extheight', '$author', '$description', '$date', '$ip')"); include 'closedb.php'; ?> Thanks.....
  24. Anyone know a simple way to count views for each product using php and a database? Each product has its own ID....... Any help? Thanks in advance.
  25. What I want to use $row['image'] again in that same loop but with the value of the next row in the database (same query) (look at the code to understand what i mean): <?php include 'exampleconnect.php'; if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 12; $cat = $cat; $from = (($page * $max_results) - $max_results); $sql = mysql_query("SELECT title, image FROM rap WHERE category = '$cat' ORDER BY id DESC LIMIT $from, $max_results"); while($row = mysql_fetch_array($sql)){ echo $row['title']; echo $row['image']; ##I want to use $row['image'] again in this loop but with the value of the next row in the database (same query) } include 'exampleclose.php'; ?>
×
×
  • 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.