Forgot password?
 Register account
Author: hbghlyj

Asymptote测试

[Copy link]

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-2-28 16:06
hbghlyj 发表于 2023-2-18 12:22
检查这个svg发现它内含一个base64的jpg
Asymptote三维图不能输出矢量图, 只能输出位图.
在3D圖,SVG不如PNG,因為base64更長,下載更慢吧

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-2-28 16:26
Last edited by kuing 2024-2-28 16:37asymptote.ualberta.ca 这个在线的还能用吗?我这边就输入一个 import venn; 点 Run 都报错

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-2-29 14:58
hbghlyj 发表于 2024-2-27 23:07
我們先等等,不做任何操作,也許過一陣子就好了😀
果然等等就好了😁
楼上的在线链接也能正常使用了

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-7 21:44
又挂了……原因不明,啥也没改……

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 04:51
Last edited by hbghlyj 2024-11-11 12:37
kuing 发表于 2024-11-7 13:44
又挂了……原因不明,啥也没改……
reqbin.com 測試:
服務器的響應竟然什麼內容都沒有!只有HTTP 标头,沒有任何內容:
Screenshot 2024-11-11 123445.png
Content是空的:
Screenshot 2024-11-11 123656.png

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-11 11:11
但是 asymptote.ualberta.ca 还是好用的,只是发送出了问题?你研究一下呗,用你的网站测试一下

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 18:02
kuing 发表于 2024-11-11 03:11
但是 asymptote.ualberta.ca 还是好用的,只是发送出了问题?你研究一下呗,用你的网站测试一下 ...
编写简短的 php 脚本进行测试

  1. <?php
  2. $url = 'http://asymptote.ualberta.ca:10007?f=pdf&render=4';
  3. $data = 'import teapot;';
  4. $options = [
  5.     'http' => [
  6.         'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
  7.         'method'  => 'POST',
  8.         'content' => $data,
  9.     ],
  10. ];
  11. $context  = stream_context_create($options);
  12. $result = file_get_contents($url, false, $context);
  13. file_put_contents('teapot.pdf', $result);
  14. ?>
Copy the Code
成功得到輸出 teapot.pdf,沒有問題!

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 18:08
这次和上次不同,上次故障出现在上游,只需等待即可,而这次上游工作正常,我想等待并不能解决问题。

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-11 20:01
hbghlyj 发表于 2024-11-11 18:02
编写简短的 php 脚本进行测试

成功得到輸出 teapot.pdf,沒有問題!
目前本站的 /asy/index.php 的代码为
  1. <?php
  2. if(empty($_GET['format'])){$f='svg';}
  3. //if(empty($_GET['format'])){$f='png';}
  4. elseif($_GET['format']=='svg'||$_GET['format']=='png'||$_GET['format']=='html') {$f=$_GET['format'];}
  5. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
  6. if(isset($_GET['code'])){
  7. $curl = curl_init($url);
  8. curl_setopt($curl, CURLOPT_URL, $url);
  9. curl_setopt($curl, CURLOPT_POST, true);
  10. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  11. $headers = array(
  12.    "Content-Type: text/plain",
  13. );
  14. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  15. curl_setopt($curl, CURLOPT_POSTFIELDS, $_GET['code']);
  16. $resp = curl_exec($curl);
  17. curl_close($curl);
  18. if($f=='svg'){header( 'Content-type: image/svg+xml' );}
  19. if($f=='png'){header("Content-Type: image/png");}
  20. print($resp);
  21. }
  22. ?>
Copy the Code
应该怎么改?

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 20:16
kuing 发表于 2024-11-11 12:01
目前本站的 /asy/index.php 的代码为

应该怎么改?
我原样在本地(Windows) 执行,竟沒出錯!
Screenshot 2024-11-11 121625.png

您也可測試一下,把文件命名為Untitled-1.php,本地(Windows)運行
  1. c:\php\php-cgi.exe Untitled-1.php code="import venn;" f="svg"
Copy the Code
我這邊是正常的

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 20:20
kuing 发表于 2024-11-11 12:01
目前本站的 /asy/index.php 的代码为

应该怎么改?
是不是上游把infinityfree禁了

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 20:24
kuing 发表于 2024-11-11 12:01
目前本站的 /asy/index.php 的代码为

应该怎么改?
建議測試一下,InfinityFree编译完的PHP有沒有设置支持cURL 扩展?否則curl_exec這些都無效了

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 20:25

如何检查 curl 是否已启用或禁用

  1. echo function_exists('curl_version');
Copy the Code

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-11 21:49
你是意思是在 /asy/ 下面再新建一个 php 文件,如 test.php,内容是 echo function_exists('curl_version'); 然后进入 /asy/test.php 看看输出啥是吗?

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-11 21:55
kuing 发表于 2024-11-11 21:49
你是意思是在 /asy/ 下面再新建一个 php 文件,如 test.php,内容是 echo function_exists('curl_version ...
进入 asy/test.php,结果是 1

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 21:58

curl 基础例子 ¶

只要你编译完的PHP设置了支持 cURL 扩展,你就可以开始使用cURL函数了。使用 cURL 函数的基本思想是先使用 curl_init() 初始化 cURL会话,接着可以通过 curl_setopt() 设置需要的全部选项,然后使用 curl_exec() 来执行会话,当执行完会话后使用 curl_close() 关闭会话。这是一个使用 cURL 函数获取 example.com 主页保存到文件的例子:

示例 #1 使用 PHP cURL 模块获取 example.com 的主页

<?php

$ch
= curl_init("http://www.example.com/");
$fp = fopen("example_homepage.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
if(
curl_error($ch)) {
fwrite($fp, curl_error($ch));
}
curl_close($ch);
fclose($fp);
?>

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 22:00
这样 cURL 确認启用了。

接下来我们检查 cURL 是否返回错误,有一个函数curl_error可以实现这个目的
curl_error — 返回当前会话最后一次错误的字符串

建议在原 php 文件中添加一个部分:
  1. curl_exec($ch);
  2. if(curl_error($ch)) {
  3.     exit(curl_error($ch));
  4. }
Copy the Code
这样程序就会退出并显示错误信息

Comment

加在哪?  Posted 2024-11-11 22:03
curl_exec 行之后  Posted 2024-11-11 22:04

682

Threads

110K

Posts

910K

Credits

Credits
90973
QQ

Show all posts

kuing Posted 2024-11-11 22:06
hbghlyj 发表于 2024-11-11 22:00
这样 cURL 确認启用了。

接下来我们检查 cURL 是否返回错误,有一个函数curl_error可以实现这个目的
  1. <?php
  2. if(empty($_GET['format'])){$f='svg';}
  3. //if(empty($_GET['format'])){$f='png';}
  4. elseif($_GET['format']=='svg'||$_GET['format']=='png'||$_GET['format']=='html') {$f=$_GET['format'];}
  5. $url = "http://asymptote.ualberta.ca:10007?f=".$f;
  6. if(isset($_GET['code'])){
  7. $curl = curl_init($url);
  8. curl_setopt($curl, CURLOPT_URL, $url);
  9. curl_setopt($curl, CURLOPT_POST, true);
  10. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  11. $headers = array(
  12.    "Content-Type: text/plain",
  13. );
  14. curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  15. curl_setopt($curl, CURLOPT_POSTFIELDS, $_GET['code']);
  16. $resp = curl_exec($curl);
  17. curl_exec($ch);
  18. if(curl_error($ch)) {
  19.     exit(curl_error($ch));
  20. }
  21. curl_close($curl);
  22. if($f=='svg'){header( 'Content-type: image/svg+xml' );}
  23. if($f=='png'){header("Content-Type: image/png");}
  24. print($resp);
  25. }
  26. ?>
Copy the Code
这样吗?然后怎么看?

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 22:07
如果仍然什么也看不见,没有 curl_error 信息,则很可能上游阻止了所有 InfinityFree 发送的请求

3152

Threads

7905

Posts

610K

Credits

Credits
64068
QQ

Show all posts

 Author| hbghlyj Posted 2024-11-11 22:08
如果cURL正常運作,我能想到的唯一可能性是服务器被上游拒绝了(如果是这种情况,唯一的解决方案就是改变上游,例如改变为 AoPS)。还有其他可能性吗?

Mobile version|Discuz Math Forum

2025-6-4 17:29 GMT+8

Powered by Discuz!

× Quick Reply To Top Edit