Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我想使用wwwcopy脚本从我的PHP内容创建几个静态html页面_Php_Mysql_Facebook_Metadata - Fatal编程技术网

我想使用wwwcopy脚本从我的PHP内容创建几个静态html页面

我想使用wwwcopy脚本从我的PHP内容创建几个静态html页面,php,mysql,facebook,metadata,Php,Mysql,Facebook,Metadata,2012年7月16日编辑 我需要重新考虑这个问题。我使用动态页面已经有一段时间了,上面有缓存的PHP。我的大部分页面都是缓存的,但元数据信息不是。正如我在下面的帖子中所解释的,我需要减少/删除到本地MySQL数据库的请求。由于即将到来的请求,我收到了500个内部服务器错误。我一直在探索Jquery/Ajax,将数据库中的数据拉入xml页面,并从中获取站点请求数据,这是可行的,但我仍然遇到了将内容从正文移动到元数据的问题,以便facebook和搜索引擎可以看到动态内容。这是我需要的 我需要一个解决

2012年7月16日编辑

我需要重新考虑这个问题。我使用动态页面已经有一段时间了,上面有缓存的PHP。我的大部分页面都是缓存的,但元数据信息不是。正如我在下面的帖子中所解释的,我需要减少/删除到本地MySQL数据库的请求。由于即将到来的请求,我收到了500个内部服务器错误。我一直在探索Jquery/Ajax,将数据库中的数据拉入xml页面,并从中获取站点请求数据,这是可行的,但我仍然遇到了将内容从正文移动到元数据的问题,以便facebook和搜索引擎可以看到动态内容。这是我需要的

我需要一个解决方案,将创建约1500个静态页面,通过查看 从0开始,数到1500http://chennaichristianradio.com/PHP/web/songinfo.php?songID=0 到这对我来说是可行的,但不是我喜欢的

第二个选项是使用PHP缓存选项,该选项将缓存整个页面,包括从PHP创建的元数据

第三个选项我的首选选项是能够从主体中的ajax/Jquery创建的数据或从xml页面本身创建元数据

感谢您再次访问此请求。请阅读我今年早些时候的原创帖子。下面是我目前使用的一些代码和示例链接

当前用于创建动态页面的PHP

 <title>Chennai Christian Radio</title>
    <meta property="og:title" content="<?php echo $song->title; ?> by <?php echo $song->artist; ?> - Found on Chennai Christian Radio"/>
    <meta property="og:type" content="song"/>
    <meta property="og:url" content="http://chennaichristianradio.com/PHP/web/songinfo.php?songID=<?php echo $song->ID; ?>"/>
    <meta property="og:image" content="<?php echo $song->picture; ?>"/> 
    <meta property="og:site_name" content="Chennai Christian Radio"/>
    <meta property="fb:admins" content="1013572426"/>
<?php

      $cachefile = "cache/".$reqfilename.$cache_folder.md5($_SERVER['REQUEST_URI']);


      $cachetime = 11000 * 60; // 110000 minutes


      // Serve from the cache if it is younger than $cachetime

      if (file_exists($cachefile) && (time() - $cachetime
         < filemtime($cachefile))) 
      {

         include($cachefile);


         echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." 
         -->n";


         exit;

      }

      ob_start(); // start the output buffer


?>
<div id="fbbutton">
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=170819122971839";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div class="fb-like" data-send="false" data-layout="box_count" data-width="50" data-show-faces="false"></div>
</div>

<div id="songinfo">

<!-- BEGIN:AlbumArt -->
<?php if(SHOW_PICTURES && !empty($song->picture)) : ?> <img class="picture" id="picture" onload="showPicture(this, <?php echo SHOW_PICTURES; ?>)" src="<?php echo $song->picture; ?>" alt="" border=0 width="142" height="142" /></a><?php endif; ?>


</div>
<!-- Song Info -->
<div id="wrapper">
<div id="title"><?php echo $song->title; ?></div>
<div id="artist"><?php echo $song->artist; ?></div>
<div id="album"><?php echo $song->album; ?></div>
<div id="duration"><?php echo $song->durationDisplay; ?></div>
<div id="year"><?php echo $song->albumyear; ?></div>
</div>
<div id="lyrics"><pre><?php if (!empty($song->lyrics)) : ?><dd class="broad"><pre><?php echo $song->lyrics; ?><?php endif; ?></pre></div>
<?php
       // open the cache file for writing
       $fp = fopen($cachefile, 'w'); 


       // save the contents of output buffer to the file
        fwrite($fp, ob_get_contents());

        // close the file

        fclose($fp); 

        // Send the output to the browser
        ob_end_flush(); 
?>
这是我创建XML的新脚本

<?php
function wwwcopy($link,$file)
{
   $fp = @fopen($link,"r");
   while(!feof($fp))
   {
       $cont.= fread($fp,1024);
   }
   fclose($fp);

   $fp2 = @fopen($file,"w");
   fwrite($fp2,$cont);
   fclose($fp2);
}

wwwcopy("http://www.domain.com/list.php?member=sample", "sample.html");
和我的html中的脚本来读取提取的内容

<?php

  $cachefile = "cache/".$reqfilename.$cache_folder.md5($_SERVER['REQUEST_URI']);


  $cachetime = 11000 * 60; // 110000 minutes


  // Serve from the cache if it is younger than $cachetime

  if (file_exists($cachefile) && (time() - $cachetime
     < filemtime($cachefile))) 
  {

     include($cachefile);


     echo "<!-- Cached ".date('jS F Y H:i', filemtime($cachefile))." 
     -->n";


     exit;

  }

  ob_start(); // start the output buffer
一些链接 使用PHP动态创建页面:

显示页面中所需数据的XML页面:

使用JQuery和Ajax创建的页面:

谢谢大家的帮助!! -鲍勃昂首阔步

原文如下

我希望使用以下脚本创建数百个静态html页面:

<title>Chennai Christian Radio</title>
<meta property="og:title" content="<?php echo $song->title; ?> by <?php echo $song->artist; ?> - Found on Chennai Christian Radio"/>
<meta property="og:type" content="song"/>
<meta property="og:url" content="http://chennaichristianradio.com/PHP/web/songinfo.php?songID=<?php echo $song->ID; ?>"/>
<meta property="og:image" content="<?php echo $song->picture; ?>"/> 
<meta property="og:site_name" content="Chennai Christian Radio"/>
<meta property="fb:admins" content="1013572426"/>
<meta property="og:description"
      content="Chennai Christian Radio is your last stop for today's best Christian Music. http://chennaichristianradio.com"/>
我创建了名为create.php的php页面,它创建了一个文件。如何使用此脚本并创建1200页

我这样做的全部目的是最大限度地减少对MySQL数据库的请求,并加快页面的更新速度。创建这些页面后,我将使用另一个脚本指向这些文件

2012年3月24日更新

谢谢你的回复。以下是我在做这件事时要达到的目标。也许有更好的解决办法

看我的页面

我的软件正在根据数据库中的歌曲ID 5351动态创建此页面 我用php去抓取歌曲信息。为了使这个过程更有效率,我设置了PHP缓存。我正在使用…缓存此文件

for ($i = 1; $i <= 1200; $i++) 
{ 
    wwwcopy("url", "file");
}
?>

PHP缓存是用这个实现的,但我的问题是它只缓存来自此代码和下面的PHP信息。这是一个问题的原因,是因为我在meta-info中使用了PHP作为我打开的图形标记。OG是这样的,人们可以在Facebook上喜欢我的音乐。下面是我的OG标签的外观


所以。。。。。。缓存我的动态页面并包含元数据信息的解决方案是什么。这无疑是最好的选择,但在我当前的代码中,它仍然会查询我的MYSql服务器的元数据信息和歌曲信息。我认为,通过为此创建静态页面,并告诉我的软件指向这些页面,而不是查询我的数据库,这将更有效率,并有助于减少返回服务器的PHP流量。希望这能澄清我的需要,我感谢大家的回应和帮助

我不确定您想要实现什么,但要实现1200次,只需使用for循环并更改文件名和URL即可


我认为你必须选择缓存选项。如果您使用的是任何框架,则有用于启用缓存的默认设置。这将真正提高您的速度。

查看我的更新,了解我正在努力实现的目标。非常感谢。
<title>Chennai Christian Radio</title>
<meta property="og:title" content="<?php echo $song->title; ?> by <?php echo $song->artist; ?> - Found on Chennai Christian Radio"/>
<meta property="og:type" content="song"/>
<meta property="og:url" content="http://chennaichristianradio.com/PHP/web/songinfo.php?songID=<?php echo $song->ID; ?>"/>
<meta property="og:image" content="<?php echo $song->picture; ?>"/> 
<meta property="og:site_name" content="Chennai Christian Radio"/>
<meta property="fb:admins" content="1013572426"/>
<meta property="og:description"
      content="Chennai Christian Radio is your last stop for today's best Christian Music. http://chennaichristianradio.com"/>
for ($i = 1; $i <= 1200; $i++) 
{ 
    wwwcopy("url", "file");
}