Jump to content

theinfamousmielie

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Posts posted by theinfamousmielie

  1. Hi there, thanks for the response :)

     

    I think you may have misunderstood me, the sessions are being set just fine, and they last, just as expected (i set it to 3600 seconds ... 1 hour) but i want to know if i can keep resetting it every time a script is accessed, thus granting a further 3600 seconds of 'idle time'.

     

    At the moment, i start off with

     

    session_set_cookie_params(3600);
    session_start();
    

     

    and any scripts that launch 'applications' via AJAX just use session_start(); which mostly seems to get ignored.

     

    But have no fear, i've decided that for the sake of my sanity and the stupidity of users, i'm going to have infinite sessions. I must just make sure that they cannot be hijacked.

  2. Hi all,

     

    This may be a very very stupid question

     

    I have an AJAX-based site going, with one page refresh, and naturally I use sessions. But the problem is that after x amount of time, the session expires. Which is good, except that on an AJAX based site I can't 'keep the session alive' by going to different pages all the time. even though every 10 minutes i check for messages with a PHP script (one of many) it doesn't see it as activity and as such the session expires.

     

    Any suggestions on how i can keep renewing the session every x minutes, or every time a script is executed? Or whether or not i can check if a session has expired and have access to what WAS in the session and reset it again?

     

    A friend of mine said something about using time() and the Epoch, which i know about but i dont quite see how it's going to help. It can tell me if a session is about to expire, but then what, how do i 'restart' it while keeping all the values?

     

    Any help would be handy. :) :)

  3. Okay, yet another insurmountable one to tease your brains.

     

    Before I start, you should know that I _COULD_ extend the entire class, but that would defeat my purpose of 'simplifying' for the novice developer. Anyway ... here goes.

     

    As it stands i have a PDF controller which does its thing very well in acting as the middleman to PEAR's File_PDF class.

     

    However, it is not acting as an 'extended' class, it is its own class. The core function: CreateDocument() does the following:

    $this->PDFLink = &File_PDF::factory(array('orientation' => $Orientation, 'unit' => $this->Unit, 'format' => $this->PageSize), $this->ExtensionClass); 
    

     

    okay so this is fine, and works well on every single thing except where i need to override a function as originally defined in PEAR's PDF class (File_PDF)

     

    The two functions in particular? header() and footer() ...

     

    Is there a way for me to extend in such a way as that i have the ability to 'redefine' the header() and footer() functions in a way similar to below:

     

    //$PDF = new PDFController; // my 'middleman' pdf controller
    
    class MyPDF extends PDFController {  // PDFController does not extend to anything but instead calls File_PDF::factory() within one of it's functions.
    
        function header() {
            //overwrites PEAR function defined in File_PDF class
        }
    
    }
    
    $PDF = new MyPDF;
    $PDF->CreateDocument();
    $PDF->AddPage(); // adds a page with included styles etc from header() and footer() functions
    

     

    Any ideas? I realise this could be impossible, but you never know, someone might know something i dont. :)

  4. Won't be any of those :)

     

    Essentially, it's for a content management / templating type system.

     

    The main table, which contains the layout and other information (the Content) table has reference to a layout file and menu items and where it sits in the site tree etc etc. The table that holds the VARCHAR/TEXT field in question is almost like an interlinking table so as such we're referencing it by an ID 99% of the time. So this table has three columns. ContentID (which references it to a particular 'page'), FieldVariable (which contains the variable used in the template which will be searched for and replaced with the actual data) and FieldData ... which is the field in question.

     

    My replacement query will be something like "SELECT FieldData FROM _ContentData WHERE ContentID = 1 AND FieldVariable = '##REPLACEME##' " - which should be quick and clean, regardless of data type.

     

    Having said that, this may not be the most efficient way of doing it ... it's still very much in prototype. But does it make sense, and with that in mind, does the memory thing even matter? (the only time the FieldData column is referenced is in a FullText search if needed)

  5. Hi Fenway,

     

    Aaah okay. Well you learn something (simple) every day! hehehe.

     

    Unfortunately, while the majority of data going into that field will be well under 65k characters, there will be a need to store more information occasionally, perhaps a very long html page, or large XML document. Is the benefit gained so great that i should essentially say 'tough luck' to content larger than 65k characters? or should i stick with MEDIUMTEXT ?

     

  6. Hey all,

     

    I'm trying to find out which is the most memory efficent (and therefore server-friendly) datatype to use for a text field that could have between 1 and several million characters. It's for content storage on a content-management system, so the majority of information would probably be less than 65535 characters (page titles, headings, etc) but i still need to be able to store large amounts of data if need be.

     

    Currently using 'MEDIUMTEXT'. ;D total overkill for now ... but i'm trying to futureproof and cover all bases.

     

    Any ideas?

  7. i did that ... started with basics. Everything fine until i added the image section

     

    <?php
    --AuroraMail-SubSection-{$sep}
    Content-Type image/jpeg; name="dvd.jpg"
    Content-Transfer-Encoding: base64
    Content-ID: <AM_IMG_{$sep2}>
    Content-Disposition: inline; filename="dvd.jpg"
    
    {$image1}
    
    --AuroraMail-SubSection-{$sep}--
    ?>
    

     

    technically, the mail works fine. I receive it fine, it just gets a 5.7 spam rating ... without the image, it gets 3! Since this is supposed to be attached to website contact forms, i'd really like it if mailservers wouldn't block simple non-spam website enquiries :(

     

    I think it's a spamassassin problem though, i guess i'll have to try find a way to get to them to find out exactly what it's expecting and why what i have isn't registering. I find it very strange that the error disappears when that image section is removed ... it isn't a header! THAT is what's confusing me, and that is why i think there's something wonky with spamassassin. Oh well.

     

    I seem to run into problems like this a lot ;)

     

    Thanks for your help mate, i've put it on notify if you think of anything else don't hesitate, hehe.

  8. regrettably, that doesn't work.

     

    I don't normally use heredoc either, but for this particular form, it is just neater and easier to read and does the job.

     

    I'm just trying to understand why, when there is clearly a blank line between the header and the body (i output to see the results in a var_dump of sorts) ... i've provided a link to the relevant portion here ... it's a vardump in <pre></pre> tags.

     

    http://www.digiworks.co.za/xSandbox/testmail4.php - blue is the output of the controller BEFORE the body is parsed, and the green is the contents of $Mail->Body

     

     

    Any thoughts?

  9. Hi all,

     

    Trying to make a multi-part email. In general it's fine, but i've also been running it through SpamAssassin (and others) to make sure it comes out all clean and shiny ... or as clean and shiny as possible. Here's the code, and i'll explain the problem afterwards.

     

    <?php
    // IN CLASS  FILE (as a part of two functions, which work okay on their own):
    // ====================
    $this->AddHeader("Content-Type", "multipart/mixed; boundary=\"AuroraMail-Mixed-" . $this->MailKey . "\""); // writes to $this->Headers
    
    $this->Headers = trim($this->Headers);
    $this->Headers .= $this->EndOfLine . $this->EndOfLine;
    
    
    // IN MAIN FILE
    // ====================
    $sep = $Mail->MailKey;  // Key generated randomly, this works fine
    $sep2 = sha1("dvd.jpg"); // excuse the dodgy naiming of variables, hhehe
    $image1 = chunk_split(base64_encode(file_get_contents('dvd.jpg')));
    
    $Mail->Body = <<<EOBODY
    --AuroraMail-Mixed-{$sep}
    Content-Type: multipart/alternative; boundary="AuroraMail-Section-{$sep}"
    
    --AuroraMail-Section-{$sep}
    Content-Type: text/plain; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit
    
    In summary, we should be giving serious consideration to image-blocking and what we can do about it. It’s natural and reasonable why people disable them, but with the right approach we can improve the experience for our subscribers
    
    I have setup SA 3.1 under FC4, which is working quite well. However, one type of message that still gets through is a series of mails that are made up of no text other than a varying subject, then a picture, which is black text on white, which looks exactly like an ordinary email. Obviously SA can't read the message since it is an image, but is there a way to make a rule that blocks a mail where there is an image only, no text?
    
    So we’ve created a structurally-sound template, we’re preparing to send our email to a permission-based list of subscribers and we’ve taken steps to see our list email-address into the address books of the said subscribers. There are still a number of people on our lists who will intentionally block images, and therefore we should account for that scenario.
    
    --AuroraMail-Section-{$sep}
    Content-Type: multipart/related; boundary="AuroraMail-SubSection-{$sep}"
    
    --AuroraMail-SubSection-{$sep}
    Content-Type: text/html; charset="iso-8859-1"
    Content-Transfer-Encoding: 7bit
    
    <h2>Hello!</h2>
    <p>In summary, we should be giving serious consideration to image-blocking and what we can do about it. It’s natural and reasonable why people disable them, but with the right approach we can improve the experience for our subscribers</p>
    <p>I have setup SA 3.1 under FC4, which is working quite well. However, one type of message that still gets through is a series of mails that are made up of no text other than a varying subject, then a picture, which is black text on white, which looks exactly like an ordinary email. Obviously SA can't read the message since it is an image, but is there a way to make a rule that blocks a mail where there is an image only, no text?</p>
    <p>So we’ve created a structurally-sound template, we’re preparing to send our email to a permission-based list of subscribers and we’ve taken steps to see our list email-address into the address books of the said subscribers. There are still a number of people on our lists who will intentionally block images, and therefore we should account for that scenario.</p>
    
    <img src="cid:AM_IMG_{$sep2}">
    
    --AuroraMail-SubSection-{$sep}
    Content-Type image/jpeg; name="dvd.jpg"
    Content-Transfer-Encoding: base64
    Content-ID: <AM_IMG_{$sep2}>
    Content-Disposition: inline; filename="dvd.jpg"
    
    {$image1}
    
    --AuroraMail-SubSection-{$sep}--
    
    --AuroraMail-Section-{$sep}--
    
    --AuroraMail-Mixed-{$sep}--
    EOBODY;
    ?>
    

     

     

    That should cover it. Here's the thing. The mail sends fine. Everything works, and if i add on an attachment too, it works perfectly. The problem is actually linked with SpamAssassin, as well as the RFC guidelines possibly. Maybe someone has run into this:

     

    According to SpamAssassin, i have the following problem: MISSING_MIME_HB_SEP

     

    According to SpamAssassin, there is a need for a blank line inbetween the headers and the message ... but there is!! But this isn't where it's weird ... the moment i take out the entire 'image attachement', the problem goes away, or if i change:

     

    <?php
    --AuroraMail-SubSection-{$sep}
    Content-Type image/jpeg; name="dvd.jpg"
    Content-Transfer-Encoding: base64
    Content-ID: <AM_IMG_{$sep2}>
    Content-Disposition: inline; filename="dvd.jpg"
    
    {$image1}
    
    --AuroraMail-SubSection-{$sep}--
    ?>

     

    to

     

    <?php
    --AuroraMail-SubSection-{$sep}
    
    Content-Type image/jpeg; name="dvd.jpg"
    Content-Transfer-Encoding: base64
    Content-ID: <AM_IMG_{$sep2}>
    Content-Disposition: inline; filename="dvd.jpg"
    
    {$image1}
    
    --AuroraMail-SubSection-{$sep}--
    ?>

     

    the problem goes away ... but then the image doesn't show. Catch 22!

     

    Does anyone have any ideas? Is my formatting correct?

     

    I've spent several hours pondering this, it's frustrating me to no end.

     

    By the way, all my end-of-line characters are /n, as the script sits on a linux box.

     

    :)

  10. Hey all,

     

    Curious question. This is the query i'm running:

     

    SELECT
    Client.Name,
    Count(Campaign.CampaignID) AS CampaignCount,
    Count(Content.ContentID) AS ContentCount,
    Max(Content.UploadDT) AS LastUpload
    FROM (Client LEFT JOIN Content ON Client.ClientID = Content.ClientID) LEFT JOIN Campaign ON Client.ClientID = Campaign.ClientID
    GROUP BY Client.Name

     

    And this is the result i'm getting:

     

    +-----------------------+---------------+--------------+---------------------+
    | Name                  | CampaignCount | ContentCount | LastUpload          |
    +-----------------------+---------------+--------------+---------------------+
    | Digiworks             |             0 |            0 | NULL                |
    | John Smith Industries |             0 |            0 | NULL                |
    | Pfizer                |             6 |            6 | 2008-06-16 17:26:56 |
    | Playback              |             0 |            0 | NULL                |
    +-----------------------+---------------+--------------+---------------------+

     

     

    ... the problem is: there are only 3 content items, and 2 campaigns ;) 3 * 2 = 6, but why it's returning both 6 for CampaignCount and ClientCount is beyond me. Any ideas? Is it a 'group by' problem?

  11. Hi all,

     

    I have a question - and it may seem stupid ... i am working on a project which involves the transfer of video files from a users computer to an FTP server. Using PHP's FTP commands in the class that i've written, i can upload the file to the FTP server (which is NOT the server where the script or web control panel is sitting)

     

    I need to know if there's a way that i can use PHP on Machine X to access the files from the Client machine (without uploading to Machine X) and transfer to Machine Y (the FTP server) - as far as i know this isn't possible

     

    Please ... help! lol  ;)

  12. Heya,

     

    Yeah the images did come through. I use a program called PostCast Server ... google it and download it, it's free ... you can then use your 'localhost' as an SMTP server, but you can preview the messages before you actually 'send' them. I did that on my side and it found the images. outlook express might be having a fit about it, but try sending your messages to a gmail or yahoo account ... see what that does?

     

    if all else fails, check my last posting under 'MY STUFF' for my email address and email me ... ;) i'll certainly let you know! hehe

  13. Okay dude, i've got it working on my side :) I made several (minor) changes:

     

    just remove the 'my stuff' with whatever hehehe

     

    <?php
    // ==== MY STUFF ====
    $merc_messageTitle = "this is a message!";
    $merc_mailingList = "david@digiworks.co.za";
    // ==================
    
    
    $image = "";
    $web_image_folder = 'http://www.acmeart.co.uk/mercury/image/thumbs';
    $exts = array('jpg', 'png', 'gif', 'jpeg');
    $image_name = 'thumb_image1';
    
    
    // check for each extension
    foreach($exts as $ext) {
       if (file_exists($web_image_folder.'/'.$image_name.'.'.$ext)) {
         $image = $image_name.'.'.$ext;
       }
    }
    
    // check if we have an image
    if ($image != "") {
        // ok we have the image
        $broad_img1='<img src="' . $web_image_folder."/".$image . '" />';
    } else {
        // error, we can't find the image.
    }
    
    
    // construct mailing list array
    $merc_list = explode(",",$merc_mailingList);
    
    // deploy the emails
    for($i=0; $i<count($merc_list); $i++){
    $message = '<style type="text/css">body {	margin: 0;	background: ;	background-image: url();	background-repeat: no-repeat;
    } .mainTxt {font-size: 11px; color:#444444; font-family: Arial, Helvetica, sans;} .whiteTxt {font-size: 9px; color:#FFFFFF; font-family: Arial, Helvetica, sans;} a:link {color:#EB7324} ul {font-size: 9px; color:#EB7324;padding-left: 5px;}
    .style3 {font-family: Geneva, Arial, Helvetica, sans-serif; color: #FFFFFF; font-weight: bold; }
    .style1 {font-family: Arial, Helvetica, sans-serif;	font-size: 10px;color: #666666;}
    </style>';
    
    $message .= '<body leftmargin="0" topmargin="0">
    <table width="900" border="0" align="center" cellpadding="0" cellspacing="5">
        <tr>
            <td height="95" colspan="2" scope="col"><img src=http://www.acmeart.co.uk/mercury/layout/BroadsheetSample/broadhead.jpg width="900" height="150"/></td>
        </tr>
        <tr>
            <td height="25" colspan="2" scope="col"><span class="mainTxt"><strong>' . $broad_topictitle1 . '</strong></span></td>
        </tr>
        <tr>
            <th width="23%" height="200" scope="col"><div align="left">' . $broad_img1 . '
    	<p> </p></div></th>
            <td width="77%" scope="col"><table width="99%" border="0" cellpadding="10" cellspacing="0">
                <tr>
                    <td align="left" valign="top"><span class="mainTxt">' . $broad_messagebody1 . '</span></td>
                    <!-- End Image 1 -->
                </tr>
            </table>
            <p>Test Email hahaha</p>
            <p> </p>
            <p>I\'m sooooo clever! </p>
            <p> </p></td>
        </tr>
        <tr>
            <td colspan="2" scope="col"><img src="http://www.acmeart.co.uk/mercury/layout/BroadsheetSample/broadfoot.jpg" width="900" height="150" /></td>
        </tr>
        
        <tr>
            <td height="13" colspan="2" scope="col"><div align="justify"><span class="style1">Linacre Voice is a monthly bulletin from LinacreOne Community Partnership 140-142 Linacre Road Litherland L21 8JU Tel: (0151) 922 4898 Open Monday - Thursday 10:00am - 4:00pm <font size="1"></font></span> </div></td>
        </tr>
    </table>
    </table>
    </body>';
    
    
    
    // Contacts
    //$replyName = $merc_replyId;
    //$replyEmail = $merc_replyAddress;
    
    $replyName = "";
    $replyEmail = $merc_list[$i];
    
    $contactname = "";
    $contactemail = $merc_list[$i];
    
    // Subject
    $subject = $merc_messageTitle;
    
    // Headers
    $headers = "From: ".$replyName." <".$replyEmail.">" . PHP_EOL;
    $headers .= "To: ".$contactname." <".$contactemail.">" . PHP_EOL;
    $headers .= "MIME-Version: 1.0" . PHP_EOL;
    $headers .= "Content-type: text/html; charset=iso-8859-1" . PHP_EOL;
    
    
    if (mail($contactemail, $subject, $message, $headers)) {
    	echo "Success!! Yay!!";
    } else {
    	echo "Boooooo it failed!";
    }
    
    } // END for
    
    ?>
    

     

    You'll notice the PHP_EOL for platform-independant newlines (yay!) and i've changed the way your message is constructed ... no more escaping " :) looks neater yes?

  14. Hmm ... well i know it wouldn't like the missing www (well, more accurately it won't know how to properly interpret the single . - but i stand to be corrected!)

     

    Give me some time with it, i'll pore over the code with a fine-toothed comb.

     

     

     

    Trust me, seemingly insurmountable problems are always the result of a missing bloody comma :P

×
×
  • 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.