Bir php sözlük scriptinde küçük bir değişiklik nasıl yapılır

Başlatan xwes, 22 Ağustos 2009 - 09:35:20

« önceki - sonraki »

0 Üyeler ve 1 Ziyaretçi konuyu incelemekte.

xwes

Merhaba, php'den anlayan arkadaşlardan ufak bir ricada bulunmak istiyorum. İnternetten basit bir sözlük scripti buldum, bu scripti kullanarak online bir mesleki terimler sözlügü oluşturmak istiyorum. Sözlüğün çalışma mantığı şu;
öncelikle bu script mysql, veritabanı kullanmıyor. Bir dictionary.php ve bir de file.txt dosyasından oluşuyor. Sözlügün arayüzü bu dictionary.php dosyası. www.siteadresi.com/dictionary.php yolunu izlediğinizde karşınıza basitçe bir arama kutusu çıkıyor. Bu arama kutusunda kelimeyi yazıp arattığınızda da file.txt dosyası içerisinden arama yapılıyor ve sonuçlar çıkıyor. www.siteadresi.com/dictionary.php?action=add_dict adresinden ise yine aynı .php dosyası sayesinde file.txt dosyasına yeni terim ekleyebiliyorsunuz. Tam istediğim gibi basit ve işlevsel. Şimdi benim sorunum file.txt dosyasında terimlerin yazılma formatı ile ilgili. Dosyada terimler şöyle yer alıyor:
[new];Alkali Metals;Metals of Group IA (Na, K, Rb).;Alkali Metals;A;1059406451;

Yani önce bir [new] kelimesi ; başlık ; açıklama; keyword ; baş harfi ; numaralandırma
ben ise şöyle olmasını istiyorum;
keyword   açıklama (arada tab boşluğu var)
Eger böyle olursa offline olarak daha hızlı kelime ekleyebilirim.
Şimdi ben php'den anlamadan sadece ingilizcem ve sezgilerimle bu dosyada bazı değişiklikler yaptım ve bu sayede, kelime ekleme sayfasından kelime eklediğimde istediğim formatta ekleniyor. Fakat arama fonksiyonu tabi ki bu şekilde eklenen kelimelerin içinde arama yapamıyor. Çünkü eski formattaki gibi bir sıralama bekliyor. Sanırım bu .php dosyasının içinde arama fonksiyonunun file.txt dosyasında kelimeleri nasıl arayacağını yazan bir kısım olmalı ancak bir türlü bulup istediğim hale getiremedim. (arama yine keyword'ler içerisinde yapılacak ancak keywordun ve açıklamanın file.txt dosyası içerisindeki yeri doğru tanımlanmalı)
Biri bu konuda yardımcı olursa çok sevinirim.
.php dosyasının içeriği şöyle;<LINK
href="st.css" rel=stylesheet
type=text/css>
<?php
extract
($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
$filename "file.txt";
$results_per_page=15//Number of listings per page
$description str_replace ("\n","<br>"$description);
$description str_replace (";"","$description);
$description stripslashes ($description);
$title str_replace ("<",","$title);
$title str_replace (";",","$title);
$keyword str_replace (";"","$keyword);
$cat str_replace (";"","$cat);
$cat stripslashes ($cat);
$title stripslashes ($title);
$keyword stripslashes ($keyword);
$copyright "";
if(
$action == "dict_find") {
$user file("file.txt");
$lis 0;
if(
strlen($keyword) <= 2){
premain();
echo "<hr noshade size=2 color=#333399><FORM action=\"?action=dict_find\" method=post><B>Dictionary Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form><hr noshade size=2 color=#333399>";
print "<p><BR><b>Your keyword must be longer than 2 characters</b><br><BR><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><BR><BR>";
}
else{
for($x=0;$x<sizeof($user);$x++) {
$temp explode(";",$user[$x]);
$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];$temp[5];";
$such stristr($temp[3],$keyword);
$meta $keyword;
$meta2 $temp[3];
$such stristr($meta2,$meta);
if($such) {
$list[$lis] = $opp[$x];
$lis++; 
}
}
function getmicrotime(){
list($usec$sec) = explode(" ",microtime());
   return ((float)$usec + (float)$sec);
}

$time microtime(); 
$time number_format($time,3); 

if(
sizeof($list) != "0") {
premain();
echo "<hr noshade size=2 color=#333399><FORM action=\"?action=dict_find\" method=post><B>Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form><hr noshade size=2 color=#333399>";
echo "<BR><font face=arial><p><b>",sizeof($list),"</b> Results found for \"$keyword\"<BR></p></font>";
}else{
premain();
echo "<hr noshade size=2 color=#333399><FORM action=\"?action=dict_find\" method=post><B>Search:</B> <INPUT name=keyword size=38><FONT class=f1>&nbsp;<INPUT name=submit_dict type=submit value= Search></form><hr noshade size=2 color=#333399>";
echo "<p><b>&nbsp;No results found for $keyword.</b><BR><BR><BR><BR>";
}
$latest_max sizeof($list);
$u $a $latest_max;
if (
is_file("file.txt"))
{
$s=sizeof($list);
if (
$page=='' or !$page) { $page=1; }
$end=$results_per_page*$page;
$start=$end-$results_per_page;

if (
$start<>'0') {
$new_page=$page-1;
$prev="<a href='?action=dict_find&keyword=$keyword&page=$new_page'><---Previous page</a>";
}
else {
$prev="";
}

if (
$end<$s) {
$new_page1=$page+1;
$next="<a href='?action=dict_find&keyword=$keyword&page=$new_page1'>Next page---></a>";
}
else {
$next="";
}
$today time();
for (
$i=$start$i<$end$i++){
if(substr($list[$i], 0)=="[new]")
{
sort($list);
    
$p=explode(';'$list[$i]);
echo "<li><font face=arial><a href='?action=detail&keyword=$keyword&id=$p[5]'><b>$p[1]</a><BR></FONT>";
}
}
$pages=$s/$results_per_page;
$pages1=round($pages2);
$pexplode("."$pages1);
$pcount=count($p);
$ext=$p[$pcount-2];
if (
$ext!=0) {
$num=$p[0]+1;
}

else {
$num=$p[0];
}
echo 
"<table width='100%'><tr><td align='left'>$prev</td><td align='center'>";
for (
$i=1$i<=$num$i++) {
if ($i==$page) {
echo 
"<B>&nbsp;$i&nbsp;</B> ";

}
else {
echo 
"<a href='?action=dict_find&keyword=$keyword&page=$i'>[$i]</a>";
}
}
echo 
"</td><td align='right'>$next</td></tr></table>";
}
}
}
if(
$action == "detail" && "cat" && "id") {
$user file("file.txt");
if(
strlen($id) <= 3){
premain();
print "<p><BR><BR><BR><b>Your Keyword must be longer than 3 characters</b><br><BR><BR><BR>";
}else{
for($x=0;$x<sizeof($user);$x++) {
$temp explode(";",$user[$x]);
$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];$temp[5];";
$meta $id;
$meta2 $temp[5];
$such stristr($meta2,$meta);
if($such) {
$list[0] = $opp[$x];
$list
}

$temp explode(";",$user[$x]);
}
if(
sizeof($list) != "0") {
for(
$y=0;$y<sizeof($list);$y++) {
$temp explode(";",$list[$y]);
premain();
echo 
"<table width=97%><td bgcolor=#001199 width=80%><A HREF=\"dictionary.php\"  class=white-b-no ><B><FONT SIZE=2 COLOR=#fffff>Chemical Dictionary</FONT></B></A></td></table><BR><table><td width=70%><font face=arial size=2><b>$temp[1]</b><br>$temp[2]<BR>";
}
}
}
}
?>

<?php 
if ($action == ""){
?>

<TABLE align=center border=0 cellPadd_dicting=0 cellSpacing=0 width=100%>
  <TBODY>
  <TR><BR>
    <TD align=middle height=3><IMG height=1
      src="space.gif" width=1></TD></TR>
  <TR>
    <TD align=middle bgColor=#001199>
      <TABLE border=0 cellPadd_dicting=0 cellSpacing=1 width="100%">
        <TBODY>
        <TR>
          <FORM action="?action=dict_find" method=post>
          <TD bgColor=#f3f3f3 height=60>
            <TABLE border=0 cellPadd_dicting=3>
              <TBODY>
              <TR>
                <TD align=middle>&nbsp;</TD>
                <TD align=middle><B>Dictionary Search:</B></TD>
                <TD align=middle><INPUT name=keyword size=38> </TD>
                <TD align=middle><FONT class=f1><INPUT name=submit_dict type=submit value=" Search">
                  </FONT></TD></TR></TBODY></TABLE><FONT class=f2></FONT><FONT
            class=f2></FONT><FONT
  class=f1></FONT></TD></FORM></TR></TBODY></TABLE></TR>
  <TR>
    <TD align=middle>&nbsp;</TD></TR>
  <TR>
    <TD align=middle>
      <TABLE border=0 cellPadd_dicting=0 cellSpacing=0 width="100%">
        <TBODY>
        <TR>
          <TD vAlign=top width=160><BR><IMG height=110
            src="a1.jpg"
          width=142><BR>&nbsp;&nbsp;</TD>
          <TD vAlign=top>
            <TABLE border=0 cellPadd_dicting=0 cellSpacing=0 width="100%">
              <TBODY>
              <TR>
                <TD class=title>Online Chemical
Dictionary<BR><BR></TD></TR>
              <TR>
                <TD class=t120>Our online chemical dictionary, with <FONT
                  color=#3366cc><B><I><?php $file file("file.txt");
$s=sizeof($file)-1;echo"$s";?>
</I></B></FONT> chemical entries. You may search the
                  dictionary either by entering the keyword in the search box or<BR><BR> <A HREF="?action=category"><FONT SIZE="4" color=#3366cc>Browse entire Dictionary</FONT></a><BR><BR>Copyright: <a href="http://www.scriptsez.net" target="_new">Scriptsez.net</a><BR><BR><BR></td></table></table></table></table>
          <?php }
function 
premain(){
}
if(
$action == "add_dict") {
echo 
" <center><font face=arial>Add a Listing in dictionary:</center><br></font><form name=\"add_dict\" method=\"post\" action=\"?action=submit_dict\">";
echo 
"<font face=arial size=2>Tltle:<BR> <input type=text name=title size=30 maxlength=120></font><br><br>";
echo 
"<font face=arial size=2>Description:<BR><textarea name=description cols=50 rows=10 ></textarea></font><br><br>";
echo 
"<font face=arial size=2>Keywords:<BR><input type=text name=keyword size=30 maxlength=300><BR>Separate keywords by spaces</font><br><br>";
echo 
"<font face=arial size=2>Starts with Alphabet:<BR></font><input type=text name=cat size=4><BR><BR>";
echo 
"<input type=submit value=submit><BR><BR></form>";
}
if(
$action == "submit_dict") {
$fp fopen ("file.txt""a+");
$data_submitted time();
fwrite ($fp"[new];");
fwrite ($fp$title);
fwrite ($fp";");
fwrite ($fp$description);
fwrite ($fp";");
fwrite ($fp$keyword);
fwrite ($fp";");
fwrite ($fp$cat);
fwrite ($fp";");
fwrite ($fp$data_submitted);
fwrite ($fp";");
fwrite ($fp"\n");
fclose ($fp);
print 
"<BR><font face=arial size=3>Listing added successfully.<br><A HREF=?action=add_dict>add another entry</A><BR><A HREF=?action=>Go to homepage</A>";
}

$filename "file.txt";
$update time();
?>

<HTML>
<HEAD>
</HEAD>
<body topmargin="50" leftmargin="50">
<?php
if(!$_GET['action']){
$date date("l jS F, Y");
?>

  <?php
}
else if(
$_GET['action'] == "change_dict") {
if($_GET['id'] >= 0){
global $filename;
$id $_GET['id'];
$fp = @fopen($filename'r');
$array explode("\n"fread($fpfilesize($filename))); 
for($x=0;$x<sizeof($array);$x++) { // start loop, each line of file
$temp explode(";",$array[$x]); // explode the line and assign to temp
$line[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];$temp[5];";
}
//<input type=\"text\" value=\"$mod[3]\" name=\"cat\" size=\"50\">
$data_submitted time();
$mod explode(";"$line[$id]);
echo "Update $mod[1]";
echo "<form method=\"POST\" action=\"?action=change_dict2\" method=\"post\">";
 
echo "Title:<BR><input type=\"text\" value=\"$mod[1]\" name=\"title\" size=\"50\"><br>";
echo "<font face=arial size=2>Description:<BR><textarea name=description cols=50 rows=10 >$mod[2]</textarea></font><br><br>";
echo "<font face=arial size=2>Keywords:<BR><input type=text name=keyword size=30 maxlength=300 value=$mod[3]><BR>Separate keywords by spaces</font><br><br>";
                echo 
"<font face=arial size=2>Starts with alphabet:<BR></font><input type=text name=cat size=4 value=$mod[4]><BR><BR>";
echo "<input type=\"hidden\" name=data_submitted value=\"$data_submitted\"> ";
echo "<input type=\"submit\" value=\"submit\"> ";
echo "<input type=\"reset\" value=\"Reset\">";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\">";
echo "</form>";

}

else{
print "No ID specified, please <A HREF=\"dictionary.php\">provide a valid update ID</A>";
}
}
else if($_GET['action'] == "change_dict2") {
if($_POST['title'] && $_POST['id'] >= 0){
global $filename;
$new="[new]";
$new stripslashes($_POST['new']);
$title stripslashes($_POST['title']);
$description stripslashes($_POST['description']);
$cat stripslashes($_POST['cat']);
$keyword stripslashes($_POST['keyword']);
$data_submitted stripslashes($_POST['data_submitted']);
$id $_POST['id'];
$fp = @fopen($filename'r');
$array explode("\n"fread($fpfilesize($filename))); 
for($x=0;$x<sizeof($array)-1;$x++) {
$temp explode(";",$array[$x]);
$line[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];$temp[5];";
}
$line[$id]= "[new];$title;$description;$keyword;$cat;$data_submitted;";
sort($line);
$fp fopen ("file.txt""w");
fwrite ($fp$line[0]);
for($i=0$i<sizeof($line);$i++){
fwrite ($fp$line[$i]);
fwrite ($fp"\n");
}
fclose ($fp);
print "<p><p>Edited successfully<br><br><A HREF=?action=edit_dict>Back to edit list</A><BR><BR>";
}
else{
print "Please go back and fill in the form properly.";
}
}
if (
$action=="update"){
print 
"<form action=\"dictionary.php\" method=\"send\">
<BR><BR>To update your Resource Enter Your Update ID and click update.<BR><BR><BR>
Update ID:
<input type=\"hidden\" name=\"action\" value=change_dict2>
<input type=\"text\" name=\"id\" size=\"20\" maxlength=\"100\">
<input type=\"submit\" name=\"submit\" value=\"Update\">
</form><BR><BR><BR><BR><BR>"
;
}

if(
$action == "browse") {
$user file("file.txt");
$lis 0;
if(
strlen($keyword) <= 0){
premain();
print "<p><BR><BR><BR><b>There has been an error.</b><br><BR><BR><BR><BR><BR><BR>";
}
else{


for($x=0;$x<sizeof($user);$x++) {
$temp explode(";",$user[$x]);
$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];$temp[5];";
$such stristr($temp[4],$keyword);
$meta $keyword;
$meta2 $temp[4];
$such stristr($meta2,$meta);
if($such) {
$list[$lis] = $opp[$x];
$lis++; 
}
}
function getmicrotime(){
list($usec$sec) = explode(" ",microtime());
   return ((float)$usec + (float)$sec);
}

$time microtime(); 
$time number_format($time,3); 


if(sizeof($list) != "0") {
premain();
echo "<BR><font face=arial><p><b>",sizeof($list),"</b> Entries in category \"$keyword\"<BR></p></font>";
}else{
premain();
echo "<p><b>&nbsp;No entries in $keyword.</b><BR><BR><BR><BR><BR>";
}
$latest_max sizeof($list);
$u $a $latest_max;
if (
is_file("file.txt"))
{
$s=sizeof($list);

if (
$page=='' or !$page) { $page=1; }
$end=$results_per_page*$page;
$start=$end-$results_per_page;

if (
$start<>'0') {
$new_page=$page-1;
$prev="<a href='?action=browse&keyword=$keyword&page=$new_page'><---Previous page</a>";
}
else {
$prev="";
}

if (
$end<$s) {
$new_page1=$page+1;
$next="<a href='?action=browse&keyword=$keyword&page=$new_page1'>Next page---></a>";
}
else {
$next="";
}
$today time();
for (
$i=$start$i<$end$i++){
if(substr($list[$i], 0)== "[new]")
{
sort($list);
    
$p=explode(';'$list[$i]);
echo "<li><font face=arial><a href='?action=detail&keyword=$keyword&id=$p[5]'><b>$p[1]</a><BR></FONT>";
}
}
$pages=$s/$results_per_page;
$pages1=round($pages2);
$pexplode("."$pages1);
$pcount=count($p);
$ext=$p[$pcount-2];
if (
$ext!=0) {
$num=$p[0]+1;
}

else {
$num=$p[0];
}
echo 
"<table width='100%'><tr><td align='left'>$prev</td><td align='center'>";
for (
$i=1$i<=$num$i++) {
if ($i==$page) {
echo 
"<B>&nbsp;$i&nbsp;</B> ";

}
else {
echo 
"<a href='?action=browse&keyword=$keyword&page=$i'>[$i]</a>";
}
}
echo 
"</td><td align='right'>$next</td></tr></table>";
}
}
}
if(
$action == "edit_dict") {
preedit();
}
if(
$action == "category") {
premain();
?>

<TABLE border=0 cellPadd_dicting=0 cellSpacing=0 width="100%">
              <TBODY>
              <TR>
                <TD class=999966-b-lar><CENTER>Online Chemical
Dictionary</CENTER><BR></TD><BR></TR>
<CENTER>
<TABLE align=center bordercolor=#001199 bgcolor=#fcfcfc border=1 cellPadd_dicting=5 cellSpacing=1>
  <TBODY>
  <TR>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=a">A</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=b">B</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=c">C</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=d">D</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=e">E</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=f">F</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=g">G</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=h">H</A></TD>
    <TD class=999966-b-lar align=center align=center><font size=4><A
      href="?action=browse&keyword=i">I</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=j">J</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=k">K</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=l">L</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=m">M</A></TD>
  </TR><TR>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=n">N</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=o">O</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=p">P</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=q">Q</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=r">R</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=s">S</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=t">T</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=u">U</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=v">V</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=w">W</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=x">X</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=y">Y</A></TD>
    <TD class=999966-b-lar align=center><font size=4><A
      href="?action=browse&keyword=z">Z</A></font></TD></TR></TBODY></TABLE></CENTER></table><BR><BR><BR><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p><p>&nbsp;</p>
  <?php
}
function 
preedit(){


global $filename;

$fp = @fopen($filename'r');

if ($filename) {  
$array explode("\n"fread($fpfilesize($filename))); 

$listed count($array);

?>


<table border="0" cellpadd_dicting="2" cellspacing="0" width="100%">
<tr>
<td width="99%"><font size="3">Edit</font></td>
</tr>
</table>
<br>

<?php

echo "Select item to edit :: Viewing all ($listed) listed by Title<P><P>";

for($x=0;$x<$listed;$x++) { // start loop, each line of 
$temp explode(";",$array[$x]); // explode the 

echo "<li>[<A HREF=\"?action=change_dict&id=$x\">edit</A>] - <b>$temp[1]</b></li>";

}
}
}
?>


m00dy

selam scripte bakamadim fakat hala ilgileniyorsan uzerinde ugrasip bi cevap atayim sana;
http://www.erenyagdiran.com for further information

xwes

Alıntı yapılan: m00dy - 03 Eylül 2009 - 10:35:20
selam scripte bakamadim fakat hala ilgileniyorsan uzerinde ugrasip bi cevap atayim sana;

Çok zamaninizi almayacaksa sevinirim :)

Onoktake

Arkadaşım,
script içindeki ";" karakteri bir ayraçtır ve görüldüğü gibi explode fonksiyonuyla veri parçalanıp dizi şeklinde sayfada kullanılıyor. Tab karakteri görünmez bir karakter olduğu için senin işini zorlaştıracaktır. Yani merakımdan soruyorum, neden tab kullanıyorsun?
Bu maskenin altında bir yüz var... Ancak benim değil.
Ne  altındaki kaslardan daha "ben"dir o yüz...
Ne de altındaki kemiklerden. Bu maskenin altında
etten daha fazlası var. Bu maskenin altında bir fikir var! Ve fikirler kurşun geçirmez!..

xwes

Alıntı yapılan: anonymtrk - 04 Eylül 2009 - 20:40:18
Arkadaşım,
script içindeki ";" karakteri bir ayraçtır ve görüldüğü gibi explode fonksiyonuyla veri parçalanıp dizi şeklinde sayfada kullanılıyor. Tab karakteri görünmez bir karakter olduğu için senin işini zorlaştıracaktır. Yani merakımdan soruyorum, neden tab kullanıyorsun?
Bir nedeni yok, sadece daha kolay oldugu icin. Arada  ";" olsa da fark etmez/

cumcum82

Şöyle orjinalinden daha da basit birkaç satır karaladım. Umarım işine yarar.
Elindeki file.txt dosyasını paylaşmamışsın ama tüm satırlar verdiğin örnekteki gibiyse aşağıdaki dosya file.txt içeriğini talep ettiğin gibi daha basit hale döndürecek ( Yeni bir dosya oluşacak orjinal dosya bozulmayacak ).

// convert.php

<?php
 session_start
();

 
$file1 "/var/www/file.txt";
 
$handle1 fopen($file1"r");
 
$content1 fread($handle1filesize($file1));
 
fclose($handle1);
 
 
$parse explode(";"$content1);
 
$n = (count($parse)-1);
 
$m = ($n/6);

 
$_SESSION["sesval"] = "";

 for (
$x=0$x<=$m$x++) {

  if (empty(
$_SESSION["sesval"])) {
  
$y 3;
  }
  else {
  
$y $_SESSION["sesval"];
  }
 
 
$file2 "/var/www/file2.txt";
 
$handle2 fopen($file2"a");
 
$content2 $parse[$y] . ":" $parse[$y-1] . "\n";
 
$y = ($y+6);
 
$_SESSION["sesval"] = $y;
 
fwrite($handle2$content2);
 
fclose($handle2);
 }
 
 unset(
$_SESSION["sesval"]);

?>



convert.php //


Bu dosya arama yapacağın parametreyi gireceğin dosya :

// search.php

<?php

 
echo "
 <html>

 <head>
 </head>
 <body>      
  <form action=\"./view.php\" method=\"post\" name=\"sform\">
  <table>
   <tr>
    <td>Bir Kelime Girin</td>
    <td><input name=\"keyword\" size=\"25\"></td>
   </tr>
  </table>
  <button type=\"submit\" value=\"send\">Send</button>
  <button type=\"reset\" value=\"clear\">Clear</button>
  </form>
 </body>

 </html>"
;
?>


search.php //

Son olarak sonuçları görüntüleyecek dosya :

// view.php

<?php

 
echo "
 <html>

  <head>
  </head>
 <body>\n"
;
 
 
$keyword $_POST["keyword"];
 
$content file("/var/www/file2.txt");
 
 foreach(
$content as $line) {
  if (
strstr($line$keyword)) {
   echo 
$line "<br />";
  }
 }
 
 echo 
"
 </body>

 </html>"
;

?>


view.php //

Umarım yararı olur.