Advertisement
terorama

dip / linkrecs1.php

Aug 21st, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.93 KB | None | 0 0
  1.  
  2. <?
  3.  
  4. include("minc.php");
  5. //--------------входной параметр rid rupid
  6. //----------------------------------------------
  7. //       связывание записей ---> и переход вниз
  8. //----------------------------------------------
  9. //--------------------авторизация
  10. $sql="select * from TINFO I, TATTR A  where A.AID=I.AID and A.ACC=2 and RID='$rid' order by A.AID";
  11. $result=mysql_query($sql);
  12. echo mysql_error();
  13.  
  14. $au_ok=1;
  15.  
  16. if (mysql_num_rows($result)!=0)
  17.    {
  18.    $row=mysql_fetch_array($result);
  19.    $login_t=$row["TEXTF"];
  20.    $row=mysql_fetch_array($result);
  21.    $pass_t=$row["TEXTF"];
  22.    
  23.    if (($login!=$login_t) || ($pass!=$pass_t))
  24.       {  
  25.       $au_ok=0;
  26.       }
  27.    //endif   
  28.  
  29.    }
  30. //endif  
  31.  
  32.  
  33. //-----------------------авторизация пароля отдела
  34. $sql="select TEXTF from TINFO I, TRECORDS R, TRECORDS R1, TRECTYPE RT ".
  35.      " where I.RID=R.RID and I.ATYPE=10+RT.RTID and RT.RTID=R1.RTID ".
  36.      " and R.RID='$rupid' and R1.RID='$rid'";
  37.  
  38. $result=mysql_query($sql);
  39. echo mysql_error();
  40.  
  41.  
  42. if (mysql_num_rows($result)!=0)
  43.    {
  44.    $row=mysql_fetch_array($result);
  45.    $authcode_t=$row["TEXTF"];
  46.    
  47.    
  48.    if ($authcode_t!=$authcode)
  49.       {  
  50.       print('<form action="linkrecs1.php" method="post"><table bgcolor="#D4D4D4">');
  51.       print('<tr><td bgcolor="#E4E4E4">Код авторизации: </td><td bgcolor="#E4E4E4"><input type="password" name="authcode"></td></tr>');
  52.       print('<input type="hidden" name="login" value='.$login.'>');
  53.       print('<input type="hidden" name="pass" value='.$pass.'>');
  54.       print('<input type="hidden" name="rid" value='.$rid.'>');
  55.       print('<input type="hidden" name="rupid" value='.$rupid.'>');
  56.       print('<tr><td bgcolor="#E4E4E4"><input type="submit" name="submit" value="сохранить"></td>');
  57.       print('<td bgcolor="#E4E4E4"><input type="reset" name="undo"></td></tr>');
  58.       print('</table></form>');
  59.       $au_ok=0;
  60.       }
  61.    //endif   
  62.  
  63.    }
  64. //endif  
  65.  
  66.  
  67.  
  68. //--------------------------Авторизация прошла успешно
  69. if ($au_ok==1):
  70.  
  71. print('<body onLoad="timer()">');
  72.  
  73. $file=fopen("title.html","r");
  74. $data=fread($file,2000);
  75. print($data);
  76.  
  77. $file=fopen("top.html","r");
  78. $data=fread($file,2000);
  79. print($data);
  80.  
  81.  
  82. //-------------------создание связи для тек. записи
  83.    $sql="select G.GDID from TRECORDS R, TRECORDS R1, TRECTYPE RT, TRECTYPE RT1, TGROUPDES G ".
  84.        "WHERE R.RID='$rupid' and R1.RID='$rid' ".
  85.        " and R.RTID=RT.RTID and R1.RTID=RT1.RTID ".
  86.        " and G.RTID=RT.RTID and G.RTID2=RT1.RTID ";
  87.    $result=mysql_query($sql);
  88.    echo mysql_error();  
  89.    $row=mysql_fetch_array($result);
  90.    $gdid=$row["GDID"];
  91.    
  92.    $sql = "SELECT GID FROM TGROUP where RID='$rupid' and GDID='$gdid'";
  93.    $result=mysql_query($sql);
  94.    if (mysql_num_rows($result)==0)
  95.       {
  96.       $sql = "INSERT INTO TGROUP VALUES(NULL,'$rupid','TEST','$gdid')";
  97.       $result=mysql_query($sql);
  98.       echo mysql_error();
  99.      
  100.        $sql = "UPDATE TRECORDS SET HAVEGR=1 WHERE RID='$rupid'";
  101.       $result=mysql_query($sql);
  102.       echo mysql_error();
  103.      
  104.       $sql="SELECT MAX(GID) as GID1 FROM TGROUP";
  105.       $result=mysql_query($sql);
  106.       $row=mysql_fetch_array($result);
  107.       $gid1=$row["GID1"];
  108.      
  109.       }
  110.    else
  111.       {
  112.       $row=mysql_fetch_array($result);
  113.       $gid1=$row["GID"];
  114.       }  
  115.    //endif   
  116.      
  117.    $sql="SELECT * FROM TLINK where RID='$rid' and GID='$gid1'";
  118.    $result=mysql_query($sql);
  119.    
  120.    if  (mysql_num_rows($result)==0)
  121.       {
  122.       $sql = "INSERT INTO TLINK VALUES(NULL,'$rid','$gid1',0)";
  123.       $result=mysql_query($sql);
  124.       echo mysql_error();
  125.       }
  126.    //endif   
  127.      
  128.  
  129.    include("testsp.php");
  130.    
  131.    print('<script language="JavaScript">');
  132.  
  133.    $r_str="location.href='recinfo.php?rid=".$rid."&login=".$login."&pass=".$pass."' ;";
  134.    print('function timer() { setTimeout("'.$r_str.'", 5);} </script>');
  135.  
  136.  print('</body>');
  137.  
  138. endif;
  139.  
  140. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement