How to copy file over to server using phpseclib (SSH2) - php

I'd like to know how can I copy a file from localhost to the remote server using the phpseclib library? Which functions within the library would achieve this?

Check this example. if you use the latest version of phpseclib you should use SOURCE_LOCAL_FILE const instead of NET_SFTP_LOCAL_FILE.

Related

protect the excel from being opened in php

How to protect excel file from being opened in php. i have created password protected zip file using
exec(zip -p file.zip /path);
but problem i faced here is when i tried to extract password protected zip in windows. i works fine in linux OS but not in windows.
Can anybody suggest me how to protect excel file with password in php either with zip method or directly password on excel file using PHP Code.
Did you try using the setEncryption method?
$dompdf->get_canvas()->get_cpdf()->setEncryption("pass", "pass");
The answer by Simone is very close.
Here is a working example with Laravel 5.4 and the Laravel DOMPDF wrapper by barryvdh:
$content = 'some html';
$dompdf = \App::make('dompdf.wrapper');
$dompdf->loadHTML($content)->setPaper('a4');
$dompdf->getDomPDF()->getCanvas()->get_cpdf()->setEncryption("pass", 'your_password');
If you are not using the barryvdh package, simply inspect your the dompdf library until you find the methods which retrieve the Canvas class and then the CPDFclass, which contains the setEncryption method.
Hope this helps!

Copy/upload file from webserver to standalone mac

How can i copy a file/directory with PHP to a MAC machine?
So from
/home/domain/file/file.jpg
to
standalone macmachine directory
You can use the php copy function. read the following article.
function.copy.php
for example:
<?php
copy('/Your/Path/From', '/Your/Path/To');
//OR
copy('http://example.com/your_path', '/Your/Path/To');
copy('/Your/Path/From', '/Your/Path/To');
//OR
copy('http://example.com/your_path', '/Your/Path/To');

Empty directory when generating Cloud Endpoints PHP client with Google APIs Client Generator

I'm trying to generate a PHP client for my Google Cloud Endpoints API using the Google APIs Client Generator but it just creates an empty directory instead.
The command I'm using looks like:
generate_library --language=php --language_variant=stable --output_dir=/path/php-client --input=/path/myApi-v1.json
It seems to work when I change the language to csharp and java. I turned on the verbose flag and don't see any errors, only tracing messages like:
DEBUG:codegen:Create: myMethod, parent=update
DEBUG:codegen:Schema.Create: updateRequestContent => MyMessage
DEBUG:codegen:DataTypeFromJson: add MyMessage to cache
Searching around I see someone at the AppEngine sub Reddit posted a similar issue with no response.
I used another approach:
downloaded the zip from
https://github.com/google/apis-client-generator
Extracted the zip file in a directory (i named it client-generator)
Executed the generate.sh script available in the extracted files.
/path/client-generator/generate.sh --input=/path/rest.json --language=php --output_dir=/path/output
The APICLassName.php file is generated
I tried again and changed the --language_variant argument from stable to 1.1.4 and it now works fine.

Using Cassandra PDO Driver on Windows

Is there any way to have Cassandra PDO at Windows with Wamp?
This is for development purposes I don't want to install Linux and change all the environment.
https://code.google.com/a/apache-extras.org/p/cassandra-pdo/
I'm using Windows 7 (64 Bit), Wamp 2.5, PHP 5.5.
OK, here's what I found out:
1) It's totally possible
2) The docs that appear in the first google search results are a bit obsolete
Start by downloading the latest Datastax Community Cassandra here:
http://planetcassandra.org/cassandra/
Install & setup properly. In fact, most of the configuration is done by the installer, you just have to edit the apache-cassandra/conf/cassandra.yaml file to find all paths to /var/lib... and change those into something like d:/cassandra/... That includes "commitlog", "data", "saved_caches". Restart the Cassandra service, examine the logs. Mine shown no problem. The OpsCenter at ...:8888/opscenter/index.html was working fine, showing one node online.
Now, the PHP part.
There's a sneaky thing called Thrift. From what I've learned today (I first heard about Cassandra and Thrift yesterday), it's a way describe a binary protocol of connecting to some online service, in this case, to Cassandra. It will basically generate PHP files that will provide all the connectivity you need from PHP itself (no extensions needed).
You will need:
1) The Thrift PHP libs
2) The .exe Thrift compiler
Both can be downloaded here:
https://thrift.apache.org/download
Then use the following command to compile PHP files that will act as a "driver" to connect your PHP applications to Cassandra:
thrift --gen php D:\DataStaxCommunity\apache-cassandra\interface\cassandra.thrift
Put the result in some PHP include_path folder.
Also, find the PHP Thrift libs (in the libs archive from the same download page) and put those in a folder accessible to your script (e.g. include_path or the project folder).
Refer this page:
thrift.apache.org/lib/php
I guess that should help!
I have same problem as you, but when i tried this method, it works correctly for me.
Reference link
Here is a code example, very easy to understand :
<?php
require_once 'Cassandra/Cassandra.php';
$o_cassandra = new Cassandra();
$s_server_host = '127.0.0.1'; // Localhost
$i_server_port = 9042;
$s_server_username = ''; // We don't use username
$s_server_password = ''; // We don't use password
$s_server_keyspace = 'cassandra_tests';
$o_cassandra->connect($s_server_host, $s_server_username, $s_server_password, $s_server_keyspace, $i_server_port);
$s_cql = "CREATE TABLE carles_test_table (s_thekey text, s_column1 text, s_column2 text,PRIMARY KEY (s_thekey));";
$st_results = $o_cassandra->query($s_cql);

Zend-PDF error: Can not open file for writing

I am using ZendFramwork1, my local sever php 5.4. and with MongoDB .I have use function Zend_Pdf to draw PDF in my project. it's run well in my local server. but when i put code to sever that have same version PHP. Everything module is okay but for function print data to pdf is errors . I got message like PDF error: Can not open 'data/reports/myfile.pdf' file for writing. . Any one can help me . what's different between my local server and real sever ?
I am looking to see your reply soon.
thank
First off, chmod 777 is a hack and shouldn't really be used. If you're using apache, you are better off chown'ing the folder to the correct user.

Categories