Skip to content

Instantly share code, notes, and snippets.

View yohgaki's full-sized avatar

Yasuo Ohgaki yohgaki

View GitHub Profile
@yohgaki
yohgaki / pgsql-refactor.patch
Created February 15, 2014 09:36
ext/pgsql refactor and cleanup
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 2ac0454..c4632ae 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -746,6 +746,104 @@ ZEND_GET_MODULE(pgsql)
static int le_link, le_plink, le_result, le_lofp, le_string;
+/* Compatibility definitions */
+
@yohgaki
yohgaki / security.xml.patch
Created February 20, 2014 00:52
Patch for en/reference/session/security.xml
Index: en/reference/session/security.xml
===================================================================
--- en/reference/session/security.xml (リビジョン 332867)
+++ en/reference/session/security.xml (作業コピー)
@@ -7,6 +7,102 @@
External links: <link xlink:href="&url.session-fixation;">Session fixation</link>
</para>
<para>
+ HTTP session management is core of web security. All of mitigation should be adopted to make
+ sure session security. User should enable/use applicable settings appropriately.
%global pkgname phalcon
Name: php-phalcon
Version: 1.3.4
Release: 1%{?dist}
Summary: PhalconPHP is a web framework delivered as a C extension
License: BSD
URL: http://phalconphp.com
Source0: c%{pkgname}-master.zip
@yohgaki
yohgaki / pg_mongo_bench.php
Last active August 29, 2015 14:16
Simple PostgreSQL and MongoDB benchmark PHP script
<?php
const RECORDS = 1000000;
const SEARCHES = 10000;
$pgsql = pg_connect('host=localhost dbname=test') or die('Failed to connect PostgreSQL');
$version = pg_version();
!version_compare($version['server'], '9.4', '<') or die('Need PostgreSQL 9.4 or later');
$mongo = (new MongoClient())->test->test;
@yohgaki
yohgaki / jsonb_partial_update_bench.php
Last active August 29, 2015 14:21
Simple JSONB partial update bench. Requires PostgreSQL 9.5
<?php
const NUM_DATA=10000;
const DUMMY_BYTES=36000;
$db = pg_connect('host=localhost dbname=yohgaki') || die('Failed to connect db');
$dummy = base64_encode(file_get_contents('/dev/urandom', false, null, -1, DUMMY_BYTES));
$dummy = substr($dummy, 0, DUMMY_BYTES);
//$dummy = str_repeat('a', DUMMY_BYTES);
@yohgaki
yohgaki / php-trunk-strict-session.patch
Created November 20, 2011 01:35
PHP master: Strict session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 621c4e1..a21e0ca 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)
@yohgaki
yohgaki / php-pgsql-escape-literal.patch
Created November 20, 2011 23:49
php-trunk pg_escape_literal patch
Index: ext/pgsql/tests/08escape.phpt
===================================================================
--- ext/pgsql/tests/08escape.phpt (リビジョン 319557)
+++ ext/pgsql/tests/08escape.phpt (作業コピー)
@@ -11,8 +11,9 @@
// pg_escape_string() test
$before = "ABC\\ABC\'";
$expect = "ABC\\\\ABC\\'";
+$expect2 = "ABC\\\\ABC\\\\''"; //the way escape string differs from PostgreSQL 9.0
$after = pg_escape_string($before);
@yohgaki
yohgaki / php-pgsql-escape-literal-identifier-example.php
Created November 22, 2011 21:28
PHP: Example code for pgsql module with pg_escape_identifier()/pg_escape_literal() patch
<?php
$db = pg_connect('host=127.0.0.1 dbname=test');
// Create test table with reserved word "user"
$sql = 'drop table test2; create table test2 ('.pg_escape_identifier('user').' text);';
var_dump($sql);
pg_query($sql);
// Example use of pg_escape_literal().
// Note that no quotes around string. Quotes are added by the function.
@yohgaki
yohgaki / gist:2224196
Created March 28, 2012 06:24
PHP 5.4: Strict Session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index 621c4e1..a21e0ca 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)
@yohgaki
yohgaki / strict-session-5.3.patch
Created March 28, 2012 06:48
PHP 5.3: Strict Session patch
diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c
index ec25bea..2046934 100644
--- a/ext/session/mod_files.c
+++ b/ext/session/mod_files.c
@@ -61,40 +61,9 @@ typedef struct {
} ps_files;
ps_module ps_mod_files = {
- PS_MOD(files)
+ PS_MOD_SID(files)