Prestashop 1.5 Cookie content - cookies

I need to display prestashop customer ID in an external PHP page.
In the official documentation http://doc.prestashop.com/display/PS15/Diving+into+PrestaShop+Core+development)
I found the php code:
If you need to access the PrestaShop cookie from non-PrestaShop code, you can use this code:
include_once('path_to_prestashop/config/config.inc.php');
include_once('path_to_prestashop/config/settings.inc.php');
include_once('path_to_prestashop/classes/Cookie.php');
$cookie = new Cookie('ps'); // Use "psAdmin" to read an employee's cookie.
So i tryed:
include_once('config/config.inc.php');
include_once('config/settings.inc.php');
include_once('classes/Cookie.php');
$cookie = new Cookie('ps');
$id_client = $cookie->id_customer;
echo $id_client;
But nothing is displayed, I tried other tokens, only "date_add" works
What's wrong with my code?

The following works:
global $smarty;
global $cookie;
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/header.php');
$cookie = new Cookie('ps');
$id_client = $cookie->id_customer;
echo $id_client;
include(dirname(__FILE__).'/footer.php');
I tested it myself. Everything including id and firstname works. It seems you should not include classes/Cookie.php file. Instead, replace it with global $cookie Make sure to change the directory of the included files.

Related

Adding a cookie to DocumentRequest

Using AngleSharp v 0.9.9, I'm loading a page with OpenAsync which sets a bunch of cookies, something like:
var configuration = Configuration.Default.WithHttpClientRequester().WithCookies();
var currentContext = BrowsingContext.New(configuration);
// ....
var doc = context.OpenAsync(url, token);
This works fine and I can see the cookies have been set. For example, I can do this:
var cookieProvider = currentContext.Configuration.Services.OfType<ICookieProvider>().First() as MemoryCookieProvider;
And examine it in the debugger and see the cookies in there (for domain=.share.state.nm.us)
Then I need to submit a post:
var request = new DocumentRequest(postUrl);
request.Method = HttpMethod.Post;
request.Headers["Content-Type"] = "application/x-www-form-urlencoded";
request.Headers["User-Agent"] = userAgent;
//...
Which eventually gets submitted:
var download = loader.DownloadAsync(request);
And I can see (using Fiddler) that it's submitting the cookies from the cookieProvider.
However, I need to add a cookie (and possible change the value in another) and no matter what I try, it doesn't seem to include it. For example, I do this:
cookieProvider.Container.Add(new System.Net.Cookie()
{
Domain = ".share.state.nm.us",
Name = "psback",
Value = "somevalue",
Path = "/"
});
And again I can examine the cookieProvider in the debugger and see the cookie I set. But when I actually submit the request and look in fiddler, the new cookie isn't included.
This seems like it should be really simple, what is the correct way to set a new cookie and have it included in subsequent requests?
I think there are two potential ways to solve this.
either use document.Cookie for setting a new cookie (would require an active document that already is at the desired domain) or
Use a Filter for getting / manipulating the request before its send. This let's you really just change the used cookie container before actually submitting.
The Filter is set in the DefaultLoader configuration. See https://github.com/AngleSharp/AngleSharp/blob/master/src/AngleSharp/ConfigurationExtensions.cs#L152.

open cart extension tell a friend not working

hi i have installed opencart extension tell a friend everything is good but email is not sending rest all emails when customer register and purchased are sending tell me the reason
here is the extension link also
http://www.opencart.com/index.php?route=extension/extension/info&extension_id=4348&filter_search=tell%20a%20friend
If some one has used this one please tell me
some time Opencart not work with emails on models. you need to put your logic in controller to fix this issue.
here is the solution:
get all value in your Opencart controller function and put Email logic init something like this.
$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->hostname = $this->config->get('config_smtp_host');
$mail->username = $this->config->get('config_smtp_username');
$mail->password = $this->config->get('config_smtp_password');
$mail->port = $this->config->get('config_smtp_port');
$mail->timeout = $this->config->get('config_smtp_timeout');
$mail->setTo($this->config->get('config_email'));
$mail->setFrom($this->request->post['email']);
$mail->setSender($this->request->post['name']);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('email_subject'), $this->request->post['name']), ENT_QUOTES, 'UTF-8'));
$mail->setText(strip_tags(html_entity_decode($this->request->post['enquiry'], ENT_QUOTES, 'UTF-8')));
$mail->send();

rest service get file parameters in yii

Hi i try to get file from postman in google chroome.
And I try to get file parameters, size, type.
This is logic of the solution
If($_POST)
{
$document='document_from_postman.docx'
$size = file size of $document
$tip = file type of $document
}
$size sent to database.
$tip sent to database.
But I don't know how to implement this in yii controller, how to get key value from postman, i never work with web service before.How to put document name from postman in variable example:
$document='document_from_postman.docx'
You must use
$file=CUploadedFile::getInstance($model,'file');
in your controller. Than you can get size and type of file
echo $file->size;
echo $file->type;
To write to database you already know i think what to do. Example:
$file=CUploadedFile::getInstance($model,'file')
$model->size = $file->size;
$model->type = $file->type;
$model->save()

How to get the content of an article via a webservice on Joomla 2.5

I need to get the content of an Article which is on my Joomla website. In order to do this, I was planning to write a simple PHP webservice to get the content (HTML) of my article. But I just don't know how to do this.
I'm new in Joomla, web developping and web services. I just want to get the content of my article in order to display it in my ruby on rails site. Can anyone explain how I can do this?
Well, here is at least a small contribution that should help to get you going: the attached code can be called with "?id={ID of article you want to retrieve}" and it displays the entire object on screen.
Next steps: pick out the pieces you're interested in and return these...
<?php
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
$username="*** insert username ***";
$password = "*** password here ***";
if (!defined('_JDEFINES')) {
define('JPATH_BASE', dirname(__FILE__));
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
$app ->login(
array('username'=>$username,
'password'=>$password),
array('remember' => true));
$dbo = JFactory::getDBO();
$id=$_GET["id"];
$art = JTable::getInstance('Content');
$art->load($id);
echo "<pre>";
var_dump($art);
echo"</pre>";
?>

SBL-ODU-01007 The HTTP request did not contain a valid SOAPAction header

I am hoping someone can help get me in the right direction...
I am using Powerbuilder 12 Classic and trying to consume a Oracle CRM OnDemand web service.
Using Msxml2.XMLHTTP.4.0 commands, I have been able to connect using https and retrieve the session id, which I need to send back when I invoke the method.
When I run the code below, I get the SBL-ODU-01007 The HTTP request did not contain a valid SOAPAction header error message. I am not sure what I am missing??
OleObject loo_xmlhttp
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login"
try
loo_xmlhttp = CREATE oleobject
loo_xmlhttp.ConnectToNewObject("Msxml2.XMLHTTP.4.0")
loo_xmlhttp.open ("GET",ls_get_url, false)
loo_xmlhttp.setRequestHeader("UserName", "xxxxxxx")
loo_xmlhttp.setRequestHeader("Password", "xxxxxxx")
loo_xmlhttp.send()
cookie = loo_xmlhttp.getResponseHeader("Set-Cookie")
sesId = mid(cookie, pos(cookie,"=", 1)+1, pos(cookie,";", 1)-(pos(cookie,"=", 1)+1))
ls_post_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration/Activity;"
ls_response_text = "jsessionid=" + sesId + ";"
ls_post_url = ls_post_url + ls_response_text
loo_xmlhttp.open ("POST",ls_post_url, false)
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
loo_xmlhttp.setRequestHeader("COOKIE", left(cookie,pos(cookie,";",1)-1) )
ls_post_url2 = "document/urn:crmondemand/ws/activity/10/2004:Activity_QueryPage"
loo_xmlhttp.setRequestHeader("SOAPAction", ls_post_url2)
loo_xmlhttp.send()
ls_get_url = "https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff"
loo_xmlhttp.open ("POST",ls_get_url, false)
loo_xmlhttp.send()
catch (RuntimeError rte)
MessageBox("Error", "RuntimeError - " + rte.getMessage())
end try
I believe you are using incorrect URL for Login and Logoff;
Here is the sample:
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=login
https://secure-ausomxxxx.crmondemand.com/Services/Integration?command=logoff
Rest of the code looks OK to me.
I have run into similar issues in PB with msxml through ole. Adding this may help:
loo_xmlhttp.setRequestHeader("Content-Type", "text/xml")
you need to make sure that the your value for ls_post_url2 is one of the values that is found in the wsdl file. Just search for "soap:operation soapAction" in the wsdl file to see the valid values for SOAPAction.