DocBlox CodeIgniter No direct script access - codeigniter

I've just installed DocBlox on Windows running Apache.
In a CodeIgniter application I have removed the following line from the top of my script
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
But when I run
docblox -f main.php -t docs
I get the error message
No direct script access allowed
Does anyone know what else is stopping this from working?
Thanks

Short version
You probably have a class that is not in the source that DocBlox parses but is in your include_path. Try to find which file causes this error using the verbose (-v) option and check which classes are not in your project's source but are being invoked.
Explanation
DocBlox does not load files using Reflection and should thus not execute the given code unless a class could not be found in the project files but could be found using the include_path.
For example:
class A extends B
{
}
if class B is not parsed by DocBlox then DocBlox will try to find it in your include path so that information can be gathered on it. In this case A is not executed but B is.

Related

SFTP Namespace with phpseclib installed manually

I am trying to connect using SFTP (phpseclib) with a manual installation. That's the very first time I'm using namespaces so I don't know if what I'm doing is the way I have to.
I did download phpseclib from GitHub as ZIP and put it in /home/libs_web/php/class/phpseclib3
After that I used this code (just as example) :
require('/home/libs_web/php/class/phpseclib3/Net/SFTP.php');
use phpseclib3\Net\SFTP;
$sftp = new SFTP('localhost');
$sftp->login('username', 'password');
As mentioned here but with an include on top : https://phpseclib.com/docs/sftp
Here is my error : Fatal error: Uncaught Error: Class 'phpseclib3\Net\SSH2' not found in /home/libs_web/php/class/phpseclib3/Net/SFTP.php:52
It seems like my Namespace doesn't work correctly. I do not use autoloader, composer, and tried to set the working directory to /home/libs_web/php/class/phpseclib3/ & /home/libs_web/php/class/.
Don't know what to do more. If I include the file /Net/SSH2.php I'll have another error about another file. I think this isn't the proper way to work.
Could you please provide some help ?
phpseclib3 is best installed with Composer. eg. on the CLI do composer init; composer require phpseclib/phpseclib:~3.0. You'd also put require __DIR__ . '/vendor/autoload.php'; at the top of your file
If you wanted to do something like make your source code available for people to download and make it work on shared hosts were CLI access might not be available I guess you could do Composer and then upload the vendor/ directory by itself or include it with your zip file or whatever.

Can I run stanza NER without downloading the language modules?

I need to run stanza ner in a platform without any access to external network. The code stanza.download('en') fails. Running without the download function, gives me an exception
Exception: Resources file not found at: \home\stanza_resources\resources.json. Try to download the model again
Is there a way to download and cache all the required modules in a resource directory and point this directory to stanza pipeline?
Thanks
It looks like both download and the Pipeline class take an argument for directory dir
So the below code works
stanza.download('en', dir='resources/', processors={ner_processor: package})
nlp_pipeline = stanza.Pipeline('en', dir='resources/', processors={ner_processor: package})

How could I do a massive install of a PrestaShop module?

I have a problem, I have to do a massive install of a custom PrestaShop module on 1500 e-commerce, but I don't know if this is possible, I was thinking to include a file called install.php and run through a.sh, this file may contain the next.
For example:
<?php
include "meli.php";
$meli = new Meli();
$meli->install();
?>
I called this file and initially, nothing happened so I check the possible reason and was:
if (!defined('_PS_VERSION_'))
exit;
So I commented this and run it again but this show me this error:
Fatal error: Class 'Module' not found in /home/dev2al5/public_html/modules/meli/meli.php on line 7
Does someone know how I can do this process?
Indeed I would do 3 things in the SH script:
Copy of the modules files in each site in the modules folder
Copy of a sql file containing the instructions to be executed
Calling a URL present in each module that would execute the SQL and then delete the SQL file in question
Regards

Run plugin's shell in cakephp 2.0

I have created a new CakePHP 2.0 app and want to run a plugin's shell.
<?php
// app\Plugin\Tmaker\Vendors\Shells\TmakerShell.php
class TmakerShell extends Shell {
}
However, I can't see it when running Console/cake from the command-line.
Please advise my what I have missed?
According to the latest documentation, the path for shells has changed to app/Console/Command/.
Move your shell to the following location: app/Plugin/Tmaker/Console/Command/TmakerShell.php (not sure if plugin directory names are camel-cased in CakePHP 2.0, but it seems to work either way.)
<?php
class TmakerShell extends Shell {
public function main() {
$this->out('It works!');
}
}
As CakePHP 2.0 requires you to load plugins manually, you also need to update app/Config/bootstrap.php by adding CakePlugin::loadAll(); or CakePlugin::load('Tmaker'); to the last line.
You should then be able to access your shell from the command-line. It looks like this in Windows:
C:\xampplite\htdocs\cake2\app>..\lib\Cake\Console\cake Tmaker.tmaker
Welcome to CakePHP v2.0.0-beta Console
---------------------------------------------------------------
App : app
Path: C:\xampplite\htdocs\cake2\app\
---------------------------------------------------------------
It works!

Perl::WSDL. Generated methods in different directory than script

I am trying to write a script for using with op5/nagios.
What it tries to do is to connect to database an get a value there, and then send a request to a webservice and match the response from the webservice with the value from the database.
Now writing the script wasn't the problem. The problem arrises when trying to run it from OP5.
When including the interface to script I use the following syntax
use MyInterfaces::PortalServicesImplService::PortalServicesImplPort;
This works just fine when I execute the script located on the same level as "MyInterfaces".
The problem is that the script itself is located in the folder /opt/plugins/custom/SOAP where both the script and the folders generated by wsdl2perl.pl is located. However when OP5 executes the script is does so from the folder /opt/monitor.
So I tried to include the "PortalServicesImplPort" using this syntax
use lib "/opt/plugins/custom/SOAP/MyInterfaces/PortalservicesImplServices/PortalServicesImplPort
The code compiles but when trying to run it I get an error message saying
Can't locate object method "new" via package "MyInterfaces::PortalServicesImplService::PortalServicesImplPort" (perhaps you forgot to load "MyInterfaces::PortalServicesImplService::PortalServicesImplPort"?)
Am I doing something wrong when importing methods from another location or doesn't SOAP::WSDL support placing the auto generated files in a different directory from where you are executing the script?
Seems I managed to solve this myself by adding use lib "/opt/plugins/custom/SOAP

Resources