Anyone got this problem before?
From codignier v1.7 i encode some data in order to provide web service to another site using codignier 2.0
$to_send = $this->encrypt->encode($data, '12345');
To another site using codignier 2.0 to get data from curl
if i dont encode and decode, data from curl is fine.
$to_get = $this->encrypt->decode($data, '12345');
I also try to add this to both site of website , but still not help in case it got some thing change in default value.
$this->encrypt->set_cipher(MCRYPT_RIJNDAEL_256);
$this->encrypt->set_mode(MCRYPT_MODE_CFB);
when echo $to_get data is not usable
"^6>þ×È·¾ˆ÷Íón´= wÁSùçâÈþbåNÚÁ»¿_óÈÔfÞã#sf=µ#¹vÏŽ§ÃíŽÞ"
Thanks
There is a encode_from_legacy method in the Encryption library introduced with the 2.0.0 updates. See the upgrading guide's Step 4. for more information.
Also make sure that you use the old site's encryption key when using the method (via the configuration files or passed in explicitly).
Related
I have an URL HTTP with get parameter who returns a JSON object. Example :
http://example.com/params?param=X
It is possible with Phalcon to get the return of this url or I should use curl ?
So far this is not included in the Phalcon project as you can see in this answer in the official forum but you can use the incubator library files. There is some info in the forum and also you can check this link for more information.
OS: Windows 7 (64-Bit)WAMP Version: 2.2Apache Version: 2.2.22PHP
Version: 5.4.3Framework: CodeIgniter 2.1.2
Hi, I am experiencing something strange, and can't seem to pinpoint the cause. I am sending a js object to server to be saved in db in BLOB. The object is converted to JSON string using JSON.stringify() before sending it in Ajax(POST) call.
Object After Using JSON.stringify
[{"page_id":"1","site_id":456,"composite_id":"456-1-text-1","type":"2","properties":"{\"id\":\"text-1\",\"isModified\":false,\"isNew\":false,\"name\":\"Text 1\",\"content\":\"<span style=\\\"text-decoration:underline;font-size:x-large;color:#7092be;background-color:#c8bfe7;\\\"><strong>Your text here</strong></span>\",\"keywords\":\"\",\"top\":103,\"left\":119,\"width\":130,\"height\":30,\"style\":{\"borderColor\":\"#1e07da\",\"borderSize\":\"2\",\"borderRadius\":\"6\",\"shadowType\":\"drop-shadow\",\"shadowColor\":\"#000000\",\"shadowSize\":\"0\",\"shadowBlur\":\"0\",\"boxShadowColor\":\"#000000\",\"boxShadowPosX\":\"3\",\"boxShadowPosY\":\"2\",\"boxShadowBlur\":\"5\",\"boxShadowType\":\"\",\"zIndex\":2020}}"}]
This is the concerning part from above string that gets modified(Key-Value Pair):
\"content\":\"<span style=\\\"text-decoration:underline;font-size:x-large;color:#7092be;background-color:#c8bfe7;\\\"><strong>Your text here</strong></span>\"
I send this string to api controller using ajax. When I receive it in the controller I use print_r() to print the variable. But now insted of the above mentioned part this is what I receive:
[{"page_id":"1","site_id":456,"composite_id":"456-1-text-1","type":"2","properties":"{\"id\":\"text-1\",\"isModified\":false,\"isNew\":false,\"name\":\"Text 1\",\"content\":\"<span ><strong><em>Your text here</em></strong></span>\",\"keywords\":\"\",\"top\":103,\"left\":119,\"width\":130,\"height\":30,\"style\":{\"borderColor\":\"#1e07da\",\"borderSize\":\"2\",\"borderRadius\":\"6\",\"shadowType\":\"drop-shadow\",\"shadowColor\":\"#000000\",\"shadowSize\":\"0\",\"shadowBlur\":\"0\",\"boxShadowColor\":\"#000000\",\"boxShadowPosX\":\"3\",\"boxShadowPosY\":\"2\",\"boxShadowBlur\":\"5\",\"boxShadowType\":\"\",\"zIndex\":2020}}"}]
As you can see the concerned part is missing the style settings and is now modified to:
\"content\":\"<span ><strong><em>Your text here</em></strong></span>\"
I have been searching it over the internet, but it does not seem to be a common problem as I cant find anything related to it. So now I am counting on SO.
Regards
UPDATE:
I used var_dump($_REQUEST)as suggested by #BogdanBurim. And this is the concerned part:
\"content\":\"<span style=\\\"text-decoration:underline;font-size:x-large;color:#7092be;background-color:#c8bfe7;\\\"><strong>Your text here</strong></span>\"
As you can see the style settings are still there. So with we come to the decision that CI filters might be removing this part from string. So now the question is how to fix this issue?
Well after discussion with #BogdanBurim, I came to conclusion that to avoid XSS to some extent CI removed any text included within quotes and double quotes, from data sent to server.
There was an option to extend CI_Input library to allow selective disabling of XSS filter. That would solve my issue but would raise security concerns. So instead what I did is I encode (base_64) the data before sending it to the api. It is saved in DB as BLOB. And when fetched is decoded on client side.
I am trying to update a document in Couchbase 2.0 server using PHP API (php-ext-couchbase).
http://www.couchbase.com/docs/couchbase-sdk-php-1.1/api-reference-summary.html
The document is similar to facebook POSTS with comments and likes associated with it.
To be more specific.
-Load the doc.
-Modify it
-Store the modified doc if it has not been accessed by any other person.
Basic operations that would be required to accomplish this will be
# Get a document by key
doc = get(key)
# Modify a document when no one has modified it since my last read
casVersion = doc.getCas()
cas(key, casVersion, changedDoc)
I just want to know how i can accomplish this in PHP.
especially how to get the casVersion or the revision_id of the document and then further carry out the update process so that changes made by simultaneous updates on same document are not lost.
No worries I found it,
The code is
$bucket='yourbucketname';
$cb=new Couchbase("127.0.0.1:8091","root","password",$bucket);
$old_doc=null;
$cb->getDelayed($obj_id, true,
function($cb, $data) use (&$old_doc) { $old_doc = $data; });
$casKey=$old_doc['cas'];
Use getDelayed method, and callback function to get the array having (key,value,caskey)
I hope the couchbase documentation would be more clear in future with usages examples.
For some reason I am unable to read any cookies from my CakePHP app on any page after they have been set, the only thing that is returned is garbled text.
My code is as simple as this:
$this->Cookie->write('Region', 'test');
$reg = $this->Cookie->read('Region');
pr($reg);
I uncomment the $this->Cookie->write() line and all I get back is a bunch of random control characters. I also recently upgraded to CakePHP 1.3 but AFAIK this should not effect cookie like this...
This was working fine until I changed server, this must be the root of my problem.
Update
After probing around further I have discovered this is a known issue with the Suhosin security patch for PHP effecting the rand() and srand() methods, I had configured Suhosin to allow the rand() functions but still it is happening, is there a more effective work around out there?
Try this code which will disable cookie encryption:
$this->Cookie->write('Region', 'test', false);
$reg = $this->Cookie->read('Region');
pr($reg);
The write method has the following params:
write(mixed $key, mixed $value, boolean $encrypt, mixed $expires)
By default all values in the cookie are encrypted by CakePHP. However for security reasons you may wish to look into working with the encryption.
CakePHP encrypts cookies by default.
Is your Security.salt value the same in this new installation?
How about the $key value in your cookie controller setup?
I created the PHP web services, which reads data from MySQL and return to my iPhone app. Previously I used the same code successfully in many apps. The web server on which I installed my web services is CakePHP based, while my web services are written in simple PHP.
I'm failing to get the data from them in my iPhone app. Web services are working perfectly on localhost, but as installed them on the server, I'm receiving binary data instead of XML file. I changed the encoding and content-type tag. Doing this web services returning the following fault code.
error in msg parsing: Charset from HTTP Content-Type 'US-ASCII' does not match encoding from XML declaration 'utf-8'
So anyone can help me? Did I need to rewrite all of my web services in CakePHP or simple PHP web services can work? Here is the code of one of my web service.
<?php
include('vp-config.php');
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
define("PATH_DIR",str_replace("\\","/",dirname(__FILE__))."/");
$server = new soap_server;
$server->register('getAllNews');
function getAllNews($page) {
$conn = mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
mysql_select_db(DB_NAME, $conn) or die(mysql_error());
$q = "SELECT
`website_contents`.`id`,
`website_contents` .`website_top_category_id`,
`website_contents` .`created`,
`website_contents` .`short_description`
FROM `website_contents`
WHERE `website_contents`.`website_content_type_id` = 2
AND `website_contents` .`short_description` IS NOT NULL
ORDER BY id DESC LIMIT " . $page ." , 30";
$rs = mysql_query($q);
while($r = mysql_fetch_array($rs)){
$items[] = array('id'=>$r['id'],
'website_top_category_id'=>$r['website_top_category_id'],
'created'=>$r['created'],
'short_description'=>$r['short_description']
);
}
return $items;
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$serve
r->service($HTTP_RAW_POST_DATA);
CakePHP does a lot of content handling to ensure that you need to do a little work as possible. If you're just attempting to access some simple data, you might just leave it out of CakePHP and keep them as separate scripts. Creating them in CakePHP might be using a sledgehammer for hanging a picture frame (if you get my analogy).
Given your explanation in the comments, I would recommend importing them into CakePHP as libraries. You would be able to take your webservice code as a set of PHP files (or however you organized them) and they can be dropped into the appropriate folder in the app/ directory according to which version of Cake is being used. From there, they can included into the rest of CakePHP without you needing to know what your client is actually doing with his code.
Read up here for how your code would be imported. Keep in mind that significant changes have been made to this process between version 1.2 and 1.3 so note that in your reading below:
Loading Vendor files in CakePHP 1.2
Plugins in CakePHP 1.3
Changes from 1.2 to 1.3 in regards to Vendor files
Hope this helps!