Skip to content

Instantly share code, notes, and snippets.

View pierrejoye's full-sized avatar

Pierre Joye pierrejoye

  • Thailand
View GitHub Profile
@pierrejoye
pierrejoye / curl ftps async upload
Created April 21, 2011 11:58
Upload a dir content asynchronously to a ftps using curl and php
<?php
$src_dir = '/some/local/directory';
$curl = array();
$ftpserver = 'ftp.example.com';
$ftp_path = "/remotedirectory";
$ftp_user = 'johndo';
$ftp_password = 'foobar';
$mh = curl_multi_init();
running 10x random bytes:
g:\php-sdk\php53\vc9\x86\php53>Release_TS\php -n -d extension_dir=release_ts -d extension=php_openssl.dll 51636.php
float(3.6231460571289)
bool(true)
g:\php-sdk\php53\vc9\x86\php53>g:\test\php536vc9x86ts\php -n -d extension_dir=release_ts -d extension=php_openssl.dll 51636.php
float(7.2904970645905)
bool(true)
@pierrejoye
pierrejoye / proc.php
Created July 20, 2011 09:37
proc_open example
<?php
$cmd = "C:\\Program Files (x86)\\Java\\jre6\\bin\\java.exe";
$parts = array(
'-jar' => 'G:\\test\\yuic\\build\\yuicompressor-2.4.6.jar',
'--type' => 'css',
'--charset' => 'UTF-8',
'H:\\projects\\assetic\\assetic\\tests\\Assetic\\Test\\Filter\\fixtures\\cssmin\\fonts.css -o g:\\temp\\test.css',
'-o' => 'g:\\temp\\test.css',
);
@pierrejoye
pierrejoye / gist:1101827
Created July 23, 2011 20:07
Short array syntax, small beautiful thing :)
c:\php-sdk\php54\vc10\x86\php54>Release_TS\php -n -r "$a = [1,2,3,4,5]; print_r($a);"
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
@pierrejoye
pierrejoye / gist:1103956
Created July 25, 2011 11:35
do not resolve links on fopen&co only
Index: main/fopen_wrappers.h
===================================================================
--- main/fopen_wrappers.h (revision 313658)
+++ main/fopen_wrappers.h (working copy)
@@ -28,6 +28,7 @@
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC);
PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC);
PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC);
+PHPAPI char *expand_filepath_use_realpath(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int use_realpath TSRMLS_DC);
@pierrejoye
pierrejoye / gist:1107279
Created July 26, 2011 17:26
Bug #55124 (recursive mkdir fails with current (dot) directory in path)
--TEST--
Bug #55124 (recursive mkdir fails with current (dot) directory in path)
--FILE--
<?php
$old_dir_path = getcwd();
chdir(__DIR__);
mkdir('a/./b');
if (is_dir('a/b')) {
rmdir('a/b');
}
<?php
class Foo {
var $foo;#, $bar;
function __construct(){
$this->foo = '';
$this->bar =& $this->foo;
}
function dump(){
var_dump($this->foo);
var_dump($this->bar);
@pierrejoye
pierrejoye / gist:1125099
Created August 4, 2011 12:58
Windows constants, 5.3+
c:\test\php536nts>php -n -d extension_dir=ext -d extension=php_openssl.dll -r "print_r(get_defined_constants());" | FIND "WINDOWS"
[PHP_WINDOWS_VERSION_MAJOR] => 6
[PHP_WINDOWS_VERSION_MINOR] => 1
[PHP_WINDOWS_VERSION_BUILD] => 7601
[PHP_WINDOWS_VERSION_PLATFORM] => 2
[PHP_WINDOWS_VERSION_SP_MAJOR] => 1
[PHP_WINDOWS_VERSION_SP_MINOR] => 0
[PHP_WINDOWS_VERSION_SUITEMASK] => 256
[PHP_WINDOWS_VERSION_PRODUCTTYPE] => 1
[PHP_WINDOWS_NT_DOMAIN_CONTROLLER] => 2
@pierrejoye
pierrejoye / gist:1153703
Created August 18, 2011 09:10
int64 usage
Index: branches/PHP_5_4/sapi/cli/php_http_parser.c
===================================================================
--- branches/PHP_5_4/sapi/cli/php_http_parser.c (revision 315059)
+++ branches/PHP_5_4/sapi/cli/php_http_parser.c (working copy)
@@ -323,12 +323,12 @@
{
char c, ch;
const char *p = data, *pe;
- int64_t to_read;
+ size_t to_read;
002+ 1076824799 [2004-02-14 23:59:59 W. Europe Standard Time] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +59 seconds]
003+ 1076824800 [2004-02-15 00:00:00 W. Europe Standard Time] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +60 seconds]
004+ 1076824801 [2004-02-15 00:00:01 W. Europe Standard Time] [2004-04-07 00:00:00 -2 months +7 days +23 hours +59 minutes +61 seconds]
005+ 1079503200 [2004-03-17 00:00:00 W. Europe Standard Time] [2004-04-07 00:00:00 -21 days]
006+ 1080367200 [2004-03-27 00:00:00 W. Europe Standard Time] [2004-04-07 00:00:00 11 days ago]
007+ 1080460800 [2004-03-28 02:00:00 W. Europe Standard Time] [2004-04-07 00:00:00 -10 day +2 hours]
008+ 1081227600 [2004-04-06 00:00:00 W. Europe Daylight Time] [2004-04-07 00:00:00 -1 day]
009+ 1081314000 [2004-04-07 00:00:00 W. Europe Daylight Time] [2004-04-07 00:00:00]
010+ 1081317600 [2004-04-07 01:00:00 W. Europe Daylight Time] [2004-04-07 00:00:00 +1 hour]
011+ 1081321200 [2004-04-07 02:00:00 W. Europe Daylight Tim