diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..066f55f --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,3 @@ +protect your php code by encode them with a php extension + +special thanks to MoXie \ No newline at end of file diff --git a/sample/encode/source/a.conf b/sample/encode/source/a.conf deleted file mode 100644 index 41edbd2..0000000 --- a/sample/encode/source/a.conf +++ /dev/null @@ -1 +0,0 @@ -this is a config file diff --git a/sample/encode/source/include/include.php b/sample/encode/source/include/include.php deleted file mode 100644 index f0136e9..0000000 --- a/sample/encode/source/include/include.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/sample/encode/source/index.php b/sample/encode/source/index.php deleted file mode 100644 index 9e95a61..0000000 --- a/sample/encode/source/index.php +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/sample/index.php b/sample/index.php deleted file mode 100644 index 0e256f5..0000000 --- a/sample/index.php +++ /dev/null @@ -1,72 +0,0 @@ - - * thanks : moxie - * blog : http:www.php-ex.com - * - **/ -if(!extension_loaded('hellovigossguard')) { - die("请先安装加密加密工具"); -} -if(count($argv) == 1){ - die("请输入需要加密的文件夹路径!"); -} - -$source_dir = $argv[1]; -$encode_dir = isset($argv[2]) ? $argv[2] : 'encode'; - -@mkdir($encode_dir); -@mkdir($encode_dir . DIRECTORY_SEPARATOR . $source_dir); - -$dir = read_dir_all($source_dir); - -function read_dir_all($dir) { - global $encode_dir; - $ret = array('dirs'=>array(), 'files'=>array()); - if ($handle = opendir($dir)) { - while (false !== ($file = readdir($handle))) { - if($file != '.' && $file !== '..') { - $cur_path = $dir . DIRECTORY_SEPARATOR . $file; - if(is_dir($cur_path)) { - @mkdir($encode_dir. DIRECTORY_SEPARATOR . $cur_path); - echo "新建目录:" . $encode_dir. DIRECTORY_SEPARATOR .$cur_path . "\n"; - $ret['dirs'][$cur_path] = read_dir_all($cur_path); - } else { - @touch($encode_dir . DIRECTORY_SEPARATOR . $cur_path); - encode_write($cur_path, $encode_dir . DIRECTORY_SEPARATOR . $cur_path); - $ret['files'][] = $cur_path; - } - } - } - closedir($handle); - } - return $ret; -} -function need_encode($file){ - $ext = pathinfo($file, PATHINFO_EXTENSION); - if (in_array($ext, array('php', 'phpt', 'php4', 'php5'))) { - return true; - } - return false; -} -function encode_write($file, $to){ - $source = file_get_contents($file); - if(need_encode($file)){ - $encode_str = encode($source); - $encode_str = ''; - echo "加密文件:" . $to . "\n"; - } - else{ - $encode_str = $source; - echo "拷贝文件:" . $to . "\n"; - } - file_put_contents($to, $encode_str); -} diff --git a/sample/source/a.conf b/sample/source/a.conf deleted file mode 100644 index 41edbd2..0000000 --- a/sample/source/a.conf +++ /dev/null @@ -1 +0,0 @@ -this is a config file diff --git a/sample/source/include/include.php b/sample/source/include/include.php deleted file mode 100644 index 1927909..0000000 --- a/sample/source/include/include.php +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/sample/source/index.php b/sample/source/index.php deleted file mode 100644 index 9332a86..0000000 --- a/sample/source/index.php +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/CREDITS b/src/CREDITS deleted file mode 100644 index 06b3352..0000000 --- a/src/CREDITS +++ /dev/null @@ -1 +0,0 @@ -hellovigossguard \ No newline at end of file diff --git a/src/EXPERIMENTAL b/src/EXPERIMENTAL deleted file mode 100644 index e69de29..0000000 diff --git a/src/config.m4 b/src/config.m4 deleted file mode 100644 index 63bf49a..0000000 --- a/src/config.m4 +++ /dev/null @@ -1,63 +0,0 @@ -dnl $Id$ -dnl config.m4 for extension hellovigossguard - -dnl Comments in this file start with the string 'dnl'. -dnl Remove where necessary. This file will not work -dnl without editing. - -dnl If your extension references something external, use with: - -dnl PHP_ARG_WITH(hellovigossguard, for hellovigossguard support, -dnl Make sure that the comment is aligned: -dnl [ --with-hellovigossguard Include hellovigossguard support]) - -dnl Otherwise use enable: - - PHP_ARG_ENABLE(hellovigossguard, whether to enable hellovigossguard support, - Make sure that the comment is aligned: - [ --enable-hellovigossguard Enable hellovigossguard support]) - -if test "$PHP_HELLOVIGOSSGUARD" != "no"; then - dnl Write more examples of tests here... - - dnl # --with-hellovigossguard -> check with-path - dnl SEARCH_PATH="/usr/local /usr" # you might want to change this - dnl SEARCH_FOR="/include/hellovigossguard.h" # you most likely want to change this - dnl if test -r $PHP_HELLOVIGOSSGUARD/$SEARCH_FOR; then # path given as parameter - dnl HELLOVIGOSSGUARD_DIR=$PHP_HELLOVIGOSSGUARD - dnl else # search default path list - dnl AC_MSG_CHECKING([for hellovigossguard files in default path]) - dnl for i in $SEARCH_PATH ; do - dnl if test -r $i/$SEARCH_FOR; then - dnl HELLOVIGOSSGUARD_DIR=$i - dnl AC_MSG_RESULT(found in $i) - dnl fi - dnl done - dnl fi - dnl - dnl if test -z "$HELLOVIGOSSGUARD_DIR"; then - dnl AC_MSG_RESULT([not found]) - dnl AC_MSG_ERROR([Please reinstall the hellovigossguard distribution]) - dnl fi - - dnl # --with-hellovigossguard -> add include path - dnl PHP_ADD_INCLUDE($HELLOVIGOSSGUARD_DIR/include) - - dnl # --with-hellovigossguard -> check for lib and symbol presence - dnl LIBNAME=hellovigossguard # you may want to change this - dnl LIBSYMBOL=hellovigossguard # you most likely want to change this - - dnl PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, - dnl [ - dnl PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $HELLOVIGOSSGUARD_DIR/lib, HELLOVIGOSSGUARD_SHARED_LIBADD) - dnl AC_DEFINE(HAVE_HELLOVIGOSSGUARDLIB,1,[ ]) - dnl ],[ - dnl AC_MSG_ERROR([wrong hellovigossguard lib version or lib not found]) - dnl ],[ - dnl -L$HELLOVIGOSSGUARD_DIR/lib -lm - dnl ]) - dnl - dnl PHP_SUBST(HELLOVIGOSSGUARD_SHARED_LIBADD) - - PHP_NEW_EXTENSION(hellovigossguard, hellovigossguard.c, $ext_shared) -fi diff --git a/src/config.w32 b/src/config.w32 deleted file mode 100644 index 392d2e9..0000000 --- a/src/config.w32 +++ /dev/null @@ -1,13 +0,0 @@ -// $Id$ -// vim:ft=javascript - -// If your extension references something external, use ARG_WITH -// ARG_WITH("hellovigossguard", "for hellovigossguard support", "no"); - -// Otherwise, use ARG_ENABLE -// ARG_ENABLE("hellovigossguard", "enable hellovigossguard support", "no"); - -if (PHP_HELLOVIGOSSGUARD != "no") { - EXTENSION("hellovigossguard", "hellovigossguard.c"); -} - diff --git a/src/hellovigossguard.c b/src/hellovigossguard.c deleted file mode 100644 index 7dcaeed..0000000 --- a/src/hellovigossguard.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: | - +----------------------------------------------------------------------+ -*/ - -/* $Id: header 321634 2012-01-01 13:15:04Z felipe $ */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_hellovigossguard.h" -#include "string.h" - -/* If you declare any globals in php_hellovigossguard.h uncomment this: -ZEND_DECLARE_MODULE_GLOBALS(hellovigossguard) -*/ - -/* True global resources - no need for thread safety here */ -static int le_hellovigossguard; - -char * key = "asdf"; -/* {{{ hellovigossguard_functions[] - * - * Every user visible function must have an entry in hellovigossguard_functions[]. - */ -const zend_function_entry hellovigossguard_functions[] = { - PHP_FE(confirm_hellovigossguard_compiled, NULL) /* For testing, remove later. */ - PHP_FE(encode, NULL) /* For testing, remove later. */ - PHP_FE(decode, NULL) /* For testing, remove later. */ - PHP_FE(run, NULL) /* For testing, remove later. */ - PHP_FE_END /* Must be the last line in hellovigossguard_functions[] */ -}; -/* }}} */ - -/* {{{ hellovigossguard_module_entry - */ -zend_module_entry hellovigossguard_module_entry = { -#if ZEND_MODULE_API_NO >= 20010901 - STANDARD_MODULE_HEADER, -#endif - "hellovigossguard", - hellovigossguard_functions, - PHP_MINIT(hellovigossguard), - PHP_MSHUTDOWN(hellovigossguard), - PHP_RINIT(hellovigossguard), /* Replace with NULL if there's nothing to do at request start */ - PHP_RSHUTDOWN(hellovigossguard), /* Replace with NULL if there's nothing to do at request end */ - PHP_MINFO(hellovigossguard), -#if ZEND_MODULE_API_NO >= 20010901 - "0.1", /* Replace with version number for your extension */ -#endif - STANDARD_MODULE_PROPERTIES -}; -/* }}} */ - -#ifdef COMPILE_DL_HELLOVIGOSSGUARD -ZEND_GET_MODULE(hellovigossguard) -#endif - -/* {{{ PHP_INI - */ -/* Remove comments and fill if you need to have entries in php.ini -PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("hellovigossguard.global_value", "42", PHP_INI_ALL, OnUpdateLong, global_value, zend_hellovigossguard_globals, hellovigossguard_globals) - STD_PHP_INI_ENTRY("hellovigossguard.global_string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_hellovigossguard_globals, hellovigossguard_globals) -PHP_INI_END() -*/ -/* }}} */ - -/* {{{ php_hellovigossguard_init_globals - */ -/* Uncomment this function if you have INI entries -static void php_hellovigossguard_init_globals(zend_hellovigossguard_globals *hellovigossguard_globals) -{ - hellovigossguard_globals->global_value = 0; - hellovigossguard_globals->global_string = NULL; -} -*/ -/* }}} */ - -/* {{{ PHP_MINIT_FUNCTION - */ -PHP_MINIT_FUNCTION(hellovigossguard) -{ - /* If you have INI entries, uncomment these lines - REGISTER_INI_ENTRIES(); - */ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MSHUTDOWN_FUNCTION - */ -PHP_MSHUTDOWN_FUNCTION(hellovigossguard) -{ - /* uncomment this line if you have INI entries - UNREGISTER_INI_ENTRIES(); - */ - return SUCCESS; -} -/* }}} */ - -/* Remove if there's nothing to do at request start */ -/* {{{ PHP_RINIT_FUNCTION - */ -PHP_RINIT_FUNCTION(hellovigossguard) -{ - return SUCCESS; -} -/* }}} */ - -/* Remove if there's nothing to do at request end */ -/* {{{ PHP_RSHUTDOWN_FUNCTION - */ -PHP_RSHUTDOWN_FUNCTION(hellovigossguard) -{ - return SUCCESS; -} -/* }}} */ - -/* {{{ PHP_MINFO_FUNCTION - */ -PHP_MINFO_FUNCTION(hellovigossguard) -{ - php_info_print_table_start(); - php_info_print_table_header(2, "hellovigossguard support", "enabled"); - php_info_print_table_end(); - - /* Remove comments if you have entries in php.ini - DISPLAY_INI_ENTRIES(); - */ -} -/* }}} */ - - -/* Remove the following function when you have succesfully modified config.m4 - so that your module can be compiled into PHP, it exists only for testing - purposes. */ - -/* Every user-visible function in PHP should document itself in the source */ -/* {{{ proto string confirm_hellovigossguard_compiled(string arg) - Return a string to confirm that the module is compiled in */ -PHP_FUNCTION(confirm_hellovigossguard_compiled) -{ - char *arg = NULL; - int arg_len, len; - char *strg; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) { - return; - } - - len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "hellovigossguard", arg); - RETURN_STRINGL(strg, len, 0); -} -/* }}} */ -/* The previous line is meant for vim and emacs, so it can correctly fold and - unfold functions in source code. See the corresponding marks just before - function definition, where the functions purpose is also documented. Please - follow this convention for the convenience of others editing your code. -*/ -PHP_FUNCTION(encode){ - long key_len = strlen(key); - char * code, * encode_code; - long code_len; - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &code, &code_len) == FAILURE){ - return; - } - encode_code = encode(code, code_len, key, key_len); - RETURN_STRING(encode_code, 0); -} -PHP_FUNCTION(decode){ - long key_len = strlen(key); - char * code, * decode_code; - long code_len; - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &code, &code_len) == FAILURE){ - return; - } - decode_code = decode(code, code_len, key, key_len); - RETURN_STRING(decode_code, 0); -} -PHP_FUNCTION(run){ - char * en_base64_code; - long en_base64_code_len; - char * decode_code; - long key_len = strlen(key); - char * eval_code; - char * str_name; - - if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &en_base64_code, &en_base64_code_len) == FAILURE){ - return; - } - - str_name = zend_make_compiled_string_description("hellovigoss" TSRMLS_CC); - decode_code = decode(en_base64_code, en_base64_code_len, key, key_len); - spprintf(&eval_code, 0, " ?>%s'", PHP_EOL); - RETURN_FALSE; - } - efree(str_name); - efree(eval_code); - RETURN_TRUE; - -} -inline char * encode(char * code, long code_len, char* key, long key_len){ - char * code_encode; - int i; - code_encode = strdup(code); - long offset = 0, ret_len; - for(i =0; i"; - -if(!extension_loaded('hellovigossguard')) { - dl('hellovigossguard.' . PHP_SHLIB_SUFFIX); -} -$a = encode(""); -run($a);?> diff --git a/src/php_hellovigossguard.h b/src/php_hellovigossguard.h deleted file mode 100644 index 9480c7b..0000000 --- a/src/php_hellovigossguard.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 5 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2012 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Author: | - +----------------------------------------------------------------------+ -*/ - -/* $Id: header 321634 2012-01-01 13:15:04Z felipe $ */ - -#ifndef PHP_HELLOVIGOSSGUARD_H -#define PHP_HELLOVIGOSSGUARD_H - -extern zend_module_entry hellovigossguard_module_entry; -#define phpext_hellovigossguard_ptr &hellovigossguard_module_entry - -#ifdef PHP_WIN32 -# define PHP_HELLOVIGOSSGUARD_API __declspec(dllexport) -#elif defined(__GNUC__) && __GNUC__ >= 4 -# define PHP_HELLOVIGOSSGUARD_API __attribute__ ((visibility("default"))) -#else -# define PHP_HELLOVIGOSSGUARD_API -#endif - -#ifdef ZTS -#include "TSRM.h" -#endif - -PHP_MINIT_FUNCTION(hellovigossguard); -PHP_MSHUTDOWN_FUNCTION(hellovigossguard); -PHP_RINIT_FUNCTION(hellovigossguard); -PHP_RSHUTDOWN_FUNCTION(hellovigossguard); -PHP_MINFO_FUNCTION(hellovigossguard); - -PHP_FUNCTION(confirm_hellovigossguard_compiled); /* For testing, remove later. */ -PHP_FUNCTION(encode); -PHP_FUNCTION(decode); -PHP_FUNCTION(run); - -char * encode(char * code, long code_len, char * key, long key_len); -char * decode(char * code, long code_len, char * key, long key_len); - -/* - Declare any global variables you may need between the BEGIN - and END macros here: - -ZEND_BEGIN_MODULE_GLOBALS(hellovigossguard) - long global_value; - char *global_string; -ZEND_END_MODULE_GLOBALS(hellovigossguard) -*/ - -/* In every utility function you add that needs to use variables - in php_hellovigossguard_globals, call TSRMLS_FETCH(); after declaring other - variables used by that function, or better yet, pass in TSRMLS_CC - after the last function argument and declare your utility function - with TSRMLS_DC after the last declared argument. Always refer to - the globals in your function as HELLOVIGOSSGUARD_G(variable). You are - encouraged to rename these macros something shorter, see - examples in any other php module directory. -*/ - -#ifdef ZTS -#define HELLOVIGOSSGUARD_G(v) TSRMG(hellovigossguard_globals_id, zend_hellovigossguard_globals *, v) -#else -#define HELLOVIGOSSGUARD_G(v) (hellovigossguard_globals.v) -#endif - -#endif /* PHP_HELLOVIGOSSGUARD_H */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: noet sw=4 ts=4 fdm=marker - * vim<600: noet sw=4 ts=4 - */ diff --git a/src/tests/001.phpt b/src/tests/001.phpt deleted file mode 100644 index 0e977e2..0000000 --- a/src/tests/001.phpt +++ /dev/null @@ -1,21 +0,0 @@ ---TEST-- -Check for hellovigossguard presence ---SKIPIF-- - ---FILE-- - ---EXPECT-- -hellovigossguard extension is available