Changeset 225 for quests/ListQuests.php


Ignore:
Timestamp:
Jan 14, 2008, 7:51:30 PM (17 years ago)
Author:
maron
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • quests/ListQuests.php

    r219 r225  
    22include('includes/global.php');
    33
    4   if(array_key_exists('Translate', $_GET)) {
    5       $ID = $Database->SQLCommand("SELECT *, (SELECT user.user FROM user WHERE user.id = quests.user) as User FROM
    6       quests WHERE quests.Language = '1' AND quests.Complete = '1' order by 2");
    7       echo '<table border="1" cellpadding="2" cellspacing="0">
    8             <tr><th>Poøadové èíslo</th><th>ID questu</th><th>Název Questu</th><th>U¾ivatel</th><th>Známka</th><th>Poèet hlasování</th></tr>';
    9       while ($Line = mysql_fetch_array($ID)) {
    10         echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
    11         <td>'.$Line['entry'].'</td>
    12         <td>'.$Line['Title'].'</td>
    13         <td>'.$Line['User'].'</td>
    14         <td>'.$Line['Vote'].'</td>
    15         <td>'.$Line['CountVote'].'</td></tr>';
    16        }
    17       echo '</table>';
     4  if(array_key_exists('order', $_GET)) {
     5    $order = $_GET['order'];
     6    $desc = $_GET['desc'];
    187  } else {
     8    $order = '';
     9    $desc = 'desc';
     10  }
    1911
    20     if(array_key_exists('limitx', $_GET)) {
    21       $limitx = mysql_escape_string($_GET['limitx']); 
    22       $limity = mysql_escape_string($_GET['limity']); 
     12  function WriteQuests($sql, $limit, $address)
     13  { // BEGIN function WriteQuests
     14    global $Database, $order, $desc;
     15   
     16    if ($limit <> '') $limit = 'LIMIT '.$limit;
    2317
    24       $ID = $Database->SQLCommand("SELECT * FROM quests WHERE Language = '0' LIMIT $limitx,$limity");
    25   //    $ID = $Database->SQLCommand("SELECT quests.entry FROM quests WHERE Language = '0' AND quests.entry NOT IN
    26    //   (SELECT quests.entry FROM quests WHERE quests.Language = '1' AND state = '2') LIMIT $limitx,$limity");
    27       while ($Line = mysql_fetch_array($ID)) {
    28         $LineTranslate = mysql_fetch_array($Database->SQLCommand("SELECT * FROM quests WHERE Language <> 0 AND entry = '".$Line['entry']."'"));
    29         if (!$LineTranslate)
    30         echo '<a href="form.php?ID='.$Line['ID'].'">['.$Line['entry'].']</a> - '.$Line['Title'].'<br />';  //.$Line['Title']
    31       }
     18    if ($address <> 'selection') {
     19      if ($order <> '') $order = 'ORDER BY '.$order;
     20      if ($desc <> 'desc') $desc = 'desc'; else $desc = '';
     21    } else {
     22      $order = '';
     23      $desc = '';
     24    }
     25       
     26        echo '<table border="1" cellpadding="2" cellspacing="0">
     27              <tr>
     28              <th><a href="ListQuests.php?'.$address.'&amp;order=ID&amp;desc='.$desc.'">Poøadové èíslo</a></th>
     29              <th><a href="ListQuests.php?'.$address.'&amp;order=entry&amp;desc='.$desc.'">ID questu</a></th>
     30              <th><a href="ListQuests.php?'.$address.'&amp;order=Title&amp;desc='.$desc.'">Název Questu</a></th>';
     31              if ($address == 'selection') echo '<th><a href="ListQuests.php?'.$address.'&amp;order=CountQuests&amp;desc='.$desc.'">Výskyd</a></th>'; else
     32              if ($address <> 'limitx') echo '<th><a href="ListQuests.php?'.$address.'&amp;order=user&amp;desc='.$desc.'">User</a></th>
     33              <th><a href="ListQuests.php?'.$address.'&amp;order=vote&amp;desc='.$desc.'">Známka</a></th>
     34              <th><a href="ListQuests.php?'.$address.'&amp;order=CountVote&amp;desc='.$desc.'">Poèet hlasování</a></th>';
     35              echo '</tr>';
     36             
     37         echo "$sql $order $desc $limit";     
     38        $ID = $Database->SQLCommand("$sql $order $desc $limit");
     39          while ($Line = mysql_fetch_array($ID)) {
     40            echo '<tr>
     41            <td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
     42            <td>'.$Line['entry'].'</td>
     43            <td>'.$Line['Title'].'</td>';
     44            if ($address == 'selection') echo '<td>'.$Line['CountQuest'].'</td>'; else
     45            if ($address <> 'limitx') echo '<td>'.@$Line['User'].'</td>
     46            <td>'.$Line['Vote'].'</td>
     47            <td>'.$Line['CountVote'].'</td>';
     48            echo '</tr>';
     49          }
     50        echo '</table>';       
     51  } // END function WriteQuests
    3252 
    33     } else {
    34       if(array_key_exists('mydevelop', $_GET) and Licence(0)) {
    35      
    36       echo '<table border="1" cellpadding="2" cellspacing="0">
    37             <tr><th>Poøadové èíslo</th><th>ID questu</th><th>Název Questu</th></tr>';
    38       $ID = $Database->SQLCommand("SELECT * FROM quests Where User='".$_SESSION['UserID']."' AND complete = '0' order by 1 ");
    39         while ($Line = mysql_fetch_array($ID)) {
    40           echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
    41           <td>'.$Line['entry'].'</td>
    42           <td>'.$Line['Title'].'</td></tr>';
    43         }
    44       echo '</table>'; 
    45       } else {
    46         if(array_key_exists('my', $_GET) and Licence(0)) {
    47        
    48         echo '<table border="1" cellpadding="2" cellspacing="0">
    49               <tr><th>Poøadové èíslo</th><th>ID questu</th><th>Název Questu</th><th>Známka</th></tr>';
    50         $ID = $Database->SQLCommand("SELECT * FROM quests Where User='".$_SESSION['UserID']."' order by 1 ");
    51           while ($Line = mysql_fetch_array($ID)) {
    52             echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
    53             <td>'.$Line['entry'].'</td>
    54             <td>'.$Line['Title'].'</td>
    55             <td>'.$Line['Vote'].'</td></tr>';
    56           }
    57         echo '</table>'; 
    58         } else {
    59         }
    60       }
    61     }
    6253
    6354        if(array_key_exists('selection', $_GET)) {             
    6455               
    65                 echo '<br /><b>Prioritnì by jste mìli pøekládat tyto questy:</b><br />';
     56                echo '<table border="0" cellpadding="10"><tr><td>
     57          <br /><b>Prioritnì by jste mìli pøekládat tyto questy:</b><br /><br />';
    6658               
    67           $ID = $Database->SQLCommand("SELECT * FROM `quests_status` ORDER BY CountQuest DESC LIMIT 10");
    68           echo '<table border="1" cellpadding="2" cellspacing="0">
    69               <tr><th>Poøadové èíslo</th><th>ID questu</th><th>Název Questu</th><th>Poèet splnìní na serveru</th></tr>';
    70           while ($Line = mysql_fetch_array($ID)) {
    71               $LineAJQuest = mysql_fetch_array($Database->SQLCommand("SELECT * FROM quests WHERE Language = 0 AND entry = '".$Line['QuestEntry']."'"));
    72               echo '<tr><td><a href="form.php?ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
    73               <td>'.$LineAJQuest['entry'].'</td>
    74               <td>'.$LineAJQuest['Title'].'</td>
    75               <td>'.$Line['CountQuest'].'</td></tr>';
    76           }
    77                
    78           echo '</table><br />';
     59                WriteQuests("SELECT * FROM quests, quests_status
     60          WHERE quests.language = 0 AND quests.entry = quests_status.questentry ORDER BY quests_status.CountQuest DESC", 18, 'selection');
    7961         
    80           echo '<b>Ostatní:</b><br /><br />';
     62          echo '</td><td>
     63          <b>Ostatní:</b><br /><br />';
    8164
    82           for ($i=0; $i<30; ++$i) {
     65          for ($i=0; $i<24; ++$i) {
    8366            $limity = 200;
    8467            $limitx = $i*$limity;
     
    8770          }
    8871                echo '<a href="ListQuests.php?limitx='.$limitx.'&amp;limity=6000">Zbytek</a><br />';
     72          echo '</td></tr></table>';
     73        }
    8974
    9075
    91     //  echo '<a href="ListQuests.php?limitx=3500&amp;limity=4000">3500-4000</a><br />';
     76      if(array_key_exists('limitx', $_GET)) {
     77        if(array_key_exists('limity', $_GET)) {
     78          $_SESSION['limitx'] = mysql_escape_string($_GET['limitx']);
     79          $_SESSION['limity'] = mysql_escape_string($_GET['limity']);
    9280        }
     81        WriteQuests("SELECT * FROM quests items WHERE items.Language = '0' AND
     82        NOT EXISTS(SELECT 1 FROM quests sub WHERE sub.Language <> 0 AND sub.entry = items.entry) ", $_SESSION['limitx'].','.$_SESSION['limity'],'limitx');
     83      }
    9384
    94   }
     85      if(array_key_exists('Translate', $_GET)) {
     86        WriteQuests("SELECT *, (SELECT user.user FROM user WHERE user.id = quests.user) as User FROM
     87        quests WHERE quests.Language = '1' AND quests.Complete = '1'", '', 'Translate');
     88      }
     89     
     90      if(array_key_exists('my', $_GET) and Licence(0)) {
     91        WriteQuests("SELECT * FROM quests Where user = ".$_SESSION['UserID'], '', 'my');
     92      }
     93
     94      if(array_key_exists('mydevelop', $_GET) and Licence(0)) {
     95        WriteQuests("SELECT * FROM quests Where user = ".$_SESSION['UserID']." AND complete = '0'", '', 'mydevelop');
     96      }
    9597 
    9698  ShowFooter();
Note: See TracChangeset for help on using the changeset viewer.