mp: ass param to force mpsessid

lm: handle curl commands
This commit is contained in:
quenousimporte 2024-05-28 16:13:52 +02:00
parent 16885de8ad
commit b9a6b7f956
2 changed files with 35 additions and 11 deletions

View File

@ -2,20 +2,27 @@
<body> <body>
<?php <?php
$url = ''; $url = '';
$coverurl = ''; $coverurl = '';
if (isset($_POST['url'])) if (isset($_POST['url']))
{ {
require('TPEpubCreator.php'); require('TPEpubCreator.php');
$url = $_POST['url']; $url = $_POST['url'];
// extract url from curl command
if (str_starts_with($url, 'curl '))
{
$url = explode("'", $url)[1];
echo '<p>extracted url from curl command:</p><p>' . $url . '</p>';
}
$epub = new TPEpubCreator(); $epub = new TPEpubCreator();
$epub->temp_folder = 'temp/'; $epub->temp_folder = 'temp/';
$epub->epub_file = $_POST['epub']; $epub->epub_file = $_POST['epub'];
$epub->title = $_POST['title']; $epub->title = $_POST['title'];
if ($_POST['cover']) if ($_POST['cover'])
{ {
$coverurl = $_POST['cover']; $coverurl = $_POST['cover'];
@ -23,7 +30,7 @@
file_put_contents('temp/cover.jpg', $coverdata); file_put_contents('temp/cover.jpg', $coverdata);
$epub->AddImage( 'temp/cover.jpg', 'image/jpeg', true ); $epub->AddImage( 'temp/cover.jpg', 'image/jpeg', true );
} }
// cache json in case url expires // cache json in case url expires
$tempjsonpath = 'temp/' . hash('md5', $url) . '.json'; $tempjsonpath = 'temp/' . hash('md5', $url) . '.json';
$json = ''; $json = '';
@ -40,7 +47,7 @@
$publication = json_decode($json); $publication = json_decode($json);
$content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; }); $content = array_filter($publication->Content, function($item) { return $item->Category == 'Le Monde'; });
usort($content, function ($a, $b) { return $a->PageNumber - $b->PageNumber; }); usort($content, function ($a, $b) { return $a->PageNumber - $b->PageNumber; });
foreach ($content as $article) foreach ($content as $article)
{ {
$articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; })[0]; $articlebody = array_filter($article->ContentItem, function($item) { return $item->ContentType == 'text/xml'; })[0];
@ -57,19 +64,19 @@
// echo($articlebody->HtmlText); // echo($articlebody->HtmlText);
} }
} }
if ( ! $epub->error ) { if ( ! $epub->error ) {
$epub->CreateEPUB(); $epub->CreateEPUB();
if ( ! $epub->error ) { if ( ! $epub->error ) {
echo 'Success: Download your book <a href="' . $epub->epub_file . '">here</a>.'; echo 'Success: Download your book <a href="' . $epub->epub_file . '">here</a>.';
} }
} else { } else {
echo $epub->error; echo $epub->error;
} }
} }
?> ?>
<form method="post"> <form method="post">

View File

@ -1,6 +1,16 @@
<html>
<body>
<?php <?php
$sessionid = 'value of cookie MPSESSID'; $sessionid = 'value of cookie MPSESSID';
if (isset($_POST['mpsessid']) && $_POST['mpsessid'])
{
$sessionid = $_POST['mpsessid'];
echo 'Using ' . $sessionid . '<br>';
}
/*ini_set('display_errors', '1'); /*ini_set('display_errors', '1');
ini_set('display_startup_errors', '1'); ini_set('display_startup_errors', '1');
error_reporting(E_ALL);*/ error_reporting(E_ALL);*/
@ -95,4 +105,11 @@ if ( ! $epub->error )
} else { } else {
echo $epub->error; echo $epub->error;
} }
?> ?>
<form method="post">
Force MPSESSID: <input name="mpsessid">
<input type="submit">
</form>
</body>
</html>