<?php
$url = 'https://mc.api.sberbank.ru:443/prod/tokens/v3/oauth';
$headers = [
'RqUID: f32925a45cc740b1b4c71473f72e5c2c',
'Authorization: Basic **************',
'Content-Type: application/x-www-form-urlencoded'
];
$data = [
'grant_type' => 'client_credentials',
'scope' => 'auth://demo/json'
];
$certPath = 'mycert.12';
$certPass = '********';
$caCertPath = 'russian-trusted-cacert.pem';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSLCERT, $certPath);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $certPass);
curl_setopt($ch, CURLOPT_CAINFO, $caCertPath);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
shell_exec
+ chromium
с флагами headless
disable-gpu
и print-to-pdf
отрисует вам что угодно, что может отобразить chrome.function mysqli_json_insert($mysqli, $tablename, $json){
$arr = json_decode($json, true);
$fields = '`' . implode('`, `', array_keys($arr)) . '`' ;
$values = implode(',', array_fill(0, count($arr)));
$stmt = $mysqli->prepare("insert into `$tablename` ($fields) values ($values)");
$types = str_repeat('s', count($arr));
$stmt->bind_param($types, ...$arr);
$stmt->execute();
}
Писал с руки, так что могут быть очепятки... data: () => ({
blocks: [
{
template: '<div><ul><li v-for="n in data" v-html="n"></li></ul></div>',
data: [
'<h2>Заголовок 1</h2><p>какой-то текст 1</p>',
'<h2>Заголовок 2</h2><p>какой-то текст 2</p>',
],
},
{
template: '<div><h3 v-for="color in data" :style="{ color }">{{ color }}</h3></div>',
data: [ 'red', 'green', 'blue' ],
},
{
template: '<div><p v-for="i in data">{{ i }}</p></div>',
data: 4,
},
],
}),
Vue.component('block-component', {
props: [ 'template', 'data' ],
computed: {
compiled() {
return Vue.compile(this.template);
},
},
render() {
return this.compiled.render.call(this);
},
});
<block-component v-for="n in blocks" v-bind="n"></block-component>
class ExtendedZip extends ZipArchive {
// Member function to add a whole file system subtree to the archive
public function addTree($dirname, $localname = '') {
if ($localname)
$this->addEmptyDir($localname);
$this->_addTree($dirname, $localname);
}
// Internal function, to recurse
protected function _addTree($dirname, $localname) {
$dir = opendir($dirname);
while ($filename = readdir($dir)) {
// Discard . and ..
if ($filename == '.' || $filename == '..')
continue;
// Proceed according to type
$path = $dirname . '/' . $filename;
$localpath = $localname ? ($localname . '/' . $filename) : $filename;
if (is_dir($path)) {
// Directory: add & recurse
$this->addEmptyDir($localpath);
$this->_addTree($path, $localpath);
}
else if (is_file($path)) {
// File: just add
$this->addFile($path, $localpath);
}
}
closedir($dir);
}
// Helper function
public static function zipTree($dirname, $zipFilename, $flags = 0, $localname = '') {
$zip = new self();
$zip->open($zipFilename, $flags);
$zip->addTree($dirname, $localname);
$zip->close();
}
}
// Example
ExtendedZip::zipTree('/foo/bar', '/tmp/archive.zip', ZipArchive::CREATE);