catch fatal error information in older php
We have an old php instance running on a server. php 5.1.6 precisely. But
it is handling all payments and some other critical stuff so there is no
plan of upgrading it as of now. There are a couple of crons running. The
requirement is to catch fatal errors. However as we know, function
error_get_last which does the job of gathering error information, was not
available in that version of php.
I have scoured the web for any method of catching the fatal error, but
have not succeeded yet. There is a way to do that mentioned by someone
here http://php.net/manual/en/function.error-get-last.php, however that
did not work. Please help.
Butner
Sunday, 1 September 2013
Serialization issues while sending struct over socket
Serialization issues while sending struct over socket
I am developing a Client/Server based on UDP I want to send different
messages to the client from the server. There are different C structures
defined for each message.
I would like to understand what is wrong in the way I am serializing the
data.
struct Task
{
int mType;
int tType;
int cCnt;
int* cId;
char data[128];
};
Serialization/Deserialization functions
unsigned char * serialize_int(unsigned char *buffer, int value)
{
buffer[0] = value >> 24;
buffer[1] = value >> 16;
buffer[2] = value >> 8;
buffer[3] = value;
return buffer + 4;
}
unsigned char * serialize_char(unsigned char *buffer, char value)
{
buffer[0] = value;
return buffer + 1;
}
int deserialize_int(unsigned char *buffer)
{
int value = 0;
value |= buffer[0] << 24;
value |= buffer[1] << 16;
value |= buffer[2] << 8;
value |= buffer[3];
return value;
}
char deserialize_char(unsigned char *buffer)
{
return buffer[0];
}
Sender side code to serialize the structure
unsigned char* serializeTask(unsigned char* msg, const Task* t)
{
msg = serialize_int(msg,t->mType);
msg = serialize_int(msg,t->tkType);
msg = serialize_int(msg,t->cCnt);
for(int i=0; i<t->cCnt; i++)
msg = serialize_int(msg,t->cId[i*4]);
for(int i=0; i<strlen(data); i++)
msg = serialize_char(msg,t->data[i]);
return msg;
}
Receiver side code to de-serialize data
printf("Msg type:%d\n", deserialize_int(message) );
printf("Task Type:%d\n", deserialize_int(message+4) );
printf("Task Count:%d\n", deserialize_int(message+8));
Output
Msg type:50364598 //Expected value is 3
Task Type:-2013036362 //Expected value is 1
Task Count:1745191094 //Expected value is 3
Question 1:
Why is the de-serialized value not same as expected?
Question 2:
How is serialization/de-serialization method different from memcpy?
Task t;
memcpy(&t, msg, sizeof(t)); //msg is unsigned char* holding the struct data
I am developing a Client/Server based on UDP I want to send different
messages to the client from the server. There are different C structures
defined for each message.
I would like to understand what is wrong in the way I am serializing the
data.
struct Task
{
int mType;
int tType;
int cCnt;
int* cId;
char data[128];
};
Serialization/Deserialization functions
unsigned char * serialize_int(unsigned char *buffer, int value)
{
buffer[0] = value >> 24;
buffer[1] = value >> 16;
buffer[2] = value >> 8;
buffer[3] = value;
return buffer + 4;
}
unsigned char * serialize_char(unsigned char *buffer, char value)
{
buffer[0] = value;
return buffer + 1;
}
int deserialize_int(unsigned char *buffer)
{
int value = 0;
value |= buffer[0] << 24;
value |= buffer[1] << 16;
value |= buffer[2] << 8;
value |= buffer[3];
return value;
}
char deserialize_char(unsigned char *buffer)
{
return buffer[0];
}
Sender side code to serialize the structure
unsigned char* serializeTask(unsigned char* msg, const Task* t)
{
msg = serialize_int(msg,t->mType);
msg = serialize_int(msg,t->tkType);
msg = serialize_int(msg,t->cCnt);
for(int i=0; i<t->cCnt; i++)
msg = serialize_int(msg,t->cId[i*4]);
for(int i=0; i<strlen(data); i++)
msg = serialize_char(msg,t->data[i]);
return msg;
}
Receiver side code to de-serialize data
printf("Msg type:%d\n", deserialize_int(message) );
printf("Task Type:%d\n", deserialize_int(message+4) );
printf("Task Count:%d\n", deserialize_int(message+8));
Output
Msg type:50364598 //Expected value is 3
Task Type:-2013036362 //Expected value is 1
Task Count:1745191094 //Expected value is 3
Question 1:
Why is the de-serialized value not same as expected?
Question 2:
How is serialization/de-serialization method different from memcpy?
Task t;
memcpy(&t, msg, sizeof(t)); //msg is unsigned char* holding the struct data
Getting the permalink to the post in wordpress
Getting the permalink to the post in wordpress
I am trying to append the facebook like button to each of the post on my
blog. I have managed to get whatever I need to add the like button, the
only thing I need is, how can I access the current post's link inside the
function author_bio_display($content) i.e. at the place where it says
rawurlencode('post permalink goes here')?
function author_bio_display($content)
{
$bio_box = '<iframe
src="http://www.facebook.com/plugins/like.php?href='.
rawurlencode('post permalink goes here')
.'&layout=standard&show-faces=true&width=450&action=like&font=arial&colorscheme=light"
scrolling="no" frameborder="0" allowTransparency="true"
id="facebook-like"></iframe>';
return $content . $bio_box;
}
add_action("the_content", "author_bio_display");
I am trying to append the facebook like button to each of the post on my
blog. I have managed to get whatever I need to add the like button, the
only thing I need is, how can I access the current post's link inside the
function author_bio_display($content) i.e. at the place where it says
rawurlencode('post permalink goes here')?
function author_bio_display($content)
{
$bio_box = '<iframe
src="http://www.facebook.com/plugins/like.php?href='.
rawurlencode('post permalink goes here')
.'&layout=standard&show-faces=true&width=450&action=like&font=arial&colorscheme=light"
scrolling="no" frameborder="0" allowTransparency="true"
id="facebook-like"></iframe>';
return $content . $bio_box;
}
add_action("the_content", "author_bio_display");
jquery mobile anchor link doesn't wrok
jquery mobile anchor link doesn't wrok
I'm trying to put an anchor link in a page as you see in the code, but
when I click "go to top" link nothing happen. I'm using jquery mobile.
<div data-role="content">
<a id="home_top">top</a>
<ul id="home_index_ul" data-role="listview">
<li>1</li>
<li>2</li>
<li>3</li>
...
</ul>
<a href="#home_top">go to top</a>
</div>
I'm trying to put an anchor link in a page as you see in the code, but
when I click "go to top" link nothing happen. I'm using jquery mobile.
<div data-role="content">
<a id="home_top">top</a>
<ul id="home_index_ul" data-role="listview">
<li>1</li>
<li>2</li>
<li>3</li>
...
</ul>
<a href="#home_top">go to top</a>
</div>
Saturday, 31 August 2013
Jquery - Using Touch Swipe to Check Radio Buttons
Jquery - Using Touch Swipe to Check Radio Buttons
So I have a CSS3 slides setup with radio buttons to trigger the next
slide. I want to be able to add touch/swipe to it for tablets and phones
(i.e. swipe left and and the next radio gets checked).
The jQuery I'm trying to use:
$(document).ready(function() { $("#cover").swipeleft(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#cover2").swiperight(function(event){
$('input:radio[class=slide_1]').attr("checked", true); });
$("#cover2").swipeleft(function(event){
$('input:radio[class=slide_3]').attr("checked", true); });
$("#ingredients").swiperight(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#ingredients").swipeleft(function(event){
$('input:radio[class=slide_4]').attr("checked", true); });
$("#directions").swiperight(function(event){
$('input:radio[class=slide_3]').attr("checked", true); }); });
http://jsfiddle.net/hakarune/ZsrdP/1/ Here's the whole setup and my
jQuery, but it doesn't work at all. Anyone have an idea how to fix it?
So I have a CSS3 slides setup with radio buttons to trigger the next
slide. I want to be able to add touch/swipe to it for tablets and phones
(i.e. swipe left and and the next radio gets checked).
The jQuery I'm trying to use:
$(document).ready(function() { $("#cover").swipeleft(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#cover2").swiperight(function(event){
$('input:radio[class=slide_1]').attr("checked", true); });
$("#cover2").swipeleft(function(event){
$('input:radio[class=slide_3]').attr("checked", true); });
$("#ingredients").swiperight(function(event){
$('input:radio[class=slide_2]').attr("checked", true); });
$("#ingredients").swipeleft(function(event){
$('input:radio[class=slide_4]').attr("checked", true); });
$("#directions").swiperight(function(event){
$('input:radio[class=slide_3]').attr("checked", true); }); });
http://jsfiddle.net/hakarune/ZsrdP/1/ Here's the whole setup and my
jQuery, but it doesn't work at all. Anyone have an idea how to fix it?
UnauthorizedAccessException Accessing XSD In Windows Store App
UnauthorizedAccessException Accessing XSD In Windows Store App
My Windows Store app uses the FileOpenPicker to allow the user to browse
to an XML document. I can open the XML document as a stream and load it
with XDocument.Load([stream]).
But now, as I parse the XML document, I want to process schema
declarations that I find. I want to open a referenced XSD and parse it,
too, using an XDocument. The referenced XSD is in the same folder as the
main XML document. How do I open the referenced XSD? If I try to access it
by its full path name, an UnauthorizedAccessException object is thrown. I
don't want to use the FileOpenPicker again and force the user to select
the XSD ... that would make for a bad UI. I know where the XSD is ... it's
with the XML.
So how do I call XDocument.Load() on the referenced XSD without an
UnauthorizedAccessException object being thrown?
My Windows Store app uses the FileOpenPicker to allow the user to browse
to an XML document. I can open the XML document as a stream and load it
with XDocument.Load([stream]).
But now, as I parse the XML document, I want to process schema
declarations that I find. I want to open a referenced XSD and parse it,
too, using an XDocument. The referenced XSD is in the same folder as the
main XML document. How do I open the referenced XSD? If I try to access it
by its full path name, an UnauthorizedAccessException object is thrown. I
don't want to use the FileOpenPicker again and force the user to select
the XSD ... that would make for a bad UI. I know where the XSD is ... it's
with the XML.
So how do I call XDocument.Load() on the referenced XSD without an
UnauthorizedAccessException object being thrown?
VB Script to launch the site and change the cookie value
VB Script to launch the site and change the cookie value
I need a VB script to launch a website and change its JESSIONID(which is
available in the cookie editor). It has to contentiously change the value
and launch the website.
I need a VB script to launch a website and change its JESSIONID(which is
available in the cookie editor). It has to contentiously change the value
and launch the website.
Subscribe to:
Comments (Atom)