Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
N

Niall Barr

@Niall Barr
About
Posts
178
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • World War Z
    N Niall Barr

    It is quite weird seeing familiar streets with totally unfamiliar skyscrapers and bridges in the background. Zombies are quite normal however.

    The Lounge com question

  • War on science?
    N Niall Barr

    The geologists said an earthquake was unlikely, but possible. They did not advise people to stay indoors. The majority of the people who gave that advice were not put on trial.

    The Lounge question announcement

  • hi evry body(i need expord doc with html)
    N Niall Barr

    You should look into headless openoffice

    Linux, Apache, MySQL, PHP html help

  • free cloud hosting for testing purpose
    N Niall Barr

    Yes, EC2 does support .NET, but not on the free tier. The cost can be very low if you only run the server for occasional tests, but is similar to a conventional hosted VM if you need it running all the time.

    Cloud Computing hosting cloud testing beta-testing help

  • determine page title
    N Niall Barr

    The usual approach would be to look for the first heading tag using preg_match. You could also look for the tag. <meta> elements are usually only useful if you're looking at pages where you know that metadata has been added, and know the metadata profile that has been followed.</x-turndown>

    Linux, Apache, MySQL, PHP question php

  • signature_invalid in Google API
    N Niall Barr

    You need to be very careful while doing this sort of thing - any little errors are going to break it, and can be hard to track down. A few I've spotted are:

    • You have the 'scope' parameter out of sequence when building the data to sign. Data must be ordered alphabetically by key for the oauth signature to be correct.
    • You use "GET" as a parameter for calculateBaseString although you're using POST
    • You miss out the & delimiter when adding the oauth_signature
    • You call curl_setopt($ch, CURLOPT_POSTFIELDS twice, overwriting the OAuth signed data with a single parameter.

    It's very possible there are other errors I've not spotted. Niall

    Linux, Apache, MySQL, PHP help com data-structures cryptography json

  • Creating file headers in php.
    N Niall Barr

    This bit of code shows you how to write an integer to an ASCII text file, then (as a four byte long) to a binary file. The key thing is that pack is used to convert the integer into a character array equivalent to its binary representation before writing it. The default behavior of PHP when writing variables to a file is to convert them to strings.

    Linux, Apache, MySQL, PHP php help question

  • Creating file headers in php.
    N Niall Barr

    If you really need to work with binary files in PHP you need to use the pack and unpack functions, along with the C like file functions (fopen, fseek, fread etc.), however if you need to work with binary files you probably really need to consider whether PHP is an appropriate language for your application. Niall

    Linux, Apache, MySQL, PHP php help question

  • uploading file via post
    N Niall Barr

    It occured to me that it's likely that the site you're posting to expects an attached file rather than the file content in a post field called file... If that's the case, then this code should work.

    Linux, Apache, MySQL, PHP php com agentic-ai data-structures help

  • uploading file via post
    N Niall Barr

    I think the only issue was the amount of memory available to PHP on my dev box. I tried with a file that was too big for it. Are you able to get the other post data transferred if you comment out the file_get_contents line? Niall

    Linux, Apache, MySQL, PHP php com agentic-ai data-structures help

  • uploading file via post
    N Niall Barr

    No - that works on my system, as long as the CSV file isn't too big. (OK with 150k, not with 30M) This is the version of your code I tried out.

    <?php
    function datapost($URLServer,$postdata)
    {

    $agent = "Mozilla/5.0";
    $cURL\_Session = curl\_init();
    curl\_setopt($cURL\_Session, CURLOPT\_URL,$URLServer);
    curl\_setopt($cURL\_Session, CURLOPT\_USERAGENT, $agent);
    curl\_setopt($cURL\_Session, CURLOPT\_HTTPGET, FALSE);
    //curl\_setopt($cURL\_Session, CURLOPT\_POST, 1);
    curl\_setopt($cURL\_Session, CURLOPT\_POSTFIELDS,$postdata);
    curl\_setopt($cURL\_Session, CURLOPT\_RETURNTRANSFER, 1);
    curl\_setopt($cURL\_Session, CURLOPT\_FOLLOWLOCATION, 1);
    $result = curl\_exec($cURL\_Session);
    
    return $result;
    

    }

    $postdata = array();
    $postdata\['Id'\] = '12340';
    $postdata\['profileName'\] = 'tsunami';
    $postdata\['file'\] = file\_get\_contents('http://localhost/tmp/test.csv');
    
    $postdata\['submit'\] = urlencode('submit');
    
    $source= datapost("http://localhost/tmp/posthere.php",$postdata);
    
    echo $source;
    

    ?>

    My test posthere.php is

    Linux, Apache, MySQL, PHP php com agentic-ai data-structures help

  • uploading file via post
    N Niall Barr

    Hi, You need to set CURLOPT_HTTPGET to false explicitly - the PHP documentation doesn't make this clear. curl_setopt($cURL_Session, CURLOPT_HTTPGET, FALSE); Niall

    Linux, Apache, MySQL, PHP php com agentic-ai data-structures help

  • Old calculators...
    N Niall Barr

    I think I bought my HP 11 in 1987 - currently on it's second set of batteries I think.

    The Lounge css help tutorial question

  • Exporting HTML file to PDF format
    N Niall Barr

    You could look into using OpenOffice.org headless. There are also some PHP libraries for writing PDF - http://www.fpdf.org/[^] is one that doesn't need any extensions installed.

    Linux, Apache, MySQL, PHP question php html help

  • imap_search problem
    N Niall Barr

    I'm surprised that works at all - POP3 and IMAP are quite different. I don't think a POP3 server keeps any information on which messages are read however, so unless you have IMAP mailboxes configured on the server you will just get a list of all messages.

    Linux, Apache, MySQL, PHP help data-structures

  • imap_search problem
    N Niall Barr

    I'm afraid I don't know much about IMAP servers, so can't help there. Niall

    Linux, Apache, MySQL, PHP help data-structures

  • imap_search problem
    N Niall Barr

    Your code looks OK - could it be something strange about the server configuration? I just tried this code to get IMAP unread numbers from our exchange server and it worked fine.

    <?php
    $himap = imap_open ('{some.server.ac.uk:143}INBOX', 'username', 'password');

    $result = imap_search ($himap, 'UNSEEN');

    if(is_array($result))
    {
    foreach ($result as $value)
    {
    echo "Unseen message number $value<br/>";
    }
    }
    else
    echo 'No unseen messages';
    ?>

    Linux, Apache, MySQL, PHP help data-structures

  • Friday's CCC
    N Niall Barr

    listless A synonym for languid a boat that isn't listing would be vertical register = list, so without a register = listless

    The Lounge question

  • Programming Question: C++ Builder String
    N Niall Barr

    Many years ago I ported an app from Turbo C++ to VC++ - one quirk of Turbo was that it had a class that encapsulated Pascal style strings where the first character of the structure is the string length, so the actual string starts at offset 1 (and is limited to 255 characters).

    The Lounge c++ question visual-studio announcement career

  • Friday's easy CCC
    N Niall Barr

    Thank you

    The Lounge
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups