home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2002 November / MICD_2002_11.iso / Www / Korespondent / K9 / scrypty / news.php < prev    next >
Encoding:
PHP Script  |  2002-06-25  |  3.9 KB  |  130 lines

  1. <HTML>
  2. <HEAD>
  3. <meta "Title"="Korespondent.pl - serwis polityczny">
  4. <meta "Author"="Marcin Hugo Kosi±ski">
  5. <meta "Subject"="Polityka, gospodarka, spo│ecze±stwo, kultura">
  6. <meta "Description"="Niezale┐ny magazyn polityczno - spo│eczny zajmuj╣cy siΩ komentowaniem aktualnych wydarze± z punktu widzenia ludzi ceni╣cych wolno£µ.">
  7. <meta "Keywords"="polityka, wolno£µ, konserwatyzm, liberalizm, libertarianizm, komunizm, socjalizm, socjaldemokracja, anarchizm, demokracja, magazyn, miesiΩcznik, komentarz, wybory, prezydent, rz╣d, sejm, senat, parlament, pa±stwo, polska, ameryka, izrael, usa, nacjonalizm, wolny, rynek, upr, nczas, media, protekcjonizm, dziennikarstwo, wybory, samorz╣d, kapitalizm, ekonomia, gospodarka, bud┐et, trzecia droga, papie┐, watykan, biblia, wiara, katolicyzm, katolik, janusz korwin mikke, janusz michalkiewicz, handel, pieni╣dze, wiadomo£ci, newsy, informacje, fakty">
  8. <meta name "Rating" Content="Rating">
  9. <meta name "Robots" Content="Robots">
  10. <meta name "Revisit" Content="1 days">
  11. <META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=windows-1250">
  12.  
  13. <BODY>
  14.  
  15.  
  16. <!--  Tu sie zaczyna skrypt PHP. Dotad mozna modyfikowac  -->
  17.  
  18. <?php
  19.  
  20.  
  21. $DATABASE_PATH = "../database";
  22.  
  23.  
  24. $id    = $HTTP_POST_VARS["id"];
  25. $pass  = $HTTP_POST_VARS["pass"];
  26. $title = $HTTP_POST_VARS["title"];
  27. $news  = $HTTP_POST_VARS["news"];
  28.  
  29.  
  30. Trim ($id);
  31. Trim ($pass);
  32. $file_name = "$DATABASE_PATH/users/$id.txt";
  33.  
  34.  
  35. if (File_Exists ($file_name))
  36. {
  37.   /*  Get data from user file  */
  38.   $f = fopen ($file_name, "r");
  39.   fscanf ($f, "%s", $file_1);
  40.   fscanf ($f, "%s", $file_2);
  41.   fscanf ($f, "%s", $file_3);
  42.   fscanf ($f, "%s", $file_4);
  43.   fscanf ($f, "%s", $file_access);
  44.   fscanf ($f, "%s", $file_password);
  45.   fscanf ($f, "%s", $file_stats);
  46.   fclose ($f);
  47.  
  48.   if (!strcmp ($pass, $file_password))
  49.   {
  50.     if ((!strcmp ($file_access, "admin")) || (!strcmp ($file_access, "registered")))
  51.     {
  52.       $counter_name  = "$DATABASE_PATH/news/last";
  53.       $news_path     = "$DATABASE_PATH/news";
  54.  
  55.       /////////////////////////////
  56.       printf ('DziΩkujemy za umieszczenie newsa. Za chwilΩ pojawi siΩ on na stronie korespondent.pl<BR>');
  57.       /////////////////////////////
  58.     } else
  59.     {
  60.       $counter_name  = "$DATABASE_PATH/moderate/last";
  61.       $news_path     = "$DATABASE_PATH/moderate";
  62.  
  63.       /////////////////////////////
  64.       printf ('News zosta│ wys│any do moderatora. Jak tylko zostanie przez niego zaakceptowany, pojawi siΩ na stronie korespondent.pl<BR>');
  65.       /////////////////////////////
  66.     }
  67.  
  68.  
  69.     /*  Deal with the counter (file 'last')  */
  70.  
  71.     $counter = 0;
  72.     if (File_Exists ($counter_name))
  73.     {
  74.       $last_file = fopen ($counter_name, "r");
  75.       fscanf ($last_file, "%d", $counter);
  76.       fclose ($last_file);
  77.     }
  78.     $counter++;
  79.     $last_file = fopen ($counter_name, "w");
  80.     fputs ($last_file, "$counter");
  81.     fclose ($last_file);
  82.  
  83.  
  84.     /*  Good, counter incremented and updated.  */
  85.     /*  Now create the news file  */
  86.  
  87.     $f = fopen ("$news_path/$counter.txt", "w");
  88.     fputs ($f, "$id\n");
  89.     $date = Date ("Y m d");
  90.     fputs ($f, "$date\n");
  91.     fputs ($f, "$title\n");
  92.     fputs ($f, "$news\n");
  93.     fclose ($f);
  94.  
  95.     /*  Update user statistics  */
  96.     $f = fopen ($file_name, "w");
  97.     fputs ($f, "$file_1\n");
  98.     fputs ($f, "$file_2\n");
  99.     fputs ($f, "$file_3\n");
  100.     fputs ($f, "$file_4\n");
  101.     fputs ($f, "$file_access\n");
  102.     fputs ($f, "$file_password\n");
  103.     $file_stats++;
  104.     fputs ($f, "$file_stats\n");
  105.     fclose ($f);
  106.  
  107.   } else
  108.   {
  109.     /////////////////////////////
  110.     printf ('Wpisa│e£ nieprawid│owe has│o.<BR>');
  111.     /////////////////////////////
  112.   }
  113.  
  114. } else
  115. {
  116.   /////////////////////////////
  117.   printf ('Poda│e£ nieprawid│owy identyfikator.<BR>');
  118.   /////////////////////////////
  119. }
  120.  
  121.  
  122. ?>
  123.  
  124. <!--  Tu sie konczy skrypt PHP. Dalej mozna modyfikowac  -->
  125.  
  126.  
  127. </BODY>
  128.  
  129. </HTML>
  130.