I have developed a local PHP application which runs on Apache. I want to distribute it to clients but don't want them or any IT guy they might have to be able to view the source code. I have looked into different encryption options and later found out that there is a website online where you copy the encrypted code and select the encryption software used and it'll decrypt the whole code. So I don't want to use any encryption.
This is a LOCAL application and has to run locally because it connects to a local database. Would it be possible to put all the php source files on an online server and create local php files with same name and only one line of code which includes the corresponding php file from online? For example, I put main 'showClients.php' online and create a local php file with same name, 'showClients.php', and put just one line of code in it like,
<?php
include('http://www.example.com/showClients.php');
?>
Is it practical in any sense?
You can't include that remote .php file because you got blank page mostly .
you can encrypt your code using various methods e.g ionCube or compile your php script to C++ .so extension using SWIG , php-cpp , , , compile a PHP extension (DLL file) in Windows , PHP-TO-C-Ext , zephir lang , PHC
to includes php files uses extension such as .inc so web server will display it as source code So you can grape it to your local machine .
to protect your showClients.php or the new showClients.inc you have to protect it from remot server to only allow your local machine to access that file .
Related
I have a local version of Windows php to test my webpage. I run it using php.exe. It has a built-in webserver so pages can be accessed from a browser through localhost:/path.
If I enter an URL pointing to a file it opens that file in browser. I would like to configure it so that it shows the content of a directory if URL points to a directory. E.g. after inserting URL http://localhost:1234/foo/bar/ into the browser I would want to see the files in the bar directory listed in the browser. Similarly how other webservers do it when configured so.
My local PHP returns 404 instead.
Is there any way how to achieve that for this built-in webserver in php.exe? How?
The built-in server is specifically for quick development and debugging as stated in the command line server doc and directory listing is one of the features is lacks. This answer provides an example for building yours though.
I have an intranet project based on the PHP and xampp server on the Windows. That intranet project have database with table where I store scanned disc drive informations of files and folders. I using simple windows command dir "$directory_path" /Q /T:C to get informations.
After that I use regex to match and parse that info to separate date, time, permission and dir name like on this example:
EXAMPLE REGEX FOR DIRECTORY PARSING
It's similar like this example: Get file owner in Windows using PHP
This working fine but sometimes file owner names are realy long and was stripped by command line. In that case I can't read full name and functionality is broken.
Now I searching for another solution.
My PHP have instaled also php_com_dotnet.dll extension and I using COM() class in some part of code.
My main question is:
-Can I use COM() class to get real file informations and avoid shell commands for the file search and listings and how?
-Is there some another extension, shell command or something 3rd what I can use to get file/folder owners?
NOTE: I need this only for the reading and indexing in the database, don't need to change permissions or ownership.
I find simple solution for this using PHP class COM() and the documentation of the IADsSecurityUtility::GetSecurityDescriptor method.
The code in PHP looks like this:
$path = 'D:\Some File\Some Another File\document.doc'; // File or dir path
$su = new COM("ADsSecurityUtility"); // Call interface
$securityInfo = $su->GetSecurityDescriptor($path, 1, 1); // Call method
echo $securityInfo->owner; // Get file owner
That's all folks.
NOTE
COM functions are only available for the Windows version of PHP.
.Net support requires PHP 5 and the .Net runtime.
As of PHP 5.3.15 / 5.4.5, this extension requires php_com_dotnet.dll
to be enabled inside of php.ini in order to use these functions.
Previous versions of PHP enabled these extensions by default.
You are responsible for installing support for the various COM objects
I'm currently developing an android application. The backend is written in PHP and takes input from the android app and connects it with a MySQL database (similar to http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/).
One of my class files (similar to the UserFunctions.java in the above link) requires the url to be given e.g. private static String loginURL = "http://10.0.2.2/android_api/index.php" so that the requisite communcation can take place. My issue is that all my PHP files are in a folder under \www e.g. \www\blah\. I'm fairly sure that I have put my PHP files in the wrong place as the link (Point 2 of http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/) shows some files being placed in \include\ and the index.php file outside this \include\ directory.
Where should I be placing my PHP files so that my file structure enables my app to communicate with the MySQL database (defined for example as android_api as in the link).
If you are using wamp it may be in C:/wamp/www/android_api. www is the web root directory. If you call http://10.0.2.2/android_api/index.php, webserver will look the file index.php in the path C:/wamp/www/android_api
I'm fairly certain all of your application's php files should be in www.
I'm not currently developing in Java so you may need to fiddle with what I tell you but the way I access mysql from an external application is this:
Connect to database and perform query within the php file. Then echo the results (JSON encode if necessary)
Then in the external application, simply use the path to the php file:
eg. "http://localhost/your_script.php"
This will be your php file if it is in the root of www
Notice that you do not specify www in the path.
hello i am implementing php files from one website into another and here is the following error message i am getting when trying to open the following page with implemented php files:
http://www.holidaysavers.ca/europe-destinations-canada.php
basically the php files i am importing from one website into another are identical , however they work on the original website but when i implement them into a new website it does not work anymore.
could you assist me in trying to get this resolved?
thank you
You can't include a PHP script that is on an external website/server into your local script - unless you enable allow_url_include on your php.ini (if you have access to it)
Instead, you can let that website/server render the page and get the resulting html output on your local script.
Replace this line in your script:
include('http://www.holidaysavers.ca/europe-canada.php?detour');
With this:
echo file_get_contents('http://www.holidaysavers.ca/europe-canada.php?detour');
Could you post the code from "europe-destinations-canada.php"? It looks like the script is asking to do stuff that's not configured in your php setup on this new site/server
I don't really know what kind of host you are using or if you are using Xampp, I do have an easy fix to it, for xampp and possibly other web server software. Go to your php.ini file, which you can search for or just look for it in c:\\xampp\php\php.ini, the php.ini should be in the php folder in the server software folder. Now search for allow_url_include in the php.ini file and than replace Off with On, if it isn't already on or something. This is most likely the fix because it worked for me.
I might be able to help further if I know if you are using a hosting or home server. If you are using a hosting website than please share what kind of hosting service you are using so I could inspect it further.
Using as example a random remote php file.
The goal is to use this remote file locally, make sure it hasn't change or be altered. The remote file will be downloaded one time only.
Hard coding the sha256 signature avoid to use the network on startup. This is just a base that can be turned to many scenarios, like checking for updates, depending your needs.
<?php
$lib_url = "https://raw.githubusercontent.com/getopt-php/getopt-php/master/src/CommandInterface.php";
$lib_filename = basename($lib_url);
// SHA256 signature
$lib_signature = hash_file("sha256",$lib_url); // "dba0b3fe70b52adbb8376be6a256d2cc371b2fe49ef35f0c6e15cd6d60c319dd"
// Hardcode the signature to avoid a network call on startup:
//$lib_signature = "dba0b3fe70b52adbb8376be6a256d2cc371b2fe49ef35f0c6e15cd6d60c319dd";
if (!is_file($lib_filename) || $lib_signature != hash_file("sha256",$lib_filename)){
// No local copy found, or file signature invalid, get a copy
copy($lib_url, $lib_filename);
}
require $lib_filename;
It is very useful if you intent to share a program as a single file, without composer.
For the case of a file hosted on Github, an ETag HTTP header is provided, it can be used to avoid to download the whole file.
php -r 'var_dump(json_decode(get_headers("https://raw.githubusercontent.com/getopt-php/getopt-php/master/src/CommandInterface.php", 1)["ETag"]));'
//string(64) "c0153dbd04652cc11cddb0876c5abcc9950cac7378960223cbbe6cf4833a0d6b"
The ETag HTTP response header is an identifier for a specific version
of a resource. It lets caches be more efficient and save bandwidth, as
a web server does not need to resend a full response if the content
has not changed.
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/content/91/8151691/html/HolidaySavers.ca/europe-destinations-canada.php on line 52
says it all. I believe this is called XXS. It appears you're attempting to include a URL based file which is denied in your server configuration which is either one of two things.
You're attempting to include the file on site B from site A which you would then use instead of include('WhateverFile'); file_get_contents('WhateverFile'); however this will only return the client side data as it is an HTTP request;
You've duplicated the file on site B and forgot to update the domain configuration. Be sure that the include path reflects the site you're running the script on ie.
include(dir($_SERVER['SCRIPT_FILENAME']) . DIRECTORY_SEPARATOR . 'WhateverFile.php');
In any case. I would have to actually examine the line 52 on the said file to see why PHP is complaining to you in detail lol
I am new to both PHP and Java. Currently I am working on a project which call java class and its methods in the PHP code. I am creating a proof of concept for this. The problem is I am not able to connect custom class I have created in java. More over it could be said I don't know how to do it. I have used java.inc and javabridge.jar files to connect to the system classes but not able to connect to a simple class.
The step I have followed is:
Created a java package, class called clsForPHP and it has a method sum() which takes 2 parameters and returns integer value. (This is created using MyEclipse IDE)
Now I am trying to call this function from PHP. I have copied the jar file containg the package to PHP project. (Eclipse- Helios is the IDE)
$d= new java("clsForPHP.class");
Please help!! I have searched a lot but couldn't able to find a proper solution. What I think is this package should be added in the java.inc file but I don't know how to do it.
First of all install Tomcat6 and Java in you Unix box. Most probably your Tomcat will be on 8080 port. Now Download JavaBridge.war from http://php-java-bridge.sourceforge.net/pjb/ unzip it. Then from WEB-INF/lib folder copy JavaBridge.jar ,php-servlet.jar and php-script.jar in lib folder of Tomcat. Then copy JavaBridge.war in your Tomcat6 webapps folder and restart your tomcat6 service which will deploy automatically JavaBridge folder in your webapps
Now try to browse http://localhost:8080/JavaBridge/. If you get working than your PHP/Java Bridge installed. First Part is over.
Now make test page in your apache as below
<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
echo java("java.lang.System")->getProperties();
?>
and run it. If it works then you can start working with your work. If it not work then you have problem with you php.ini file. Try to make allow_url_once=on in your php.ini.
Now just copy your java jar file in tomcat /webapps/JavaBridge/WEB-INF/lib/ folder
and Just always put following line in your page where ever you want java to work
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
$yourObj = Javav("your java class");
$yourObj->yourMethod();
$yourObj->setProperty("xxx");
Hope this can help you out.
IF you have still any problem get back.
Yea it will throw error because you must not have copied your java compiled file may be your jar file in PHP / Java Bridge.
You can to do in following 2 options way
If you have define your CATALINA_HOME then copy
$CATALINA_HOME/webapps/JavaBridge/WEB-INF/lib
If you have not define your CATALINA_HOME then copy
/var/lib/tomcat6/webapps/webapps/JavaBridge/WEB-INF/lib
Path which I am telling it assumes that you have install tomcat6, may be your tomcat webapps folder may be in different path.