Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: BBcodes tivia

Parašė Vaidotas-· 2008 Gru. 23 23:12:35
#1

Sveiki, išminčiai,

gal galėtumėt padėt padaryt tokį paprastą dalyką, man reikia, jog žemiau pateiktam kode (tivia- viktorina) veiktų bbcodes, t.y jei klausime įrašau



būtų paveiksliukas ir tt.

<?php
require_once "../../maincore.php";
require_once BASEDIR."subheader.php";
require_once BASEDIR."side_left.php";
$version='1.0.4';
$PHP_SELF = basename($_SERVER['PHP_SELF']);//windoze fix (fusion)
//set it up so guests can play
global $username,$userdata,$db_prefix,$locale, $score, $total;

if (iMEMBER)
{
$username=$userdata['user_name'];
}
else
{
$username=$REMOTE_ADDR;
}

// Check if locale file is available matching the current site locale setting.
if (file_exists(INFUSIONS."trivia/locale/".$settings['locale'].".php")) {
   // Load the locale file matching the current site locale setting.
   include INFUSIONS."trivia/locale/".$settings['locale'].".php";
} else {
   // Load the infusion's default locale file.
   include INFUSIONS."trivia/locale/English.php";
}

if (!isset($cat))
{
$getcats = dbquery("SELECT DISTINCT cat FROM ".$db_prefix."trivia ORDER BY cat");
if (dbrows($getcats)=='0')
{
opentable($locale['QIZ117']);
echo $locale['QIZ118'];
closetable();
require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
exit;
}
opentable($locale['QIZ119']);
echo '<p>'.$locale['QIZ120'].'</p>';
echo '<form action="" method="POST">
<br><select class="textbox" name="cat">';

while($cat=dbarray($getcats))
{
echo '<option value="'.$cat['cat'].'">'.$cat['cat'].'</option>';
}//while($cat
echo '</select><input class="button" type="submit" value="'.$locale['QIZ121'].'">
</form>';
closetable();
require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
exit;
}//if (!isset($cat))


global $op, $query;

$display = dbquery("SELECT * FROM ".$db_prefix."trivia WHERE cat='$_POST[cat]' ORDER BY id");
if (dbrows($display)=='0')
{
opentable($locale['QIZ126']);
echo $locale['QIZ125'].' '.$_POST['cat'];
closetable();
require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
exit;
}



opentable($locale['QIZ127']);
if (!$submit) {


   echo "<form method=post action=$PHP_SELF>";
   echo "<table border=0>";
$x=0;
   while ($quiz_data = dbarray($display))
   {
   if ($x % 2 == 0) { $rowclass = "tbl1"; } else { $rowclass = "tbl2"; }
   $id = $quiz_data["id"];
   $question = $quiz_data["question"];
   $opt1 = $quiz_data["opt1"];
   $opt2 = $quiz_data["opt2"];
   $opt3 = $quiz_data["opt3"];
   $answer = $quiz_data["answer"];
   echo "<tr class='".$rowclass."'>
   <td colspan=3><b>$quiz_data[question]</b></td>
   </tr>
   <tr class='".$rowclass."'>
   <td>$quiz_data[opt1] <input type=radio name=q$quiz_data[id] value=\"$quiz_data[opt1]\"></td>
   <td>$quiz_data[opt2] <input type=radio name=q$quiz_data[id] value=\"$quiz_data[opt2]\"></td>
   <td>$quiz_data[opt3] <input type=radio name=q$quiz_data[id] value=\"$quiz_data[opt3]\"></td>
   </tr><td colspan=3><hr></td>";
   $x++;
   }

   echo '</table>
   <input type="hidden" name="cat" value="'.$_POST['cat'].'">
   <input class="button" type="submit" value="'.$locale['QIZ103'].'" name="submit">
   </form>';

}

elseif ($submit)

{

   $score = 0;
   $total = dbrows($display);
      while ($result = dbarray($display))
      
      
      {
         $cat = $result["cat"];
         $answer = $result["answer"];
         $q = $result["q"];
         
      if ($$q == $answer)
      {
      $score++;
      }
   
   }
   
   echo '<p align=center><b>'.$username.' '.$locale['QIZ104_A'].' '.$score.' '.$locale['QIZ104_B'].' '.$total.'</b></p>';
   
   if   ($score == $total) {
   echo $locale['QIZ105'];
   }
   elseif ($score/$total < 0.34) {
   echo $locale['QIZ106'];
   }
   elseif ($score/$total > 0.67) {
   echo $locale['QIZ107'];
   }
   else {
   echo $locale['QIZ108'];
   }
   
//check for current score
$curcheck = dbquery("SELECT * FROM ".$db_prefix."trivia_results WHERE quiz_cat='$cat' AND quiz_id = '$id' AND quiz_name='$username'");
if (dbrows($curcheck))
{
echo '<p><font color="#FF0000">'.$locale['QIZ109'].'</font></p><br>';
}
else
{
//Score of $score entered to the system for $username
echo '<br><font color="#008000">'.$locale['QIZ110_A'].' '.$score.' '.$locale['QIZ110_B'].' '.$username.'.</font>';
//add the score to the database
dbquery("INSERT INTO ".$db_prefix."trivia_results ( `id` , `quiz_id` , `quiz_cat`, `quiz_name` , `quiz_date` , `quiz_time` , `quiz_score` )VALUES ('', '$id', '$cat', '$username', CURDATE( ) , CURTIME( ) , '$score');");
}


echo '<p>'.$locale['QIZ111'].'</p>';

echo '<table border="0" width="100%">';
$display = dbquery("SELECT * FROM ".$db_prefix."trivia WHERE cat = '$cat' ORDER BY id");
$x=0;
while ($row = dbarray($display))
{
if ($x % 2 == 0) { $rowclass = "tbl1"; } else { $rowclass = "tbl2"; }
$cat = $row["cat"];
$question = $row["question"];
$answer = $row["answer"];
$q = $row["q"];

echo '<tr>
      <td class="tbl2"><strong class="'.$rowclass.'">'.$question.'</strong></td>
   </tr>
   <tr>
   <td class="tbl1">';

if ($$q == $answer)
{
echo '<li class="'.$rowclass.'"> '.$locale['QIZ112'].' <strong>"'.${$q}.'"</strong>, <font color="#008000">'.$locale['QIZ113'].'</font></li>';
}
elseif ($$q == "")
{
echo '<li class="'.$rowclass.'"><font color="#FF0000">'.$locale['QIZ114'].' '.$locale['QIZ124'].' '.$locale['QIZ115'].' '.$answer.'</font></li>';
}
else
{
echo '<li class="'.$rowclass.'">'.$locale['QIZ112'].' <strong>"'.${$q}.'"</strong>, <font color="#FF0000">'.$locale['QIZ124'].' '.$locale['QIZ115'].' '.$answer.'</font></li>';
}
$x++;
}
echo "</td></tr></table></p>";



}
closetable();

tablebreak();




require_once BASEDIR."side_right.php";
require_once BASEDIR."footer.php";
?>




Redagavo Vaidotas-· 2008 Gru. 24 18:12:18

Parašė Vaidotas-· 2008 Gru. 24 19:12:20
#2

Sorry, kad rašau antrą kartą iš eilės, bet mano tema kažkaip į užmarštį nugrimzdo. Tai gal atsiras žmonių, kurie kokį sprendimą pasiūlys? :)