How can I get "DOCUMENT_ROOT" in phpbb 3.1? - phpbb3

I have tried to use this
require $_SERVER['DOCUMENT_ROOT'] . '/lib/MyClass.php';
But I got this message
Illegal use of $_SERVER. You must use the request class or request_var() to access input data
I have attempted to use request_var(), but it doesn't work.
How can I get "DOCUMENT_ROOT" in phpbb 3.1 ?

I have found the next decision of this problem - use filter_input instead of $_SERVER.
require filter_input(INPUT_SERVER, 'DOCUMENT_ROOT') . '/lib/MyClass.php';

Related

Upgrading to Ruby 3.1 causes Psych::DisallowedClass exception when using YAML.load_file

When upgrading to ruby 3.1, I am seeing the following sort error message when using YAML.load_file some_file_name
Psych::DisallowedClass:
Tried to load unspecified class: Matrix
Other load statements cause similar errors but cite different unspecified classes e.g. OpenStruct. It appears that the latest version of YAML only loads classes from a permitted white list, so it is necessary to use a permitted_class keyword to allow other classes. I have tried
hsh = YAML.load_file some_file_name, permitted_classes: [Matrix, OpenStruct]
but this gives the error
Psych::DisallowedClass:
Tried to load unspecified class: Symbol
how do I fix this?
The working solution is to add this line to config/application.rb
config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess]
You can do the same with any class name, like
config.active_record.yaml_column_permitted_classes = [Symbol, Hash, Array, ActiveSupport::HashWithIndifferentAccess]
Symbol is also not allowed per default. Therefore just add Symbol to the permitted_classes too:
hash = YAML.load_file(
some_file_name,
permitted_classes: [Matrix, OpenStruct, Symbol]
)
See the list of default permitted_classes.
Had this on rails 6.1 upgrade. If you have no other choice, maybe this workaround will bring you some time (application.rb):
config.active_record.use_yaml_unsafe_load = true

Trying to implement FPDF with all forms of instantiation but only one form works. Others give Error

Installed crabbley/fpdf-laravel as per instructions. Tried some sample code as follows:
$pdf= app('FPDF');
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Swordsmen Class Times');
$pdf->Output();
While the instantiation of fpdf is different from the samples in the tutorials, all works as expected and the pdf is displayed in the browser. I got this working sample from the crabbley packagist.org/packages/crabbly/fpdf-laravel readme under 'usage'. The 'usage' instructions also provide an alternative instantiation viz: $pdf = new Crabbly\FPDF\FPDF;
The tutorial samples use something slightly different again, ie
require('fpdf.php');
x=new FPDF();
and thus are a little different. When I changed it to be the same as the tutorial, all I changed was the instantiation line from
$pdf= app('FPDF');
to
$pdf = new FPDF('L', 'mm','A4');
and I get the error 'Class 'App\Http\Controllers\FPDF' not found'. I do not understand the difference between the different forms of instantiation and not sure what is going on but I need the latter format so I can set page orientation etc. I also tried the usage format as described above with the same sort of error, ie new Crabbly\FPDF\FPDF not found.
I have tried the require statement but FPDF is not found and I am unsure where to point 'require' to.
Installation consisted of:
composer require crabbly/fpdf-laravel
add Crabbly\FPDF\FpdfServiceProvider::class to config/app.php in the providers section
Any suggestions will be appreciated.
You are using an implementation for the Laravel framework that binds an instance of FPDF to the service container. Using app('FPDF') returns you a new instance of FPDF, which is pretty much the same what new FPDF() would do.
The require way of using it is framework agnostic and would be the way to use FPDF if you are just using a plain PHP script. While you could use this way with Laravel too, why would you want to do that?
The reason the require does not work, by the way, is that the fpdf.php file is not found from where you call it. It would be required to sit in the same directory unless you give it a path. Considering you installed it using composer, the fpdf.php script, if any, should sit inside the vendor directory.
However, just go with using the service container. The line $pdf = new FPDF('L', 'mm','A4'); just creates a new instance of the FPDF class and initializes it by passing arguments to the constructor, these being 'L' for landscape orientation, 'mm' for the measurement unit, and 'A4' for the page size. Without knowing the package you use and having testing it, you should also be able to set them equivalently by calling:
$pdf = app('FPDF', ['L', 'mm', 'A4']);
Hope that helps!

PHPBB3and super globals?

I try to customize my PHPBB3 interface.
For that I need to include a header and a footer.
The header file I try to include has the use of...
$this->_agent = $_SERVER['HTTP_USER_AGENT'];
...wrapped in a function.
Here is the error message when I open the PHPBB3 index page:
Illegal use of $_SERVER. You must use the request class or
request_var() to access input data.
For info, the file I try to include works well in any other context than PHPBB3.
Can someone tell me what I have to do and where I have to do it in order to get rid of this error message and have my included file work properly?
Thank you.
You only have to use the request_var() function to access your datas.
$userAgent = request_var('HTTP_USER_AGENT','');
You can find more information about this function here :
https://wiki.phpbb.com/Function.request_var

CodeIgniter parser addon

Can't load my_parser class.
Added this http://codepad.org/QtHsyRN3 to application/libraries
than in controller i wrote
$this->load->library('my_parser');
but i am getting
Unable to load the requested class: my_parser
What can be? I need something like this
{if 10 > 8}10 is greater then 8<br />{/if}
But without smarty and etc.
The user guide states you shouldn't include the 'MY_' when calling the library, so:
$this->load->library('parser');
should work - see http://codeigniter.com/user_guide/general/creating_libraries.html
.php file was wrong name. Solutions is "class name = .php file name"

Rally API using Ruby: How do I reference the testcase method (Automated/Manual)?

I am using Ruby to work with the Rally API. I am trying to reference the testcase method. The method being Manual or Automated, but I always get an error. I am using Ruby, so I don’t know if method is a reserved word in Ruby, or what is happening. Could you please let me know how to reference the test case method?
I am able to do:
testcase.objective
testcase.priority
etc.
But I can’t do
testcase.method
I always get this error.
‘method’: wrong number of arguments (0 for 1) (ArgumentError)
Are you using rally_rest_api or rally_api?
If you are using rally_rest_api - Charles is correct. try testcase.elements[:method]
(fieldname downcased and underscored as a symbol)
If you are using rally_api - http://rubygems.org/gems/rally_api -
Getting fields can just be:
testcase["FieldName"]
Hope that helps.
You just need to capitalize the names when trying to access built-in fields (i.e. fields that are not custom). I came across this problem myself and using tc.Method instead of tc.method fixed it.
The reason this error shows up can be seen in the docs for Object#method which, as you've likely figured out by now, causes your code to call the method method instead of access the field named method.

Resources