Thread: php help needed

Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2006
    Location
    Kihikihi, New Zealand
    Posts
    230
    Plugin Contributions
    3

    Default php help needed

    Hi all,

    I have recently written a live support module for Zen Cart, using Skype.
    This was an easy mod, as Skype returns all what is needed to publish the status online.

    However, as the images used are from another server, it gives a warning on https. So now I am rewriting this mod.

    The concept is easy:
    1. Call a file from Skype with status info
    2. Read the file contents
    3. Use the results to display status (online/offline)


    But as a newbie (wannabe maybe....LOL) programmer I have not been able to read the contents of the file, and turn it into a if/else statement. Now it does just display "offline" all the time, even if you are "online"

    Code:
    <?php
      $content = '';
      $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent centeredContent">' . "\n" ;
      $filename = "http://mystatus.skype.com/, SkypeUserName.num";
      $status = file_get_contents($filename);
    //  $result = include($filename);
        if ($result=='2')
    	$content .= '<a href="skype:SkypeUserName?call"><img src="./images/skype/online.gif" style="border: none;" width="140" height="56" alt="Available" /></a>';
    	else	
    	$content .= '<img src="./images/skype/not_online.gif" style="border: none;" width="140" height="56" alt="Not Available" />';
      $content .= '</div>';
    ?>
    The SkypeUserName.num file contains just one line, with digits (0, 1, 2, 3, 4, 5, 6). Digit "2" means that the user is online, so that is why ($result=='2') is used.

    The same file could be called as SkypeUserName.text which returns one line with one word, or as SkypeUserName.xml.

    Can anyone tell me how to get "$result =" to read the contents?.

    The results of the above code can be seen here

    Once I have this portion of the code working, I will attempt to create a menu in manager to fill in "SkypeUserName" so no one needs to edit any code during install.

    Many thanks,

    Goshawk
    Time is but an illusion, there is only "now"!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: php help needed

    try changing this:
    Code:
      $status = file_get_contents($filename);
    //  $result = include($filename);
        if ($result=='2')
    to this:
    Code:
      $status = file_get_contents($filename);
      $result = substr($status, 1, 1); // to read 1 character starting at the 2nd position (0 = first position)
        if ($result=='2')
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Aug 2006
    Location
    Kihikihi, New Zealand
    Posts
    230
    Plugin Contributions
    3

    Default Re: php help needed

    Thank you for your reply DrByte,

    Unfortunately neither code "$result = substr($status, 1, 1);" nor "$result = substr($status, 1, 0);" does work.

    I spend a whole day browsing through PHP material trying to find an answer, but no avail as yet.

    Goshawk
    Time is but an illusion, there is only "now"!

  4. #4
    Join Date
    Jan 2004
    Posts
    66,373
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: php help needed

    add a line before the IF to see what data you're really getting:
    Code:
    echo $result;
    or maybe this would be more appropriate so it shows in the sidebox
    Code:
    $content .= 'results: ' . $result;
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Aug 2006
    Location
    Kihikihi, New Zealand
    Posts
    230
    Plugin Contributions
    3

    Default Re: php help needed

    I do not get a response with:
    Code:
    http://mystatus.skype.com/, SkypeUserName.num http://mystatus.skype.com/SkypeUserName.num 
    http://mystatus.skype.com/, SkypeUserName.xml  http://mystatus.skype.com/SkypeUserName.xml
    But I do with:
    Code:
    http://mystatus.skype.com/, SkypeUserName.txt http://mystatus.skype.com/SkypeUserName.txt
    This returns:
    Code:
    Warning: file_get_contents(http://mystatus.skype.com/, SkypeUserName.txt): failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable in /home/content/....../sideboxes/tpl_SkypeLive.php on line 16
    Warning: file_get_contents(http://mystatus.skype.com/SkypeUserName.txt): failed to open stream: HTTP request failed! HTTP/1.1 406 Not Acceptable in /home/content/......./sideboxes/tpl_SkypeLive.php on line 16
    While if I type http://mystatus.skype.com/SkypeUserName.num in my browser, I get:
    Code:
    2
    If I type: http://mystatus.skype.com/SkypeUserName.txt, I get:
    Code:
    Not Available
    Which is strange, as I am available and was expecting "online"
    And if I type: http://mystatus.skype.com/SkypeUserName.xml, I get:
    Code:
    −<rdf:RDF>
    −<Status rdf:about="urn:skype:skype.com:skypeweb/1.1">
    <statusCode rdf:datatype="http://www.skype.com/go/skypeweb">4</statusCode>
    <presence xml:lang="NUM">4</presence>
    <presence xml:lang="en">Not Available</presence>
    <presence xml:lang="fr">Pas disponible</presence>
    <presence xml:lang="de">Nicht verf&#252;gbar</presence>
    <presence xml:lang="ja">退席中</presence>
    <presence xml:lang="zh-cn">離開</presence>
    <presence xml:lang="zh-tw">没空</presence>
    <presence xml:lang="pt">Indispon&#237;vel</presence>
    <presence xml:lang="pt-br">N&#227;o dispon&#237;vel</presence>
    <presence xml:lang="it">Non al computer</presence>
    <presence xml:lang="es">No disponible</presence>
    <presence xml:lang="pl">Niedostępny</presence>
    <presence xml:lang="se">Ej tillg&#228;nglig</presence>
    </Status>
    </rdf:RDF>
    Which is strange too, as I am available en it should have returned "<presence xml:lang="NUM">2</presence>

    Does this sound like the Skype API is acting up?

    ******Oops, the strange status codes have been due to my browser cache, as after refresh it displays the correct status*******
    Last edited by Goshawk; 1 Sep 2007 at 01:31 AM. Reason: More information added
    Time is but an illusion, there is only "now"!

  6. #6
    Join Date
    Aug 2006
    Location
    Kihikihi, New Zealand
    Posts
    230
    Plugin Contributions
    3

    Default Re: php help needed

    After further investigation in this problem, I have found out that the Skype API is not fully compatible with PHP4. Due to difficulties reading files from a COM server. I will see if I can find a work around using VB or JavaScript.
    I will get this module updated when Zen cart moves to PHP5.
    Time is but an illusion, there is only "now"!

 

 

Similar Threads

  1. v151 tpl_ezpages_bar_header.php help needed.
    By charles.persinger in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 30 Nov 2013, 10:34 PM
  2. v139h Help Needed With order.php
    By traytray in forum General Questions
    Replies: 9
    Last Post: 14 Feb 2013, 11:02 PM
  3. Help needed after updating PHP 5.3
    By SlimMoses in forum General Questions
    Replies: 3
    Last Post: 1 Mar 2010, 12:11 PM
  4. PHP help needed - custom form
    By Goshawk in forum General Questions
    Replies: 0
    Last Post: 13 Mar 2008, 06:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR