create a .php file through the launch of a .bat - php

I need to launch a .bat file that creates a php file, containing this text:
<?php
$_mail_mailSpooler = array (
'classname' => 'mail_mailSpooler',
'from' => 'test#test.com',
'array_indirizzi_mail' =>
array (
0 => ‘lol#hotmail.com’,
'testo_mail' => ‘prova’,
'filename_html' => NULL,
'oggetto_mail' => ‘prova’,
'elenco_allegati' => '',
'forza_mail_txt' => 0,
'asl_logger' => '',
'log_identifier' => NULL,
'log_in_web' => 0,
'log_str' => '',
'nome_file_dump' => '../mailSpooler/mail_incoming/maildda2.php',
);
I have tried echo " (test)" >gnagna.php
but it doen't work.
any suggestion please?
thanks

use type instead of echo - echo's only supposed to give user feedback, file reading and writing is properly done by type. Have a look at http://www.robvanderwoude.com/allhelpw2ksp4_en.php#TYPE for more

sorry, but i'm not already able to launch my php with right code.
i've tried type <?php
$_mail_mailSpooler = array (
'classname' => 'mail_mailSpooler',
'from' => 'test#test.com',
'array_indirizzi_mail' =>
array (
0 => ‘lol#hotmail.com’,
'testo_mail' => ‘prova’,
'filename_html' => NULL,
'oggetto_mail' => ‘prova’,
'elenco_allegati' => '',
'forza_mail_txt' => 0,
'asl_logger' => '',
'log_identifier' => NULL,
'log_in_web' => 0,
'log_str' => '',
'nome_file_dump' => '../mailSpooler/mail_incoming/maildda2.php',
); C:\>test.php
but it doesn't work.
moreover your link says that this command displays the content of an existing file and i need to create a new one!

Related

Array to string conversion error using php v7.0.13

I have the following code in my laravel controller file.
$j_decode->$data['_kfdTourDate']->available = ($j_decode->$data['_kfdTourDate']->available+$totalincrement);
and I am getting the following error.
ErrorException in BookingsController.php line 325: Array to string
conversion in BookingsController.php line 325 at
HandleExceptions->handleError('8', 'Array to string conversion',
'D:\XAMPP\htdocs\lara\app\Http\Controllers\BookingsController.php',
'325', array('request' => object(Request), 'id' => '0', 'rules' =>
array(), 'validator' => object(Validator), 'data' => array('_kpnID' =>
'153290', '_kfnTourID' => '2', '_kfdTourDate' => '2017-03-16',
'nAdults' => '2', 'nChildren' => '1', 'nInfants' => '0', 'nBabies' =>
'2', 'nFOC' => '2', 'nPriceAdult' => '74.25', 'nPriceChild' => '49.5',
'nPriceInfant' => '0', 'nPriceBaby' => '0', 'nTotalPrice' => '148.5',
'tGuestName' => 'Yuhiko Nishioka', 'tGuestOrigin' => 'Unknown',
'tEnquirySourceWhat' => 'Unknown', 'tStatus' => 'Confirmed',
'_kfnAgentID' => '0', '_kfnPersonID' => '0', '_kfnInvoiceID' => '0',
'nAgentCommissionPercent' => '0', 'nDiscount_percent' => '0',
'nDiscount_fixed' => '0', 'tNotes' => '4WD Tour package/Rezdy, applied
discount', 'tInitials' => 'JD', 'CreatedOn' => '2017-01-21 15:08:00',
'ModifiedOn' => '2017-01-21 15:10:00', 'tTicketNumber' => 'Rezdy',
'_kfnOrganisationID' => '0'), 'schedule' => object(Collection),
'j_decode' => object(stdClass), 'update_id_data' => object(stdClass),
'totalincrement' => '3')) in BookingsController.php line 325
Interesting part that it's working on the linux server when I upload it to my host. I have PHP Version 7.0.13 on localhost and PHP Version 5.6.30 on the server.
How can this line cause an Array to string conversion error?
I am not willing to downgrade my php version on localhost as I have other codes that php5 is not supporting.
The whole code in controller:
$rules = $this->validateForm();
$validator = Validator::make($request->all(), $rules);
if ($validator->passes()) {
$data = $this->validatePost( $request );
$schedule = DB::table('schedule')
->where('id','=',$data['_kfnTourID'])
->get();
if(isset($_SESSION['bookingiddata']))
{
print_r ($j_decode= json_decode($schedule[0]->data));
$update_id_data = json_decode($_SESSION['bookingiddata']);
$totalincrement = $update_id_data->nAdults+$update_id_data->nChildren+$update_id_data->nInfants+$update_id_data->nFOC;
//$j_decode->$data['_kfdTourDate']->available = ($j_decode->$data['_kfdTourDate']->available+$totalincrement);
$j_decode->$data['_kfdTourDate']['available'] = ($j_decode->$data['_kfdTourDate']['available']+$totalincrement);
($j_decode->$data)['_kfdTourDate']->status = "available";
Also print_r $j_encode = json_encode($j_decode); prints me the following
{"2017-02-13":{"available":1,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"available"},"2017-02-14":{"available":1,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"available"},"2017-02-08":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-12":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-10":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-15":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"},"2017-02-16":{"available":0,"bind":0,"info":"","notes":"","price":0,"promo":0,"status":"booked"}...
well, as mentioned here
in php 5.6.3 , it's allowed to use this expression:
echo $json_decode->$data['_kfdTourDate']->available;
so , you are trying to access the value of $data['_kfdTourDate'] which is element in $json_decode object
for example: https://3v4l.org/i9Q7p
in php 7,
Indirect access to variables, properties, and methods will now be
evaluated strictly in left-to-right order, as opposed to the previous
mix of special cases. The table below shows how the order of
evaluation has changed.
so, the interpreter will interpret this code as follow:
echo $json_decode->$data['_kfdTourDate']->available;
// first , give me the value $json_decode->$data,
// then choose the _kfdTourDate key
and to solve this, you need to :
echo $json_decode->{$data['_kfdTourDate']}->available;
to tell php that $data['_kfdTourDate'] is just a value;
There were some order-of-operations changes in PHP7 (see Changes to the handling of indirect variables, properties, and methods). I suspect you might need to mess around with some parentheses within $j_decode->$data['_kfdTourDate']->available to make it evaluate in the order you want.

how to manage multiple form templates in fuelphp

Hello I just migrated from CI to Fuel.... I am using Fieldset class to auto generate form in the view.... The problem i am facing is I have multiple types of form templates i.e some of my models use twitter bootstrap horizontal inline form where as few models use custom templates... I am able to set single type of form template in form.php which i copy from fuel/core/config/form.php to fuel/app/config/form.php
Here is the sample return array for form template
return array(
// regular form definitions
'prep_value' => true,
'auto_id' => true,
'auto_id_prefix' => 'form_',
'form_method' => 'post',
'form_template' => "\n\t\t{open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{close}\n",
'fieldset_template' => "\n\t\t<tr><td colspan=\"2\">{open}<table>\n{fields}</table></td></tr>\n\t\t{close}\n",
'field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} <span>{description}</span> {error_msg}</td>\n\t\t</tr>\n",
'multi_field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}<span>{description}</span>\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n",
'error_template' => '<span>{error_msg}</span>',
'group_label' => '<span>{label}</span>',
'required_mark' => '*',
'inline_errors' => false,
'error_class' => null,
'label_class' => null,
// tabular form definitions
'tabular_form_template' => "<table>{fields}</table>\n",
'tabular_field_template' => "{field}",
'tabular_row_template' => "<tr>{fields}</tr>\n",
'tabular_row_field_template' => "\t\t\t<td>{label}{required} {field} {error_msg}</td>\n",
'tabular_delete_label' => "Delete?",
);
I want multiple form templates like this so that i will be able to auto generate the form where it is needed using $fieldset->form()->build() function...
Is there any way to do this??
yes. try this:
forge($name = 'default', $config = array());
$article_form = Fieldset::forge('article',array(
// regular form definitions
'prep_value' => true,
'auto_id' => true,
'auto_id_prefix' => 'form_',
'form_method' => 'post',
'form_template' => "\n\t\t{open}\n\t\t<table>\n{fields}\n\t\t</table>\n\t\t{close}\n",
'fieldset_template' => "\n\t\t<tr><td colspan=\"2\">{open}<table>\n{fields}</table></td></tr>\n\t\t{close}\n",
'field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{field} <span>{description}</span> {error_msg}</td>\n\t\t</tr>\n",
'multi_field_template' => "\t\t<tr>\n\t\t\t<td class=\"{error_class}\">{group_label}{required}</td>\n\t\t\t<td class=\"{error_class}\">{fields}\n\t\t\t\t{field} {label}<br />\n{fields}<span>{description}</span>\t\t\t{error_msg}\n\t\t\t</td>\n\t\t</tr>\n",
'error_template' => '<span>{error_msg}</span>',
'group_label' => '<span>{label}</span>',
'required_mark' => '*',
'inline_errors' => false,
'error_class' => null,
'label_class' => null,
// tabular form definitions
'tabular_form_template' => "<table>{fields}</table>\n",
'tabular_field_template' => "{field}",
'tabular_row_template' => "<tr>{fields}</tr>\n",
'tabular_row_field_template' => "\t\t\t<td>{label}{required} {field} {error_msg}</td>\n",
'tabular_delete_label' => "Delete?",
));

php fedex set signature Label ADULT

I am working on wordpress site and using woocommerce extension http://www.woothemes.com/products/fedex-shipping-module/
I am Passing the values Signature value to adults. But it is not working
Please correct me where i am wrong
$request['RequestedShipment']['RateRequestTypes'] = $this->request_type;
$request['RequestedShipment']['PackageDetail'] = 'INDIVIDUAL_PACKAGES';
$request['RequestedShipment']['SpecialServicesRequested'][] = array(
'SpecialServiceTypes' => 'SIGNATURE_OPTION',
'SignatureOptionDetail' => array(
'OptionType' => 'ADULT'
)
);
`
Do i need to change something from the from the RateService_v13.wsdl file
Please suggest
Thanks
I resolved this issue
For further user having the same issue can resolve this by below code
$item['SpecialServicesRequested'] = array(
'SpecialServiceTypes' => 'SIGNATURE_OPTION',
'SignatureOptionDetail' => array(
'OptionType' => 'ADULT'
)
);
$request['RequestedShipment']['RequestedPackageLineItems'][] = $item;
If Suppose anyone is using Fedex Integration with Laravel you may use below code.
In place of _DIRECT you may use _ADULT or any other option.
$packageLineItem1 = new FedexShipServiceCT\RequestedPackageLineItem();
$packageLineItem1
->setSequenceNumber(1)
->setItemDescription('Product')
->setSpecialServicesRequested(new FedexShipServiceCT\PackageSpecialServicesRequested(array(
'SignatureOptionDetail' => new FedexShipServiceCT\SignatureOptionDetail(array(
'OptionType' => FedexShipServiceST\SignatureOptionType::_DIRECT
))
)))
->setDimensions(new FedexShipServiceCT\Dimensions(array(
'Width' => 1,
'Height' => 1,
'Length' => 1,
'Units' => FedexShipServiceST\LinearUnits::_IN
)))
->setWeight(new FedexShipServiceCT\Weight(array(
'Value' => 1,
'Units' => FedexShipServiceST\WeightUnits::_LB
)));
Thanks

Medoo - Updating table row matching field

I am using Medoo but know very little php, the update below works fine but I only want it to update when the clientId matches what is posted:
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
));
//$_POST["clientId"];
I am using a newer version of PHP and am a little confused on the syntax, here is how it is with older versions of PHP
http://medoo.in/api/update
I assume you have clientId field in that table, you can try:
$database->update("clientInfo", array(
"businessName" => $_POST['businessName'],
"contactName" => $_POST['contactName'],
"businessEmail" => $_POST['businessEmail'],
"businessPhone" => $_POST['businessPhone'],
"businessWebsite" => $_POST['businessWebsite'],
"businessAddress" => $_POST['businessAddress'],
"businessAddress2" => $_POST['businessAddress2'],
"businessCity" => $_POST['businessCity'],
"businessState" => $_POST['businessState'],
"businessZip" => $_POST['businessZip']
), array(
"clientId" => $_POST['clientId']
));
Hope it helps.

Using MeioUpload with CakePHP 1.3

I'm trying to implement some fairly simple image uploading using the MeioUpload behaviour in CakePHP 1.3, but I can't for the life of me get it to work. When I try to save $this->data in my controller, it tries to save a regular file array (for lack of a better word) rather than just the filename.
Here's what I'm doing:
I've put meio_upload.php into /app/models/behaviors
In my model, I'm doing the following:
var $actsAs = array(
'MeioUpload.MeioUpload' => array(
'filename' => array(
'dir' => 'img{DS}upload{DS}brawlers',
'allowedMime' => array('image/png'),
'allowedExt' => array('.png', '.PNG'),
'zoomCrop' => false,
'thumbsizes' => array(
'normal' => array(
'width' => 150,
'height' => 150
)
),
'default' => 'default.png',
'length' => array(
'minWidth' => 100,
'minHeight' => 100,
'maxWidth' => 150,
'maxHeight' => 150
)
)
)
);
In my view, I've got the following form:
<?php
echo $this->Form->create('Brawler', array('type' => 'file'));
echo $this->Form->input('name', array(
'label' => 'Name',
'maxLength' => '45'
)
);
echo $this->Form->input('comment', array(
'label' => 'Description',
'rows' => '3'
)
);
echo $this->Form->input('author', array(
'label' => 'Your name)',
'maxLength' => '45'
)
);
echo $this->Form->input('email', array(
'label' => 'Email (will not be shown)',
'maxLength' => '45'
)
);
echo $this->Form->input(
'filename',
array(
'between'=>'<br />',
'type'=>'file',
'label' => 'Image (Max 2mb, 150x150 pixels, .png)'
)
);
echo $this->Form->end('Submit');
?>
And finally my add action in the associated controller looks like this:
function add() {
if (!empty($this->data)) {
$this->Brawler->create();
if($this->Brawler->save($this->data)) {
$this->Session->setFlash('The brawler has been saved', true);
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash('The Brawler could not be saved. Please try again.', true);
debug($this->data);
debug($this->validationErrors);
die();
//$this->redirect(array('action'=>'add'));
}
}
}
For posterity, here's my table design:
delimiter $$
CREATE TABLE `brawlers` (
`id` int(11) NOT NULL,
`name` varchar(45) NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`comment` text,
`email` varchar(45) NOT NULL,
`author` varchar(45) NOT NULL,
`filename` varchar(100) NOT NULL,
PRIMARY KEY (`id`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8$$
When I try to submit my form, this is the output I get:
app/controllers/brawlers_controller.php (line 37)
Array
(
[Brawler] => Array
(
[name] => Viking
[comment] => Herp. This is a description.
[author] => Me
[email] => me#gmail.com
[filename] => Array
(
[name] => 5.png
[type] => image/png
[tmp_name] => /storage/configuration/upload_tmp_dir/phpEF2okD
[error] => 0
[size] => 15863
)
)
)
app/controllers/brawlers_controller.php (line 37)
Obviously, this fails when it tries to save an array to the filename field. The image is never saved in the specified upload directory either. It seems like the meioupload behavior is never actually used. How can I verify this?
You'll have to excuse the mass of code that I've posted, but I figure it's better that I show you everything than to have you guess at what I may be doing. If someone can spot the error, that would save me many hours of pulling my hair.
Hey i have answer for ur Query
That is u have to make anther variable Say
$d1 and copy $this->date array into that array like below
$d1['brawlers']['name'] = $this->data['brawlers']['name'];
all ur variables
$d1['brawlers']['filename'] = $this->data['brawlers']['filename']['name'];
and then save it like $this->brawlers->save($d1);
I'm NOT PHP guy, but I had to use the CakePHP and Meio.Upload some time ago.
AFAIK you need 4 fields in your database for image:
filename (you can change name of this one in
settings)
dir
mimetype
filesize
Judging on your error and db schema I would say you are missing some of the fields.
Edit:
See the documentation
I had the same problem, the MeioUpload version your are using is incompatible with your version of Cake. I ended using version 2.3 of MeioUpload.

Categories