GVKun编程网logo

如何检查远程网站在 php 中是否有自定义 404 页面?(php判断远程文件是否存在)

14

如果您对如何检查远程网站在php中是否有自定义404页面?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于如何检查远程网站在php中是否有自定义404页面?的详细内容,我们还

如果您对如何检查远程网站在 php 中是否有自定义 404 页面?感兴趣,那么本文将是一篇不错的选择,我们将为您详在本文中,您将会了解到关于如何检查远程网站在 php 中是否有自定义 404 页面?的详细内容,我们还将为您解答php判断远程文件是否存在的相关问题,并且为您提供关于Magento如何自定义404页面?、php – 在下载之前检查远程服务器上是否存在图像、php – 如何检查IF用户是否已经喜欢Facebook页面?、php – 检查远程URL是否具有有效的图像扩展名的有价值信息。

本文目录一览:

如何检查远程网站在 php 中是否有自定义 404 页面?(php判断远程文件是否存在)

如何检查远程网站在 php 中是否有自定义 404 页面?(php判断远程文件是否存在)

我正在使用此代码检查状态代码。任何网址。

 public function callAPI($method,$url,$data = false,$headers = [])
{
    $curl = curl_init();

    if (count($headers) > 0) {
        curl_setopt($curl,CURLOPT_HTTPHEADER,$headers);
    }

    switch ($method) {
        case "POST":
            curl_setopt($curl,CURLOPT_POST,1);

            if ($data) {
                curl_setopt($curl,CURLOPT_POSTFIELDS,$data);
            }

            break;
        case "PUT":
            curl_setopt($curl,CURLOPT_CUSTOMREQUEST,"PUT");
            break;
        default:
            if ($data) {
                $url = sprintf("%s?%s",http_build_query($data));
            }

    }

    curl_setopt($curl,CURLOPT_URL,$url);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);

    $result = curl_exec($curl);
    $httpcode = curl_getinfo($curl,CURLINFO_HTTP_CODE);

    curl_close($curl);

    return [
        'result' => $result,'statusCode' => $httpcode,];
}
//this will send request to given URL and function will return response code and whole response.
$response = callAPI("GET",$url);
$responseCode = $response["statusCode"];
if($responseCode == '404'){
    echo "404 not found";
}

Magento如何自定义404页面?

Magento如何自定义404页面?

magento修改404页面

Magento有默认的404页面,如果想自定义一个404页面,又该如何做呢?

方法一

首先,先来看下默认的404页面:
Magento如何自定义404页面?
1.Magento的CMS部分,可以通过定义它来改变错误页面,登录后台admin->CMS->Pages:

2.打开404 Not Found页面,点击左侧的Content,就可以看到404页面的详情:
Magento如何自定义404页面?

3.现在来重新定义下404页面,比如,输入以下代码:

<div>
    <h3>D''oh! That page can''t be found.</h3>
    <p><strong>Don''t get angry, and don''t cry.</strong> Let us
    take that burden. It''s not your fault. No, really, listen to me.
    It''s not your fault. We have a 24 hour hotline to deal with things
    just like this. Okay, its not really a hotline, its really
    just some encouraging words to keep trying, but hotline sounds
    so much .</p>
    <p>Sorry but the page you are looking for cannot be found.
    If you''re in denial and think this is a conspiracy that cannot
    possibly be true,</p>
</div>
登录后复制
Perhaps you are here because:
  • The page has moved
  • The page is no longer exists
  • You were looking for your puppy and got lost
  • You like 404 pages
What can you do?
Have no fear, help is near! There are many ways you can get back on track with Magento Demo Store.
  • Go back to the previous page.
  • CMS and Design 30
  • Use the search bar at the top of the page to search for your products.
  • Follow these links to get you back on track!
    Store Home
    My Account

4.点击save page,重新打开,可以看到404页面已经发生变化。
Magento如何自定义404页面?

方法二

方法一,是通过在后台配置修改,除此之外,还需要知道的是,修改404页面,也可以通过修改模板来更改。

1.首先要将CMS中的404 Not Found 的状态改成disable。

2.找到 no-route.phtml页面,路径为app/design/frontend/base/default/
template/cms/default/no-route.phtml,打开,会看到如下代码:

There was no 404 CMS page configured or found.
登录后复制

3.再次打开前台页面,查看是否与上述代码内容一致,前台页面为:
Magento如何自定义404页面?

4.由此,可以通过修改模板文件来修改404页面。

以上就介绍了Magento如何自定义404页面?,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

php – 在下载之前检查远程服务器上是否存在图像

php – 在下载之前检查远程服务器上是否存在图像

我试图从远程服务器下载图像,调整大小,然后保存本地计算机.

为此,我使用WideImage.

<?PHP 

include_once($_SERVER['DOCUMENT_ROOT'].'libraries/wideimage/index.PHP');

include_once($_SERVER['DOCUMENT_ROOT'].'query.PHP');    


do { 


wideImage::load($row_getimages['remote'])->resize(360, 206, 'outside')->savetoFile($_SERVER['DOCUMENT_ROOT'].$row_getimages['local']);}

while ($row_getimages = MysqL_fetch_assoc($getimages)); 


?>

这大部分时间都有效.但它有一个致命的缺陷.

如果由于某种原因,其中一个图像不可用或不存在.
Wideimage引发致命错误.防止下载可能存在的任何其他图像.

我试过像这样检查文件存在

    do { 

if(file_exists($row_getimages['remote'])){

    wideImage::load($row_getimages['remote'])->resize(360, 206, 'outside')->savetoFile($_SERVER['DOCUMENT_ROOT'].$row_getimages['local']);}

}        
    while ($row_getimages = MysqL_fetch_assoc($getimages)); 

但这不起作用.

我究竟做错了什么??

谢谢

解决方法:

根据this page,file_exists无法检查远程文件.有人在评论中建议他们使用fopen作为解决方法:

<?PHP
function fileExists($path){
    return (@fopen($path,"r")==true);
}
?>

php – 如何检查IF用户是否已经喜欢Facebook页面?

php – 如何检查IF用户是否已经喜欢Facebook页面?

我的网站上有一个类似按钮(用户喜欢fb粉丝页面).

如果用户点击了,我检查是否已经触发了偶数(事件订阅),然后向他们显示一些内容.

我真的很感激帮助的是以下内容:

如果用户登录到Facebook并且他们已经喜欢该页面,我希望它显示“你已经是粉丝!”并显示内容. (而不是显示像按钮一样的灰色)

要么

如果用户没有登录到Facebook并且他们点击了类似按钮,我希望它显示“你已经是粉丝!”并显示内容. (而不是显示像按钮一样的灰色)

编辑:伙计们,我在SO上研究了这个问题并找到了类似的问题,但并不完全是我追求的问题.也许我错了,但是如果有人可以提供一个描述我确切问题的链接,那么它会比问题更有帮助.我检查了以下内容:
Check if the user is connected to facebook and then check if he liked a page
Facebook Like Box: How to detect if user already liked the page?
Facebook LIKE button hiding when page is already LIKED by user
How to check whether user has liked the page or not using php/javascript
Check if user already likes fanpage

如果你使用facebook PHP API.我想出了这个简短的函数,你可以将base_facebook.PHP文件包含在BaseFacebook类中.
public function userIsFan() {
    $sr = $this->getSignedRequest();
    if($sr && is_array($sr)){
        if(array_key_exists('page',$sr)){
            return $sr['page']['liked'] == 1;
        }
    }
    return 0;
}

php – 检查远程URL是否具有有效的图像扩展名

php – 检查远程URL是否具有有效的图像扩展名

如何检查远程URL是否具有有效的图像扩展名?

我想要做的是使用PHP通过链接上传图像

copy('http://website.com/image.jpg', '/upload/filename.jpeg');

代码工作正常但我想检查输入的url是否具有有效的图像扩展名.

它应该是jpg,png或gif文件.喜欢看一个如何做到这一点的例子.

非常感谢您的帮助和时间.

解决方法:

您可以使用preg_match将文件名与已知列表进行比较:

if (preg_match('/\.(jpeg|jpg|png|gif)$/i', $image_url)) {
    // Successful match!
} else {
    // Not an image file extension
}

这将匹配以’.jpeg’,’.jpg’,’.png’或’.gif’结尾的字符串,无论它们是大写,小写还是大小写混合.

关于如何检查远程网站在 php 中是否有自定义 404 页面?php判断远程文件是否存在的问题就给大家分享到这里,感谢你花时间阅读本站内容,更多关于Magento如何自定义404页面?、php – 在下载之前检查远程服务器上是否存在图像、php – 如何检查IF用户是否已经喜欢Facebook页面?、php – 检查远程URL是否具有有效的图像扩展名等相关知识的信息别忘了在本站进行查找喔。

本文标签: