<?php class WeChatMenu{ private $AppId = ""; //公共平台提供的AppId private $AppSecret = ""; //公共平台提供的AppSecret public $AccessToken = ""; //公共平台提供的AccessToken private $platform = "weixin"; //平台类型。如果是易信,则为 "weixin"; 如果是易信,则为 "yixin" public $host = "api.weixin.qq.com"; ///平台服务器. 微信为api.weixin.qq.com, 易信为api.yixin.im public $errcode = 0; //错误代码 public $errmsg = ""; //错误信息文本這是一個選單類別庫1、增加單一一層選單 addSingleMenu($name,$type,$value) #2、增加子集選單類型 addMenuItem($name,$type,$value) 3、修改部分bug #
<?php namespace iter; use iter\fn; use PHPUnit\Framework\TestCase; class IterFnTest extends TestCase { public function testIndex() { $getIndex3 = fn\index(3); $getIndexTest = fn\index('test'); $arr1 = [10, 11, 12, 13, 14, 15]; $arr2 = ['foo' => 'bar', 'test' => 'tset', 'bar' => 'foo']; $this->assertSame($arr1[3], $getIndex3($arr1)); $this->assertSame($arr2['test'], $getIndexTest($arr2)); } public function testNestedIndex() { $getIndexFooBar = fn\nested_index('foo', 'bar'); $getIndexFooBarBaz = fn\nested_index('foo', 'bar', 'baz'); $getEmptyIndex = fn\nested_index(); $array = [ 'foo' => [ 'bar' => [ 'baz' => 42 ] ] ]; $this->assertSame($array['foo']['bar'], $getIndexFooBar($array)); $this->assertSame($array['foo']['bar']['baz'], $getIndexFooBarBaz($array)); $this->assertSame($array, $getEmptyIndex($array)); }這是一個生成器提供迭代原語的PHP函式庫,需要的朋友可以直接下載使用,十分的方便。
<?php spl_autoload_register(function ($className) { $prefix = 'galapagos\'; $basePath = __DIR__.'/src/'; if (strncmp($prefix, $className, strlen($prefix)) === 0) { require $basePath.str_replace('\', '/', substr($className, strlen($prefix))).'.php'; } }); require __DIR__.'/src/core.php'; require __DIR__.'/src/php54.php';這是一個語言轉換演化的PHP函式庫,需要的朋友可以直接下載使用。
<?php BILITY OF SUCH DAMAGE. */ namespace Hoa\Eventsource; use Hoa\Exception as HoaException; /** * Class \Hoa\Eventsource\Exception. * * Extending the \Hoa\Exception\Exception class. * * @copyright Copyright © 2007-2017 Hoa community * @license New BSD License */ class Exception extends HoaException { }前段時間在考慮怎麼把我們的自動部署工具 essay 包一層web的殼,這樣每次發版就不用敲很多命令了,只需要點幾個按鈕就搞定,也可以減少發版是的心智負擔。在做的時候主要的一個問題是如何更好的把本來在Terminal上輸出的結果實時的輸出到web界面上,最後發現了EventSource這個東西,除了IE瀏覽器不支持,其他瀏覽器都內置這個對象,可以很好得完成我的這個需求。於是就有了這個Eventsource-masterPHP事件來源函式庫,非常的好用,需要的朋友可以下載使用。
<?php require 'vendor/autoload.php'; use Jenssegers\Date\Date; $translations = array(); foreach ($months as $month) { $date = new Date($month); $translation = strftime('%B', $date->getTimestamp()); $translations[$month] = $translation; echo "'" . $month . "'\t=> '" . $translation . "',\n"; } echo "\n"; foreach ($days as $day) { $date = new Date($day); $translation = strftime('%A', $date->getTimestamp()); $translations[$day] = $translation; echo "'" . $day . "'\t=> '" . $translation . "',\n"; }這個函式庫是多國語言組成的PHP,使用哪個國家的語言可以直接進行調用,十分的方便。
<?php namespace igorw; class ComposeTest extends \PHPUnit_Framework_TestCase { /** * @expectedException InvalidArgumentException */ function testComposeWithoutArgs() { compose(); } function testComposeWithSingleFunc() { $id = function ($x) { return $x; }; $composed = compose($id); $this->assertNull($composed(null)); $this->assertTrue($composed(true)); $this->assertFalse($composed(false)); $this->assertSame('foo', $composed('foo')); } function testComposeWithMultipleFuncs() { $composed = compose( function ($x) { return "baz($x)"; }, function ($x) { return "bar($x)"; }, function ($x) { return "foo($x)"; } ); $this->assertSame('baz(bar(foo(x)))', $composed('x')); }Compose是Docker的服務編排工具,主要用來建構基於Docker的複雜應用,Compose 透過一個設定檔來管理多個Docker容器,非常適合組合使用多個容器進行開發的場景。
<?php use Tackk\Cartographer\AbstractSitemap; class MockAbstractSitemap extends AbstractSitemap { protected function getRootNodeName() { return 'urlset'; } protected function getNodeName() { return 'url'; } } class AbstractSitemapTest extends PHPUnit_Framework_TestCase { /** * @var Tackk\Cartographer\AbstractSitemap */ protected $abstractMock; public function setUp() { $this->abstractMock = new MockAbstractSitemap(); } public function testFormatDateWithDates() { $this->assertEquals('2005-01-01T00:00:00+00:00', $this->callProtectedMethod('formatDate', ['2005-01-01'])); $this->assertEquals('2005-01-01T00:00:01+00:00', $this->callProtectedMethod('formatDate', ['2005-01-01 12:00:01am'])); }Google Cartographer利用同步定位與建圖技術繪製室內建築平面圖,可用於二維和三維空間的建圖,可以在非ros(機器人操作系統)系統和ros系統中使用。根據google的說明,該技術易於部署機器人、無人駕駛、無人機等系統。 Google在官方聲明中提到,Cartographer的SLAM演算法結合了來自多個感測器的數據,例如LiDAR雷射雷達感測器、IMU慣性測量單元,以及來自多個攝影機的數據。綜合這些龐雜的數據,得以計算感測器及感測器周圍的環境。據報道Cartographer現已支援Toyota HSR、TurtleBots、PR2、RevoLDS這幾個機器人平台。
<?php namespace SensioLabs\AnsiConverter\Tests; use SensioLabs\AnsiConverter\AnsiToHtmlConverter; class AnsiToHtmlConverterTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getConvertData */ public function testConvert($expected, $input) { $converter = new AnsiToHtmlConverter(); $this->assertEquals($expected, $converter->convert($input)); } public function getConvertData() { return array( // text is escaped array('<span style="background-color: black; color: white">foo <br /></span>', 'foo <br />'), // newlines are preserved array("<span style=\"background-color: black; color: white\">foo\nbar</span>", "foo\nbar"), // backspaces array('<span style="background-color: black; color: white">foo </span>', "foobar\x08\x08\x08 "), array('<span style="background-color: black; color: white">foo</span><span style="background-color: black; color: white"> </span>', "foob\e[31;41ma\e[0mr\x08\x08\x08 "), // color array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[0m"), // color with [m as a termination (equivalent to [0m]) array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[m"), // bright color array('<span style="background-color: red; color: red">foo</span>', "\e[31;41;1mfoo\e[0m"), // carriage returns array('<span style="background-color: black; color: white">foobar</span>', "foo\rbar\rfoobar"), // underline array('<span style="background-color: black; color: white; text-decoration: underline">foo</span>', "\e[4mfoo\e[0m"), // non valid unicode codepoints substitution (only available with PHP >= 5.4) PHP_VERSION_ID < 50400 ?: array('<span style="background-color: black; color: white">foo '."\xEF\xBF\xBD".'</span>', "foo \xF4\xFF\xFF\xFF"), ); } }ANSI是一種字元代碼,為使電腦支援更多語言,通常使用 0x00~0x7f 範圍的1 個位元組來表示 1 個英文字元。超出此範圍的使用0x80~0xFFFF來編碼,即擴展的ASCII編碼。 HTML則是超文本標記語言,標準通用標記語言下的一個應用。 「超文本」是指頁面內可以包含圖片、鏈接,甚至音樂、程式等非文字元素。超文本標記語言的結構包括「頭」部分(英文:Head)、和「主體」部分(英
<?php namespace PhpAmqpLib\Channel; use PhpAmqpLib\Exception\AMQPBasicCancelException; use PhpAmqpLib\Exception\AMQPProtocolChannelException; use PhpAmqpLib\Exception\AMQPRuntimeException; use PhpAmqpLib\Message\AMQPMessage; use PhpAmqpLib\Wire\AMQPReader; use PhpAmqpLib\Wire\AMQPWriter; class AMQPChannel extends AbstractChannel { /** @var array */ public $callbacks = array(); /** @var bool Whether or not the channel has been "opened" */ protected $is_open = false; /** @var int */ protected $default_ticket; /** @var bool */ protected $active; /** @var array */ protected $alerts; /** @var bool */ protected $auto_decode;AMQP,即Advanced Message Queuing Protocol,一個提供統一訊息服務的應用層標準高級訊息佇列協定,是應用層協定的一個開放標準,為面向訊息的中間件設計。基於此協定的用戶端與訊息中間件可傳遞訊息,且不受客戶端/中介軟體不同產品,不同的開發語言等條件的限制。 Erlang中的實作有 RabbitMQ等。
<?php $error_level = E_ALL & E_STRICT; ini_set('error_reporting', $error_level); ini_set('display_errors', 1); $tcryptoLocation = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'TCrypto'; require $tcryptoLocation . DIRECTORY_SEPARATOR . 'Loader.php'; require 'apps.php'; $loader = new TCrypto\Loader(); $loader->register(); $settings = new TCrypto\Tools\SettingStore(); $cli = new TCrypto\Tools\Cli\Horde\Cli(); if (file_exists('keytool.config.php')) { $optionParser = new TCrypto\Tools\ArrayOptionParser('keytool.config.php'); }TCrypto是可以很方便加密解密的函式庫,可以使用它來加密需要在網路中傳輸的資料。可以使用非對稱加密:公鑰加密,私鑰解密。 openssl提供了對RSA的支持,但RSA存在計算效率低的問題,所以一般的做法是使用對稱密鑰加密數據,然後再把這個只在當前有效的臨時生成的對稱密鑰用非對稱密鑰的公鑰加密之後傳遞給目標方,目標方使用約定好的非對稱金鑰中的私鑰解開,得到資料加密的金鑰,再進行資料解密,得到數據,這種使用方式很常見,可以認為是HTTPS的裁剪。對稱金鑰加密可以選擇AES,比DES更優秀。 下載原始碼之後,開始編譯: 產生動態函式庫的做法:1、安裝ActivePerl2、進入OpenSSL所在資料夾,執行:perl Configure VC-WIN32 --prefix=C:\openssl-dll3、進入VC/BIN目錄,運行VCVARS32.BAT 設定環境變數4、返回OpenSSL目錄,運行ms\do_ms5、在OpenSSL目錄下執行編譯nmake -f ms\ntdll.mak6、把必要生成物拷貝到prefix定義的目錄中nmake -f ms\ntdll .mak install注意:可以透過修改ntdll.mak檔案中的CFLAG,確定編譯MT、MD函式庫 產生靜態函式庫的做法:1、安裝ActivePerl 2、perl configure VC-WIN32 --prefix=C:\openssl-lib3、ms\do_ms.bat4、nmake -f ms\nt .mak5、nmake -f ms\nt.mak install#注意:可以透過修改nt.mak檔案中的CFLAG,確定編譯MT、MD函式庫。重編的時候把生成物刪掉。
SecurityMultiTool-masterPHP安全庫是一套易於使用、結構良好、速度優異且專門針對PHP類Web應用程式的先進安全層。這套入侵偵測系統既不提供任何緩和殺毒機制,也不會對惡意輸入內容進行過濾,其作用單純為識別出攻擊者們針對網站進行的惡意活動、並以大家需要的方式作出及時提醒。憑藉著一整套經過實踐檢驗及相當嚴格的過濾規則,該檢測系統會針對任何攻擊活動給出一個影響評級數值,從而幫助用戶更輕鬆地了解應如何應對當前出現的黑客攻擊。具體應對方式多種多樣,包括簡單將日誌紀錄透過緊急郵件發送給開發團隊、顯示關於攻擊者的警告訊息甚至立即中止用戶的當前會話。
偽數據產生器依照一定的數據規則,產生大量的數據,支援teradata數據導入和oracle數據導入。 軟體作用:為測試軟體在大數據量下的效能而給資料庫導入大量的資料。 <?php namespace Samsui\Generator; use \Samsui\Provider\ProviderInterface; class Generator implements GeneratorInterface { protected $providers = array(); protected static $instance; /** * @param string $name */ public function registerProvider($name, ProviderInterface $provider) { $this->providers[$name] = $provider; } public function __get($name) { if (isset($this->providers[$name])) { return $this->providers[$name]; } }#