PHP SendToHost function not working
So I'm currently trying to implement the 'SendToHost' function that is
widely used for 'GET' and 'POST' procedures. In my case, I want to use it
for sending a 'postcode' to a shopping website's postcode input form for
use with retrieving that postcode's specific catalogue. More specifically,
the code should automatically generate the web page that has the results
for the postcode. Below is my code coupled with the function and I'd like
to know why it isn't working:
function SendToHost($host, $method, $path, $data, $useragent=0)
{
// Supply a default method of GET if the one passed was empty
if (empty($method))
$method = 'GET';
$method = strtoupper($method);
$fp = fsockopen($host,80);
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: MSIE\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
return $buf;
}
echo
sendToHost('catalog.coles.com.au','get','/default.aspx','ctl00_Body_PostcodeTextBox=4122');
Wednesday, 18 September 2013
Qt server and android ssl client Certificates
Qt server and android ssl client Certificates
I Use Qtas server side,and android as client side. I set in
SSLSocketFactory certification
private ConnectionManager(MBoxConfiguration config) {
try {
this.config = config;
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(trusted);
Socket socket;
socket = ssf.createSocket();
socket.connect(new InetSocketAddress(config.ip, config.port));
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in =
MainActivity.context.getResources().openRawResource(R.raw.truststore);
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
ssf = new SSLSocketFactory(trusted);
ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
}
When i Want connect in QT Give me That error
Thread Address in peerVerifyError "The peer did not present any
certificate" Thread Address in sslErrors ("The peer did not present any
certificate") Thread Address in error QAbstractSocket::SocketError( 13 )
Thread Address in destroyThreadfirst: QThread(0x12ec9448) Thread Address
in destroyThread: QThread(0x12ec9238)
I Use Qtas server side,and android as client side. I set in
SSLSocketFactory certification
private ConnectionManager(MBoxConfiguration config) {
try {
this.config = config;
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
SSLSocketFactory sf = new SSLSocketFactory(trusted);
Socket socket;
socket = ssf.createSocket();
socket.connect(new InetSocketAddress(config.ip, config.port));
KeyStore trusted = KeyStore.getInstance("BKS");
InputStream in =
MainActivity.context.getResources().openRawResource(R.raw.truststore);
try {
trusted.load(in, "password".toCharArray());
} finally {
in.close();
}
ssf = new SSLSocketFactory(trusted);
ssf.setHostnameVerifier(SSLSocketFactory.STRICT_HOSTNAME_VERIFIER);
} catch (Exception e) {
e.printStackTrace();
}
}
When i Want connect in QT Give me That error
Thread Address in peerVerifyError "The peer did not present any
certificate" Thread Address in sslErrors ("The peer did not present any
certificate") Thread Address in error QAbstractSocket::SocketError( 13 )
Thread Address in destroyThreadfirst: QThread(0x12ec9448) Thread Address
in destroyThread: QThread(0x12ec9238)
Asynchronous tableView loading
Asynchronous tableView loading
So I have a class with methods that sends asynchronous requests to my
database and then returns the objects into an array, I use blocks as a
form of callbacks. I save the array in a singleton that can return it with
a method.
The problem is I have almost no experience with tableViews, and I followed
a tutorial that accesses data from an array and then creates tableView
cells based on the number of objects in the array, and populates each
cell's text label with the description of each object. Now I'm trying to
make it work with my method and singleton, however the tableView loads
before my singleton has recieved anything from the database, so how do I
get through this problem?
So I have a class with methods that sends asynchronous requests to my
database and then returns the objects into an array, I use blocks as a
form of callbacks. I save the array in a singleton that can return it with
a method.
The problem is I have almost no experience with tableViews, and I followed
a tutorial that accesses data from an array and then creates tableView
cells based on the number of objects in the array, and populates each
cell's text label with the description of each object. Now I'm trying to
make it work with my method and singleton, however the tableView loads
before my singleton has recieved anything from the database, so how do I
get through this problem?
wpf Datagrid: Auto Increment number column in datagrid
wpf Datagrid: Auto Increment number column in datagrid
Iam new to wpf , I have a datagrid with 5 columns ,now I want to set first
column as a serial number column ,column which has a sequence numbers
starting from 1 to n rows . If the user add or delete one row to the
datagrid the serial number must be auto update how to do this in wpf...?
My Xaml :
<my:DataGrid Name="dataGrid1" ItemsSource="{Binding}"
AutoGenerateColumns="False" Height="150"
BeginningEdit="dataGrid1_BeginningEdit" KeyDown="dataGrid1_KeyDown">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Sl No"
Binding="{Binding}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Code" Binding="{Binding
Product_Code}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Name" Binding="{Binding
Product_Name}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Purchase Rate" Binding="{Binding
PurchaseRate}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Qty" Binding="{Binding
Qty}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Amount" Binding="{Binding
Amount}"></my:DataGridTextColumn>
</my:DataGrid.Columns>
</my:DataGrid>
My code behind is:
public class clsItemCollection
{
public string ProductName { get; set; }
public decimal PurchaseRate { get; set; }
public int Qty { get; set; }
public decimal Amount { get; set; }
}
ObservableCollection<clsItemCollection> obsItems = new
ObservableCollection<clsItemCollection>();
dgvSales.ItemsSource = obsItems; //On window constructor
Iam new to wpf , I have a datagrid with 5 columns ,now I want to set first
column as a serial number column ,column which has a sequence numbers
starting from 1 to n rows . If the user add or delete one row to the
datagrid the serial number must be auto update how to do this in wpf...?
My Xaml :
<my:DataGrid Name="dataGrid1" ItemsSource="{Binding}"
AutoGenerateColumns="False" Height="150"
BeginningEdit="dataGrid1_BeginningEdit" KeyDown="dataGrid1_KeyDown">
<my:DataGrid.Columns>
<my:DataGridTextColumn Header="Sl No"
Binding="{Binding}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Code" Binding="{Binding
Product_Code}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Product Name" Binding="{Binding
Product_Name}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Purchase Rate" Binding="{Binding
PurchaseRate}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Qty" Binding="{Binding
Qty}"></my:DataGridTextColumn>
<my:DataGridTextColumn Header="Amount" Binding="{Binding
Amount}"></my:DataGridTextColumn>
</my:DataGrid.Columns>
</my:DataGrid>
My code behind is:
public class clsItemCollection
{
public string ProductName { get; set; }
public decimal PurchaseRate { get; set; }
public int Qty { get; set; }
public decimal Amount { get; set; }
}
ObservableCollection<clsItemCollection> obsItems = new
ObservableCollection<clsItemCollection>();
dgvSales.ItemsSource = obsItems; //On window constructor
PHP random date and multiple dates
PHP random date and multiple dates
I have a problem regarding randoming a PHP date like this 2013-09-18
12:30. I want to random 6 dates like that one for 6 users, so dates don't
mix (dates can be the same but time must be +/- few hours). To random date
i used:
<?php
echo date('Y-m-d', strtotime( '+'.mt_rand(0,31).' days'));
?>
and had success with it but i can random hours or minutes (seconds i don't
need). The page is for reserving appointments for patients and giving them
random therapy dates. I also have an eventCalendar to show dates.
P.S is it possible to input multiple dates like an array (date1, date2,
date3) and show in mysql table i always get 0000-00-00. Thanks in advance.
I have a problem regarding randoming a PHP date like this 2013-09-18
12:30. I want to random 6 dates like that one for 6 users, so dates don't
mix (dates can be the same but time must be +/- few hours). To random date
i used:
<?php
echo date('Y-m-d', strtotime( '+'.mt_rand(0,31).' days'));
?>
and had success with it but i can random hours or minutes (seconds i don't
need). The page is for reserving appointments for patients and giving them
random therapy dates. I also have an eventCalendar to show dates.
P.S is it possible to input multiple dates like an array (date1, date2,
date3) and show in mysql table i always get 0000-00-00. Thanks in advance.
Tuesday, 17 September 2013
How to change the locale of a web application e.g. JSF, Struts, Spring MVC
How to change the locale of a web application e.g. JSF, Struts, Spring MVC
I have created a JSF application where in to implement localization, I
need to create separate property files for each locale. Is there any way
that these can be generated dynamically. Google translator is not a option
for me.
I have created a JSF application where in to implement localization, I
need to create separate property files for each locale. Is there any way
that these can be generated dynamically. Google translator is not a option
for me.
How to replace comma in textbox?
How to replace comma in textbox?
I have two textboxes, the textbox1 echo's value from database $row and
displays 1,900,200.00 on digit grouping. My textbox2 automatically copies
the exact value of textbox1 using javascript. What I want to do is to
replace the comma (,) in textbox2.
I have two textboxes, the textbox1 echo's value from database $row and
displays 1,900,200.00 on digit grouping. My textbox2 automatically copies
the exact value of textbox1 using javascript. What I want to do is to
replace the comma (,) in textbox2.
Subscribe to:
Posts (Atom)