Jump to content
xisto Community
takashiro1405241549

What's Wrong With My Php Webpage? there may be something wrong in my php code.

Recommended Posts

This is the first time I use the functions fopen() and preg_replace() . It seems that there's somthing wrong. Where did I write by mistake?

<?phpinclude('data/workinfo/0.php');$viewwork = substr($work[0],0,249);/* HERE CAN'T WORK WELL! */$newthread = fopen("http://c8s2007.freetzi.com/bbs/new.php?action=article&digest=0&postdate=0&author=1&fname=0&hits=0&replies=1&pre=6&num=10&length=35&order=1", "rb");if(!$newthread){		$newthread = "无法调用信息";	}else{		$ad = "</div></span></ilayer></layer></iframe></noframes></style></noscript></script></applet></xmp></pre></comment></xml></noembed>";		$ad .= "<script type='text/javascript'";		$ad .= "src='http://forums.xisto.com/no_longer_exists/;;		$ad .= "</script>";		$newthread = preg_replace($ad, "", $newthread);};/* HERE CAN'T WORK WELL! */echo <<< EOT<div class="container"><div class="side">	<div class="credit_info"><h2>最近更新</h2><ul>	<li><img src="daily/2007-11-24-1.jpg" />	<p>参加â无车日â千人骑车活动</p>	</li>	<li><img src="daily/2007-11-24-2.jpg" />	<p>运动会中我们留下了美好的记忆我们不是最好的但我们可以更好...</p>	</li>	</ul></div></div><div class="content">	<div id="announcement"><div id="announcementbody">		<marquee behavior="scroll" direction="left" scrolldelay="170" onMouseOver="this.stop();" onMouseOut="this.start();">		<script src="http://c8s2007.007ihost.com/bbs/new.php?action=notice&num=5&date=1&length=30"></script>		</marquee>	</div></div>	<div class="box"><h4>Class 8, Senior 2007</h4><table>		<tr><td width="33%">		<h2><a href="index.php?page=photo">班级相册</a></h2><p>放置我们留下的每一个瞬间。</p>		</td>		<td width="33%">		<h2><a href="index.php?page=creation">班级作品展</a></h2><p>这里准备放设计的作品文章等等。</p>		</td>		<td width="33%">		<h2><a href="bbs/">班级论坛</a></h2><p>灌水的好去处。发挥你灌水的本能....</p>		</td>		</tr><tr>		<td>		<h2><a href="index.php?page=teacher">教师风采</a></h2><p>展示我们最最可爱的老师。</p>		</td>		<td>		<h2><a href="bbs/thread.php?fid=10">留言本</a></h2><p>对网站的任何意见都可以在这里提出来。</p>		</td>		<td>		<h2></h2><p></p>		</td>		</tr></table>	</div>	<div class="mainbox"><h1>主页内容</h1><table><thead><tr>		<td width="33%">最新图片</td>		<td width="33%">最新作品</td>		<td width="33%">最新论坛帖子</td>		</tr></thead><tbody><tr>		<td><script src="include/pixviewer.js"></script></td>		<td><p><b>$worklist[0]</b>($author[0])</p> $viewwork âŚâŚ<br><p><strong><a href="index.php?page=creation&id=0">查看详细</a></strong></p></td>		<td><script>$newthread</script></td>		</tr></tbody></table>	</div></div></div>EOT;?>

Edited by pyost (see edit history)

Share this post


Link to post
Share on other sites

You are trying to remove some fixed portion of the text read from the remote file, correct? There's no use for a regular expression over there. Besides, the pattern you are specifying as the first parameter for the preg_replace function is not much of a regular expression either. Just use substr_replace function, that would do the job.

 

P.S. I was unsure if a remote file with query in the URL could be read using fopen but none of the documentation pages depict that.

 

You should post the code inside the [ code ] [ /code ] tags. Codes are not meant to fetch you Credits. Better make this change yourself. You'll loose a lot more points as penalty, if a moderator changes it.

Share this post


Link to post
Share on other sites

Which PHP version do you use and what is the exactly error code/message that you receive if available???

 

do you try to do the same thing using cUrl??? because i know that it has more or less the same functionality.

 

Take a look to these pages at the online PHP manual:

Filesystem - allow_url_fopen

Using remote files

List of Supported Protocols/Wrappers

Best regards,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.