Jump to content

IanArcher

Members
  • Content Count

    115
  • Joined

  • Last visited

Community Reputation

1 Neutral

1 Follower

About IanArcher

  • Rank
    Member
  • Birthday 05/14/1990

Previous Fields

  • Languages
    PHP, HTML

Profile Information

  • Location
    The Bahamas
  • Interests
    Visual FX/Motion Graphics, PHP
  1. Ok, using this setup or building off of it (because i've never used AJAX before) how would I implement that? If possible, can you provide some coding snippets?
  2. I'm writing an application using PHP and MySQL that is a TV Guide/TV Listings to pull the results of the following fields: id – int(11) name – varchar(255) chan_position – int(3) src_image – varchar(255) time – varchar(255) title – varchar(255) date – varchar(25) This is the code I've tried so far that basically displays all results as a table: <?php require('db.php'); ?> <div class="container"> <? //Start table echo "<table id='guide'>"; echo "<th>Channel</th>"; echo "<th>Title</th>"; echo "<th>Time</th>"; echo "<th>Date</th>"; echo "</tr>"; // Loop through database for ($i = 1; $i < $rowcount; $i++) { $row = mysqli_fetch_assoc($result); $chan_name = $row['name']; $chan_num = $row['chan_position']; $chan_logo = $row['src_image']; $time = date("g:i a", strtotime($row['time'])); $title = $row['title']; $date = $row['date']; // Show entries echo "<tr> <td style='text-align: center;'>"."<img src='".$chan_logo."'><br>".$chan_name."</td> <td>".$title."</td> <td>".$time."</td> <td>".$date."</td> </tr>"; } echo "</table>" ?> The ultimate goal is to have it display closely (but not exactly) to how its done here: http://www.zap2it.com/tvlistings 1. Getting the pagination to be horizontal and the loop through the results based on the time that is stored in the `time` column from 00:00 to 23:00 (use of AJAX necessary?) **Additional details** This is what is currently being output and the link above is what is needed to be output in terms of scrolling and pagination functionality. The output of the table at the moment is how the data is currently stored in the table as well.
  3. You're right, It's pretty tricky, but I managed to achieve what i wanted with this: <script type="text/javascript" language="javascript"> window.onload = function() { $('.form_input_select[name="Country[]"]').attr("value","PSC"); /*$('.form_input_select[name="REGION[]"]').html('');*/ /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { //$('.form_input_select[name="REGION[]"]').html(r); }); }); //$('.form_input_select[name="REGION[0]"]').html(''); /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); };</script> It still doesn't filter if you select the Region dropdown itself, but it comes with the the user's chosen Region, and the Country change event still works.
  4. I commented out those lines of code: /*$('.form_input_select[name="REGION[]"]').html('');*/ /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[]"]').html(r); }); }); $('.form_input_select[name="REGION[0]"]').html(''); /*$('.form_input_select option[value=""]').attr("selected","selected");*/ $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); And it prepopulates the entire list of Regions/Provinces for the world and when i change the Country drop-down it filters the Regions/Provinces by Country, which is fine, but when i am editing a user's profile with those two fields, by default the Region field still is blank with no options below it until you change the Country, instead of showing the user's chosen region that's stored in the MySQL database. Any ideas?
  5. In essence, PHP is putting out the list of options to the dropdown, but the person before used this javascript code to work with the Country dropdown. Before the Region dropdown was a standalone field filled with options from the database using PHP. And on a slower connection, you can see the pre-populated value that the user has chosen for their region, until the page is finished loading and the Javascript overwrites it to be blank. I only want the javascript to stop doing that until the Country menu is changed. Does that look possible in the code?
  6. Thanks for the response, there is an existing code for this on the site i'm doing it for, i was just thinking of reinventing it. Here it is, i've highlighted the part i'm referring to: <script type="text/javascript"> var oBxUserStatus = new BxUserStatus(); oBxUserStatus.userStatusInit('<bx_url_root />', __is_profile_page__); /** * Zehair : */ $(document).ready(function() { /*** Region Code Starts Here ***/ $('.form_input_select[name="REGION[]"]').html(''); $('.form_input_select option[value=""]').attr("selected","selected"); $('.form_input_select[name="Country[]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[]"]').html(r); }); }); $('.form_input_select[name="REGION[0]"]').html(''); $('.form_input_select option[value=""]').attr("selected","selected"); $('.form_input_select[name="Country[0]"]').live('change', function(e) { var pay = $(this).val(); $.get('/m/events/home/?ajax=state&country='+pay, {}, function(r) { $('.form_input_select[name="REGION[0]"]').html(r); }); }); /*** Region Code Ends Here ***/ if(window.location.pathname == '/index.php' || window.location.pathname == '/' ) { $('.mainLogo').css("margin-left","-3px"); } $('.topMenu td:last-child').remove(); $('input[name=copy_to_profile_photos]').attr('checked', false); // $('input[name=copy_to_profile_photos]').hide(); // $('label[for=copy_to_profile_photos]').hide(); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Personnaliser ' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Ajouter son' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == 'Ajouter des vidéos' ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $(".form_input_submit img").each(function (i) { $(this).filter(function() { return (($(this).attr('alt') == "Demander une info" ) ? true : false ); }).parent().parent().parent().parent().hide(); }); $('.subMenuInfoKeeper .thumbnail_block').hide() }); </script> By default there is a field called Region, and it's populating from a table in the database. The issue is whatever value is stored for that user for this field is being cloaked by a blank option value. I still want the code to be intact for when the Country is changed, but to populate with the user's region by default. Like uncloacking it, until it's changed. I attempted to comment out the lines of code where the option[value=""], but it did nothing. Any ideas?
  7. Hello,I need a some assistance with this javascript/jquery script.I have a page where Every Region/Province/State is a MySQL table called `States`Organization: There is a dropdown menu called Province, that has all these Regions in it. I'm trying to make it so that when a user selects a country from the Country dropdown menu: <select add_other="" multiplyable="true" class="form_input_select" name="Country[]"> The Province drop-down menu below it runs a query to show all States/Provinces that belong to the Country selected and filters/strips out the others that don't. <select add_other="" multiplyable="true" class="form_input_select" name="Province[]"><option value="204">Alsace</option><option value="239">Aquitaine</option><option value="271">Auvergne</option> The SQL Query that could work for this SELECT * FROM `States` WHERE (Selected Country) LIKE 'Country` I've read and looked around and apparently the only effective way to do this with Javascript/JSON to use it with PHP as you can only use node.js to connect to a MySQL database.I'm fairly new to Javascript and really need some pointing in the right direction to put this together as most of the scripts I've found around are really specific to their needs for their site.I'm doing this on Boonex Dolphin so not much modifying the hardcoded HTML itself, which is why I have to take the Javascript/Jquery route with this. Thanks in advance
  8. Agreed, also Apple iPhone Mail doesn't use text/html Content, it uses text/plain. No matter where you add a photo into the body as well, no image tag will show up. Just the photo's Content headers. The most logical thing to do would be just to extract the plain text from the body. I considered writing a script to create img tags where those photo insertions should be, but that would require appending the parts together somehow, set a default image size say 400x350 (But that presents even more complications), and changing the header to text/html. But that literally seems near impossible to do and definitely not logical.
  9. I managed to get around this and successfully deal with this image looping & image naming process by using a recently published class found here:http://www.electrict...ge-attachments/ and followed up that class by using it as an include in the script that creates variables such as $text_part, $html_part, and wrote the following: /**** The below sequence manages IMAGE Tags in E-mail are supplied by direct URL links ****/ if (preg_match_all('/<img\s+([^>]*)src="http(s)?:\/\/(.*)"/i', $emailMessage->bodyHTML, $matches)) { echo '<br />Detected E-mail Client uses URL links for image tags...continuing News from Mail session<br />'; } /**** The below sequence manages IMAGE Tags in E-mail are supplied by attachments ****/ if (preg_match_all('/src="cid:(.*)"/Uims', $emailMessage->bodyHTML, $matches)) { if(count($matches)) { $search = array(); $replace = array(); $num_img = sizeof($emailMessage->attachments); for($i = 1; $i <= $num_img; $i++){ foreach($matches[1] as $match) { $matchExt = $emailMessage->attachments[$match]['subtype']; $fnameExt = (string)$matchExt; $fnameExt = strtolower($fnameExt); $uniqueFilename = "image$i.$fnameExt"; $i++; file_put_contents("$dirname/$uniqueFilename", $emailMessage->attachments[$match]['data']); $search[] = "src=\"cid:$match\""; $replace[] = "src=\"$dirname/$uniqueFilename\""; } $emailMessage->bodyHTML = str_ireplace($search, $replace, $emailMessage->bodyHTML); } } } /**** The below sequence manages IMAGE Tags in E-mail are supplied by inline image data ****/ if(preg_match_all('/src="data:(image\/(.*);.*,(.*))"/Uims', $emailMessage->bodyHTML, $basematches)) { $img_num = sizeof($basematches[2]); if(count($basematches[3])) { $search = array(); $replace = array(); for($i = 1; $i <= $img_num; $i++) { foreach($basematches[3] as $base64data) { $uniqueFilename = "$dirname/image".$i.".png"; $i++; $base64data_decoded = base64_decode($base64data); $imCreate = imagecreatefromstring($base64data_decoded); if ($imCreate !== false) { imagepng($imCreate, $uniqueFilename); imagedestroy($imCreate); } $search[] = "$base64data\""; $replace[] = "$uniqueFilename\""; } $emailMessage->bodyHTML = str_ireplace($search, $replace, $emailMessage->bodyHTML); $emailMessage->bodyHTML = preg_replace("/data:image\/(jpeg|png|bmp|gif);base64,/i", "", $emailMessage->bodyHTML); } }} I am kind of worried about using all that regex to parse this HTML as opposed to finding a DOMDocument solution, but through my research i haven't seen anything that DOMDocuments can do to that length as opposed to PCRE functions. The best one can do is include as many 'possible modifiers' as you can. I'm just trying to get around another bug where Apple iPhone's standard Mail app splits messages in different parts because of inline attachments, i proved this with some testing.An example: --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Title: iPhone Email=0A=Snippet: iPhone Test=0A=Tags: iphone=2Cemail=2Cpictures=0A=Category: Member=0A=Message:=0A=Brothers and sisters have I none but this man's father is my father's son.==0A==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.png"Content-Type: image/png; name="image.png"Content-Transfer-Encoding: base64 iVBORw0KGgoAAAANSUhEUgAAAUAAAAHgCAYAAADUjLREAAAgAElEQVR4AeydB3xUVfbHTzpJCITemwgIWEBRFARBV117WxVde11X176WXeuuZdUt6t+1u4oFe8MK9opiQRAUadJ7S0hIz/zP94YbXh5v --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" =0A==0A=Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQAAAQABAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAQAA9tYAAQAA --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEAYABgAAD/4gxYSUNDX1BST0ZJTEUAAQEAAAxITGlubwIQAABtbnRyUkdCIFhZWiAHzgACAAkABgAxAABhY3NwTVNGVAAAAABJRUMgc1JHQgAAAAAAAAAAAAAAAQAA9tYAAQAA --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEASABIAAD/4QI2RXhpZgAATU0AKgAAAAgACgEPAAIAAAAGAAAAhgEQAAIAAAALAAAAjAESAAMAAAABAAYAAAEaAAUAAAABAAAAmAEbAAUAAAABAAAAoAEoAAMAAAABAAIAAAEx --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" Brothers and sisters have I none but this man's father is my father's son.==0A==0A=Brothers and sisters have I none Inline image:= --Apple-Mail-1-577088534Content-Disposition: inline; filename="image.jpeg"Content-Type: image/jpeg; name="image.jpeg"Content-Transfer-Encoding: base64 /9j/4AAQSkZJRgABAQEASABIAAD/4QI2RXhpZgAATU0AKgAAAAgACgEPAAIAAAAGAAAAhgEQAAIAAAALAAAAjAESAAMAAAABAAYAAAEaAAUAAAABAAAAmAEbAAUAAAABAAAAoAEoAAMAAAABAAIAAAEx --Apple-Mail-1-577088534Content-Transfer-Encoding: quoted-printableContent-Type: text/plain; charset="us-ascii" but this man's father is my father's son.= --Apple-Mail-1-577088534-- The email contained multiple lines of the same words where as i just inserted pictures amongst them, and also concluded that the client doesn't use <img> tags, (EXCEPT for when forwarding process, then the client uses <img> tags).
  10. Wow to be honest, i really have no idea where to start off writing something for that. Again, not asking to be spoonfed, but maybe some example code please?
  11. How could i start to write something like that? Any specific functions>? Because this sounds similar to the example code you gave for the $fname = ''; $cid = '';
  12. I wrote something to deal with filenames in the MIME headers that causeuse individual names like that, which can cause overwriting, no where i need to save the attachment with that filename that has been modified is the issue. This is somehwere earlier in the script where attachments and filenames for them are processed: // DECODE DATA $data = ($partno)? imap_qprint(imap_fetchbody($mbox,$mid,$partno)): // multipart imap_body($mbox,$mid); // not multipart // Any part may be encoded, even plain text messages, so check everything. if ($p->encoding==4) $data = quoted_printable_decode($data); elseif ($p->encoding==3) $data = base64_decode($data); // no need to decode 7-bit, 8-bit, or binary // PARAMETERS // get all parameters, like charset, filenames of attachments, etc. $params = array(); if ($p->ifparameters) foreach ($p->parameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; if ($p->ifdparameters) foreach ($p->dparameters as $x) $params[ strtolower( $x->attribute ) ] = $x->value; // ATTACHMENT // Any part with a filename is an attachment, // so an attached text file (type 0) is not mistaken as the message. if (!empty($params['filename']) || !empty($params['name'])) { // filename may be given as 'Filename' or 'Name' or both $filename = (!empty($params['filename']))? $params['filename'] : $params['name']; // filename may be encoded, so see imap_mime_header_decode() $attachments[$filename] = $data; // this is a problem if two files have same name This is where i change the filename if it is just image.jpg|png|bmp or whatever popular extension if ($fname != '' && $cid != '') $images[$cid] = $fname; // map the $cid to the $image to produce the image filename $ifname = $fname; //while(){ if($f = preg_match('/(filename|name)="(image.(png|jpg|jpeg|gif|bmp))"/i', $mimeheaders, $plainfile)){ echo '<br>This is a dangerous filename match that could result in file overwriting and must be numbered sequentially<br />'; if( $ifname === $plainfile[2] ) { echo 'This is the right filename<br>'; echo $plainfile[2] . "<br>"; if ($pos = strrpos($ifname, '.')) { $n = substr($ifname, 0, $pos); $ext = substr($ifname, $pos); echo $ifname = $n . "_" . $i . $ext."<br />"; echo "<a style='font-size:18px; font-weight: bold'>$ifname</a><br />"; } } } But this is where it gets sort of tricky, the below code is in an include file that will save the attachments/images and create a directory to hold them but will only be included only based upon certain validation criterion. // searches the plain text portion of the email for the Title: and its corresponding text.$aSubject = preg_match('/Title:\s+(.*)/i', $text_part, $matches) ? $matches[1] : '';// trim Title: string from the subject, and keeps the group matched corresponding text$aSubject = str_replace("Title: ", "" ,$aSubject);// removes special characters from article/directory name and makes all characters lowercase$stripped = trim(strtolower(preg_replace("/[^A-Za-z0-9 ]/", "", $aSubject)));$aSubject = str_replace(" ", "_", $stripped); // the directory will be created here in the /newsfrommail/ application folder$dirname = "../newsfrommail/$aSubject/";// creates the directory$dir = mkdir($dirname, 0777);// process attachmentsforeach ($attachments as $filename => $data){ // places all attachments in the directory defined by $aSubject file_put_contents("$aSubject/".$filename, $data);} I must change the filename somehow to that of $ifname so the attachment data gets saved to the modified filename and it isn't as simple as changing $filename to $ifname. Any ideas?
  13. Another realization i had is that, because the script i'm using to replace the src attribute's value of an image tag with that of the filename for the CID element in the MIME headers, once a filename is renamed, the replace will be useless if the file that has been saved has been renamed. So the image tag's src won't be pointing to an actual file anymore
  14. Images are saved using: // process attachments foreach ($attachments as $imageFilename => $data) { // places all attachments in the directory defined by $aSubject file_put_contents("$aSubject/" . $imageFilename, $data); } Will that be an issue or just follow what you suggested?
×
×
  • Create New...