I need to transfer some xml files via sftp to another server.
I tried to get phpseclib running for like 4 hours. Composer crashed several times trying to install phpseclib, so i downloaded it manually.
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
require('phpseclib/Net/SFTP.php');
I can't get around this error:
Fatal error: Call to undefined method Crypt_Rc4::enableContinuousBuffer() in
/Applications/XAMPP/xamppfiles/htdocs/phpseclib/Net/SSH2.php
on line 1640
I tried to track down if there are some classes which override some parent classes of Crypt_TripleDES (object on line 1640), but I did not find anything. All other classes in this project are written by me.
Edit:
Problem could be tracked down to the PHP class /Applications/XAMPP/xamppfiles/lib/php/Crypt/Rc4.php
My unsatisfying but working solution is renaming the file to _Rc4.php. But I need an another solution since I don't have too much influence on the productive server.
Related
If i have some PDF files, each has one page and i would like to merge all files into on single file using PHP
I have read dozens of questions here about same but most of all are out of date or no longer working since for PHP version >= 7.0
One of the solutions was to use PDFMerger and here is my code
require_once ('PDFMerger.php');
use PDFMerger\PDFMerger;
$pdf = new PDFMerger;
$pdf->addPDF('books/1.pdf');
$pdf->addPDF('books/2.pdf');
$pdf->merge('download','books/merged.pdf');
but if simply gives blank page and no file is created and same to this library PDFMerger
UPDATE1! wihtout namespace use PDFMerger\PDFMerger; iam getting this error
Fatal error: Uncaught Error: Class "PDFMerger" not found in mypath\sample.php:4 Stack trace: #0 {main} thrown in mypath\sample.php on line 4
so is there any way that is still working to merger PDF files without have to care how such file are created.
NOTE! I can not use shell_exec since files are on shared hosting
After trying a lot of time , i decide to shift back to a lower PHP version 7.1 rather than 8.0 and everything goes fine though
I have an activity plugin that requires another plugin to work correctly.
I followed the recommendation of requesting this plugin as a dependency in the version.php file like this :
$plugin->dependencies = array('local_aws' => 2017071501 ); //AWS php SDK dependency
The problem is when I install my plugin I receive a Warning :
Warning:
require_once(/var/www/moodle/local/aws/sdk/aws-autoloader.php): failed
to open stream: No such file or directory in
/var/www/moodle/mod/tutorship/lib.php on line 37
Fatal error: require_once(): Failed opening required
'/var/www/moodle/local/aws/sdk/aws-autoloader.php'
(include_path='/var/www/moodle/lib/pear:.:/usr/share/php') in
/var/www/moodle/mod/mymodulep/lib.php on line 37
Line 37 uses this code:
// For AWS API Part
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');
So it seems to me during the install of my plugin the require_ once is not being satisfied as the AWS plugin has yet to be installed. Well I followed the recommendation of making it a dependency in version.php but it isn't being installed before the require_ once is checked ?
How can I resolve this conundrum ?
I think you are right in your supposition that "require_ once is not being satisfied as the AWS plugin has yet to be installed". To avoid this kind of problem, you should try to avoid to require files of other plugins/libraries in lines that are actually executed during the plugin installation/upgrading procedures. Is it necessary to use the other plugin during the installation of yours?
I would move the require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php'); to some file that is never run during the actual installation/upgrading (avoid the header of lib.php). For example, I would create a class mod/tutorship/classes/some_class.php (properly "namespaced" with namespace mod_tutorship;), do the require_once there and then just instantiate the class in my lib.php within the function that actually needs it.
I'm writing a web app, and I created a scraper to get data from my own site.
I have a few dependencies, so they're being extended, but now that I'm trying to run this php script from exec, and it doesn't work, I get the error:
PHP Fatal error: Uncaught Error: Class 'App\Helpers\ScraperHelper' not found in /home/username/public_html/App/Libraries/Scraper/execute.php:6.
Begin.php
This is how I'm calling my script:
exec('/usr/bin/php/ home/username/public_htm/App/Libraries/Scraper/execute.php');
Execute.php
namespace App\Libraries\Scraper;
use \App\Helpers\ScraperHelper;
$recipe = new ScraperHelper();
$recipe->fromFeed();
fromFeed() runs the script that's included in the ScraperHelper class, scrape the information from the site and inserts it into the database.
I've tried removing all the namespaces, and using require with full server path, but there are a 4 other dependencies that doesn't allow me to access them.
require_once '/home/username/public_html/App/Helpers/ScraperHelper.php';
require_once '/home/username/public_html/App/Models/Food.php';
require_once '/home/username/public_html/Core/Model.php';
Composer is autoloading two folders. Core and App, but I figure that the exec function ignores it which is why I keep getting Uncaught Error.
I believe exec isn't being able to process the namespaces and use calls, I included all the files with require_once and it worked, but It's not what I need still, I really need to know how to make exec process namespaces, use calls.
I just updated Drupal core from 7.4 to 7.26. After running update.php site stopped working – both public and admin part. When I load it fatal error occurs:
Fatal error: Call to undefined function _system_default_theme_features() in /[drupal_path]/includes/theme.inc on line 1422
and when I reload it another fatal error apperars:
Fatal error: Call to a member function getDirectoryPath() on a non-object in /[drupal_path]/modules/image/image.module on line 83
next reload – first error, one more – second. Also, second error is loading much faster.
And one more thing, after applaying update.php I got one failed, I don't know if this is connected:
media_gallery module
Update #7009
Failed: FieldException: Próba aktualizacji egzemplarza nieistniejącego pola media_gallery_media. w field_update_instance() (linia 557 z /[drupal_path]/modules/field/field.crud.inc).
which is something like:
Failed: FieldException: Attempt to update an instance of a nonexistent field media_gallery_media. in field_update_instance() (line 557 in /[drupal_path]/modules/field/field.crud.inc).
PHP Version 5.5.6
Any tips where the problem is? I was trying disabling some modules from db, but this did't help.
It's difficult to explain the reason and to provide a solution.
My attempt would be to copy the DB and the files on a neutral platform (local machine or so) and experiment with the update.php script.
My suspicion would be that media module needs also update since it's using the old URI function definition (call). Also try to update other modules that are working with files.
The update is quite big since 7.4 to 7.22 (years of improvement). Reading the change log would be helpful but not realistic.
Did you also cleared the cache? (via drush if the web interface not working - /?q=admin/config/development/performance)
Please don't forget to post the solution if you find one for other users with the same issue.
I am attempting to use require to load the ExcelPHP API to manipulate CSV spreadsheets. I am using EasyPHP 12.1 with PHP 5.4.6, Apache 2.4.2, MySQL 5.5.27 and Xdebug 2.2.1. I am on Windows 7.
When I attempt to run the following code:
require_once('classes/PHPexcel/Autoloader.php');
$mySheet = new PHPExcel();
I get a fatal error:
Notice: Use of undefined constant PHPEXCEL_ROOT - assumed 'PHPEXCEL_ROOT' in C:\Program Files\EasyPHP-12.0\www\Classes\Classes\PHPExcel\Autoloader.php on line 73
Fatal error: Class 'PHPExcel_Shared_ZipStreamWrapper' not found in C:\Program Files\EasyPHP-12.0\www\Classes\Classes\PHPExcel\Autoloader.php on line 31
I have tried commenting out line 31 in the Autoloader.php file, and that prevents the the fatal error but then the API won't work and PHP doesn't recognize the PHPExcel class.
Can someone please help me figure out how to get my library to work? Thanks in advance!
Load the PHPExcel class in your require once, rather than the Autoloader (as Seth) has said. Case-sensitivity is also a potential problem, because your scripts won't transfer without error unless you get it right:
require_once('classes/PHPexcel/Autoloader.php');
should be
require_once('classes/PHPExcel.php');
and the library is PHPExcel, not ExcelPHP as you call it in your subject line
Instead of your current require statement, you should call
require_once('classes/PHPExcel.php');
That file defines the constant PHPEXCEL_ROOT that you are missing, and then calls require_once() on the autoloader file. It also loads the main class PHPExcel that the whole library uses.
This may have come a bit too late as PHPExcel has pivoted to PHPSpreadsheet but if you're still using PHPExcel and you want to use the autoloader, all you have to do is define the PHPExcel root before requiring autoloader.
define('PHPEXCEL_ROOT', dirname(__FILE__).'/');
i use it composer in my custom mvc framework
require_once ROOT . '/vendor/autoload.php';
PHPExcel_Autoloader::Register();