I'm following the information here:
http://www.yiiframework.com/doc/guide/1.1/en/topics.logging
Please take a look at my log component on my dev machine configuration file:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CProfileLogRoute',
'levels'=>'error, warning, trace, info, profile',
),
array(
'class'=>'CWebLogRoute',
'levels'=>'error, warning, trace, info, profile',
'showInFireBug'=>true,
),
),
Using CProfileLogRoute is of any use JUST AND ONLY IF we place something like this on our application code:
Yii::beginProfile('blockID');
...code block being profiled...
Yii::endProfile('blockID');
1)
IF the only purpose is to measure the speed, then what does those levels
'error, warning, trace, info, private'
really mean on this context ?
Thanks a lot in advance,
MEM
Looks like those are remnants from CLogRoute (a parent class) that are unused in the code:
http://code.google.com/p/yii/source/browse/tags/1.1.10/framework/logging/CProfileLogRoute.php
The only variable I tend to set got CProfileLogRoute is 'report':
http://www.yiiframework.com/doc/api/1.1/CProfileLogRoute#setReport-detail
Related
How to use WHMCS LocalAPI (InternaAPI)
Hi
I have a problem to use WHMCS LocalAPI
WHMCS Documentation is very poor and unclear about this problem
when I run this code a blank page appear and any thing is happened
<?php
require('../init.php');
require('../includes/api.php');
$command = 'AddOrder';
$postData = array(
'clientid' => '1',
'domain' => array('domain1.com'),
'billingcycle' => array('annually'),
'domaintype' => array('register',),
'regperiod' => array(1),
'nameserver1' => 'ns1.demo.com',
'nameserver2' => 'ns2.demo.com',
'paymentmethod' => 'zarinpalgw',
);
$adminUsername = 'myadminname'; // Optional for WHMCS 7.2 and later
$results = localAPI($command, $postData, $adminUsername);
print_r($results);
?>
I expected to add order after run this code
External API is very slow and not suitable for me for some reason such as
I have a dynamic IP and External API work with static IP because IP must be recognize in WHMCS->General setting->Security
The Internal API code in your example looks like it should work. Temporarily enabling PHP errors can help narrow down the exact cause of this issue (Setup > General Settings > Other > Display Errors), although I believe it is due to the way you are initializing the WHMCS environment in your PHP file.
WHMCS provides specific guidelines on building custom pages, which appears to be what you were trying to do in the example provided. Custom PHP files must be located in the root WHMCS directory, however require('../init.php'); indicates that your script is currently inside a subdirectory. You also should not be requiring api.php, as that is already being handled by init.php. Moving your script to the WHMCS root directory and commenting out the require('../includes/api.php'); line should hopefully fix the blank page issue.
Please note: the example you provided does not display the normal WHMCS client interface and does not check to see if the user is logged in. If that is functionality you will be needing as well, you can create a page with the same interface and functionality as a native WHMCS client area page. The following is a slightly modified version of the example code WHMCS provides in their guide for creating client area pages:
<?php
// Define WHMCS namespaces
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;
// Initialize WHMCS client area
define('CLIENTAREA', true);
require __DIR__ . '/init.php';
$ca = new ClientArea();
$ca->setPageTitle('Your Page Title Goes Here');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('mypage.php', 'Your Custom Page Name');
$ca->initPage();
// Uncomment to require a login to access this page
//$ca->requireLogin();
// Uncomment to assign variables to the template system
//$ca->assign('variablename', $value);
// Code to run when the current user IS logged in
if ($ca->isLoggedIn()) {
$clientName = Capsule::table('tblclients')->where('id', '=', $ca->getUserID())->pluck('firstname');
$ca->assign('clientname', $clientName);
// Code to run when the current user is NOT logged in
} else {
$ca->assign('clientname', 'Random User');
}
// Setup the primary and secondary sidebars
Menu::addContext();
Menu::primarySidebar('announcementList');
Menu::secondarySidebar('announcementList');
// Define the template filename to be used (without the .tpl extension)
$ca->setTemplate('mypage');
// Display the contents of the page (generated by the Smarty template)
$ca->output();
I'm trying to fill out my PDF document using FPDM with a script I found here:
http://www.fpdf.org/en/script/script93.php
First, keep in mind that I don't want to install any additional libraries on the shared hosting setup I am using. I would have to switch hosts to do this.
Here's what I've tried:
Downgrading my PDF template to Acrobat 5.x (v1.4)
Disabling compression and fast web mode
Using the paid version of PDFTK and the Advanced output params "%PDFTK% %PDFIN% output %PDFOUT%" to modify the template I'm using (this prevents the weird error about object streams)
Used variations of FDF files with a different method.
Successfully wrote out an HTML version of my PDF, but it didn't look like my template exactly
My code:
require('/libs/fpdm/fpdm.php');
$fields = array(
'dealer_name' => 'My name',
'dealer_address' => 'My address',
'dealer_phone' => 'My city',
);
$pdf = new FPDM('/some/pdf/filename.pdf');
$pdf->Load($fields, false);
$pdf->Merge();
$pdf->Output('someoutput.pdf', 'F');
The Error
The error that I cannot seem to find anywhere is the following:
<b>FPDF-Merge Error:</b> extract_pdf_definition_value() does not support definition '/Type'
The Question
Are there any other things I can do to my PDF or any other methods to make this work?
fpdm.php is quite old but can be fixed up. The problem is the global variables can't be accessed from within the class FPDM.
To resolve the issue, the global variables need to be moved inside the class as protected properties.
Step 1
Remove the following lines:
$FPDM_FILTERS=array(); //holds all supported filters
$FPDM_REGEXPS= array(
"/Type"=>"/\/Type\s+\/(\w+)$/",
"/Subtype" =>"/^\/Subtype\s+\/(\w+)$/"
);
Step 2
Put the following immediately after "class FPDM {", around line 65:
protected $FPDM_FILTERS = array(); //holds all supported filters
protected $FPDM_REGEXPS = array(
"/Type"=>"/\/Type\s+\/(\w+)$/",
"/Subtype" =>"/^\/Subtype\s+\/(\w+)$/"
);
Step 3
Delete all instances of global $FPDM_FILTERS; and global $FPDM_REGEXPS;.
Step 4
Update the remaining references (except the property declarations).
Change $FPDM_FILTERS to $this->FPDM_FILTERS
Change $FPDM_REGEXPS to $this->FPDM_REGEXPS
Step 5
To properly include filters from the filters/ directory, we need to move the includes into the class. Remove the require_once()s from the beginning of the file then add the following at the beginning of the constructor FPDM()
$FPDM_FILTERS = array();
//Major stream filters come from FPDI's stuff but I've added some :)
require_once("filters/FilterASCIIHex.php");
require_once("filters/FilterASCII85.php");
require_once("filters/FilterFlate.php");
require_once("filters/FilterLZW.php");
require_once("filters/FilterStandard.php");
$this->FPDM_FILTERS = $FPDM_FILTERS;
What's the correct way to go about logging out information about tests using the velocity framework with Meteor?
I have some mocha tests that I'd like to output some values from, I guess it'd be good if the output could end up in the logs section of the velocity window... but there doesn't seem to be any documentation anywhere?
I haven't seen it documented either.
I don't know how to log messages into the Velocity window, though I don't like the idea of logging into the UI.
What I've done is created a simple Logger object that wraps all of my console.{{method}} calls and prevents logging if process.env.IS_MIRROR. That will only output test framework messages on the terminal. If I need to debug an specific test, I activate logging output for a while on Logger.
This is a terrible hack. It will expose an unprotected method that writes to your DB.
But it works.
I was really annoyed to lack this feature so I digged into the Velocity code to find out that they have a VelocityLogs collection that is globally accessible. But you need to access it from your production, not testing, instance to see it in the web reporter.
So it then took me a good while to get Meteor CORS enabled, but I finally managed - even for Firefox - to create a new route within IronRouter to POST log messages to. (CORS could be nicer with this suggestion - but you really shouldn't expose this anyway.)
You'll need to meteor add http for this.
Place outside of /tests:
if Meteor.isServer
Router.route 'log', ->
if #request.method is 'OPTIONS'
#response.setHeader 'Access-Control-Allow-Origin', '*'
#response.setHeader 'Access-Control-Allow-Methods', 'POST, OPTIONS'
#response.setHeader 'Access-Control-Max-Age', 1000
#response.setHeader 'Access-Control-Allow-Headers', 'origin, x-csrftoken, content-type, accept'
#response.end()
return
if #request.method is 'POST'
logEntry = #request.body
logEntry.level ?= 'unspecified'
logEntry.framework ?= 'log hack'
logEntry.timestamp ?= moment().format("HH:mm:ss.SSS")
_id = VelocityLogs.insert(logEntry)
#response.setHeader 'Access-Control-Allow-Origin', '*'
#response.end(_id)
return
, where: 'server'
Within tests/mocha/lib or similar, as a utility function:
#log = (message, framework, level) ->
HTTP.post "http://localhost:3000/log",
data: { message: message, framework: framework, level: level}
(error) -> console.dir error
For coffee haters: coffeescript.org > TRY NOW > Paste the code to convert > Get your good old JavaScript.
I have just installed the yii-user-management module but when I try to access it via browser I get
Fatal error: Call to a member function get() on a non-object in ..../modules/user/models/YumUser.php on line 368
$relations = Yii::app()->cache->get('yum_user_relations');
Appreciate any help.
It seems like the yii-user-management module requires a cache component for it to work. So in your application config add the cache component as
'cache'=>array(
'class'=>'CDummyCache',
),
Here we are using CDummyCache copmponent which is, as its name says, acts as a dummy. You can replace it by any other cache components as described here
Thanks #dInGd0nG. Your answer works for me too. Just would want to remind people to follow his link. In the link, you will see the configure statement shall be added in
'components'=>array(
......
'cache'=>array(
'class'=>'CDummyCache',
),
)
I have an admin module which I'm using for backend user management etc...
I would like to have the 'rights' extension nested under this admin module and be able to get to it with mysite.com/index.php?r=admin/rights
Apparently I need to declare child modules in the parent so under the AdminModule init, i've set:
$this->setModules(array(
'rights'=>array(
'install'=>true, // rights - Enables the installer
'baseUrl'=>'/admin/rights',
'debug'=>true,
),
));
I've also tried importing from AdminModule init: (clueless on this one)
$this->setImport(array(
'admin.models.*',
'admin.components.*',
'admin.modules.rights.*',
'admin.modules.rights.components.*',
));
Also I've tried declaring the module in the main.php config:
'admin'=>array(
'modules'=>array(
'rights'=>array(
'install'=>true, // rights - Enables the installer
'baseUrl'=>'/admin/rights',
'debug'=>true,
),
),
),
And even importing it there:
'import'=>array(
'application.models.*',
'application.components.*',
'application.modules.admin.*',
'application.modules.admin.modules.rights.*', // rights
'application.modules.admin.modules.rights.components.*', // rights
),
Anywho, no matter what I've tried so far, I cannot get to the rights module. It gives me Unable to resolve the request "admin/rights". when trying to get to admin/rights.
The extension works fine as an un-nested module at ?r=rights. Any ideas? I've not found many examples of the actual code when dealing with nested modules.
Could the problem be a missing route?
Try adding the following:
<module:\w+>/<controller:\w+>/<action:\w+>'=>'<module>/<controller>/<action>
I guess that you have multiple rights modules. To use particular one (from „deeper“ hierarchy) you must declare its class. Something like that:
'admin'=>array(
'modules'=>array(
'rights'=>array(
'class' => 'application.modules.admin.modules.rights.RightsModule'
),
),
),