problem in Encrypt php code for intellectual property - php

I have downloaded phpshadow which is a php encoder
I followed whole of explanation of installing it in the tutorial such as adding php extension which was phpshadow.so
I copied this file in /usr/lib/php5/extensions
and in php.ini
I wrote this line
extension=phpshadow.so
it is the site:
http://www.phpshadow.com/index.php
I can encrypt my projects successfully
I went to my php pages all of them were encrypted
when I encrypt it it will make a backup from it too
I can't again go to browser and again see my project when I've encrypted it.
How can I encrypt my pages while I can access them too?
I don't know what's wrong with it
I have downloaded a free trial
also I've downloaded phpshadow.licence too
it is the command that I try and then my project will be encrypted:
./phpshadow-encoder -l /etc/phpshadow/phpshadow.licence /srv/www/htdocs/didebansnort/
If you have any other suggestion about encoding files I would be happy to know.
Thanks.

After spending 45' I made it work!
I tested both standard software version and online version.
Standard Software Version
Download the appropriate extension and encoder tool.
Warning! I am working in x64 Linux but I am using a 32bit version of lampp(xampp) and I needed to download the Linux 32bit version to make it work. Otherwise I was getting an "ELFCLASS64 in Unknown on line 0" in php error log.
Place the extension in your extension directory and edit your php.ini to include the file like
extension=phpshadow.so or extension="/full/path/phpshadow.so"
Then download the license and place it in /etc/phpshadow.
Use the encoder to encode your php files.
Then test it!
Problems
The free license has expired since 01/08/2011. You can set your computer clock back to 30/07/2011 and it will work.
Also, let me remind you:
Note: The free trial licence introduces a 10-second delay on each HTTP request. It is otherwise fully functional
Finally, if you don't place the license file in /etc/phpshadow it won't work.
Online Version
Encrypt a single .php file under 200 bytes for FREE
Everything except the encryption process works as the Standard Software Version.
Warning! You have to download the license for this from here.
That license hasn't expire yet. Also the online version doesn't introduces the 10-second delay.
Finally, again if you don't place the license file in /etc/phpshadow it won't work.
TIPS
Check your php and webserver error log if something goes wrong
To change date in linux see here
You can find your php extension directory in php.ini or use the phpinfo(); function
and look for *extension_dir*
If your php.ini changes doesn't take place make sure that you are modifying the correct file (in phpinfo(); look for Loaded Configuration File)
When the phpshadow.so is loaded check it with phpinfo(); or print_r(get_loaded_extensions());

Related

update CURL in PHP WAMP windows

i encountered an issue and can't seem to be able to solve it.
i downloaded the cURL from http://winampplugins.co.uk/curl/
and mapped my sys path to it which runs at 7.49.1 but my PHP is still running 7.42.1
How can i map or point the latest CURL to my php?
any pointer are greatly appreciated.
Cheers
As far as I know there is no such thing as downloading vanilla cURL and binding it with PHP. You need PHP version of cURL.
Step by Step
Step 1
Download for 32-bit:
http://windows.php.net/downloads/releases/php-5.6.7-Win32-VC11-x86.zip
Download for 64-bit:
http://windows.php.net/downloads/releases/php-5.6.7-Win32-VC11-x64.zip
Step 2
Extract File (Overwrite file - It is a good idea to keep a backup of
the file in case something fails): /etx/php_curl.dll into
C:\wamp\bin\php\php5.5.12\ext\
NOTE: your phpx.x.x folder might be different (depends on your php version)
Step 3
Restart Apache from WAMP Control Panel
Source

locating dependencies on windows php extension builds

I am writing a php extension for a library. I have a generic swig file to build wrappers for the library. This has been very successful so far on Python.
A user is trying to build the library for php and I am trying to help out. I generated the code using swig, and I can build the .dll extension using Visual Studio. The problem is getting it into php. When I build php_mylib.dll, it needs to find mylib.dll and it can't.
So I am trying to build via the command line a la:
http://blog.benoitblanchon.fr/build-php-extension-on-windows/
I have put all the files to be compiled and the libraries needed (i.e. mylib64.lib and mylib64.dll) in a folder called mylib in the C:\php-src\ext folder with all the other extension folders.
The problem is I that I can't get the config.w32 file to communicate the location of mylib. Here is my config.w32 file (pretty standard -- you can see that I copied it from the curl config.w32 file):
// $Id$
// vim:ft=javascript
ARG_ENABLE("mylib", "mylib support", "no");
if (PHP_MYLIB != "no") {
if (CHECK_LIB("mylib64.lib", "mylib", PHP_MYLIB) &&
CHECK_HEADER_ADD_INCLUDE("mylib_cpp.h", "CFLAGS_MYLIB")
) {
EXTENSION("mylib", "mylib_c_wrap.cpp", true);
AC_DEFINE('HAVE_MYLIB', 1, 'Have mylib library');
// TODO: check for curl_version_info
} else {
WARNING("mylib not enabled; libraries and headers not found");
}
}
When I run buildconf and then configure --disable-all --enable-cli --enable-mylib it always shoots me the 'libraries and headers not found' warning from the script.
On Unix systems (config.m4) there appears to be a PHP_ADD_LIBRARY_WITH_PATH macro but I don't see any equivalent for windows. It seems like this is what I need.
I have also tried adding the full path to mylib into the system's path but to no avail. It seems like there might be an environment variable somewhere in the PHP build cosmos that needs to be set to find external dependencies, but I can't find any information about this.
It would also be good to do all this as a Visual Studio project -- easier for Windows users the world over. I have not seen anything on the web that looks like this.
By the way, I have successfully phpized this library using the same swig+phpize procedure on Linux (I followed this guide for the php part:http://www.sitepoint.com/install-php-extensions-source/) and it works beautifully.
In most cases you can use this info to build a PECL extension https://wiki.php.net/internals/windows/stepbystepbuild#building_pecl_extensions . Your config.w32 looks ok, though please note that that when depending on some additional library, usually it should be ARG_WITH(...) for semantics. Your lib stuff can be then put into the deps dir as in the wiki.
Another way could be passing --with-extra-libs and --with-extra-includes to configure. Those have to contain paths to *.lib and *.h dirs respectively. When using a static lib, that should be it, otherwise you'll need to place the corresponding *.dll onto the %path% for the ext to work.
Hope this helps, otherwise you can also gain some attention on the PHP mailing lists or specifically on #winphp-dev at freenode.
Thanks.

How to get pthreads working in PHP?

I am using wampserver to test & run wordpress code in my local computer. In order to run pthread, I have followed the following steps:
1) I got the pthread zip file from http://windows.php.net/downloads/pecl/releases/pthreads/0.44/
(My machine has php 5.3.13 and downloaded the php_pthreads-0.44-5.3-ts-vc9-x86.zip file from the above link).
2) Extracted the zip file. Moved the php_pthreads.dll to the C:\wamp\bin\php\php5.3.13\ext directory.
3) Moved pthreadVC2.dll to the C:\wamp\bin\php\php5.3.13 directory.
4) Then Opened C:\wamp\bin\php\php5.3.13\php.ini and added the code extension=php_pthreads.dll at the begining of the file.
But when I try to run the following code:
<?php
class My extends Thread {
public function run() {
printf("%s is Thread #%lu\n", __CLASS__, $this->getThreadId());
}
}
$my = new My();
$my->start();
?>
It gives me the following error:
Fatal error: Class 'Thread' not found in C:\wamp\www\wp-admin\includes\post.php on line 2
Can you please tell me how to install pthreads in my computer to use with php? and do I have to install any other software?
I've noticed that wampserver has php.ini in two separate places. One place is in the /wamp/bin/php/php5... directory, and the other place is in the /wamp/bin/apache/apache.../bin directory (where "..." represents version numbers). The two files need to be identical, because apparently both are loaded at different times by the overall wampserver boot-up procedure.
(Note I only discovered this recently, and may be well "behind the curve" of doing fancy things with wampserver --maybe everyone else has been dealing with both files for a long time. So I don't know if this simple thing will fix your problem; I came here looking for info, myself, regarding doing some multi-threading stuff. :)
One other thing. According to this page: www.php.net/manual/en/pthreads.requirements.php
PHP has to be compiled with "--enable-zts" in order for pthreads stuff to work. I have not been able to find any evidence that the PHP part of wampserver was compiled that way.
(months later)
Having decided I didn't really immediately need to do any threading stuff, I went on to do other things, until the need actually arose. I now can say that the version of PHP compiled into WampServer does support the "pthread" extension, although some set-up work is needed, first. The instructions I saw mentioned putting a couple of .dll files (after a download and unZip) into certain places, but that didn't work for me. Copying them to the \Windows\System32 directory did work. (Putting them into the \apache...\bin directory also works; there are some other php .dll files in there.)
After that, much like what you did, it is necessary to define a "class" that extends the "Thread" class, in order to actually do something in another thread. The "run()" function in the Thread class is "abstract", and needs to be "realized" as an actual function in the extended class. Then the "new" operator can create an "instance", an object of that specified class, for actual use. Here's the class that I needed:
//Purpose: Use another thread to run the code in another php file, after a delay
class xT extends Thread
{ var $fil, $tim;
function savWhatWhen($f="", $t=0)
{ $this->fil = $f; //save What, file to process
$this->tim = $t; //save When, delay before processing file
return;
}
function run()
{ ini_set('max_execution_time', 600); //600 seconds = 10 minutes
sleep($this->tim); //do a delay; beware of max-exec-time!
include($this->fil); //load file-to-process, and process it
return;
} }
That "savWhatWhen()" function was created specifically for this extension of the basic Thread class. Here's some code for using that class:
$TH = new xT(); //prepare a separate Thread
$TH->savWhatWhen("d:/wamp/myscripts/test.php", 45);//file-name and delay time
$TH->start(); //after delay, process file
//the code that does this can terminate, while OTHER thread is doing a delay
Note for anyone copying this code, you might need to make sure your "open_basedir" setting in the php.ini allows access to the specified file.
More months later: With lots of things being worked on, I haven't put a lot of time into using my pthread object. I did encounter a peculiarity that makes me wonder about whether or not I can actually use pthreads the way I had hoped. Here is what I have observed:
1. An initial php file is called by AJAX, to do something.
2. The PHP processor on the Web Server does that thing.
3. Various data is supposed to be echoed to the browser.
4. The initial php file calls for the creation of another thread, and terminates.
5. The browser does not yet receive the echoed data!
6. The PHP processor on the Web Server does the work delegated to the second thread.
7. When the second thread terminates, NOW the browser receives the echoed data!
At this writing I'm thinking I missed something. Perhaps I need to do some forceful "flush" stuff when the first thread ends, so that the browser can receive the echoed data and the user can do things while the PHP processor on the server is also doing things.
Check for extension_dir = "ext" in you php.ini file. Make sure it points to the folder where your extensions reside and make sure it's not commented (it has a semicolon ; in front of it)
You have to add a require_once() with the path of the Thread class before extending it (if your framework don't use an autoload class system)
I've encountered the same problem, in my case placing the pthreadVC2.dll in
..wamp\bin\apache\Apache2.4.4\bin
(instead of ..\wamp\bin\php\php5.4.16 as the guide in php.net instructs) solved the problem
Wamp server has a separate php.ini config file for the browser and for the cli.
To use the pthreads module in the browser with WAMP Server you need to copy the "pthreadVC2.dll" into the apache "bin" directory also.
You should now have he "pthreadVC2.dll" in both of these folders (if installed in default location):
C:\wamp\bin\php\php[x.x.xx]\bin
C:\wamp\bin\apache\apache[x.x.x]\bin
You will also need to update the php.ini file within the php bin directory AND the apache bin directory to include:
extension=php_pthreads.dll
This now means you can use pthreads in the browser and in the cli with wamp server
After encountering the same problem, I noticed that I have installed the wrong Pthread version (3.1.6 : requires PHP7+) which wasn't compatible with my PHP version (5.5.12). Solved the problem with Pthread version 0.0.44. An earlier version should probably work well.
Here is the download page for Pthread and the installation page. Be careful about the both php.ini location as mentioned above (Apache folder=for Browser, PHP folder=CLI).

CentOS Ioncube make_license is "Killed" each time I try to execute it

I am trying to generate ioncube license using "make_license" generator provided by ioncube for Unix systems. It works on my desktop Ubuntu system, but does not work on my CentOS webserver.
Each time I try to run the file, I get message "Killed" in terminal, so it looks like this:
[root#myserver test]# ./make_license --passphrase 'secret' --expire-in 20d > 'license.txt'
Killed
[root#myserver test]#
Just a weird message "Killed" after I execute the file and nothing else. I also tried placing "sudo" in front of "./make_license --passphrase ....." and it worked, but license file was generated empty (0 bytes).
I have tried chmod 755 and 777 to "make_license", and it didnt help. Also I tried stopping "/etc/init.d/amavisd", just in case it's antivirus, but same thing.
My server configuration is: CentOS-6.2 64bit + Nginx, PHP-FPM, APC, php-ioncube-loader-4.2.2-2.el6.art.x86_64
I found the same question on Ioncube forum without answer:
http://forum.ioncube.com/viewtopic.php?t=3909&sid=8d595f7005f5b851479a00d387635ad7
Please share any ideas you might have.
So I contacted the ioncube support and this is what they replied:
There are two things to check here:-
That you have uploaded the make_license program to your server in binary mode and not in ASCII mode.
You have the 32-bit compatibility libraries installed (as make_license, like the Encoder, is a 32-bit program).
The loader does not matter in this case as it has nothing to do with
the problem with make_license.
You may need to install the 32-bit compatibility libraries for
CentOS for make_license to work as that is a 32-bit program.
The make_license file will be a binary in any case but if you uploaded
to your server via FTP in ASCII mode rather than binary then that
might corrupt the file and cause the "killed" message. So please
upload make_license again, making sure to choose binary mode in your
FTP client.
So I checked my make_license file:
[root#localhost test]# file make_license
make_license: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, stripped
It says that file is "executable", which I thought is = "binary".
But apparently it wasn't binary. Because after I uploaded it again, making sure that transfer mode was "binary" in my FTP client - everything worked. No more "Killed" message and licenses are generated.
Hope this helps someone.

php custom c extension with external shared lib

I would like to develop an extension which depends on an external shared library. My current problem is that I am not being able to link this shared library to my extension.
My development environment is Fedora Linux x64 + PHP 5.4. This external shared library is a proprietary one, I just have its headers (.h) and .so files (for 32 and 64 bits).
The project's current config.m4 file is as follows:
PHP_ARG_WITH(projectname,
[Whether to enable ProjectName support],
[ --with-projectname enable ProjectName support])
if test "$PHP_PROJECTNAME" != "no"; then
PHP_ADD_LIBRARY_WITH_PATH(externallib, lib64, PROJECTNAME_SHARED_LIBADD)
AC_DEFINE(HAVE_PROJECTNAME, 1, [Whether you have ProjectName])
PHP_NEW_EXTENSION(projectname, projectname.c, $ext_shared)
fi
The problem here is every time I run ./configure --with-projectname the generated makefile does not have any reference to the library, plus the compiled .so file fails (obviously).
It would also be useful if I had a way to determine the right lib directory according to the architecture.
You've included the library, but looks you're missing the actual link option. I haven't done this in the longest time, but I think something like the following should work.
EXTERNAL_LIB="blahLibName"
LIB_LINK_CMD="-L/usr/local/lib -l$EXTERNAL_LIB"
PHP_ADD_LIBRARY_WITH_PATH(externallib, lib64, PROJECTNAME_SHARED_LIBADD)
PHP_EVAL_LIBLINE($LIB_LINK_CMD, PROJECTNAME_SHARED_LIBADD)
The syntax here might not be right at all, but you definitely need the PHP_EVAL_LIBLINE.

Categories