Jump to content

woolyg

Members
  • Posts

    254
  • Joined

  • Last visited

    Never

Everything posted by woolyg

  1. Hi all, I need to take a PNG image, and superimpose a triangle shape into it, and make everything *outside* the triangle to be resampled as transparent, so it appears like the once-rectangular image is now a triangle (but it's still a rectangle with a non-transparent triangle within it). I've been searching all over, but the GD library seems to only work on rectangle/square images... has anyone seen any resources on how to do this? All the best, WoolyG
  2. Hi Daj, I'm currently writing a similar app for a client, and have gotten a certain distance - I can save single attachments locally as well as the email details, but if there is more than one attachment, I run into problems. I'd be interested in working with you to see if you've managed to attain what you need to do, maybe my code thus far might help you out also..? Drop me a PM and I'll send you my email address. All the best, WoolyG
  3. Hi all, Does anyone know how to extract attachments from an email that has more than one attachment associated with it? Getting the overall attachment data works fine using <?php $attachment_data = imap_fetchbody($inbox,$email_number,2); ?> ..but breaking up that data into its component attachments is eluding me, and I can't find anything on the PHP doco that enabled me to do it. All info appreciated, WoolyG
  4. Hi all, Here's the code I'm using, after opening an IMAP stream to an inbox. The code previous to this opens the inbox, grabs the emails and iterates through them. This bit is checking an individual mail for attachments. <?php $structure = imap_fetchstructure($mbox, $email_number); $parts = $structure->parts; $fpos=2; for($i = 1; $i < count($parts); $i++) { $message["pid"][$i] = ($i); $part = $parts[$i]; if($part->disposition == 'ATTACHMENT') { // Save the attachment locally to the server // Find the file extension // Save the attachment to DB code here $fpos+=1; } } ?> When I run the script, I get a load of the following reply: Notice: Undefined property: stdClass::$parts in /var/www/html/site/public_html/cron/cron_email_import.php on line XXX Would this mean that there are no actual attachments in the email being processed? Has anyone ever dealt with this function before? All input appreciated. WoolyG
  5. Hi all, Has anybody here had any experience controlling relays through a webserver (specifically PHP)? I'm looking at a potentially cool project, and functionality would be greatly added if I could control relays.. Possibly a left-field question, but any resources would be appreciated! WoolyG
  6. Hi all, I have a little MySQL question I hope I can get some input on. I'm designing a DB, and one of the tables' fields is going to comprise of a non-unique 10-digit integer. This tabel has the possibility to be huge (millions of rows), and the integer will be one of a couple of fields of the table that will be placed in the WHERE part of a SQL query, exactly matching the string in the field. My question is - assuming the table already has a primary key index, should I use an INT data type for this field, or a VARCHAR data type with a FULLTEXT index for more efficient searching? The number will always be 10 characters - either 10 characters or a zero (0). What would be the best data type to use here? Thanks, WoolyG
  7. Sorry, I should have specified. msg_data_array is an array built out of a long string (messages_list), split and delimited by two colons. Just above the for() loop, is this code: var msg_data_array = messages_list.split('::'); Any ideas?
  8. Here's my javascript: for(i=0;i<=20;i++) { // msg_data_array is a string with 20 items in it, all delimited by 2 hashes - ## var msgtext = msg_data_array[i].split('##'); } The script returns msgtext just fine, but I'm getting an error in firebug: msg_data_array is undefined .. Can anybody shed any light on this? All info appreciated. Thanks WoolyG
  9. I've solved it - the end uer was placing a tab prior to the img ref. Thanks!
  10. Hi voip03 1. I've ensure the path exists. 2. I'm calling the image half way down a page from a function, so this will cause issues won't it?
  11. Hi all, I'm iterating 4 images out in a loop. All 4 images exist (definitely), and using an earlier script, have been resized to a width of 200px, so they are not large. I'm finding that if I use the following code: $image_info = getimagesize($filename); $type = $image_info['mime']; echo $type; .. some of the images come up with no mime type. Is this normal? As a (possible) result of / link to having no mime type assigned to it, I'm getting: [function.getimagesize]: failed to open stream: No such file or directory .. but I am positive the image exists. Viewing the image info in a browser gives "image/jpeg", so I'm a bit weirded out as to how the script queries the image for a mime type, and it returns nothing. Has anybody else seen this, can anyone help? All the best, WoolyG
  12. Hi phpmady, You use the word "refresh", which could indicate that you need to use setInterval rather than setTimeout? Please see http://www.phpfreaks.com/forums/index.php?topic=327711.0, which I managed to work out for my own regularly-updating div issue... If you add a unique identifier in the URI of the data.php call (like a current timestamp, generated by javascript , something like that) then the recurring call will not be cached as it has a unique value in the URI being called. Just a thought. WoolyG
  13. OK, having delved a bit deeper, it was because IE was caching the ajax call. Once I changed: function update_user_credit_left_div($user_id){ // FUNCTION 48 ajax_refresh('<?php echo base_url(); ?>assets/ajax/ajax.update_user_credit_left_div.inc.php?uid=<?php echo $user_id; ?>', 'user_credit_left'); } // FUNCTION 48 to: function update_user_credit_left_div($user_id){ // FUNCTION 48 ajax_refresh('<?php echo base_url(); ?>assets/ajax/ajax.update_user_credit_left_div.inc.php?uid=<?php echo $user_id; ?>&t=' + (new Date()).getTime(), 'user_credit_left'); } // FUNCTION 48 .. the div began updating every 10 seconds as expected! Solved. Hopefully this can help someone else out some time. WoolyG
  14. This could possibly be grouped with this post: http://www.phpfreaks.com/forums/index.php?topic=327454.0 - the code works in FF and Chrome, etc, but not IE, and I'm wondering if anyone has seen a workaround. Basically, the page is loading a setInterval() on the fly to dynamically update a user's credit left in their account, and show it within a constantly updating div. Every 10 seconds, it runs an ajax call to a PHP script, and the info comes through. It works with everything but IE. I know IE deals with ajax differently that the other browsers, etc, but does it have a distinct problem with setInterval()? Here's the code being used: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Updater test</title> <script language="JavaScript" type="text/javascript"> function ajax_refresh(dataSource, divID) { var XMLHttpRequestObject = false; if (window.XMLHttpRequest) { XMLHttpRequestObject = new XMLHttpRequest(); } else if (window.ActiveXObject) { XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp"); } if(XMLHttpRequestObject) { var obj = document.getElementById(divID); //var starting_data = obj.innerHTML; document.getElementById(divID).innerHTML = obj.innerHTML; XMLHttpRequestObject.open("GET", dataSource, true); XMLHttpRequestObject.onreadystatechange = function() { if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) { obj.innerHTML = XMLHttpRequestObject.responseText; delete XMLHttpRequestObject; XMLHttpRequestObject = null; } } XMLHttpRequestObject.send(null); } } // STANDARD AJAX CALL END </script> </head> <body> <script type="text/javascript"> var refresher_update_user_credit_left_div = 0; refresher_update_user_credit_left_div = setInterval("update_user_credit_left_div('<?php echo $user_id; ?>')", 10000); function update_user_credit_left_div($user_id){ // FUNCTION 48 ajax_refresh('<?php echo base_url(); ?>assets/ajax/ajax.update_user_credit_left_div.inc.php?uid=<?php echo $user_id; ?>', 'user_credit_left'); } // FUNCTION 48 </script> <div id="user_credit_left" title="Your account credit."></div> </body> </html> All input appreciated. Regards WoolyG
  15. Cheers businessman332211, I will most definitely do more reading on it.
  16. That's mostly why I'm looking at this - the site rules are going to dictate that users may not have more than one account. The site will only allow them to carry out a certain action once per page (based on their session ID) and while I'm not going to actively disallow them from doing it, I'll be logging IPs to check if the same action is done on the same page by the same IP, but using different session IDs. This will then be highlighted to admins to 'flag' for a possible duplicate account - also understanding that 2 PCs on the same home or workplace network will be sharing the same IP as seen by the site. Visitors to the site that do not log in will not have the IP recorded. Thanks for your input Crayon, it's made it clearer in my head in any case!! - Wooly
  17. Over the past 6 or so months I've gotten into CodeIgniter, and found it's really speeding up my development time. It took me a while to get used to it as I'm not the sharpest tool in the box, but that's where the CodeIgniter user guide comes into play - it's simple and clear, and very easy to understand. I've seen discussions saying that CodeIgniter is not true MVC, and one of the slower of the 'fast' frameworks, but it serves my needs perfectly right now:) WoolyG
  18. Hey all, I'm building a PHP app that requires that the user's IP is recorded upon registration, and am in the middle of coding the logic that allows or disallows registration. A question for those who know about IP 'spoofing', really. Is it possible, if you obfuscated or hid your IP, to have a PHP script think you have no IP, ie for $_SERVER['REMOTE_ADDR'] to return nothing? The script will require that an IP is returned in the first place - if none is shotwing, the script will die out. All input appreciated, I'd like to know what I'm up against with regards to the possibilty of IP obfuscators/hiders/spoofers... WoolyG
  19. WRT the original loop - My thoughts are that if you looped through the rows on a table, then created a new row on a table for every row you find, you would pop the RAM on the server, as the table would never run out of rows to write: 1. Find a row 2. Write a new row 3. Find the row you have just written 4. Write a new row 5. Find the row you have just written 6. *kablam* You might want to use CREATE TEMPORARY TABLE here? If you created a temporary table before running the script, then ran the script, and for every line you find, copy the line you have found to the temporary table, and write another line to the temporary table showing the new OfficeID, then you would come to the end of the script once the first table had run out of lines. You could then (possibly, there might be another better answer here) run a TRUNCATE on the original table, then output the values of the temporary table in a similar query to the first query -- you could output the values back into the original table. You'd need to do it all in one script, as temporary tables are scrapped once the PHP file is finished parsing. Or else actually create a 'real' holding table for the temp data. Having said all that, there is probably a better, cleaner way to do it... Wool
  20. Hey Sean, Are you writing the new information to the same table, or a different table? Where is the second value for OfficeID coming from? Regards, WoolyG
  21. Hi all, Here's my table: -- Table structure for table `table1` -- CREATE TABLE IF NOT EXISTS `table1` ( `id` int(11) unsigned NOT NULL auto_increment, `title` varchar(256) NOT NULL, `parent_id` int(11) unsigned NOT NULL default '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ; -- -- Dumping data for table `table1` -- INSERT INTO `table1` (`id`, `title`, `parent_id`) VALUES (1, 'Top Level 1', 0), (2, 'Top Level 2', 0), (3, 'Second Level 1', 1), (4, 'Second Level 2', 2), (5, 'Third Level 1', 3); ID TITLE PARENT_ID 1 Top Level 1 0 2 Top Level 2 0 3 Second Level 1 1 4 Second Level 2 2 5 Third Level 1 3 What I'm trying to do with my query is order the results by parent_id, then by title, then by id, EG: Top Level 1 - Second Level 1 -- Third Level 1 Top Level 2 - Second Level 2 The Query SELECT * FROM table1 ORDER BY parent_id, title, id .. orders each row simply by 'parent_id', then moves on to the next row. I'd ideally like it to output a row of parent 0, then the children of that parent id, then the children of its children, etc... then once it't finished iterating through the children of the first ID of parent 0, it moves on to the next ID of parent 0... Can anyone point me in the right direction? Thanks WoolyG
  22. Cheers for the answers! I guess I'll get my head into the vcs way then.
  23. Hi all, I'm after opinions here. I'm researching version control systems for a project, and all of the standard ones seem a tad fiddly. I'm considering using a private forum, say built on SMForum just like PHPFreaks is, utilizing the 'code' button to log changes made to the PHP for individual files. Has anyone tried this with any success? Any advice? I'm open to suggestions. Cheers, WoolyG
×
×
  • 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.