Skip to content

Instantly share code, notes, and snippets.

View suin's full-sized avatar
😃

suin

😃
  • Craftsman Software, Inc.
  • Japan Tokyo
View GitHub Profile
$ git blame -L 78,88 AdminSideMenu.class.php
29319ebd (minahito 2008-11-23 15:53:45 +0000 78)
29319ebd (minahito 2008-11-23 15:53:45 +0000 79) if ($this->mCurrentModule->get('dirname') == 'legacy') {
29319ebd (minahito 2008-11-23 15:53:45 +0000 80) if (xoops_getrequest('action') == "help") {
29319ebd (minahito 2008-11-23 15:53:45 +0000 81) $moduleHandler =& xoops_gethandler('module');
29319ebd (minahito 2008-11-23 15:53:45 +0000 82) $t_module =& $moduleHandler->getByDirname(xoops_gethandler('dirname'));
29319ebd (minahito 2008-11-23 15:53:45 +0000 83) if (is_object($t_module)) {
29319ebd (minahito 2008-11-23 15:53:45 +0000 84) $this->mCurrentModule =& $t_module;
29319ebd (minahito 2008-11-23 15:53:45 +0000 85) }
29319ebd (minahito 2008-11-23 15:53:45 +0000 86) }
@suin
suin / CVE_2012_1823.class.php
Created May 10, 2012 03:06
URLに?-sをつけると隠しページが見れるプリロード
<?php
class CVE_2012_1823 extends XCube_ActionFilter
{
public function preFilter()
{
if ( $_SERVER['QUERY_STRING'] === '-s' )
{
header('Content-type: text/html; charset=utf-8');
$sourceCode = $this->_getSourceCode();
$ git diff templates/profile_inc_data_edit.html
diff --git a/html/modules/profile/templates/profile_inc_data_edit.html b/html/modules/profile/templates/profile_inc_data_edit.html
index a354763..657a917 100644
--- a/html/modules/profile/templates/profile_inc_data_edit.html
+++ b/html/modules/profile/templates/profile_inc_data_edit.html
@@ -21,7 +21,7 @@
<{elseif $def->get('type')=="selectbox"}>
<select name="<{$def->getShow('field_name')}>" id="legacy_xoopsform_<{$def->getShow('field_name')}>">
<{foreach item=option from=$def->mFieldType->getOption($def)}>
- <option value="<{$option}>"<{if $profile->get($def->getShow('field_name'))==$option}> selected="selected"<{/if}>><{$option}></option>
function fish_prompt -d "Write out the prompt"
if [ $status -eq 0 ]
set emoticon "^_^"
set color green
else
set emoticon ">_<"
set color red
end
@suin
suin / PDOTest.php
Created March 5, 2012 11:25
【PHPUnitに詳しい人教えて!】 コンストラクタのテスト方法 ref: http://qiita.com/items/3008
<?php
class PDOTest extends \PHPUnit_Framework_TestCase
{
public function test__construct()
{
$pdo = $this
->getMockBuilder('\Suin\PDO')
->setMethods(array('_getDefaultAttributes'))
->disableOriginalConstructor()
->getMock();
@suin
suin / file0.php
Created March 3, 2012 11:45
PHP5.4.0のtraitはfinalキーワードは無視されるっぽい。 ref: http://qiita.com/items/2971
<?php
trait Foo
{
final public static function staticMethod()
{
echo __METHOD__, PHP_EOL;
}
}
@suin
suin / file0.php
Created February 25, 2012 15:47
PHPのクロージャで $this を使う方法 ref: http://qiita.com/items/2810
<?php
class Foo
{
public function getClosure()
{
$that = $this;
$closure = function() use ($that) {
$that->bar();
@suin
suin / shell
Created February 23, 2012 03:17
decToBits()
php > var_dump(PHP_INT_MAX);
int(9223372036854775807)
php > var_dump(decbin(PHP_INT_MAX));
string(63) "111111111111111111111111111111111111111111111111111111111111111"
php > var_dump(-1 * PHP_INT_MAX);
int(-9223372036854775807)
php > var_dump(decbin(-1 * PHP_INT_MAX));
string(64) "1000000000000000000000000000000000000000000000000000000000000001"
php > var_dump(decbin(-1));
string(64) "1111111111111111111111111111111111111111111111111111111111111111"
@suin
suin / file0.php
Created February 17, 2012 06:36
整数をビットの数列に分解する関数 ( 7 を渡したら [1, 2, 4] に分解するやつ ) ref: http://qiita.com/items/2582
<?php
function decToBits($dec)
{
$bin = decbin($dec);
$bits = str_split($bin);
$bits = array_reverse($bits);
$bits = array_filter($bits);
foreach ( $bits as $pos => $bit ) {
@suin
suin / file0.php
Created February 16, 2012 05:57
MySQLの「暗黙のトランザクションコミット」対策:トランザクション中でも安全にCREATE TABLEなどをする方法 ref: http://qiita.com/items/2545
<?php
$dbname = 'test';
$host = 'localhost';
$user = 'root';
$pass = 'root';
$dsn = sprintf('mysql:dbname=%s;host=%s', $dbname, $host);
$options = array(
PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL,