1. PHP_Class_Code::pageList

    Date: 12/24/10     Keywords: php, java

    One of a few things I've put together to help on some projects I've been working on. Hopefully you can make use of this, or tear it to pieces if you think it demonstrates poor coding practices. I've tried to keep the documentation as short and concise as possible.

    This started out as a jQuery plugin, but I prefer to use the PHP one in normal operation rather than populating post-DOM load. The jQuery one has been relegated to creating pages for AJAX calls only.

    My normal output is << First < Previous   7 8 [9] 10 11   Next > Last >> 

        /*    PHP Paginator
            Usage    : $var=new pageList(array('link'=>'http://linktouse.com/index.php?page=#' [,opt page=x [,opt perpage=x [,opt results=x [,opt display=x [,opt javascript=false [,opt regex='/pattern/']]]]]]));
                    : (or) $var=new pageList(array('link'=>'jsfunction("page=#")' [,opt page=x [,opt perpage=x [,opt results=x [,opt display=x [,opt javascript=true [,opt regex='/pattern/']]]]]]));
                    : The # in the link is the default regex for page numbers. If you include a |, for example, be sure to modify the optional regex variable in order for this to work
            Return    : $var->firstPage = «« First
                    : $var->previousPage = « Previous [current-1]
                    : $var->currentPresent = [[current]
                    : $var->nextPage = Next »[current+1]
                    : $var->lastPage = Last »»
                    : $var->previousPresent = [x] (number shown depends on the current page and 'display' variable)
                    : $var->nextPresent = [x] (number shown depends on the current page vs total pages and 'display' variable)
                    : $var->errorMessage = Returns which variable failed. Only present when an error occurs
            Notes    : The link variable is not escaped. Note that on output the link is enclosed in single quotes (').
                    : If using javascript links, use double quotes (") to contain your variables.
        */
       
        class pageList {
            public function __construct($arrayList) {
                $this->defaultConfig=array('page'=>'0','perpage'=>'15','results'=>'15','display'=>'5','link'=>'default','javascript'=>false,'regex'=>'/\#/i');
                $this->numberVariables=array('page','perpage','results','display');
                if($this->verifyConfig($arrayList)) {
                    $this->firstPage='&laquo;&laquo; First'; $this->previousPage='&laquo; Previous'; $this->nextPage='Next &raquo;'; $this->lastPage='Last &raquo;&raquo;';
                   
                    $this->lowerDisplay=(($this->defaultConfig['display']-1)/2); $this->higherDisplay=($this->defaultConfig['display']-1);
                    $this->numberPages=ceil($this->defaultConfig['results']/$this->defaultConfig['perpage']);
                    $this->preCap=$this->defaultConfig['page']; if($this->preCap>$this->lowerDisplay) { $this->preCap=$this->lowerDisplay; }
                    $this->postOffset=($this->higherDisplay-$this->preCap); $this->postOffset=$this->postOffset>(($this->numberPages-1)-$this->defaultConfig['page'])?(($this->numberPages-1)-$this->defaultConfig['page']):$this->postOffset;
                    $this->javascript=''; if($this->defaultConfig['javascript']==true) { $this->javascript='javascript:'; }
                    $this->previousPresent=''; $this->nextPresent=''; $this->currentPresent="[javascript.preg_replace($this->defaultConfig[regex],$this->defaultConfig['page'], $this->defaultConfig['link'])."'>".($this->defaultConfig['page']+1)."]";
                   
                    if($this->defaultConfig['page']>0) {
                        $this->firstPage="javascript.preg_replace($this->defaultConfig['regex'],"0", $this->defaultConfig['link'])."'>".$this->firstPage."";
                        $this->previousPage="javascript.preg_replace($this->defaultConfig['regex'],($this->defaultConfig['page']-1), $this->defaultConfig['link'])."'>".$this->previousPage."";
                        for($i=(($this->defaultConfig['page']-$this->lowerDisplay)-($this->lowerDisplay-$this->postOffset)); $i<$this->defaultConfig['page']; $i++) {
                            if($i>=0) { $this->previousPresent.="javascript.preg_replace($this->defaultConfig['regex'],$i,$this->defaultConfig['link'])."'>".($i+1)."&nbsp;"; }
                        }
                    }
                   
                    if(($this->numberPages-1)>$this->defaultConfig['page']) {
                        $this->lastPage="javascript.preg_replace($this->defaultConfig['regex'],($this->numberPages-1), $this->defaultConfig['link'])."'>".$this->lastPage."";
                        $this->nextPage="javascript.preg_replace($this->defaultConfig['regex'],($this->defaultConfig['page']+1), $this->defaultConfig['link'])."'>".$this->nextPage."";
                        for($i=($this->defaultConfig['page']+1); $i<=($this->defaultConfig['page']+$this->postOffset); $i++) {
                            if($i<$this->numberPages) {  $this->nextPresent.="&nbsp;javascript.preg_replace($this->defaultConfig['regex'],$i, $this->defaultConfig['link'])."'>".($i+1)."";  }
                        }
                    }
                }
            }
           
            public function verifyConfig($arrayList) {
                $this->defaultConfig=array_merge($this->defaultConfig,$arrayList);
                foreach($this->defaultConfig as $key => $value) {
                    if(in_array($key,$this->numberVariables)) { $this->defaultConfig[$key]=intval($this->defaultConfig[$key]); if(is_nan($this->defaultConfig[$key])) { $this->errorMessage=$key.' failed.'; return false; } }
                    else if($this->defaultConfig[$key]=='default') { $this->errorMessage=$key.' failed.'; return false; }
                }
                return true;
            }
        }

    Source: http://webdev.livejournal.com/571905.html

  2. PHP_Class_Code::pageList

    Date: 12/24/10     Keywords: php, java

    One of a few things I've put together to help on some projects I've been working on. Hopefully you can make use of this, or tear it to pieces if you think it demonstrates poor coding practices. I've tried to keep the documentation as short and concise as possible.

    This started out as a jQuery plugin, but I prefer to use the PHP one in normal operation rather than populating post-DOM load. The jQuery one has been relegated to creating pages for AJAX calls only.

    My normal output is << First < Previous   7 8 [9] 10 11   Next > Last >> 

        /*    PHP Paginator
            Usage    : $var=new pageList(array('link'=>'http://linktouse.com/index.php?page=#' [,opt page=x [,opt perpage=x [,opt results=x [,opt display=x [,opt javascript=false [,opt regex='/pattern/']]]]]]));
                    : (or) $var=new pageList(array('link'=>'jsfunction("page=#")' [,opt page=x [,opt perpage=x [,opt results=x [,opt display=x [,opt javascript=true [,opt regex='/pattern/']]]]]]));
                    : The # in the link is the default regex for page numbers. If you include a |, for example, be sure to modify the optional regex variable in order for this to work
            Return    : $var->firstPage = «« First
                    : $var->previousPage = « Previous [current-1]
                    : $var->currentPresent = [[current]
                    : $var->nextPage = Next »[current+1]
                    : $var->lastPage = Last »»
                    : $var->previousPresent = [x] (number shown depends on the current page and 'display' variable)
                    : $var->nextPresent = [x] (number shown depends on the current page vs total pages and 'display' variable)
                    : $var->errorMessage = Returns which variable failed. Only present when an error occurs
            Notes    : The link variable is not escaped. Note that on output the link is enclosed in single quotes (').
                    : If using javascript links, use double quotes (") to contain your variables.
        */
       
        class pageList {
            public function __construct($arrayList) {
                $this->defaultConfig=array('page'=>'0','perpage'=>'15','results'=>'15','display'=>'5','link'=>'default','javascript'=>false,'regex'=>'/\#/i');
                $this->numberVariables=array('page','perpage','results','display');
                if($this->verifyConfig($arrayList)) {
                    $this->firstPage='&laquo;&laquo; First'; $this->previousPage='&laquo; Previous'; $this->nextPage='Next &raquo;'; $this->lastPage='Last &raquo;&raquo;';
                   
                    $this->lowerDisplay=(($this->defaultConfig['display']-1)/2); $this->higherDisplay=($this->defaultConfig['display']-1);
                    $this->numberPages=ceil($this->defaultConfig['results']/$this->defaultConfig['perpage']);
                    $this->preCap=$this->defaultConfig['page']; if($this->preCap>$this->lowerDisplay) { $this->preCap=$this->lowerDisplay; }
                    $this->postOffset=($this->higherDisplay-$this->preCap); $this->postOffset=$this->postOffset>(($this->numberPages-1)-$this->defaultConfig['page'])?(($this->numberPages-1)-$this->defaultConfig['page']):$this->postOffset;
                    $this->javascript=''; if($this->defaultConfig['javascript']==true) { $this->javascript='javascript:'; }
                    $this->previousPresent=''; $this->nextPresent=''; $this->currentPresent="[javascript.preg_replace($this->defaultConfig[regex],$this->defaultConfig['page'], $this->defaultConfig['link'])."'>".($this->defaultConfig['page']+1)."]";
                   
                    if($this->defaultConfig['page']>0) {
                        $this->firstPage="javascript.preg_replace($this->defaultConfig['regex'],"0", $this->defaultConfig['link'])."'>".$this->firstPage."";
                        $this->previousPage="javascript.preg_replace($this->defaultConfig['regex'],($this->defaultConfig['page']-1), $this->defaultConfig['link'])."'>".$this->previousPage."";
                        for($i=(($this->defaultConfig['page']-$this->lowerDisplay)-($this->lowerDisplay-$this->postOffset)); $i<$this->defaultConfig['page']; $i++) {
                            if($i>=0) { $this->previousPresent.="javascript.preg_replace($this->defaultConfig['regex'],$i,$this->defaultConfig['link'])."'>".($i+1)."&nbsp;"; }
                        }
                    }
                   
                    if(($this->numberPages-1)>$this->defaultConfig['page']) {
                        $this->lastPage="javascript.preg_replace($this->defaultConfig['regex'],($this->numberPages-1), $this->defaultConfig['link'])."'>".$this->lastPage."";
                        $this->nextPage="javascript.preg_replace($this->defaultConfig['regex'],($this->defaultConfig['page']+1), $this->defaultConfig['link'])."'>".$this->nextPage."";
                        for($i=($this->defaultConfig['page']+1); $i<=($this->defaultConfig['page']+$this->postOffset); $i++) {
                            if($i<$this->numberPages) {  $this->nextPresent.="&nbsp;javascript.preg_replace($this->defaultConfig['regex'],$i, $this->defaultConfig['link'])."'>".($i+1)."";  }
                        }
                    }
                }
            }
           
            public function verifyConfig($arrayList) {
                $this->defaultConfig=array_merge($this->defaultConfig,$arrayList);
                foreach($this->defaultConfig as $key => $value) {
                    if(in_array($key,$this->numberVariables)) { $this->defaultConfig[$key]=intval($this->defaultConfig[$key]); if(is_nan($this->defaultConfig[$key])) { $this->errorMessage=$key.' failed.'; return false; } }
                    else if($this->defaultConfig[$key]=='default') { $this->errorMessage=$key.' failed.'; return false; }
                }
                return true;
            }
        }

    Source: https://webdev.livejournal.com/571905.html

  3. WebDAV / Exchange 2003 OWA / PHP

    Date: 12/19/10     Keywords: php, html, xml, asp, web, microsoft

    There is very little reference for this anywhere on the internet that I can find. MSDN has the properties listed with what data type the property is expected to be.

    I'm hoping someone here may be able to help? My head has been scratched.

    My three main points of reference are:

        #    Content Classes                http://msdn.microsoft.com/en-us/library/aa486257%28v=EXCHG.65%29.aspx
        #    Content Classes:Message        http://msdn.microsoft.com/en-us/library/aa123730%28v=EXCHG.65%29.aspx
        #    Properties by Namespace        http://msdn.microsoft.com/en-us/library/aa486269%28v=EXCHG.65%29.aspx

    I have also looked at the MAPI references.

    Outgoing mail XML

        xmlns:a=\"DAV:\"
        xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\"
        xmlns:c=\"xml:\"
        xmlns:d=\"urn:schemas:mailheader:\"
        xmlns:e=\"urn:schemas:httpmail:\"
        xmlns:f=\"http://schemas.microsoft.com/mapi/proptag/\"
        xmlns:g=\"http://schemas.microsoft.com/mapi/\"
        xmlns:h=\"http://schemas.microsoft.com/exchange/\"
        xmlns:i=\"urn:schemas-microsoft-com:office:office\"
        xmlns:j=\"urn:schemas:calendar:\"
        xmlns:k=\"http://schemas.microsoft.com/repl/\"
        xmlns:l=\"urn:schemas-microsoft-com:exch-data:\"
        >
       
           
                urn:content-classes:message
                http://localhost/exchange/
                attachment; filename=test.txt
                IPM.Note
                1
                2
                3
                ".$toEmail."
                ".$messageSubject."
                Test email
                test.txt
           

       



    I cannot get the signature, nor the attachment to send. I have tried with/without content-base, content-disposition, attachmentfilename, signaturehtml, signaturetext and autoaddsignature in all combinations.

    1. Is it possible to add signatures to outgoing messages through WebDAV with PHP? If so, how? I could] set the signatures up in my script, but I would like the user to be able to edit them via Outlook Web Access (OWA).

    2. Is it possible to add attachment to outgoing messages through WebDAV with PHP? If so, how? A report will be generated before the mail functions are called. The report will be saved locally (e.g., http://localhost/report/2010-12-19.pdf) and not on the Exchange server (http://server.com/Exchange) -- I assume this is what content-base is for.

    I know there are name spaces in the code that are unused. The emails send fine, but do not come with attachments or signatures.

    Source: http://webdev.livejournal.com/571691.html

  4. WebDAV / Exchange 2003 OWA / PHP

    Date: 12/19/10     Keywords: php, html, xml, asp, web, microsoft

    There is very little reference for this anywhere on the internet that I can find. MSDN has the properties listed with what data type the property is expected to be.

    I'm hoping someone here may be able to help? My head has been scratched.

    My three main points of reference are:

        #    Content Classes                http://msdn.microsoft.com/en-us/library/aa486257%28v=EXCHG.65%29.aspx
        #    Content Classes:Message        http://msdn.microsoft.com/en-us/library/aa123730%28v=EXCHG.65%29.aspx
        #    Properties by Namespace        http://msdn.microsoft.com/en-us/library/aa486269%28v=EXCHG.65%29.aspx

    I have also looked at the MAPI references.

    Outgoing mail XML

        xmlns:a=\"DAV:\"
        xmlns:b=\"urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/\"
        xmlns:c=\"xml:\"
        xmlns:d=\"urn:schemas:mailheader:\"
        xmlns:e=\"urn:schemas:httpmail:\"
        xmlns:f=\"http://schemas.microsoft.com/mapi/proptag/\"
        xmlns:g=\"http://schemas.microsoft.com/mapi/\"
        xmlns:h=\"http://schemas.microsoft.com/exchange/\"
        xmlns:i=\"urn:schemas-microsoft-com:office:office\"
        xmlns:j=\"urn:schemas:calendar:\"
        xmlns:k=\"http://schemas.microsoft.com/repl/\"
        xmlns:l=\"urn:schemas-microsoft-com:exch-data:\"
        >
       
           
                urn:content-classes:message
                http://localhost/exchange/
                attachment; filename=test.txt
                IPM.Note
                1
                2
                3
                ".$toEmail."
                ".$messageSubject."
                Test email
                test.txt
           

       



    I cannot get the signature, nor the attachment to send. I have tried with/without content-base, content-disposition, attachmentfilename, signaturehtml, signaturetext and autoaddsignature in all combinations.

    1. Is it possible to add signatures to outgoing messages through WebDAV with PHP? If so, how? I could] set the signatures up in my script, but I would like the user to be able to edit them via Outlook Web Access (OWA).

    2. Is it possible to add attachment to outgoing messages through WebDAV with PHP? If so, how? A report will be generated before the mail functions are called. The report will be saved locally (e.g., http://localhost/report/2010-12-19.pdf) and not on the Exchange server (http://server.com/Exchange) -- I assume this is what content-base is for.

    I know there are name spaces in the code that are unused. The emails send fine, but do not come with attachments or signatures.

    Source: https://webdev.livejournal.com/571691.html

  5. Ecommerce integration

    Date: 12/10/10     Keywords: ecommerce, hosting

    I’ve been asked to identify an Ecommerce solution for my office.

    Despite what the sales people think (an exaggerating bunch) we’ll likely be low volume, but product prices can range from $5 to $20,000.
    Like something scalable.

    Thought we might use some of the Free/Cheap Solutions (ZenCart PayQuake) offered with our hosting site, but I’m having reservations.

    Quickbooks integration a plus.
    Any and All thoughts on topic would be helpful.  Thanks!

    (A little more information might be helpful-- We only require one storefront, we'll put it on a sub-domain, and we would like reseller and discount/coupon options)

    Source: http://webdev.livejournal.com/570938.html

  6. Ecommerce integration

    Date: 12/10/10     Keywords: ecommerce, hosting

    I’ve been asked to identify an Ecommerce solution for my office.

    Despite what the sales people think (an exaggerating bunch) we’ll likely be low volume, but product prices can range from $5 to $20,000.
    Like something scalable.

    Thought we might use some of the Free/Cheap Solutions (ZenCart PayQuake) offered with our hosting site, but I’m having reservations.

    Quickbooks integration a plus.
    Any and All thoughts on topic would be helpful.  Thanks!

    (A little more information might be helpful-- We only require one storefront, we'll put it on a sub-domain, and we would like reseller and discount/coupon options)

    Source: https://webdev.livejournal.com/570938.html

  7. N00blet soup

    Date: 11/29/10     Keywords: programming, java, web

    Hello!  Long time lurker first time poster.  I am just beginning my adventures with web programming, and am trying to make an application within the Netbeans IDE that says "Hello World!"



    My code is
    package bigjava;   
    public class HelloPrinter
        {
            public static void main(String[] args)
            {
                // Display a greeting in the console window

                  System.out.println("Hello, World!");
            }
        }


    I just created a project called BigJava after the textbook Big Java 3rd edition.  Java is case sensitive and my subfolder is in all lower case.  When I run it the application doesn't have any errors, but it also doesn't print out the "Hello, World" that I desire.

    Any thoughts?  If this isn't appropriate for the community let me know.  Thanks for any advice or thoughts!

    Source: http://webdev.livejournal.com/570056.html

  8. N00blet soup

    Date: 11/29/10     Keywords: programming, java, web

    Hello!  Long time lurker first time poster.  I am just beginning my adventures with web programming, and am trying to make an application within the Netbeans IDE that says "Hello World!"



    My code is
    package bigjava;   
    public class HelloPrinter
        {
            public static void main(String[] args)
            {
                // Display a greeting in the console window

                  System.out.println("Hello, World!");
            }
        }


    I just created a project called BigJava after the textbook Big Java 3rd edition.  Java is case sensitive and my subfolder is in all lower case.  When I run it the application doesn't have any errors, but it also doesn't print out the "Hello, World" that I desire.

    Any thoughts?  If this isn't appropriate for the community let me know.  Thanks for any advice or thoughts!

    Source: https://webdev.livejournal.com/570056.html

  9. Image Resizing / Showing with JavaScript

    Date: 03/12/09     Keywords: java

    So we have a client with a 'vision' for their site. They sell artwork; either in portrait or landscape size. For each, they have several size options, several frame options, and several mat options. They want us to be able to generate images to show the user what they are purchasing.

    Right now I have a functioning bit of JavaScript to show / hide frames, and show / hide mats and I'm just overlaying them on top of the image. But they say that if you switch from say - a 12x16 to say... 10x14 well... that size change has to be reflected in the 'perspective'.

    My boss says they are paying enough that I need to 'do it' and just ignore my grinding teeth - but it's just... how am I going to account for all of these options? They're going to have like, 5 frame options, and 10 mat options (all of these will be standard) that I have to account for... and now they want me to basically double or triple that already large combination by having frame options that are only 'slightly' different for each size option?

    If any of you have done anything similar and could share your wisdom (or booze-inspired jokes) with me I would be forever grateful.

    Source: http://community.livejournal.com/webdev/524546.html

  10. Unreadable emails from html form

    Date: 03/12/09     Keywords: php, browser, html, web

    May I ask for help? I created an html form in Russian. A user is expected to fill out the form (presumably, using some sort of Cyrillic) and the results are emailed to a target person in an html format. Sometimes, the emails are just right. In other cases they are unreadable. What a target person sees in his mailbox looks like this: 

    X-PHP-Script: www.mysite.net/myscript.php for 213.87.87.151
    From: Mywebsite
    MIME-Version: 1.0
    Content-Type: multipart/mixed; boundary=6e08630ddf04bdc61a715d0d0bad61dd
    Message-Id: <E1LhQ7J-00051B-P0@srv19.000webhost.com>
    Date: Wed, 11 Mar 2009 08:13:09 -0700
    X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
    X-AntiAbuse: Primary Hostname - srv19.000webhost.com
    X-AntiAbuse: Original Domain - gmail.com
    X-AntiAbuse: Originator/Caller UID/GID - [99 99] / [47 12]
    X-AntiAbuse: Sender Address Domain - srv19.000webhost.com

    --6e08630ddf04bdc61a715d0d0bad61dd
    Content-Type: text/html; charset=windows-1251
    Content-Transfer-Encoding: 8bit




    windows-1251' />


    Browser: IE 7.0

    OS: Win

    &#1050;&#1072;&#1082; &#1091;&#1079;&#1085;&#1072;&#1083;&#1080; &#1087;&#1088;&#1086; &#1089;&#1072;&#1081;&#1090;: Internet search





    &#1050;&#1086;&#1085;&#1090;&#1072;&#1082;&#1090;&#1085;&#1072;&#1103; &#1080;&#1085;&#1092;&#1086;&#1088;&#1084;&#1072;&#1094;&#1080;&#1103;


    Èìÿ ðîäèòåëÿ: Íàòàëüÿ

    Ãîðîä: Âëàäèìèð

      




    --6e08630ddf04bdc61a715d0d0bad61dd

    This is instead of a decent html file that comes in other cases. I am able to decode it using charset.ru. However, it's still annoying. These kinds of emails come from any browsers and both Mac and Win. What might be the reason? Thank you!

    Source: http://community.livejournal.com/webdev/524369.html

  11. PHP page issues?

    Date: 03/11/09     Keywords: php, css, html, asp, java, web

    Hi, so I run a site here and it's been... well, going swimmingly for the past couple of years, but for some reason, all of the PHP pages stopped working a couple of days ago - as in, every time I try to access a page with a .php extension, I get a "The page cannot be found" error. However, I can access most other extensions - my index page ends with a .html, so that works, plus I can get to my style.css and javascript.js pages, along with my image files. But if I log in with FTP, all my .php files are still there, and if I open one up its content is still there as well.

    I also haven't updated the site since the end of January, and I don't think my host has done anything either, so nothing we did could have triggered it.

    Furthermore, I uploaded a test file onto the site and discovered that in addition to .php extensions, .phtml and .xhtml files didn't work either, though .html, .asp, .txt, and everything else I tried did.

    Anyone have an idea as to what might be happening? With the exception of my index page, all of my other web pages end with .php, so... this is kind of an inconvenience, to say the least. D: Thanks!

    Source: http://community.livejournal.com/webdev/523875.html

  12. Free website magazine

    Date: 03/11/09     Keywords: web

    Free website magazine TO QUALIFY FOR A FREE SUBSCRIPTION, YOU (or your company) MUST HAVE AN ACTIVE WEB SITE.

    Source: http://community.livejournal.com/webdev/523766.html

  13. Firefox / CSS / JavaScript / Printing

    Date: 03/09/09     Keywords: css, html, xml, java

    I have an XSL transform that turns an XML document into HTML. There is a div that contains data and scrolls by using CSS: overflow: auto;. When printing or when JavaScript is disabled, I would like to simply display the contents: overflow: visible;. However,

    This works for printing, but not when JavaScript is disabled.

    My next thought was to use JavaScript, something along these lines: