Jump to content

shortysbest

Members
  • Posts

    414
  • Joined

  • Last visited

Everything posted by shortysbest

  1. Well yeah, but also with multiple files. (images).
  2. I have am uploading files with iframes (to fake an ajax system) And I allow multiple photo uploads, Now I just want it to show the progress, either by percentage, or number of photos uploaded out of the total number. my form is: <form><input type="file" name="uploadFile[]" class="custom-upload" multiple="multiple" onChange="photoUpload(this.form,'ajax/profile/photos/photo_upload.php','photo', '<?php print $albumID?>'); return false;"/></form> this is the javascript that makes it work: //###########MULTIPLE PHOTOS///####//// function photoUpload(form, action_url, div_id, albumID) { // Create the iframe... var iframe = document.createElement("iframe"); iframe.setAttribute("id","upload_iframe"); iframe.setAttribute("name","upload_iframe"); iframe.setAttribute("width","0"); iframe.setAttribute("height","0"); iframe.setAttribute("border","0"); iframe.setAttribute("style","width: 0; height: 0; border: none;"); // Add to document... form.parentNode.appendChild(iframe); window.frames['upload_iframe'].name="upload_iframe"; iframeId = document.getElementById("upload_iframe"); // Add event... var eventHandler = function() { if (iframeId.detachEvent) iframeId.detachEvent("onload", eventHandler); else iframeId.removeEventListener("load", eventHandler, false); // Message from server... if (iframeId.contentDocument) { content = iframeId.contentDocument.body.innerHTML; } else if (iframeId.contentWindow) { content = iframeId.contentWindow.document.body.innerHTML; } else if (iframeId.document) { content = iframeId.document.body.innerHTML; } if(content) { document.getElementById(div_id).innerHTML = content; //###################RESULT ACTIONS ON SUCCESS#################/ } else { //###################ERROR RESULTS#############/// } //$('#post-photo'+session).attr("src","photos/small_thumb/"+content); // Del the iframe... setTimeout('iframeId.parentNode.removeChild(iframeId)', 250); } if (iframeId.addEventListener) iframeId.addEventListener("load", eventHandler, true); if (iframeId.attachEvent) iframeId.attachEvent("onload", eventHandler); // Set properties of form... form.setAttribute("target","upload_iframe"); form.setAttribute("action", action_url); form.setAttribute("method","post"); form.setAttribute("enctype","multipart/form-data"); form.setAttribute("encoding","multipart/form-data"); // Submit the form... form.submit(); //$(".upload-error").attr("class","add-photo-loading"); //$(".upload-photo-loading").html("Uploading..."); }
  3. Actually, oddly enough I just tried it in javascript again, and it worked this time (Only posted here because the javascript thread doesn't get much traffic, and figured anyone good with regexp could do both)
  4. preg_match('`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i', $string, $found_url)
  5. Yeah, thanks that did help a bit.
  6. Oh sorry, when i initially googled it I just checked the first link and it didn't seem to have anything, just the basic operators, Now I see how it would make it shorter. (this is also inside of a function like you said it should be) And well I guess what I was trying to accomplish by this post was maybe merging parts of the codes into one or something, aside from using ternary operators it seemed like there would be a shorter way of doing this. But thank you for your help thus far.
  7. I'm not really sure how that would help?
  8. I'd like to get the same result, but in as little code as possible. Thanks (: //find link preg_match('`((http)+(s)?:(//)|(www\.))((\w|\.|\-|_)+)(/)?(\S+)?`i', $url, $found_url); $url = $found_url[0]; //found link //find website name preg_match('/.(\w+).com/', $url, $matches); $website = $matches[1]; if(!$website) { preg_match('/.(\w+).be/', $url, $matches); $website = $matches[1]; } //found website name #####################YOUTUBE############################# if($website=="youtube") { preg_match('/=([^&]+)/', $url, $video_img); $videoID = $video_img[1]; $thumbnail = "http://img.youtube.com/vi/".$videoID."/2.jpg"; } ####################YOUTU.BE############################ else if($website=="youtu") { preg_match('/youtu.be\/([^&]+)/', $url, $video_img); $videoID = $video_img[1]; $thumbnail = "http://img.youtube.com/vi/".$videoID."/2.jpg"; }
  9. I'm trying to detect Urls with or without http:// this detects with: /\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]/
  10. I'm building a social networking, quite similar to facebook at the moment, however what I am looking to do is have as much realtime data as possible, but the problem with that for me has been in order to do so I have had to have a number of periodic queries hitting the server, depending on what the purpose, different frequencies, some maybe 5 seconds, and some 60 seconds, however I would like to be able to have the data be as real time as possible but not have to give up the performance side of my website. I had a version of my website that had several to 10 periodic queries to the server quite frequently, the downside to that was my website would be very slow, and if you weren't using the website (which would clear some of the queries) the page may never load, or take a very long time. Well I ditched that version and created a entire new version. So my idea to "fix" this problem was to have a table in my database dedicated for updating the users information when new information was added. Basically what I would do is whenever a user writes a new post on somebodies profile it would also insert a row in the dedicated table which would have the users_id the post was for, along with the command number associated with that action. There would be a single periodic updater that would query this table every 5-10 seconds and would search for commands, once it found a command it would then fire the function that would carry out that action. So in this example, it would load the new post into the users feed. Does this sound like it would be an efficient way of faking Comet or some other data push system?
  11. Favorite Friends table: id---|---user_id---|---friend_id---|---date 1----|---1----------|-------3---------|------ 2----|---1----------|-------5---------|------- 3----|---1----------|------18--------|------ 4----|---5----------|-------21-------|-------- 5----|---1----------|-------14-------|------- etc. Posts table: id---|---to_id---|---from_id---|----post---|---state---|---date 1----|---3----------|-----3------|-----Me------|----0--------------------- 2----|---5----------|-----5------|-----You----|----0----------------- 3----|---1----------|----14-----|-----None---|---0-------------------- 4----|---21--------|-----21----|-----ABC-----|----0----------------- 5----|---5----------|----18-----|-------Q-----|----0------------------ etc. so what I need to do is use my session, my session would be #1 let's say, so all rows with the user_id of 1 in the favorite_friend table should be selected, and then I need to compare each row of the friend_id column where user_id is still matched to #1 and find the to_id and from_id that is equal to that, then the result of the favorite friends should be ordered by the id of the posts table so the newer posts are on top. Also it should only look for the posts where the state is equal to 0 (that changed to 1 when a user hides a post) To break it down: 1. User_id has to be my id (the session I'm in) 2. friend_id has to match to_id and from_id 3. state has to be equal to 0 4. to_id and from_id have to be the same as each other because that means that it's a status update on their own profile, not a comment on someone elses. so a working example of the output would be: 1. Q 2. None 3. You 4. Me because the id is is incremented the higher the id, the newer the posts. I hope this isn't too confusing, some what difficult to explain real well.
  12. I have tried that before but I still have the problem, sort of, using the query below it does order them in the correct order however it prints out many many more rows then it should. For instance, user 1 has 4 favorited friends, so the query should only print out those four results in the order of their posts, however I suspect it is printing out them the number of times as posts the user has made, so if user 6 is on user 1 favorite list and user 6 has made 10 posts, it prints his name 10 times, etc. $fav_query = mysql_query("SELECT favorite_friends.*, posts.* FROM favorite_friends, posts WHERE favorite_friends.user_id='$session' AND favorite_friends.friend_id = posts.to_id AND posts.to_id=posts.from_id ORDER BY posts.id DESC");
  13. I'm selecting from two tables, table favorite_friends, and table posts. Right now it just orders it by the id of the favorite_friends, but i want it to order by the id/date of latest posts. This is the first part of my script right now: $fav_query = mysql_query("SELECT * FROM favorite_friends WHERE user_id='$session' ORDER BY id"); while($row = mysql_fetch_array($fav_query)) { $friend_id = $row['friend_id']; $lastPost = mysql_fetch_assoc(mysql_query("SELECT * FROM posts WHERE from_id='$friend_id' AND to_id='$friend_id' ORDER BY id DESC LIMIT 1")); however both queries need to be combined into one, So the result of the 1st query can be ordered by the 2nd query
  14. I want to select all favorite friends, but I want to order them in order from who has posted something most recent. $fav_query = mysql_query("SELECT * FROM favorite_friends WHERE user_id='$session' ORDER BY id"); Posts table name is "posts" The row that it should be ordered by is "id"
  15. I appreciate your critique and I'm with you 100%. I'm sure this goes without saying, I'm not the best with coming up with new designs and systems, on the fly that is. I'm more of one that takes the basic principle of a feature, then as I come up with new thoughts along the way implement change on those. Most everything will be changed before it's all said and done, for instance; Notifications, I have to come up with a completely new innovative system that works better, and is still simple; that's a tough challenge. As far as the features for the site, I've got new feature ideas, but again, it's something that I have to take a step at a time. Another thing I was hoping to get was some insight as far as how others thought would be a better way of doing something, and features that would be good. Again thanks for your feedback, it's all appreciated
  16. Completely redesigned, much faster and cleaner.
  17. I have put these into the database how you showed me earlier, now I just need to figure out how to manage the name of the info field. $title = array( 1 => 'Introduction', 2 => 'About Me', 3 => 'Occupation', 4 => 'Phone', 5 => 'Email', 6 => 'Relationship Status', 7 => 'Gender', 8 => 'Birthday', 9 => 'Location'); in the database i have numbers next to each to indicate which field is which, so 1 means introduction, 2 means about me, etc. The problem is I need to replace that number with the correct field name. so 1 would change to Introduction. putting them in that array and putting them inside the while loop works, but it's not very good, because if someone hides one of their information spots, or doesn't fill it in, then it would throw the names off and they would be next to the wrong field. So what I need to do is detect the number, when it's found the number match it up with the number of the title and print that. if that makes sense?
  18. Ah I see. Thanks a lot. Ill try it once I get home, should be ok. And Also, isn't listID pointless to have? Can just user ID in place of it. But thanks a lot for the ideas.
  19. I really appreciate all your help, but the way you are doing it doesn't really make sense. Could you show an example so I could see how you Have ot thought out. Maybe make a complete example with two different users that have their email, and phone with one hidden, one showing. The usersID Should be a number, so use 1 and 2 tonrepresrnt the two different users. Hope I'm not asking for too much, thank you very much.
  20. Oh ok, so listID would just be a number for the field for example listID 1 would represent email, listID 2 would represent phone, etc?
  21. I don't think I'm understanding how you would do this? Maybe elaborate some more because the way I understand this now wouldn't work - I don't think. Info table UserID, ListID <-- *note* This is a foreign key, coming from the table below List table ListID, Field, Show <-- *note* 'Field' would be where you stored the name of the field such as Phone, email, etc, and 'Show' would be a true/false value indicating show or hide
  22. Iron, Thanks for your responses but I don't think you quite understand what I'm trying to accomplish - I already have a profile system and everything all set up, I've got everything to work, however I'm just trying to find a better - more efficient way of doing so
  23. I have a website all built, and the users will be able to edit their information from the website. My website is a social networking website. I use MYSQL
  24. Well not exactly how I want, I don't know how to crop an image, I've never really worked with php image techniques, perhaps I should begin. What i am looking for is to take an image, say 1280x800 and crop it to let's say 50x50. I don't want to just simply change the size from 1280x800 to 50x50, I want to crop it so it's not distorted
×
×
  • 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.