Bitcoin sendfrom do not processing transaction - php

I have very strange problem with sendfrom. To process I am using dynamic vales from form received with $_POST.
$myaccount = trim($_POST['myaccount']);
$to_wallet = trim($_POST['to_wallet']);
$wammount = trim($_POST['wammount']);
I can echo them and I can clearly see all the data passed from form
Now I am inserting them to
$message = ($bitcoin->sendfrom($myaccount, $to_wallet, $wammount));
What I discovered that all the $myaccount, $to_wallet are correctly passed but $wammount causing problem and code is not executed. I am inserting in form 0.0001 inside the field
"wammount" however once this is hard coded
$myaccount = trim($_POST['myaccount']);
$to_wallet = trim($_POST['to_wallet']);
$wammount = 0.0001;
and running command below everything run well and transaction is processed. Any idea why ?
$message = ($bitcoin->sendfrom($myaccount, $to_wallet, $wammount));

What does adding floatval() do?
$wammount = floatval(trim($_POST['wammount']));

Related

Sending data from AngularJS to PHP for IF-statement in PHP with perhaps in proper syntax?

I am trying to send data from AngularJS to PHP.
I am sending the data from the controller.js of AngularJS.
I am receiving the data through PHP. The data comes well for others variables.
However, I don't know which part is the problem.
My goal is to have the PHP recognize $step_number and run through the IF-statement in PHP, but even though I send wrong data, it works!
Which means,
if the $step_number in PHP is '2', then the IF-statement in PHP should not work as shown in below. But, it runs!
I thought this was the proper way to write the code as other data are being passed to PHP.
Controller.js
$http.post("../crud/projects_update.php",{
step_number : '1', // This one, I am trying to send, but I don't know whether this is not being sent or the problem is occurred in PHP.
project_id : $scope.project_data.project_id // This works in the PHP. It is well sent.
project_title : $scope.project_data.project_title
}
PHP
require_once 'connect.php';
$data = json_decode(file_get_contents("php://input"));
$step_number = $data->step_number; // This should be received from AngularJS and if the $step_number is not matched in the IF-statement, then the function in { } should not work.
if ($step_number = '1'){
$project_id = $data->project_id;
$project_title = $data->project_title;
$conn->query("UPDATE `projects` SET
`project_title` = '$project_title',WHERE `project_id` = $project_id") or die(mysqli_error());
}
Two things need to change:-
1.Change step_number : '1', to step_number : 1,
2.Change
if ($step_number = '1'){ //this is assignment not comparison
to:-
if ($step_number == 1){ // now it's comparison

Unable to send data using POST in Python

I am trying to send data using POST from StachExchange API. I am not sure what seems to be the problem. I have checked the script, it's working fine when I try to POST data some other way. The problem seems to be with the python script. The scripts gets the data from the API but doesn't seems to be posting to "generate.php" Nonetheless here's the code:
#!/usr/bin/env python
import requests, json
userinput = input('Enter a keyword: ')
userinputq = input('Enter page: ')
getparams = {'page':userinputq, 'pagesize':'100', 'order':'desc', 'sort':'votes', 'intitle':userinput, 'site':'stackoverflow', 'filter': '!5-HwXhXgkSnzI0yfp0WqsC_-6BehEi(fRTZ7eg'}
r = requests.get('https://api.stackexchange.com/2.2/search', params=getparams)
result = json.loads(r.text)
if result['has_more'] == False:
print("Error given.")
else:
for looping in result['items']:
if looping['is_answered'] == True:
try:
newparams = {'order':'desc', 'sort':'votes', 'site':'stackoverflow', 'filter': '!4(Yrwr)RRK6oy2JSD'}
newr = requests.get('https://api.stackexchange.com/2.2/answers/'+str(looping['accepted_answer_id']), params=newparams)
newresult = json.loads(newr.text)
titletopost = 'Title:', looping['title']
bodytopost = '<h1>Question:</h1><br>'+(looping['body'])+'<br>'+'Link to Question: '+(looping['link'])+'<br><br><br>'+'<h1>Answer:</h1><br>'+(newresult['items'][0]['body'])
enterremove = bodytopost.replace('\n', '').replace('\r', '')
print(enterremove)
userdata = {"secret":"Secret", "topic_title":titletopost, "body":enterremove}
requests.post("http://www.example.com/generate.php", data=userdata)
except KeyError: print("No answer ID found.")
print("")
print("")
Can anyone please explain the problem?
Nevermind! There's nothing wrong with the python script. Actually I forgot to change "$_GET" to "$_POST" in 'generate.php' while I was testing it.

Trying to add an attachment to an Estimate via PHP (works but, doesn't.)

This is my second day messing with the PHP SDK, I've encountered a road block with uploading an attachment to an Estimate with my code. I wanted a PHP form where one can upload a file and shoot it into the QBO company; my first step was to first try and set a static variable to see if it works, my code look slike this:
$Estimate = $dataService->query("SELECT * FROM Estimate WHERE DocNumber in ('{$ID}')");
// Create a new IPPAttachable
$up = "http://www.somedomain.com/test.pdf";
$sendMimeType = "application/pdf";
$randId = rand();
$entityRef = new IPPReferenceType($Estimate->Id);
$attachableRef = new IPPAttachableRef($entityRef);
$objAttachable = new IPPAttachable();
$objAttachable->FileName = $randId."TEST02.pdf";
//$objAttachable->AttachableRef = $Estimate->DocNumber;
$objAttachable->AttachableRef = $attachableRef;
$objAttachable->Note = "Test";
$objAttachable->ContentType = $sendMimeType;
$resultObj = $dataService->Upload($up,
$objAttachable->FileName,
$sendMimeType,
$objAttachable);
This code fires, adds an attachment to the proper estimate but the attachment is less than 1k and is unreadable. Almost as if it never fetched the document to attach, it simply made some kind of a "generic" success.
Can anyone assist with updating the above code? I'm sure its right in front of me, but I keep missing.
Thank you!

Webrequest faster downloading (Googled for days)

Im working on a project that downloads up to 5000 individual pieces of data from a server. It basically is a PHP page that takes POST variable, gets the data from the DB and sends it back to the .NET client.
It is slow. It takes about 1 second per request. I've googled a lot and tried all sorts of tweaks to the code, like the famous proxy-setting etc. But nothing speeds it up.
Any idea's? All solutions that make this super fast are welcome. Even C-written DLL's or anything you can think of. This just needs to be a lot faster.
Public Function askServer(oCode As String) As String
oBytesToSend = Encoding.ASCII.GetBytes("cmd=" & System.Web.HttpUtility.UrlEncode(oCode))
Try
oRequest = WebRequest.Create(webServiceUrl)
oRequest.Timeout = 60000
oRequest.Proxy = WebRequest.DefaultWebProxy
CType(oRequest, HttpWebRequest).UserAgent = "XXXXX"
oRequest.Method = "POST"
oRequest.ContentLength = oBytesToSend.Length
oRequest.ContentType = "application/x-www-form-urlencoded"
oStream = oRequest.GetRequestStream()
oStream.Write(oBytesToSend, 0, oBytesToSend.Length)
oResponse = oRequest.GetResponse()
If CType(oResponse, HttpWebResponse).StatusCode = Net.HttpStatusCode.OK Then
oStream = oResponse.GetResponseStream()
oReader = New StreamReader(oStream)
oResponseFromServer = oReader.ReadToEnd()
oResponseFromServer = System.Web.HttpUtility.UrlDecode(oResponseFromServer)
Return oResponseFromServer
Else
MsgBox("Server error", CType(vbOKOnly + vbCritical, MsgBoxStyle), "")
Return ""
End If
Catch e As Exception
MsgBox("Oops" & vbCrLf & e.Message, CType(vbOKOnly + vbCritical, MsgBoxStyle), "")
Return ""
End Try
End Function
Some ideas :
Run the http requests in parallel. (Client)
If the data response size allows it get all data needed in one request (you need change your server implementation).
Caching data. (Server)

Populate Flex ComboBox from XML from PHP

I'm having trouble populating a combobox from an XML response. Here is the XML that I am receiving:
<distros>
<entry>
<distro>CentOS</distro>
<distro>Debian</distro>
<distro>Other</distro>
<distro>Sabayon</distro>
<distro>Ubuntu</distro>
<distro>VMware</distro>
<distro>Windows</distro>
</entry>
</distros>
So probably the most basic form of XML ever!
and here is the flex code:
private function getDistros():void
{
httpReq = new HTTPService;
httpReq.url = 'http://myserver/xml.php';
httpReq.resultFormat = 'e4x';
httpReq.method = 'GET';
httpReq.addEventListener(ResultEvent.RESULT, popDistros);
httpReq.send( null );
}
private function popDistros(event:ResultEvent):void
{
if(event.result != "")
{
// Set the data to the XMLListCollection for lookup
myXmlCollection= new XMLListCollection(event.result.entry);
// Bind the ListCollection to the comboBox
Alert.show(myXmlCollection.toString());
distroCombo.dataProvider = myXmlCollection.toString();
}
}
and the MXML:
<mx:ControlBar x="139" y="10" width="266" height="358" verticalAlign="top" horizontalAlign="left" direction="vertical">
<mx:ComboBox id="distroCombo" labelField="distro"></mx:ComboBox>
<mx:ComboBox id="imageCombo"></mx:ComboBox>
<mx:Button label="Download"/>
</mx:ControlBar>
The XML comes back fine in the Alert but the comboBox won't populate and I have tried this so many different ways now, anyone got any suggestions? Have I just been staring at it far too long?
if the result (event.result) is XML, then It should wotk like this: (it differs with .distro in the end compared to yours)
myXmlCollection = new XMLListCollection(event.result.entry.distro);
...this should create valid data in myXmlCollection
But then also this row is wrong:
distroCombo.dataProvider = myXmlCollection.toString();
it creates just one item in dataProvider of type string, (Just BTW: if you would have used spark combobox, you would have get compile error at this row).
just use this instead:
distroCombo.dataProvider = myXmlCollection;
And also note, that you can see correct result in the Alert, but it does not say if the data are of correct type, coz Alert evertyhing converts to string :)

Categories