SlideShare a Scribd company logo
Page 1



Quiz component for Joomla
1.The component files:




File adauga_test.php:

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!=quot;Super Administratorquot;) $mainframe-
>redirect('index.php');
?>

<?php
$previz=JRequest::getVar('previz',null);

if($previz==quot;Previzualizarequot;)
{
$titlu_test=JRequest::getVar('titlu_test','');
$editor_test=JRequest::getString('editor_test', '', 'POST',
JREQUEST_ALLOWRAW);
$descriere_test=JRequest::getString('descriere_test', '', 'POST',
JREQUEST_ALLOWRAW);



                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 2

print(quot;<h1>quot;.$titlu_test.quot;</h1>quot;); print(quot;<br/>quot;);
print(quot;quot;.$descriere_test.quot;quot;); print(quot;<br/>quot;); print(quot;<br/>quot;);

$intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test);
foreach($intrebari_teste as $intrebare)
            {
                        $intrebare=trim($intrebare);

                        $intrebare1=explode(quot;nquot;, $intrebare);
                        $i=1;
                        foreach($intrebare1 as $raspuns)

                               {
                                      if($i==1)
                                            {

     print(quot;<h3>quot;.$raspuns.quot;</h3>quot;);
                                            $i++; continue;
                                            }
                                      print('<input name=quot;quot;
type=quot;radioquot; value=quot;quot;>');
                                      print($raspuns);
                                      print(quot;<br/>quot;);
                               }
            print(quot;<br/>quot;);
            }
print(quot;<br/>quot;);
}

if($previz==quot;Inregistreazaquot;)
{
$titlu_test=JRequest::getVar('titlu_test','');
$editor_test=JRequest::getString('editor_test', '', 'POST',
JREQUEST_ALLOWRAW);
$descriere_test=JRequest::getString('descriere_test', '', 'POST',
JREQUEST_ALLOWRAW);

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table');
$table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table');

$table_test->reset();
$uniqid=uniqid(quot;quot;);
$table_test->set('nume_test', $uniqid);

if (!$table_test->store())    print('<h1>Eroare - functia
$table_test->store().</h1>');


$db = &JFactory::getDBO();
$query = 'SELECT id FROM #__cunoastere_test WHERE
nume_test=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ;
$db->setQuery($query);
$id_test=$db->loadResult();

$table_test->load($id_test);



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 3


$table_test->set('nume_test', $titlu_test);
$table_test->set('descriere_test', addslashes($descriere_test));

if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_test->check().</h1>');
      }


$intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test);
$j=1;
foreach($intrebari_teste as $intrebare)
            {
                        $intrebare=trim($intrebare);

                           $intrebare1=explode(quot;nquot;, $intrebare);
                           $i=1;

                           foreach($intrebare1 as $raspuns)

                                  {

                                         if($i==1)
                                               {
                                               if(trim($raspuns)==quot;quot;)
continue;
                                               $table_intreb->reset();
                                               $table_intreb-
>set('nume_intrebare', $uniqid);
                                          if (!$table_intreb-
>store())   print('<h1>Eroare - functia $table_intreb-
>store().</h1>');
                                          $db = &JFactory::getDBO();
                                          $query = 'SELECT id FROM
#__cunoastere_intrebari WHERE nume_intrebare=quot;'.$uniqid.'quot;'.'ORDER BY
id DESC LIMIT 1' ;
                                          $db->setQuery($query);
                                          $id_intrebare=$db-
>loadResult();
                                          $table_intreb-
>load($id_intrebare);
                                          $table_intreb-
>set('id_test', $id_test);
                                          $table_intreb-
>set('nume_intrebare', addslashes( $raspuns));

                                               if ($table_intreb->check())
                                                     {




                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 4

                                                      if (!$table_intreb-
>store())
                                                {
      print('<h1>Eroare - functia $table_intreb->store().</h1>'); }
                                                }
                                          else
                                                {
                                                print('<h1>Eroare -
functia $table_intreb->check().</h1>');
                                                }

                                               $table_intreb->load(0);
                                               $i++; continue;
                                               }

                                  if(trim($raspuns)==quot;quot;) continue;
                                  $table_rasp->reset();
                                  $table_rasp->set('nume_raspuns',
$uniqid);
                              if (!$table_rasp->store())
      print('<h1>Eroare - functia $table_rasp->store().</h1>');
                              $db = &JFactory::getDBO();
                              $query = 'SELECT id FROM
#__cunoastere_raspunsuri WHERE nume_raspuns=quot;'.$uniqid.'quot;'.'ORDER BY
id DESC LIMIT 1' ;
                              $db->setQuery($query);
                              $id_raspuns=$db->loadResult();
                              $table_rasp->load($id_raspuns);
                              $table_rasp->set('id_intrebari',
$id_intrebare);
                              $table_rasp->set('nume_raspuns',
addslashes($raspuns));
                              if ($table_rasp->check())
                                          {
                                          if (!$table_rasp->store())
                                          {     print('<h1>Eroare -
functia $table_rasp->store().</h1>');     }
                                          }
                              else
                                          {
                                          print('<h1>Eroare - functia
$table_rasp->check().</h1>');
                                          }
                              $table_rasp->load(0);
                              }

              }

$mainframe-
>redirect('index.php?option=com_componentamea&task=adauga');
}

if($previz==quot;Reinitializeazaquot;)
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=adauga');
}



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 5


?>
<script type=quot;text/javascriptquot;>
function introduceti_entitate(tip)
{
if(tip==quot;intrebarequot;)
document.getElementById(quot;editor_testquot;).value=document.getElementById(
quot;editor_testquot;).value+quot;<intrebare/>quot;;
if(tip==quot;raspunsquot;)
document.getElementById(quot;editor_testquot;).value=document.getElementById(
quot;editor_testquot;).value+quot;<raspuns/>quot;;
if(tip==quot;breakquot;)
document.getElementById(quot;editor_testquot;).value=document.getElementById(
quot;editor_testquot;).value+quot;<break/>quot;;
}
</script>
<form method=quot;postquot; action=quot;quot;>
<strong>Introduceti un titlu pentru testul dumneavoastra:
</strong>
<input name=quot;titlu_testquot; type=quot;textquot; id=quot;titlu_testquot;
style=quot;width:98%quot; value=quot;<?php print($titlu_test); ?>quot;
maxlength=quot;255quot;>
<strong>Introduceti o descriere pentru testul dumneavoastra:
</strong>
<textarea id=quot;descriere_testquot; name=quot;descriere_testquot; rows=quot;3quot; cols=quot;1quot;
style=quot;width:98%quot;><?php print($descriere_test); ?></textarea>
<strong>Introduceti intrebarile care compun testul dumneavoastra:
</strong>
<div style=quot;border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2pxquot;>
<a href=quot;javascript: void(0);quot;
onClick='introduceti_entitate(quot;intrebarequot;)'>Intrebare</a>
<a href=quot;javascript: void(0);quot;
onClick='introduceti_entitate(quot;raspunsquot;)'>Raspuns</a>
<a href=quot;javascript: void(0);quot;
onClick='introduceti_entitate(quot;breakquot;)'>Break</a>
</div>
<textarea id=quot;editor_testquot; name=quot;editor_testquot; rows=quot;20quot; cols=quot;1quot;
style=quot;width:98%quot;><?php print($editor_test); ?></textarea>
<input name=quot;previzquot; type=quot;submitquot; value=quot;Previzualizarequot;>
<input name=quot;previzquot; type=quot;submitquot; value=quot;Inregistreazaquot;>
<input name=quot;previzquot; type=quot;submitquot; value=quot;Reinitializeazaquot;>
</form>

<textarea rows=quot;3quot;   cols=quot;1quot; style=quot;width:98%quot;><intrebare/>
Care este capitala   Timisului?
Buzias
Timisoara
Lugoj
<intrebare/>
Care este capitala   Romaniei?
Bucuresti
Budapesta
Sofia
<intrebare/>
Care este capitala   Turciei?



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 6

Ankara
Istanbul
Atena
</textarea>


File admin.componentamea.php:

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$task=JRequest::getVar('task',null).quot;quot;;
if(!isset($task) || trim($task)==quot;quot;)
JRequest::setVar('task','admin_test');
$task=JRequest::getVar('task',null).quot;quot;;

if($task==quot;admin_testquot;) include_once(quot;admin.principal.phpquot;);
if($task==quot;publishquot;) include_once(quot;admin.publish.phpquot;);
if($task==quot;unpublishquot;) include_once(quot;admin.unpublish.phpquot;);
if($task==quot;editquot;) include_once(quot;admin.edit.phpquot;);
if($task==quot;applyquot;) include_once(quot;admin.edit.phpquot;);
if($task==quot;cancelquot;) include_once(quot;admin.edit.phpquot;);

if($task==quot;rezult_testquot;) include_once(quot;admin.rezultate.phpquot;);
if($task==quot;removequot;) include_once(quot;admin.remove.phpquot;);

?>

File admin.edit.php:

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>

<?php

$cid = JRequest::getVar( 'cid', array(0));
$id=$cid[0];
// obtinem o refeinta la clasa JUser
$user =& JFactory::getUser();
// obtinem o referinta la baza de date
$db =& JFactory::getDBO();

if($task== quot;applyquot;)
{
      $titlu_test=JRequest::getVar('titlu_test','');
      $descriere_test=JRequest::getString('descriere_test', '',
'POST', JREQUEST_ALLOWRAW);

        JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables
');
        $table_test = JTable::getInstance('cunoastere_test', 'Table');




                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 7

     $table_test->load($id);

      $table_test->set('nume_test', $titlu_test);
      $table_test->set('descriere_test',
addslashes($descriere_test));

      if ($table_test->check())
            {
                  if (!$table_test->store())
                        {
                        print('<h1>Eroare - functia $table_test-
>store().</h1>');
                        }
            }
      else
            {
            print('<h1>Eroare - functia $table_test->check().</h1>');
            }
$mainframe-
>redirect('index.php?option=com_componentamea&task=edit&mesaj=salvat&
cid[]='.$id.'');
}



if($task== quot;cancelquot;)
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=admin_test');
}

$mesaj = JRequest::getVar( 'mesaj', '');
if($mesaj==quot;salvatquot;)
{
JError::raiseNotice('','Modificarile au fost efectuate.');
}

$query=quot;SELECT `id` , `nume_test` , `descriere_test`, `published`
FROM `jos_cunoastere_test` WHERE id=quot;.$id.quot;quot;;
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
foreach($rows as $row)
{
print('<div style=quot;width:50%quot;>');

print('<form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;>');
print('<strong>Introduceti un titlu pentru testul
dumneavoastra:</strong>');
print('<input name=quot;titlu_testquot; type=quot;textquot; id=quot;titlu_testquot;
style=quot;width:98%quot; value=quot;'.$row->nume_test.'quot; maxlength=quot;255quot;>');
print('<strong>Introduceti o descriere pentru testul
dumneavoastra:</strong>');
print('<textarea id=quot;descriere_testquot; name=quot;descriere_testquot; rows=quot;3quot;
cols=quot;1quot; style=quot;width:98%quot;>'.stripslashes($row-
>descriere_test).'</textarea>');

print('<input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;quot; />');



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 8


print('</form>');

print('</div>');
}
JRequest::setVar('hidemainmenu', 1);
?>


File admin.principal.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>

<?php
$ordine=JRequest::getVar('ordine',null);
if(!isset($ordine))$ordine=quot;DESCquot;;
?>


<form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;>

<script type=quot;text/javascriptquot;>
function stabileste_ordinea(param)
{
document.getElementById(quot;ord_txtquot;).value=param;
document.getElementById(quot;ord_txtquot;).form.submit();
}
</script>

<table class=quot;adminlistquot;>
<thead>
<tr>
<th width=quot;20quot; class='title'>#</th>
<th width=quot;20quot; class='title'>
<input type=quot;checkboxquot; name=quot;togglequot; value=quot;quot;
onclick=quot;checkAll(nr_chk);quot; /></th>
<th class='title'>Numele testului</th>
<th class='title'>Descrierea testului</th>
<th width=quot;30quot; class='title'>Publicare test</th>
<th width=quot;30quot; class='title'>
<a href=quot;javascript: void(0);quot; onClick=quot;stabileste_ordinea('ASC')quot;
title=quot;Ascendentquot;>[I</a><a href=quot;javascript: void(0);quot;
onClick=quot;stabileste_ordinea('DESC')quot; title=quot;Descendentquot;>d]</a>
</th>
</tr>
</thead>
<?php
$db =& JFactory::getDBO();
$db->setQuery('SELECT count(*) FROM `jos_cunoastere_test`');
$total = $db->loadResult();

$limit = $mainframe-
>getUserStateFromRequest(quot;limitquot;,'limit',$mainframe-
>getCfg('list_limit'));



                                  Download
          http://24secunde.com/joomla/media/com_componentamea.zip
Page 9

if($limit==0)$limit=500;
$limitstart = $mainframe-
>getUserStateFromRequest(quot;$option.view.limitstartquot;,'limitstart',0);
$query='SELECT * FROM `jos_cunoastere_test` ORDER BY id '.$ordine.'
LIMIT '.$limitstart.','.$limit.'';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
$int_j=0;
foreach ($rows as $row)
      {

?>
<tr class=quot;row<?php print($int_j%2);?>quot;>
<td align=quot;centerquot;><?php print($int_j);?></td>
<td><input type=quot;checkboxquot; id=quot;cb<?php print($int_j);?>quot; name=quot;cid[]quot;
value=quot;<?php print($row->id);?>quot; onclick=quot;isChecked(this.checked);quot;
/></td>
<td><?php print('<a
href=quot;index.php?option=com_componentamea&task=edit&cid[]='.$row-
>id.'quot;>'.$row->nume_test.'</a>');?></td>
<td><?php print(stripslashes($row->descriere_test));?></td>
<td>
<?php
if($row->published==1)
print('<a href=quot;javascript:void(0);quot; onclick=quot;return
listItemTask('cb'.$int_j.'','unpublish')quot; title=quot;Unpublish Itemquot;>
<img src=quot;images/tick.pngquot; width=quot;16quot; height=quot;16quot; border=quot;0quot;
alt=quot;Noquot; /></a>');
if($row->published==0)
print('<a href=quot;javascript:void(0);quot; onclick=quot;return
listItemTask('cb'.$int_j.'','publish')quot; title=quot;Publish Itemquot;>
<img src=quot;images/publish_x.pngquot; width=quot;16quot; height=quot;16quot; border=quot;0quot;
alt=quot;Noquot; /></a>');
?>
</td>
<td><?php print($row->id);?></td>
</tr>
<?php
$int_j++;
}
print('<script type=quot;text/javascriptquot;>');
print('var nr_chk='.$int_j);
print('</script>');
?>

<tfoot>
<td colspan=quot;10quot;>
<?php
jimport('joomla.html.pagination');
if($limit==500)$limit=0;
$pageNav = new JPagination($total,$limitstart,$limit);
print($pageNav->getListFooter());
?>
</td>
</tfoot>




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 10

</table>


<input id=quot;id_txtquot; type=quot;hiddenquot; name=quot;idquot; value=quot;quot; />
<input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;quot; />
<input id=quot;ord_txtquot; type=quot;hiddenquot; name=quot;ordinequot; value=quot;<?php
print($ordine); ?>quot; />
<input type=quot;hiddenquot; name=quot;boxcheckedquot; value=quot;0quot; />

</form>

File admin.publish.php

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>

<?php
$cid = JRequest::getVar( 'cid', array(0));
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
foreach($cid as $value)
{
$id=$value;
?>
<?php

$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',1);
if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_test->check().</h1>');
      }
?>
<?php
}
$mainframe->redirect('index.php?option=com_componentamea');
?>


File admin.remove.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$db =& JFactory::getDBO();




                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 11


$user=JRequest::getVar('user_del','');
$user=$user.'';
if(trim($user)==quot;quot;)$user='[{<##>}]';

$test=JRequest::getVar('test_del',0);
$test=0+$test;


JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_user = JTable::getInstance('cunoastere_user', 'Table');

$query='SELECT `id` FROM `jos_cunoastere_user` WHERE
id_test='.$test.' OR user LIKE quot;'.$user.'%quot;';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
foreach($rows as $row)
{
$table_user->delete($row->id);
}
$mainframe-
>redirect('index.php?option=com_componentamea&task=rezult_test');
?>

File admin.rezultate.php

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;>
<h4>Sterge rezultatele utilizatorului: </h4>
<input type=quot;textquot; name=quot;user_delquot; id=quot;user_delquot; class=quot;text_areaquot; />
(Ex: Ion, Rizache, John) % - sterge tot
<br/>
<h4>Sterge rezultatele care includ testul:</h4>
<input type=quot;textquot; name=quot;test_delquot; id=quot;test_delquot; class=quot;text_areaquot; />
(Ex: 1, 100, 2000)
<br/><br/>
<button onclick=quot;this.form.submit();quot;>Go</button><br/>
<input id=quot;id_txtquot; type=quot;hiddenquot; name=quot;idquot; value=quot;quot; />
<input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;removequot; />
<input type=quot;hiddenquot; name=quot;boxcheckedquot; value=quot;1quot; />

</form>

File admin.unpublish.php

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$cid = JRequest::getVar( 'cid', array(0));
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
foreach($cid as $value)



                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 12

{
$id=$value;
?>
<?php
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_test->load($id);
$table_test->set('published',0);
if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_test->check().</h1>');
      }
?>
<?php
}
$mainframe->redirect('index.php?option=com_componentamea');
?>

File componentamea.php

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$task=JRequest::getVar('task',null);
if($task==quot;adaugaquot;) include_once(quot;adauga_test.phpquot;);
if($task==quot;view_testquot;) include_once(quot;vezi_test.phpquot;);
if($task==quot;nu_publicaquot;) include_once(quot;nu_publica.phpquot;);
if($task==quot;publicaquot;) include_once(quot;publica.phpquot;);
if($task==quot;sterge_articolquot;) include_once(quot;sterge_articol.phpquot;);
if($task==quot;edit_articolquot;) include_once(quot;edit_articol.phpquot;);
if($task==quot;xml_feedquot;) include_once(quot;xml_feed.phpquot;);
if(!isset($task)) include_once(quot;principal.phpquot;);
?>

File edit_articol.php
<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!=quot;Super Administratorquot;) $mainframe-
>redirect('index.php');
?>
<?php
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
$query='SELECT * FROM `jos_cunoastere_test` WHERE id='.$id.'';




                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 13

$result = $db->setQuery($query);
$rows = $db->loadObjectList();
$titlu_test =$rows[0]->nume_test;
$descriere_test =$rows[0]->descriere_test;
$editor_test=quot;quot;;
      $query='SELECT * FROM `jos_cunoastere_intrebari` WHERE
`id_test` ='.$id.'';
      $result = $db->setQuery($query);
      $rows = $db->loadObjectList();

     foreach($rows as $row)
           {
           $editor_test=$editor_test.quot;<intrebare/>quot;.quot;nquot;;
           $editor_test=$editor_test.$row->nume_intrebare.quot;nquot;;

                  $query_='SELECT * FROM `jos_cunoastere_raspunsuri`
WHERE `id_intrebari` ='.($row->id).'';
                  $result_ = $db->setQuery($query_);
                  $rows_ = $db->loadObjectList();
                  foreach($rows_ as $row_)
                  {
                  $editor_test=$editor_test.$row_->nume_raspuns.quot;nquot;;
                  }
            }
$previz=JRequest::getVar('previz',null);

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table');
$table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table');

if($previz==quot;Inregistreazaquot;)
{
$titlu_test=JRequest::getVar('titlu_test','');
$editor_test=JRequest::getString('editor_test', '', 'POST',
JREQUEST_ALLOWRAW);
$descriere_test=JRequest::getString('descriere_test', '', 'POST',
JREQUEST_ALLOWRAW);

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table');
$table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table');

$table_test->reset();
$uniqid=uniqid(quot;quot;);
$table_test->set('nume_test', $uniqid);

if (!$table_test->store())    print('<h1>Eroare - functia
$table_test->store().</h1>');


$db = &JFactory::getDBO();
$query = 'SELECT id FROM #__cunoastere_test WHERE
nume_test=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ;
$db->setQuery($query);
$id_test=$db->loadResult();



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 14


$table_test->load($id_test);

$table_test->set('nume_test', $titlu_test);
$table_test->set('descriere_test', addslashes($descriere_test));

if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_test->check().</h1>');
      }


$intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test);
$j=1;
foreach($intrebari_teste as $intrebare)
            {
                        $intrebare=trim($intrebare);

                           $intrebare1=explode(quot;nquot;, $intrebare);
                           $i=1;

                           foreach($intrebare1 as $raspuns)

                                  {

                                         if($i==1)
                                               {
                                               if(trim($raspuns)==quot;quot;)
continue;
                                                $table_intreb->reset();
                                                $table_intreb-
>set('nume_intrebare', $uniqid);
                                          if (!$table_intreb-
>store())   print('<h1>Eroare - functia $table_intreb-
>store().</h1>');
                                          $db = &JFactory::getDBO();
                                          $query = 'SELECT id FROM
#__cunoastere_intrebari WHERE nume_intrebare=quot;'.$uniqid.'quot;'.'ORDER BY
id DESC LIMIT 1' ;
                                          $db->setQuery($query);
                                          $id_intrebare=$db-
>loadResult();
                                          $table_intreb-
>load($id_intrebare);
                                          $table_intreb-
>set('id_test', $id_test);
                                          $table_intreb-
>set('nume_intrebare', addslashes( $raspuns));

                                                if ($table_intreb->check())



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 15

                                                      {
                                                      if (!$table_intreb-
>store())
                                                {
      print('<h1>Eroare - functia $table_intreb->store().</h1>'); }
                                                }
                                          else
                                                {
                                                print('<h1>Eroare -
functia $table_intreb->check().</h1>');
                                                }

                                               $table_intreb->load(0);
                                               $i++; continue;
                                               }

                                  if(trim($raspuns)==quot;quot;) continue;
                                  $table_rasp->reset();
                                  $table_rasp->set('nume_raspuns',
$uniqid);
                              if (!$table_rasp->store())
      print('<h1>Eroare - functia $table_rasp->store().</h1>');
                              $db = &JFactory::getDBO();
                              $query = 'SELECT id FROM
#__cunoastere_raspunsuri WHERE nume_raspuns=quot;'.$uniqid.'quot;'.'ORDER BY
id DESC LIMIT 1' ;
                              $db->setQuery($query);
                              $id_raspuns=$db->loadResult();
                              $table_rasp->load($id_raspuns);
                              $table_rasp->set('id_intrebari',
$id_intrebare);
                              $table_rasp->set('nume_raspuns',
addslashes($raspuns));
                              if ($table_rasp->check())
                                          {
                                          if (!$table_rasp->store())
                                          {     print('<h1>Eroare -
functia $table_rasp->store().</h1>');     }
                                          }
                              else
                                          {
                                          print('<h1>Eroare - functia
$table_rasp->check().</h1>');
                                          }
                              $table_rasp->load(0);
                              }

              }

$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
_test.'');
}

include_once(quot;adauga_test.phpquot;);
?>




                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 16


File index.php

<?php
print(quot;Componenta meaquot;);
?>

File nu_publica.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!=quot;Super Administratorquot;) $mainframe-
>redirect('index.php');
?>
<?php
$id=JRequest::getVar('id',0);
$id=$id+0;

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');

$table_test->load($id);
$table_test->set('published',0);

if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_test->check().</h1>');
      }
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
?>

File principal.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
print('<div style=quot;clear:both;quot;></div>');
$url_partaj=JURI::base().quot;index.php?option=com_componentamea%26task=x
ml_feed%26format=feedquot;;
jimport('joomla.utilities.date');
$date1 = new JDate();
$date1=$date1->toFormat('%d-%m-%Y %H:%M:%S EET');
print('<div style=quot;background-color:#e1e1e1; padding:3px 3px 3px 3px;
margin-bottom:5px; font-weight:boldquot;>');



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 17

print('<div style=quot;float:left;quot;>Ora vizitei: '.$date1.'</div>');

print('<div style=quot;float:right;background-color:#e1e1e1; padding:0px
0px 1px 0px;quot;>');
print('<a
href=quot;'.JURI::base().'index.php?option=com_componentamea&task=xml_fee
d&format=feedquot; title=quot;RSSquot;><img
src=quot;components/com_hello/imagini/rss.gifquot; alt=quot;RSSquot;></a>');
print('<a href=quot;http://add.my.yahoo.com/rss?url='.$url_partaj.'quot;
title=quot;Yahooquot;><img src=quot;components/com_hello/imagini/yahoo.gifquot;
alt=quot;Yahooquot;></a>');
print('<a href=quot;http://fusion.google.com/add?feedurl='.$url_partaj.'quot;
title=quot;Googlequot;><img src=quot;components/com_hello/imagini/google.gifquot;
alt=quot;Googlequot;></a>');
print('<a
href=quot;http://www.netvibes.com/subscribe.php?url='.$url_partaj.'quot;
title=quot;Netvibesquot;><img src=quot;components/com_hello/imagini/netvibes.gifquot;
alt=quot;Netvibesquot;></a>');
print('</div>');
print('.</div>');
print('<div style=quot;clear:both;quot;></div>');

$tip_user=quot;Super Administratorquot;;
// setam titlul ce apare in browser
$document =& JFactory::getDocument();
$document->setTitle(quot;Teste de cunoasterequot;);

// setam parametrii pentru bara de navigatie
$limit = 20;
$limitstart = JRequest::getVar('limitstart',0);
$limitstart = 0 + intval($limitstart);
$total = 0; //numarul total de articole
// obtinem o refeinta la clasa JUser
$user =& JFactory::getUser();
// obtinem o referinta la baza de date
$db =& JFactory::getDBO();

// avem interogari diferite pentru un user obisnuit si un
administrator
// administratorul poate sa aiba acces la toate inregistrarile, si la
cele marcate ca nepublicate
// interogarea urmatoare va intoarce numarul total de teste din baza
de date; informatia este necesara pentru bara de navigatie
if($user->usertype==$tip_user)
$query=quot;SELECT count(*) FROM `jos_cunoastere_test` WHERE 1 quot;;
else
$query=quot;SELECT count(*) FROM `jos_cunoastere_test` WHERE
`published`=1 quot;;
$result = $db->setQuery($query);
$total=$db->loadResult();
if($user->usertype==quot;Super Administratorquot;)
$query=quot;SELECT `id` , `nume_test` , `descriere_test` FROM
`jos_cunoastere_test` WHERE 1 ORDER BY `id` DESC LIMIT
quot;.$limitstart.quot; , quot;.$limit.quot;quot;;
else




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 18

$query=quot;SELECT `id` , `nume_test` , `descriere_test` FROM
`jos_cunoastere_test` WHERE `published`=1 ORDER BY `id` DESC LIMIT
quot;.$limitstart.quot; , quot;.$limit.quot;quot;;

$result = $db->setQuery($query);
$rows = $db->loadObjectList();

foreach ($rows as $row)
      {
            print('<a
href=quot;index.php?option=com_componentamea&task=view_test&id='.$row-
>id.'quot; style=quot;text-decoration:none; cursor: pointer; quot; title=quot;'.$row-
>nume_test.'quot;><h3>'.$row->nume_test.'</h3></a>');
            print(stripslashes($row->descriere_test));
            print(quot;<br/>quot;); print(quot;<br/>quot;);
      }

jimport('joomla.html.pagination');
$_pagination = new JPagination($total, $limitstart, $limit);
?>
<div style=quot;clear:bothquot;></div>
<div class=quot;pagenavquot; style=quot;text-align:center; margin-top:10px; quot;>
<?php print($_pagination->getPagesLinks()); ?>
<br/>
<?php print($_pagination->getPagesCounter()); ?>
</div>

File publica.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!=quot;Super Administratorquot;) $mainframe-
>redirect('index.php');
?>
<?php
$id=JRequest::getVar('id',0);
$id=$id+0;

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');

$table_test->load($id);
$table_test->set('published',1);

if ($table_test->check())
{
      if (!$table_test->store())
      {
      print('<h1>Eroare - functia $table_test->store().</h1>');
      }
}
else
      {




                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 19

      print('<h1>Eroare - functia $table_test->check().</h1>');
      }
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
?>

File sterge_articol.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!=quot;Super Administratorquot;) $mainframe-
>redirect('index.php');
?>
<?php
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table');
$table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table');
$table_test->delete($id);
            $query='SELECT `id` FROM `jos_cunoastere_intrebari` WHERE
`id_test` ='.$id.'';
            $result = $db->setQuery($query);
            $rows = $db->loadObjectList();
            foreach($rows as $row)
            {
                  $query_='SELECT id FROM `jos_cunoastere_raspunsuri`
WHERE `id_intrebari` ='.($row->id).'';
                  $result_ = $db->setQuery($query_);
                  $rows_ = $db->loadObjectList();
                  foreach($rows_ as $row_)
                  {
                  $table_rasp->delete($row_->id);
                  }
            $table_intreb->delete($row->id);
            }
$mainframe->redirect('index.php?option=com_componentamea');
?>

File toolbar.componentamea.php

<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>

<?php
if($task==quot;admin_testquot;)
{
JToolBarHelper::title('Administrare teste');



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 20

JToolBarHelper::editList();
JToolBarHelper::divider();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::divider();
JToolBarHelper::preferences('com_componentamea');
}
if($task==quot;editquot; || $task==quot;applyquot; )
{
JToolBarHelper::title('Editare test');
JToolBarHelper::apply();
JToolBarHelper::cancel();
}
if($task==quot;rezult_testquot;)
{
JToolBarHelper::title('Rezultate teste');
JToolBarHelper::deleteList();
}
?>

File vezi_test.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();

$id=JRequest::getVar('id',0);
$id=$id+0;

$previz=JRequest::getVar('previz',null);
if($previz==quot;Reinitializeazaquot;)
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
}


if($previz==quot;Inregistreazaquot;)
{
if(!isset($user->name)) $mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&alert_us
er=not&id='.$id.'');
$sir=quot;quot;.JRequest::getVar('sir','');
$sir_array=explode(quot;:quot;,$sir);
if(!isset($sir_array[2])) $mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&alert_us
er=script&id='.$id.'');

jimport('joomla.utilities.date');
$date_ = new JDate();
$date = $date_->toFormat('%d/%m/%Y');

JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 21

$table_user = JTable::getInstance('cunoastere_user', 'Table');

$table_user->reset();

$table_user->set('id_test', $sir_array[2]);
$table_user->set('user', $user->name.quot; :: quot;.$date);
$table_user->set('punctaj', $sir_array[1]*1000+$sir_array[0]);

if ($table_user->check())
{
      if (!$table_user->store())
      {
      print('<h1>Eroare - functia $table_user->store().</h1>');
      }
}
else
      {
      print('<h1>Eroare - functia $table_user->check().</h1>');
      }

$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&alert_us
er=BD&id='.$id.'');
}

$query=quot;SELECT `id` , `nume_test` , `descriere_test`, `published`
FROM `jos_cunoastere_test` WHERE id=quot;.$id.quot;quot;;
$result = $db->setQuery($query);
$rows = $db->loadObjectList();

$url_partaj=JURI::base().quot;index.php?option=com_componentamea%26task=v
iew_test%26id=quot;.$id;

foreach($rows as $row)
{
      if($user->usertype!=quot;Super Administratorquot;)
      {
            print('<div style=quot;float:right;quot;>');
            print('<a
href=quot;http://www.facebook.com/sharer.php?u='.$url_partaj.'quot;
title=quot;Partajeaza pe Facebookquot;><img
src=quot;components/com_hello/imagini/facebook.gifquot;
alt=quot;Facebookquot;></a>');
            print('<a
href=quot;http://digg.com/submit?phase=2&url='.$url_partaj.'quot;
title=quot;Partajeaza pe Diggquot;><img
src=quot;components/com_hello/imagini/diggit.gifquot; alt=quot;Diggitquot;></a>');
            print('<a
href=quot;http://del.icio.us/post?url='.$url_partaj.'&title='.$row-
>title.'quot; title=quot;Partajeaza pe Deliciousquot;><img
src=quot;components/com_hello/imagini/delicious.gifquot;
alt=quot;Deliciousquot;></a>');
            print('<a
href=quot;https://favorites.live.com/quickadd.aspx?marklet=1&top=1&url='.
$url_partaj.'quot; title=quot;Partajeaza pe Livequot;><img
src=quot;components/com_hello/imagini/live.gifquot; alt=quot;Livequot;></a>');




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 22

            print('<a
href=quot;http://blogmarks.net/my/new.php?mini=1&simple=1&url='.$url_part
aj.'&title='.$row->nume_test.'quot; title=quot;Partajeaza pe Blogmarksquot;><img
src=quot;components/com_hello/imagini/blogmarks.gifquot;
alt=quot;Blogmarksquot;></a>');
            print('<a
href=quot;http://www.technorati.com/faves?add='.$url_partaj.'quot;
title=quot;Partajeaza pe Technoratiquot;><img
src=quot;components/com_hello/imagini/technorati.gifquot;
alt=quot;Technoratiquot;></a>');
            print('<a
href=quot;http://www.myspace.com/Modules/PostTo/Pages/?c='.$url_partaj.'quot;
title=quot;Partajeaza pe Myspacequot;><img
src=quot;components/com_hello/imagini/myspace.gifquot; alt=quot;Myspacequot;></a>');
            print('<a
href=quot;http://twitthis.com/twit?url='.$url_partaj.'&title='.$row-
>nume_test.'quot; title=quot;Partajeaza pe Twitterquot;><img
src=quot;components/com_hello/imagini/twitter.gifquot; alt=quot;Twitterquot;></a>');
            print('</div>');
      }

      if($user->usertype==quot;Super Administratorquot;)
      {
            print('<div style=quot;float:right;quot;>');
            if($row->published==1)
            print('<a
href=quot;index.php?option=com_componentamea&task=nu_publica&id='.$row-
>id.'quot; title=quot;Nu publica acest articolquot;><img
src=quot;components/com_componentamea/imagini/yes.pngquot;
alt=quot;yes.pngquot;></a>');
            if($row->published==0)
            print('<a
href=quot;index.php?option=com_componentamea&task=publica&id='.$row-
>id.'quot; title=quot;Publica articolquot;><img
src=quot;components/com_componentamea/imagini/no.pngquot;
alt=quot;no.pngquot;></a>');
            print('<a
href=quot;index.php?option=com_componentamea&task=edit_articol&id='.$row-
>id.'quot; title=quot;Editeaza articolquot;><img
src=quot;components/com_componentamea/imagini/edit.pngquot;
alt=quot;edit.pngquot;></a>');
            print('<a
href=quot;index.php?option=com_componentamea&task=sterge_articol&id='.$ro
w->id.'quot; title=quot;Sterge articolquot;><img
src=quot;components/com_componentamea/imagini/del.pngquot;
alt=quot;del.pngquot;></a>');
            print('</div>');
      }
print('<div style=quot;clear:both;quot;></div>');

$alert_user=JRequest::getVar('alert_user','');
$alert_user=$alert_user.quot;quot;;

if($alert_user==quot;notquot;)
{




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 23

print('<div style=quot;width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2pxquot;>');
print('<h4>Trebuie sa va conectati ca sa puteti inregistra
rezultatele testelor.</h4>');
print('</div>');
}

if($alert_user==quot;scriptquot;)
{
print('<div style=quot;width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2pxquot;>');
print('<h4>Programul necesita Javascript pentru a rula.</h4>');
print('</div>');
}

if($alert_user==quot;BDquot;)
{
print('<div style=quot;width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2pxquot;>');
print('<h4>Rezultatul testului a fost inregistrat in baza de
date.</h4>');
print('</div>');
}

$document =& JFactory::getDocument();
$document->setTitle($row->nume_test);

print(quot;<h1>quot;.$row->nume_test.quot;</h1>quot;); print(quot;<br/>quot;);
print(quot;quot;.stripslashes($row->descriere_test).quot;quot;); print(quot;<br/>quot;);
print(quot;<br/>quot;);

$id_test=$row->id;

$tablou_int=array();
$tablou_raspuns=array();


$query = 'SELECT `id` , `nume_intrebare` FROM
`jos_cunoastere_intrebari` WHERE `id_test` ='.$id_test.'';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
?>
<script type=quot;text/javascriptquot;>
var radio=new Array();
var raspuns_dat=new Array();

var rasp_date=0;
var total=0;
function verifica(param, param2)
{
var diviz=quot;div[quot;+param2+quot;]quot;;
if(radio[param2]==param.value)
{
//visibility:visible



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 24

document.getElementById(diviz).style.visibility=quot;visiblequot;;
document.getElementById(diviz).style.color=quot;greenquot;;
document.getElementById(diviz).innerHTML=quot;Raspuns corectquot;;
 if(raspuns_dat[param2]==-1)
      {
      raspuns_dat[param2]=raspuns_dat[param2]+2;
      rasp_date=rasp_date+raspuns_dat[param2];
      total++;
      document.getElementById(quot;div_raspunsquot;).innerHTML=quot;Total test:
quot;+ rasp_date + quot; / quot; + total + quot; : quot;+ parseInt(rasp_date*100/total)
+quot;%quot;;
      }
}
else
{
document.getElementById(diviz).style.visibility=quot;visiblequot;;
document.getElementById(diviz).style.color=quot;redquot;;
document.getElementById(diviz).innerHTML=quot;Raspuns incorectquot;;
      if(raspuns_dat[param2]==-1)
      {
      raspuns_dat[param2]=raspuns_dat[param2]+1;
      rasp_date=rasp_date+raspuns_dat[param2];
      total++;
      document.getElementById(quot;div_raspunsquot;).innerHTML=quot;Total test:
quot;+ rasp_date + quot; / quot; + total + quot; : quot;+ parseInt(rasp_date*100/total)
+quot;%quot;;
      }
}
}

</script>
<?php

if($user->usertype!=quot;Super Administratorquot;)
                  {
                  $doc =& JFactory::getDocument();
                  $params =&$mainframe-
>getPageParameters('com_componentamea');
                  $zone = $params->get('zona1');
                  if($doc->countModules('publicitate') && $doc-
>countModules('publicitate')>$zone)
                        {
                        jimport('joomla.application.module.helper');
                        $module =
JModuleHelper::getModules('publicitate');
                        echo
JModuleHelper::renderModule($module[$zone]);
                        }
                  }

     foreach($rows as $row)
     {
     print(quot;<h3>quot;.stripslashes($row->nume_intrebare).quot;</h3>quot;);


     $id_intreb=$row->id;
     $tablou_int[]=$id_intreb;



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 25


      $query='SELECT `id`,`nume_raspuns` FROM
`jos_cunoastere_raspunsuri` WHERE `id_intrebari`='.$id_intreb.'';
      $result_ = $db->setQuery($query);
      $rows_ = $db->loadObjectList();

     $tablou_rasp=array();
     $tablou_rasp_indice=array();

      foreach($rows_ as $row_)
            {
                  $tablou_rasp_indice[]=$row_->id;
                  $tablou_rasp[$row_->id]=stripslashes($row_-
>nume_raspuns);
            }

     $tablou_raspuns[]=$tablou_rasp_indice[0];

print('<script type=quot;text/javascriptquot;>');
print('radio['.$id_intreb.']='.$tablou_rasp_indice[0].';');
print('raspuns_dat['.$id_intreb.']=-1;');
print('var test_id='.$id_test.';');
print('</script>');

     srand((double)microtime()*1000000);
     shuffle($tablou_rasp_indice);

      foreach($tablou_rasp_indice as $value)
            {
                  print('<input name=quot;radio'.$id_intreb.'quot;
type=quot;radioquot; value=quot;'.$value.'quot;
onclick=quot;verifica('.this.','.$id_intreb.')quot;>');
                  print($tablou_rasp[$value]);
                  print(quot;<br/>quot;);
            }
      print('<div id=quot;div['.$id_intreb.']quot; style=quot;visibility:hidden;
width:50%; border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2pxquot;></div>');
      print(quot;<br/>quot;);
      }

}
print('<script type=quot;text/javascriptquot;>');
print('var total_ver='.count($tablou_int).';');
print('</script>');
?>
<h3>Rezultat test</h3>
<div id=quot;div_raspunsquot; style=quot;width:50%; border-width:1px; border-
style:solid; background-color:#CCCCCC; padding-top:2px; padding-
left:2px; padding-bottom:2px; margin-bottom:2pxquot;>
Nici un rezultat inca.
</div>
<script type=quot;text/javascriptquot;>
var tip_submit=null;
function verifica_form()
{



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 26

document.getElementById(quot;sirquot;).value=rasp_date+quot;:quot;+total+quot;:quot;+
test_id;

if(tip_submit.value==quot;Reinitializeazaquot;) return true;
      if(tip_submit.value==quot;Inregistreazaquot;)
      {
            if(total_ver==total)
            {
            return true;
            }
            else return false;
      }
}
</script>
<form action=quot;quot; method=quot;postquot; onSubmit=quot;return verifica_form();quot;>
<input id=quot;sirquot; name=quot;sirquot; type=quot;hiddenquot; value=quot;quot;>
<input name=quot;previzquot; type=quot;submitquot; value=quot;Inregistreazaquot;
onClick=quot;tip_submit=this;quot;> sau
<input name=quot;previzquot; type=quot;submitquot; value=quot;Reinitializeazaquot;
onClick=quot;tip_submit=this;quot;>
</form>
<?php
print(quot;<br/>quot;);

$query='SELECT DISTINCT `id_test` FROM      `jos_cunoastere_user` ORDER
BY id DESC LIMIT 0, 10';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();

$teste_recom=array();
foreach($rows as $row)
            {
                  $teste_recom[]=$row->id_test;
            }
print(quot;<h3>Alte teste de cunostinte recomandate:</h3>quot;);
foreach($teste_recom as $value)
            {
            $query='SELECT `id`,`nume_test` FROM
`jos_cunoastere_test` WHERE id='.$value.' AND `published`=1 ';
            $result = $db->setQuery($query);
            $rows = $db->loadObjectList();
            if(trim($rows[0]->nume_test.quot;quot;)==quot;quot;)continue;
            print('<a
href=quot;index.php?option=com_componentamea&task=view_test&id='.($rows[0
]->id).'quot; style=quot;text-decoration:nonequot; title=quot;Citeste mai
mult...quot;>');
            print($rows[0]->nume_test);
            print('</a><br/>');
            }


if(isset($user->name))
{
            print(quot;<h4>quot;); print(quot;Rezultate obtinute la
test:quot;);print(quot;</h4>quot;);
            $id_test=0+$id_test;




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 27

            $query='SELECT `user` , `punctaj` FROM
`jos_cunoastere_user` WHERE `id_test` ='.$id_test.' AND `user` LIKE
quot;'.($user->name).'%quot; ORDER BY id DESC LIMIT 0 , 30';
            $result = $db->setQuery($query);
            $rows = $db->loadObjectList();
            foreach($rows as $row)
            {
            $user_data=explode(quot;::quot;,$row->user);
            print($user_data[1]); print(quot; quot;);
            $total_intreb=(int)($row->punctaj/1000);
            $total_dat=(int) ($row->punctaj- $total_intreb*1000);
            print(quot; quot;.$total_dat.quot;/quot;);print(quot;quot;.$total_intreb.quot; quot;);
            print(quot;Procentaj:
quot;.(int)($total_dat*100/$total_intreb).quot;%quot;);
            print(quot;<br/>quot;);
            }
}

if($user->usertype!=quot;Super Administratorquot;)
                  {
                  $doc =& JFactory::getDocument();
                  $params =&$mainframe-
>getPageParameters('com_componentamea');
                  $zone = $params->get('zona2');
                  if($doc->countModules('publicitate') && $doc-
>countModules('publicitate')>$zone)
                        {
                        jimport('joomla.application.module.helper');
                        $module =
JModuleHelper::getModules('publicitate');
                        echo
JModuleHelper::renderModule($module[$zone]);
                        }
                  }

?>

File xml_feed.php

<?php
 defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;);
?>
<?php
/// Pasul 1 - stabileste linkul de baza
$document = & JFactory::getDocument();;
$document->setLink(JRoute::_('index.php?option=com_componentamea'));

$db =& JFactory::getDBO();

$query=quot;SELECT * FROM `jos_cunoastere_test` WHERE `published`=1
ORDER BY `id` DESC LIMIT 0,30quot;;
$db->setQuery($query);
$rows = $db->loadObjectList();
$document->description=quot;Fluxul RSS pentru componenta de testequot;;

foreach ($rows as $row)
{



                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 28

      $item = new JFeedItem();
      $item->description =stripslashes($row-
>descriere_test).quot;<br/>quot;.quot;<br/>quot;;
      $item->link =
JRoute::_('index.php?option=com_componentamea&task=view_test&id='.$ro
w->id);
      $item->title = $row->nume_test;
      $document->addItem($item);
}
jimport('joomla.utilities.date');
$date1 = new JDate();
$item->description=$date1->toFormat('%d-%m-%Y');
$item->link = JRoute::_('index.php?option=com_componentamea');
$item->title = quot;Data de generare a fluxuluiquot;;
$document->addItem($item);

$document->render();
?>

File componenta mea.xml

<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<!DOCTYPE install SYSTEM quot;http://dev.joomla.org/xml/1.5/component-
install.dtdquot;>
<install type=quot;componentquot; version=quot;1.5quot;>
<name>Componenta mea</name>
<creationDate>Martie 2009</creationDate>
<author>Farcas Adrian</author>
<authorEmail>farcas88@yahoo.com</authorEmail>
<authorUrl>http://24secunde.com</authorUrl>
<copyright>Copyright</copyright>
<license>Licenta</license>
<version>Versiunea 1.0</version>
<description>Componenta de test</description>

<administration>
<menu>Admin Teste</menu>
<submenu>
<menu task=quot;rezult_testquot;
img=quot;js/ThemeOffice/component.pngquot;>Administrare rezultate
teste</menu>
<menu task=quot;admin_testquot;
img=quot;js/ThemeOffice/component.pngquot;>Administrare teste</menu>
</submenu>

<files>
<filename>admin.componentamea.php</filename>
<filename>admin.edit.php</filename>
<filename>admin.principal.php</filename>
<filename>admin.publish.php</filename>
<filename>admin.remove.php</filename>
<filename>admin.rezultate.php</filename>
<filename>admin.unpublish.php</filename>
<filename>componenta mea.xml</filename>
<filename>config.xml</filename>
<filename>index.php</filename>
<filename>toolbar.componentamea.php</filename>



                                  Download
          http://24secunde.com/joomla/media/com_componentamea.zip
Page 29

<folder>imagini</folder>
<folder>tables</folder>
</files>

</administration>

<install>
<queries>
<query>DROP   TABLE   IF   EXISTS   `jos_cunoastere_intrebari`;</query>
<query>DROP   TABLE   IF   EXISTS   `jos_cunoastere_raspunsuri`;</query>
<query>DROP   TABLE   IF   EXISTS   `jos_cunoastere_test`;</query>
<query>DROP   TABLE   IF   EXISTS   `jos_cunoastere_user`;</query>

<query>CREATE TABLE `jos_cunoastere_intrebari`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_test` INT NOT NULL,
`nume_intrebare` TEXT NOT NULL
)
</query>

<query>CREATE TABLE `jos_cunoastere_raspunsuri`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_intrebari` INT NOT NULL,
`nume_raspuns` TEXT NOT NULL
)
</query>

<query>CREATE TABLE `jos_cunoastere_test` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`nume_test` TEXT NOT NULL ,
`descriere_test` TEXT NOT NULL ,
`published` TINYINT( 1 ) NOT NULL DEFAULT 0
)
</query>

<query>CREATE TABLE `jos_cunoastere_user`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_test` INT NOT NULL,
`user` VARCHAR(255) NOT NULL,
`punctaj` INT NOT NULL DEFAULT 0
)
</query>

<query>
<![CDATA[
INSERT INTO `jos_cunoastere_test` ( `id` , `nume_test` ,
`descriere_test` , `published` )
VALUES (
'', 'Primul tau test aici / Your first quiz here:', 'Log in as
Administrator and click: <a
href=quot;index.php?option=com_componentamea&task=adaugaquot;
title=quot;quot;>index.php?option=com_componentamea&task=adauga</a>', '1'
)
]]>



                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip
Page 30

</query>

</queries>
</install>

<uninstall>
<queries>
<query>DROP TABLE   IF   EXISTS   `jos_cunoastere_intrebari`;</query>
<query>DROP TABLE   IF   EXISTS   `jos_cunoastere_raspunsuri`;</query>
<query>DROP TABLE   IF   EXISTS   `jos_cunoastere_test`;</query>
<query>DROP TABLE   IF   EXISTS   `jos_cunoastere_user`;</query>
</queries>
</uninstall>

<files>
<filename>adauga_test.php</filename>
<filename>componentamea.php</filename>
<filename>edit_articol.php</filename>
<filename>index.php</filename>
<filename>nu_publica.php</filename>
<filename>principal.php</filename>
<filename>publica.php</filename>
<filename>sterge_articol.php</filename>
<filename>vezi_test.php</filename>
<filename>xml_feed.php</filename>
<folder>imagini</folder>
</files>


</install>

File config.xml

<?xml version=quot;1.0quot; encoding=quot;utf-8quot;?>
<config>
<params>
<param name=quot;zona1quot; type=quot;textquot; default=quot;quot; label=quot;Zona de publicitate
1quot; description=quot;Selecteaza modulul pentru zona de publicitate 1quot;
size=quot;3quot; />
<param name=quot;zona2quot; type=quot;textquot; default=quot;quot; label=quot;Zona de publicitate
2quot; description=quot;Selecteaza modulul pentru zona de publicitate 2quot;
size=quot;3quot; />
</params>
</config>




                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 31




The folder imagini




                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 32




                        Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 33




The folder tables




File index.html
Ooops! Nu e chiar ceea ce cauti!

File cunoastere_intrebari.php

<?php
class Tablecunoastere_intrebari extends JTable
{

/*
CREATE TABLE `jos_cunoastere_intrebari`
(



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 34

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_test` INT NOT NULL,
`nume_intrebare` TEXT NOT NULL
);
*/

// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
var $id = null;
var $id_test=NULL;
var $nume_intrebare=NULL;

// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{
parent::__construct('#__cunoastere_intrebari', 'id', $db);
}

// validarea datelor daca este cazul
function check()
{
            if(!$this->id_test)
            {
                  $this->setError(JText::_('Eroare - lipseste campul
ID din tabela TEST.'));
                  return false;
            }

            if(!$this->nume_intrebare)
            {
                  $this->setError(JText::_('Eroare - intrebarea nu
poate fi vida.'));
                  return false;
            }
            return true;
}

}
?>

File cunoastere_raspunsuri.php

<?php
class Tablecunoastere_raspunsuri extends JTable
{

/*
CREATE TABLE `jos_cunoastere_raspunsuri`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_intrebari` INT NOT NULL,
`nume_raspuns` TEXT NOT NULL
);
*/

// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita



                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 35

var $id = null;
var $id_intrebari=NULL;
var $nume_raspuns=NULL;

// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{
parent::__construct('#__cunoastere_raspunsuri', 'id', $db);
}

// validarea datelor daca este cazul;
function check()
{
            if(!$this->id_intrebari)
            {
                  $this->setError(JText::_('Eroare - lipseste campul
ID din tabela INTREBARI.'));
                  return false;
            }

            if(!$this->nume_raspuns)
            {
                  $this->setError(JText::_('Eroare - testul nu are
definit un raspuns.'));
                  return false;
            }
            return true;
}

}
?>

File cunoastere_test.php

<?php
class Tablecunoastere_test extends JTable
{

/*
CREATE TABLE `jos_cunoastere_test` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`nume_test` TEXT NOT NULL ,
`descriere_test` TEXT NOT NULL ,
`published` TINYINT( 1 ) NOT NULL DEFAULT 0
);
*/

// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
var $id = null;
var $nume_test=NULL;
var $descriere_test=NULL;
var $published = 0;

// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{



                                    Download
            http://24secunde.com/joomla/media/com_componentamea.zip
Page 36

parent::__construct('#__cunoastere_test', 'id', $db);
}

// validarea datelor daca este cazul; verificam ca testul sa aiba un
titlu si o descriere
function check()
{
            if(!$this->nume_test)
            {
                  $this->setError(JText::_('Eroare - testul nu are
definit un titlu.'));
                  return false;
            }

            if(!$this->descriere_test)
            {
                  $this->setError(JText::_('Eroare - testul nu are
definita o descriere.'));
                  return false;
            }
            return true;
}

}
?>

File cunoastere_user.php

<?php
class Tablecunoastere_user extends JTable
{

/*
CREATE TABLE `jos_cunoastere_user`
(
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`id_test` INT NOT NULL,
`user` VARCHAR(255) NOT NULL,
`punctaj` INT NOT NULL DEFAULT 0
);
*/

// cream variabile pentru fiecare camp din tabel si dam fiecarei
valori o valoare implicita
var $id = null;
var $id_test=NULL;
var $user=NULL;
var $punctaj = 0;

// functia constructor are ca parametru o referinta la baza de date
function __construct( &$db )
{
parent::__construct('#__cunoastere_user', 'id', $db);
}

// validarea datelor daca este cazul;
function check()



                                   Download
           http://24secunde.com/joomla/media/com_componentamea.zip
Page 37

{
            if(!$this->id_test)
            {
                  $this->setError(JText::_('Eroare - lipseste campul
ID din tabela TEST.'));
                  return false;
            }

            if(!$this->user)
            {
                  $this->setError(JText::_('Eroare - testul nu are
definit un USER.'));
                  return false;
            }
            return true;
}

}
?>




                                 Download
         http://24secunde.com/joomla/media/com_componentamea.zip

More Related Content

What's hot

Palestra PythonBrasil[8]
Palestra PythonBrasil[8]Palestra PythonBrasil[8]
Palestra PythonBrasil[8]
Thiago Da Silva
 
Minishell
MinishellMinishell
Minishell
hacker indonesia
 
บทที่ 1 บทนำ
บทที่ 1 บทนำบทที่ 1 บทนำ
บทที่ 1 บทนำNuthapol Jullawan
 
Drupal Cms Prezentace
Drupal Cms PrezentaceDrupal Cms Prezentace
Drupal Cms PrezentaceTomáš Kafka
 
Understanding Social Media’s Impact on Business
Understanding Social Media’s Impact on BusinessUnderstanding Social Media’s Impact on Business
Understanding Social Media’s Impact on Business
Jared Degnan
 
Jsoon
JsoonJsoon
Dennis zapana perez
Dennis zapana perezDennis zapana perez
Dennis zapana perezdennis_elvis
 
Emerging tier 1 & tier 2
Emerging   tier 1 & tier 2Emerging   tier 1 & tier 2
Emerging tier 1 & tier 2matrix3g
 
Trabalhando com imagens no PHP
Trabalhando com imagens no PHPTrabalhando com imagens no PHP
Clase 10 electiva profesional 3 aws rds php y mysql
Clase 10 electiva profesional 3 aws rds php y mysqlClase 10 electiva profesional 3 aws rds php y mysql
Clase 10 electiva profesional 3 aws rds php y mysql
Richard Eliseo Mendoza Gafaro
 
Aimmah Arbah ka Aweedah
Aimmah Arbah ka AweedahAimmah Arbah ka Aweedah
Aimmah Arbah ka Aweedah
Zaffer Khan
 
Zend Framework: abordagem prática
Zend Framework: abordagem práticaZend Framework: abordagem prática
Zend Framework: abordagem prática
Marcelo Andrade
 
Jess
JessJess
إنا كفيناك المستهزئين
إنا كفيناك المستهزئينإنا كفيناك المستهزئين
إنا كفيناك المستهزئينغايتي الجنة
 

What's hot (19)

Palestra PythonBrasil[8]
Palestra PythonBrasil[8]Palestra PythonBrasil[8]
Palestra PythonBrasil[8]
 
New 3
New  3New  3
New 3
 
Minishell
MinishellMinishell
Minishell
 
บทที่ 1 บทนำ
บทที่ 1 บทนำบทที่ 1 บทนำ
บทที่ 1 บทนำ
 
Index2
Index2Index2
Index2
 
Drupal Cms Prezentace
Drupal Cms PrezentaceDrupal Cms Prezentace
Drupal Cms Prezentace
 
Understanding Social Media’s Impact on Business
Understanding Social Media’s Impact on BusinessUnderstanding Social Media’s Impact on Business
Understanding Social Media’s Impact on Business
 
Jsoon
JsoonJsoon
Jsoon
 
Dennis zapana perez
Dennis zapana perezDennis zapana perez
Dennis zapana perez
 
Emerging tier 1 & tier 2
Emerging   tier 1 & tier 2Emerging   tier 1 & tier 2
Emerging tier 1 & tier 2
 
Trabalhando com imagens no PHP
Trabalhando com imagens no PHPTrabalhando com imagens no PHP
Trabalhando com imagens no PHP
 
With enter
With enterWith enter
With enter
 
20091181
2009118120091181
20091181
 
Clase 10 electiva profesional 3 aws rds php y mysql
Clase 10 electiva profesional 3 aws rds php y mysqlClase 10 electiva profesional 3 aws rds php y mysql
Clase 10 electiva profesional 3 aws rds php y mysql
 
Aimmah Arbah ka Aweedah
Aimmah Arbah ka AweedahAimmah Arbah ka Aweedah
Aimmah Arbah ka Aweedah
 
A z railphp v1.0
A z railphp v1.0A z railphp v1.0
A z railphp v1.0
 
Zend Framework: abordagem prática
Zend Framework: abordagem práticaZend Framework: abordagem prática
Zend Framework: abordagem prática
 
Jess
JessJess
Jess
 
إنا كفيناك المستهزئين
إنا كفيناك المستهزئينإنا كفيناك المستهزئين
إنا كفيناك المستهزئين
 

Quiz Component For Joomla

  • 1. Page 1 Quiz component for Joomla 1.The component files: File adauga_test.php: <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); if($user->usertype!=quot;Super Administratorquot;) $mainframe- >redirect('index.php'); ?> <?php $previz=JRequest::getVar('previz',null); if($previz==quot;Previzualizarequot;) { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 2. Page 2 print(quot;<h1>quot;.$titlu_test.quot;</h1>quot;); print(quot;<br/>quot;); print(quot;quot;.$descriere_test.quot;quot;); print(quot;<br/>quot;); print(quot;<br/>quot;); $intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test); foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode(quot;nquot;, $intrebare); $i=1; foreach($intrebare1 as $raspuns) { if($i==1) { print(quot;<h3>quot;.$raspuns.quot;</h3>quot;); $i++; continue; } print('<input name=quot;quot; type=quot;radioquot; value=quot;quot;>'); print($raspuns); print(quot;<br/>quot;); } print(quot;<br/>quot;); } print(quot;<br/>quot;); } if($previz==quot;Inregistreazaquot;) { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); $table_test->reset(); $uniqid=uniqid(quot;quot;); $table_test->set('nume_test', $uniqid); if (!$table_test->store()) print('<h1>Eroare - functia $table_test->store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_test WHERE nume_test=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_test=$db->loadResult(); $table_test->load($id_test); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 3. Page 3 $table_test->set('nume_test', $titlu_test); $table_test->set('descriere_test', addslashes($descriere_test)); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } $intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test); $j=1; foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode(quot;nquot;, $intrebare); $i=1; foreach($intrebare1 as $raspuns) { if($i==1) { if(trim($raspuns)==quot;quot;) continue; $table_intreb->reset(); $table_intreb- >set('nume_intrebare', $uniqid); if (!$table_intreb- >store()) print('<h1>Eroare - functia $table_intreb- >store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_intrebari WHERE nume_intrebare=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_intrebare=$db- >loadResult(); $table_intreb- >load($id_intrebare); $table_intreb- >set('id_test', $id_test); $table_intreb- >set('nume_intrebare', addslashes( $raspuns)); if ($table_intreb->check()) { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 4. Page 4 if (!$table_intreb- >store()) { print('<h1>Eroare - functia $table_intreb->store().</h1>'); } } else { print('<h1>Eroare - functia $table_intreb->check().</h1>'); } $table_intreb->load(0); $i++; continue; } if(trim($raspuns)==quot;quot;) continue; $table_rasp->reset(); $table_rasp->set('nume_raspuns', $uniqid); if (!$table_rasp->store()) print('<h1>Eroare - functia $table_rasp->store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_raspunsuri WHERE nume_raspuns=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_raspuns=$db->loadResult(); $table_rasp->load($id_raspuns); $table_rasp->set('id_intrebari', $id_intrebare); $table_rasp->set('nume_raspuns', addslashes($raspuns)); if ($table_rasp->check()) { if (!$table_rasp->store()) { print('<h1>Eroare - functia $table_rasp->store().</h1>'); } } else { print('<h1>Eroare - functia $table_rasp->check().</h1>'); } $table_rasp->load(0); } } $mainframe- >redirect('index.php?option=com_componentamea&task=adauga'); } if($previz==quot;Reinitializeazaquot;) { $mainframe- >redirect('index.php?option=com_componentamea&task=adauga'); } Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 5. Page 5 ?> <script type=quot;text/javascriptquot;> function introduceti_entitate(tip) { if(tip==quot;intrebarequot;) document.getElementById(quot;editor_testquot;).value=document.getElementById( quot;editor_testquot;).value+quot;<intrebare/>quot;; if(tip==quot;raspunsquot;) document.getElementById(quot;editor_testquot;).value=document.getElementById( quot;editor_testquot;).value+quot;<raspuns/>quot;; if(tip==quot;breakquot;) document.getElementById(quot;editor_testquot;).value=document.getElementById( quot;editor_testquot;).value+quot;<break/>quot;; } </script> <form method=quot;postquot; action=quot;quot;> <strong>Introduceti un titlu pentru testul dumneavoastra: </strong> <input name=quot;titlu_testquot; type=quot;textquot; id=quot;titlu_testquot; style=quot;width:98%quot; value=quot;<?php print($titlu_test); ?>quot; maxlength=quot;255quot;> <strong>Introduceti o descriere pentru testul dumneavoastra: </strong> <textarea id=quot;descriere_testquot; name=quot;descriere_testquot; rows=quot;3quot; cols=quot;1quot; style=quot;width:98%quot;><?php print($descriere_test); ?></textarea> <strong>Introduceti intrebarile care compun testul dumneavoastra: </strong> <div style=quot;border-width:1px; border-style:solid; background- color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px; margin-bottom:2pxquot;> <a href=quot;javascript: void(0);quot; onClick='introduceti_entitate(quot;intrebarequot;)'>Intrebare</a> <a href=quot;javascript: void(0);quot; onClick='introduceti_entitate(quot;raspunsquot;)'>Raspuns</a> <a href=quot;javascript: void(0);quot; onClick='introduceti_entitate(quot;breakquot;)'>Break</a> </div> <textarea id=quot;editor_testquot; name=quot;editor_testquot; rows=quot;20quot; cols=quot;1quot; style=quot;width:98%quot;><?php print($editor_test); ?></textarea> <input name=quot;previzquot; type=quot;submitquot; value=quot;Previzualizarequot;> <input name=quot;previzquot; type=quot;submitquot; value=quot;Inregistreazaquot;> <input name=quot;previzquot; type=quot;submitquot; value=quot;Reinitializeazaquot;> </form> <textarea rows=quot;3quot; cols=quot;1quot; style=quot;width:98%quot;><intrebare/> Care este capitala Timisului? Buzias Timisoara Lugoj <intrebare/> Care este capitala Romaniei? Bucuresti Budapesta Sofia <intrebare/> Care este capitala Turciei? Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 6. Page 6 Ankara Istanbul Atena </textarea> File admin.componentamea.php: <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $task=JRequest::getVar('task',null).quot;quot;; if(!isset($task) || trim($task)==quot;quot;) JRequest::setVar('task','admin_test'); $task=JRequest::getVar('task',null).quot;quot;; if($task==quot;admin_testquot;) include_once(quot;admin.principal.phpquot;); if($task==quot;publishquot;) include_once(quot;admin.publish.phpquot;); if($task==quot;unpublishquot;) include_once(quot;admin.unpublish.phpquot;); if($task==quot;editquot;) include_once(quot;admin.edit.phpquot;); if($task==quot;applyquot;) include_once(quot;admin.edit.phpquot;); if($task==quot;cancelquot;) include_once(quot;admin.edit.phpquot;); if($task==quot;rezult_testquot;) include_once(quot;admin.rezultate.phpquot;); if($task==quot;removequot;) include_once(quot;admin.remove.phpquot;); ?> File admin.edit.php: <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $cid = JRequest::getVar( 'cid', array(0)); $id=$cid[0]; // obtinem o refeinta la clasa JUser $user =& JFactory::getUser(); // obtinem o referinta la baza de date $db =& JFactory::getDBO(); if($task== quot;applyquot;) { $titlu_test=JRequest::getVar('titlu_test',''); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables '); $table_test = JTable::getInstance('cunoastere_test', 'Table'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 7. Page 7 $table_test->load($id); $table_test->set('nume_test', $titlu_test); $table_test->set('descriere_test', addslashes($descriere_test)); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test- >store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } $mainframe- >redirect('index.php?option=com_componentamea&task=edit&mesaj=salvat& cid[]='.$id.''); } if($task== quot;cancelquot;) { $mainframe- >redirect('index.php?option=com_componentamea&task=admin_test'); } $mesaj = JRequest::getVar( 'mesaj', ''); if($mesaj==quot;salvatquot;) { JError::raiseNotice('','Modificarile au fost efectuate.'); } $query=quot;SELECT `id` , `nume_test` , `descriere_test`, `published` FROM `jos_cunoastere_test` WHERE id=quot;.$id.quot;quot;; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { print('<div style=quot;width:50%quot;>'); print('<form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;>'); print('<strong>Introduceti un titlu pentru testul dumneavoastra:</strong>'); print('<input name=quot;titlu_testquot; type=quot;textquot; id=quot;titlu_testquot; style=quot;width:98%quot; value=quot;'.$row->nume_test.'quot; maxlength=quot;255quot;>'); print('<strong>Introduceti o descriere pentru testul dumneavoastra:</strong>'); print('<textarea id=quot;descriere_testquot; name=quot;descriere_testquot; rows=quot;3quot; cols=quot;1quot; style=quot;width:98%quot;>'.stripslashes($row- >descriere_test).'</textarea>'); print('<input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;quot; />'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 8. Page 8 print('</form>'); print('</div>'); } JRequest::setVar('hidemainmenu', 1); ?> File admin.principal.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $ordine=JRequest::getVar('ordine',null); if(!isset($ordine))$ordine=quot;DESCquot;; ?> <form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;> <script type=quot;text/javascriptquot;> function stabileste_ordinea(param) { document.getElementById(quot;ord_txtquot;).value=param; document.getElementById(quot;ord_txtquot;).form.submit(); } </script> <table class=quot;adminlistquot;> <thead> <tr> <th width=quot;20quot; class='title'>#</th> <th width=quot;20quot; class='title'> <input type=quot;checkboxquot; name=quot;togglequot; value=quot;quot; onclick=quot;checkAll(nr_chk);quot; /></th> <th class='title'>Numele testului</th> <th class='title'>Descrierea testului</th> <th width=quot;30quot; class='title'>Publicare test</th> <th width=quot;30quot; class='title'> <a href=quot;javascript: void(0);quot; onClick=quot;stabileste_ordinea('ASC')quot; title=quot;Ascendentquot;>[I</a><a href=quot;javascript: void(0);quot; onClick=quot;stabileste_ordinea('DESC')quot; title=quot;Descendentquot;>d]</a> </th> </tr> </thead> <?php $db =& JFactory::getDBO(); $db->setQuery('SELECT count(*) FROM `jos_cunoastere_test`'); $total = $db->loadResult(); $limit = $mainframe- >getUserStateFromRequest(quot;limitquot;,'limit',$mainframe- >getCfg('list_limit')); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 9. Page 9 if($limit==0)$limit=500; $limitstart = $mainframe- >getUserStateFromRequest(quot;$option.view.limitstartquot;,'limitstart',0); $query='SELECT * FROM `jos_cunoastere_test` ORDER BY id '.$ordine.' LIMIT '.$limitstart.','.$limit.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); $int_j=0; foreach ($rows as $row) { ?> <tr class=quot;row<?php print($int_j%2);?>quot;> <td align=quot;centerquot;><?php print($int_j);?></td> <td><input type=quot;checkboxquot; id=quot;cb<?php print($int_j);?>quot; name=quot;cid[]quot; value=quot;<?php print($row->id);?>quot; onclick=quot;isChecked(this.checked);quot; /></td> <td><?php print('<a href=quot;index.php?option=com_componentamea&task=edit&cid[]='.$row- >id.'quot;>'.$row->nume_test.'</a>');?></td> <td><?php print(stripslashes($row->descriere_test));?></td> <td> <?php if($row->published==1) print('<a href=quot;javascript:void(0);quot; onclick=quot;return listItemTask('cb'.$int_j.'','unpublish')quot; title=quot;Unpublish Itemquot;> <img src=quot;images/tick.pngquot; width=quot;16quot; height=quot;16quot; border=quot;0quot; alt=quot;Noquot; /></a>'); if($row->published==0) print('<a href=quot;javascript:void(0);quot; onclick=quot;return listItemTask('cb'.$int_j.'','publish')quot; title=quot;Publish Itemquot;> <img src=quot;images/publish_x.pngquot; width=quot;16quot; height=quot;16quot; border=quot;0quot; alt=quot;Noquot; /></a>'); ?> </td> <td><?php print($row->id);?></td> </tr> <?php $int_j++; } print('<script type=quot;text/javascriptquot;>'); print('var nr_chk='.$int_j); print('</script>'); ?> <tfoot> <td colspan=quot;10quot;> <?php jimport('joomla.html.pagination'); if($limit==500)$limit=0; $pageNav = new JPagination($total,$limitstart,$limit); print($pageNav->getListFooter()); ?> </td> </tfoot> Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 10. Page 10 </table> <input id=quot;id_txtquot; type=quot;hiddenquot; name=quot;idquot; value=quot;quot; /> <input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;quot; /> <input id=quot;ord_txtquot; type=quot;hiddenquot; name=quot;ordinequot; value=quot;<?php print($ordine); ?>quot; /> <input type=quot;hiddenquot; name=quot;boxcheckedquot; value=quot;0quot; /> </form> File admin.publish.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $cid = JRequest::getVar( 'cid', array(0)); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); foreach($cid as $value) { $id=$value; ?> <?php $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_test->load($id); $table_test->set('published',1); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } ?> <?php } $mainframe->redirect('index.php?option=com_componentamea'); ?> File admin.remove.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $db =& JFactory::getDBO(); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 11. Page 11 $user=JRequest::getVar('user_del',''); $user=$user.''; if(trim($user)==quot;quot;)$user='[{<##>}]'; $test=JRequest::getVar('test_del',0); $test=0+$test; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_user = JTable::getInstance('cunoastere_user', 'Table'); $query='SELECT `id` FROM `jos_cunoastere_user` WHERE id_test='.$test.' OR user LIKE quot;'.$user.'%quot;'; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $table_user->delete($row->id); } $mainframe- >redirect('index.php?option=com_componentamea&task=rezult_test'); ?> File admin.rezultate.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <form action=quot;quot; method=quot;postquot; name=quot;adminFormquot;> <h4>Sterge rezultatele utilizatorului: </h4> <input type=quot;textquot; name=quot;user_delquot; id=quot;user_delquot; class=quot;text_areaquot; /> (Ex: Ion, Rizache, John) % - sterge tot <br/> <h4>Sterge rezultatele care includ testul:</h4> <input type=quot;textquot; name=quot;test_delquot; id=quot;test_delquot; class=quot;text_areaquot; /> (Ex: 1, 100, 2000) <br/><br/> <button onclick=quot;this.form.submit();quot;>Go</button><br/> <input id=quot;id_txtquot; type=quot;hiddenquot; name=quot;idquot; value=quot;quot; /> <input id=quot;task_txtquot; type=quot;hiddenquot; name=quot;taskquot; value=quot;removequot; /> <input type=quot;hiddenquot; name=quot;boxcheckedquot; value=quot;1quot; /> </form> File admin.unpublish.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $cid = JRequest::getVar( 'cid', array(0)); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); foreach($cid as $value) Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 12. Page 12 { $id=$value; ?> <?php $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_test->load($id); $table_test->set('published',0); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } ?> <?php } $mainframe->redirect('index.php?option=com_componentamea'); ?> File componentamea.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php $task=JRequest::getVar('task',null); if($task==quot;adaugaquot;) include_once(quot;adauga_test.phpquot;); if($task==quot;view_testquot;) include_once(quot;vezi_test.phpquot;); if($task==quot;nu_publicaquot;) include_once(quot;nu_publica.phpquot;); if($task==quot;publicaquot;) include_once(quot;publica.phpquot;); if($task==quot;sterge_articolquot;) include_once(quot;sterge_articol.phpquot;); if($task==quot;edit_articolquot;) include_once(quot;edit_articol.phpquot;); if($task==quot;xml_feedquot;) include_once(quot;xml_feed.phpquot;); if(!isset($task)) include_once(quot;principal.phpquot;); ?> File edit_articol.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); if($user->usertype!=quot;Super Administratorquot;) $mainframe- >redirect('index.php'); ?> <?php $db =& JFactory::getDBO(); $id=JRequest::getVar('id',0); $id=$id+0; $query='SELECT * FROM `jos_cunoastere_test` WHERE id='.$id.''; Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 13. Page 13 $result = $db->setQuery($query); $rows = $db->loadObjectList(); $titlu_test =$rows[0]->nume_test; $descriere_test =$rows[0]->descriere_test; $editor_test=quot;quot;; $query='SELECT * FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $editor_test=$editor_test.quot;<intrebare/>quot;.quot;nquot;; $editor_test=$editor_test.$row->nume_intrebare.quot;nquot;; $query_='SELECT * FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari` ='.($row->id).''; $result_ = $db->setQuery($query_); $rows_ = $db->loadObjectList(); foreach($rows_ as $row_) { $editor_test=$editor_test.$row_->nume_raspuns.quot;nquot;; } } $previz=JRequest::getVar('previz',null); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); if($previz==quot;Inregistreazaquot;) { $titlu_test=JRequest::getVar('titlu_test',''); $editor_test=JRequest::getString('editor_test', '', 'POST', JREQUEST_ALLOWRAW); $descriere_test=JRequest::getString('descriere_test', '', 'POST', JREQUEST_ALLOWRAW); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); $table_test->reset(); $uniqid=uniqid(quot;quot;); $table_test->set('nume_test', $uniqid); if (!$table_test->store()) print('<h1>Eroare - functia $table_test->store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_test WHERE nume_test=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_test=$db->loadResult(); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 14. Page 14 $table_test->load($id_test); $table_test->set('nume_test', $titlu_test); $table_test->set('descriere_test', addslashes($descriere_test)); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } $intrebari_teste=explode(quot;<intrebare/>quot;, $editor_test); $j=1; foreach($intrebari_teste as $intrebare) { $intrebare=trim($intrebare); $intrebare1=explode(quot;nquot;, $intrebare); $i=1; foreach($intrebare1 as $raspuns) { if($i==1) { if(trim($raspuns)==quot;quot;) continue; $table_intreb->reset(); $table_intreb- >set('nume_intrebare', $uniqid); if (!$table_intreb- >store()) print('<h1>Eroare - functia $table_intreb- >store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_intrebari WHERE nume_intrebare=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_intrebare=$db- >loadResult(); $table_intreb- >load($id_intrebare); $table_intreb- >set('id_test', $id_test); $table_intreb- >set('nume_intrebare', addslashes( $raspuns)); if ($table_intreb->check()) Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 15. Page 15 { if (!$table_intreb- >store()) { print('<h1>Eroare - functia $table_intreb->store().</h1>'); } } else { print('<h1>Eroare - functia $table_intreb->check().</h1>'); } $table_intreb->load(0); $i++; continue; } if(trim($raspuns)==quot;quot;) continue; $table_rasp->reset(); $table_rasp->set('nume_raspuns', $uniqid); if (!$table_rasp->store()) print('<h1>Eroare - functia $table_rasp->store().</h1>'); $db = &JFactory::getDBO(); $query = 'SELECT id FROM #__cunoastere_raspunsuri WHERE nume_raspuns=quot;'.$uniqid.'quot;'.'ORDER BY id DESC LIMIT 1' ; $db->setQuery($query); $id_raspuns=$db->loadResult(); $table_rasp->load($id_raspuns); $table_rasp->set('id_intrebari', $id_intrebare); $table_rasp->set('nume_raspuns', addslashes($raspuns)); if ($table_rasp->check()) { if (!$table_rasp->store()) { print('<h1>Eroare - functia $table_rasp->store().</h1>'); } } else { print('<h1>Eroare - functia $table_rasp->check().</h1>'); } $table_rasp->load(0); } } $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&id='.$id _test.''); } include_once(quot;adauga_test.phpquot;); ?> Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 16. Page 16 File index.php <?php print(quot;Componenta meaquot;); ?> File nu_publica.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); if($user->usertype!=quot;Super Administratorquot;) $mainframe- >redirect('index.php'); ?> <?php $id=JRequest::getVar('id',0); $id=$id+0; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_test->load($id); $table_test->set('published',0); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { print('<h1>Eroare - functia $table_test->check().</h1>'); } $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); ?> File principal.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php print('<div style=quot;clear:both;quot;></div>'); $url_partaj=JURI::base().quot;index.php?option=com_componentamea%26task=x ml_feed%26format=feedquot;; jimport('joomla.utilities.date'); $date1 = new JDate(); $date1=$date1->toFormat('%d-%m-%Y %H:%M:%S EET'); print('<div style=quot;background-color:#e1e1e1; padding:3px 3px 3px 3px; margin-bottom:5px; font-weight:boldquot;>'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 17. Page 17 print('<div style=quot;float:left;quot;>Ora vizitei: '.$date1.'</div>'); print('<div style=quot;float:right;background-color:#e1e1e1; padding:0px 0px 1px 0px;quot;>'); print('<a href=quot;'.JURI::base().'index.php?option=com_componentamea&task=xml_fee d&format=feedquot; title=quot;RSSquot;><img src=quot;components/com_hello/imagini/rss.gifquot; alt=quot;RSSquot;></a>'); print('<a href=quot;http://add.my.yahoo.com/rss?url='.$url_partaj.'quot; title=quot;Yahooquot;><img src=quot;components/com_hello/imagini/yahoo.gifquot; alt=quot;Yahooquot;></a>'); print('<a href=quot;http://fusion.google.com/add?feedurl='.$url_partaj.'quot; title=quot;Googlequot;><img src=quot;components/com_hello/imagini/google.gifquot; alt=quot;Googlequot;></a>'); print('<a href=quot;http://www.netvibes.com/subscribe.php?url='.$url_partaj.'quot; title=quot;Netvibesquot;><img src=quot;components/com_hello/imagini/netvibes.gifquot; alt=quot;Netvibesquot;></a>'); print('</div>'); print('.</div>'); print('<div style=quot;clear:both;quot;></div>'); $tip_user=quot;Super Administratorquot;; // setam titlul ce apare in browser $document =& JFactory::getDocument(); $document->setTitle(quot;Teste de cunoasterequot;); // setam parametrii pentru bara de navigatie $limit = 20; $limitstart = JRequest::getVar('limitstart',0); $limitstart = 0 + intval($limitstart); $total = 0; //numarul total de articole // obtinem o refeinta la clasa JUser $user =& JFactory::getUser(); // obtinem o referinta la baza de date $db =& JFactory::getDBO(); // avem interogari diferite pentru un user obisnuit si un administrator // administratorul poate sa aiba acces la toate inregistrarile, si la cele marcate ca nepublicate // interogarea urmatoare va intoarce numarul total de teste din baza de date; informatia este necesara pentru bara de navigatie if($user->usertype==$tip_user) $query=quot;SELECT count(*) FROM `jos_cunoastere_test` WHERE 1 quot;; else $query=quot;SELECT count(*) FROM `jos_cunoastere_test` WHERE `published`=1 quot;; $result = $db->setQuery($query); $total=$db->loadResult(); if($user->usertype==quot;Super Administratorquot;) $query=quot;SELECT `id` , `nume_test` , `descriere_test` FROM `jos_cunoastere_test` WHERE 1 ORDER BY `id` DESC LIMIT quot;.$limitstart.quot; , quot;.$limit.quot;quot;; else Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 18. Page 18 $query=quot;SELECT `id` , `nume_test` , `descriere_test` FROM `jos_cunoastere_test` WHERE `published`=1 ORDER BY `id` DESC LIMIT quot;.$limitstart.quot; , quot;.$limit.quot;quot;; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach ($rows as $row) { print('<a href=quot;index.php?option=com_componentamea&task=view_test&id='.$row- >id.'quot; style=quot;text-decoration:none; cursor: pointer; quot; title=quot;'.$row- >nume_test.'quot;><h3>'.$row->nume_test.'</h3></a>'); print(stripslashes($row->descriere_test)); print(quot;<br/>quot;); print(quot;<br/>quot;); } jimport('joomla.html.pagination'); $_pagination = new JPagination($total, $limitstart, $limit); ?> <div style=quot;clear:bothquot;></div> <div class=quot;pagenavquot; style=quot;text-align:center; margin-top:10px; quot;> <?php print($_pagination->getPagesLinks()); ?> <br/> <?php print($_pagination->getPagesCounter()); ?> </div> File publica.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); if($user->usertype!=quot;Super Administratorquot;) $mainframe- >redirect('index.php'); ?> <?php $id=JRequest::getVar('id',0); $id=$id+0; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_test->load($id); $table_test->set('published',1); if ($table_test->check()) { if (!$table_test->store()) { print('<h1>Eroare - functia $table_test->store().</h1>'); } } else { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 19. Page 19 print('<h1>Eroare - functia $table_test->check().</h1>'); } $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); ?> File sterge_articol.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); if($user->usertype!=quot;Super Administratorquot;) $mainframe- >redirect('index.php'); ?> <?php $db =& JFactory::getDBO(); $id=JRequest::getVar('id',0); $id=$id+0; JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); $table_test = JTable::getInstance('cunoastere_test', 'Table'); $table_intreb = JTable::getInstance('cunoastere_intrebari', 'Table'); $table_rasp = JTable::getInstance('cunoastere_raspunsuri', 'Table'); $table_test->delete($id); $query='SELECT `id` FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $query_='SELECT id FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari` ='.($row->id).''; $result_ = $db->setQuery($query_); $rows_ = $db->loadObjectList(); foreach($rows_ as $row_) { $table_rasp->delete($row_->id); } $table_intreb->delete($row->id); } $mainframe->redirect('index.php?option=com_componentamea'); ?> File toolbar.componentamea.php <?php // nu permite accesul direct la acest fisier defined('_JEXEC') or die('<center>Restricted access.</center>'); ?> <?php if($task==quot;admin_testquot;) { JToolBarHelper::title('Administrare teste'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 20. Page 20 JToolBarHelper::editList(); JToolBarHelper::divider(); JToolBarHelper::publishList(); JToolBarHelper::unpublishList(); JToolBarHelper::divider(); JToolBarHelper::preferences('com_componentamea'); } if($task==quot;editquot; || $task==quot;applyquot; ) { JToolBarHelper::title('Editare test'); JToolBarHelper::apply(); JToolBarHelper::cancel(); } if($task==quot;rezult_testquot;) { JToolBarHelper::title('Rezultate teste'); JToolBarHelper::deleteList(); } ?> File vezi_test.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php $user =& JFactory::getUser(); $db =& JFactory::getDBO(); $id=JRequest::getVar('id',0); $id=$id+0; $previz=JRequest::getVar('previz',null); if($previz==quot;Reinitializeazaquot;) { $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&id='.$id .''); } if($previz==quot;Inregistreazaquot;) { if(!isset($user->name)) $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&alert_us er=not&id='.$id.''); $sir=quot;quot;.JRequest::getVar('sir',''); $sir_array=explode(quot;:quot;,$sir); if(!isset($sir_array[2])) $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&alert_us er=script&id='.$id.''); jimport('joomla.utilities.date'); $date_ = new JDate(); $date = $date_->toFormat('%d/%m/%Y'); JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 21. Page 21 $table_user = JTable::getInstance('cunoastere_user', 'Table'); $table_user->reset(); $table_user->set('id_test', $sir_array[2]); $table_user->set('user', $user->name.quot; :: quot;.$date); $table_user->set('punctaj', $sir_array[1]*1000+$sir_array[0]); if ($table_user->check()) { if (!$table_user->store()) { print('<h1>Eroare - functia $table_user->store().</h1>'); } } else { print('<h1>Eroare - functia $table_user->check().</h1>'); } $mainframe- >redirect('index.php?option=com_componentamea&task=view_test&alert_us er=BD&id='.$id.''); } $query=quot;SELECT `id` , `nume_test` , `descriere_test`, `published` FROM `jos_cunoastere_test` WHERE id=quot;.$id.quot;quot;; $result = $db->setQuery($query); $rows = $db->loadObjectList(); $url_partaj=JURI::base().quot;index.php?option=com_componentamea%26task=v iew_test%26id=quot;.$id; foreach($rows as $row) { if($user->usertype!=quot;Super Administratorquot;) { print('<div style=quot;float:right;quot;>'); print('<a href=quot;http://www.facebook.com/sharer.php?u='.$url_partaj.'quot; title=quot;Partajeaza pe Facebookquot;><img src=quot;components/com_hello/imagini/facebook.gifquot; alt=quot;Facebookquot;></a>'); print('<a href=quot;http://digg.com/submit?phase=2&url='.$url_partaj.'quot; title=quot;Partajeaza pe Diggquot;><img src=quot;components/com_hello/imagini/diggit.gifquot; alt=quot;Diggitquot;></a>'); print('<a href=quot;http://del.icio.us/post?url='.$url_partaj.'&title='.$row- >title.'quot; title=quot;Partajeaza pe Deliciousquot;><img src=quot;components/com_hello/imagini/delicious.gifquot; alt=quot;Deliciousquot;></a>'); print('<a href=quot;https://favorites.live.com/quickadd.aspx?marklet=1&top=1&url='. $url_partaj.'quot; title=quot;Partajeaza pe Livequot;><img src=quot;components/com_hello/imagini/live.gifquot; alt=quot;Livequot;></a>'); Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 22. Page 22 print('<a href=quot;http://blogmarks.net/my/new.php?mini=1&simple=1&url='.$url_part aj.'&title='.$row->nume_test.'quot; title=quot;Partajeaza pe Blogmarksquot;><img src=quot;components/com_hello/imagini/blogmarks.gifquot; alt=quot;Blogmarksquot;></a>'); print('<a href=quot;http://www.technorati.com/faves?add='.$url_partaj.'quot; title=quot;Partajeaza pe Technoratiquot;><img src=quot;components/com_hello/imagini/technorati.gifquot; alt=quot;Technoratiquot;></a>'); print('<a href=quot;http://www.myspace.com/Modules/PostTo/Pages/?c='.$url_partaj.'quot; title=quot;Partajeaza pe Myspacequot;><img src=quot;components/com_hello/imagini/myspace.gifquot; alt=quot;Myspacequot;></a>'); print('<a href=quot;http://twitthis.com/twit?url='.$url_partaj.'&title='.$row- >nume_test.'quot; title=quot;Partajeaza pe Twitterquot;><img src=quot;components/com_hello/imagini/twitter.gifquot; alt=quot;Twitterquot;></a>'); print('</div>'); } if($user->usertype==quot;Super Administratorquot;) { print('<div style=quot;float:right;quot;>'); if($row->published==1) print('<a href=quot;index.php?option=com_componentamea&task=nu_publica&id='.$row- >id.'quot; title=quot;Nu publica acest articolquot;><img src=quot;components/com_componentamea/imagini/yes.pngquot; alt=quot;yes.pngquot;></a>'); if($row->published==0) print('<a href=quot;index.php?option=com_componentamea&task=publica&id='.$row- >id.'quot; title=quot;Publica articolquot;><img src=quot;components/com_componentamea/imagini/no.pngquot; alt=quot;no.pngquot;></a>'); print('<a href=quot;index.php?option=com_componentamea&task=edit_articol&id='.$row- >id.'quot; title=quot;Editeaza articolquot;><img src=quot;components/com_componentamea/imagini/edit.pngquot; alt=quot;edit.pngquot;></a>'); print('<a href=quot;index.php?option=com_componentamea&task=sterge_articol&id='.$ro w->id.'quot; title=quot;Sterge articolquot;><img src=quot;components/com_componentamea/imagini/del.pngquot; alt=quot;del.pngquot;></a>'); print('</div>'); } print('<div style=quot;clear:both;quot;></div>'); $alert_user=JRequest::getVar('alert_user',''); $alert_user=$alert_user.quot;quot;; if($alert_user==quot;notquot;) { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 23. Page 23 print('<div style=quot;width:98%; border-width:1px; border-style:solid; background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding- bottom:2px; margin-bottom:2pxquot;>'); print('<h4>Trebuie sa va conectati ca sa puteti inregistra rezultatele testelor.</h4>'); print('</div>'); } if($alert_user==quot;scriptquot;) { print('<div style=quot;width:98%; border-width:1px; border-style:solid; background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding- bottom:2px; margin-bottom:2pxquot;>'); print('<h4>Programul necesita Javascript pentru a rula.</h4>'); print('</div>'); } if($alert_user==quot;BDquot;) { print('<div style=quot;width:98%; border-width:1px; border-style:solid; background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding- bottom:2px; margin-bottom:2pxquot;>'); print('<h4>Rezultatul testului a fost inregistrat in baza de date.</h4>'); print('</div>'); } $document =& JFactory::getDocument(); $document->setTitle($row->nume_test); print(quot;<h1>quot;.$row->nume_test.quot;</h1>quot;); print(quot;<br/>quot;); print(quot;quot;.stripslashes($row->descriere_test).quot;quot;); print(quot;<br/>quot;); print(quot;<br/>quot;); $id_test=$row->id; $tablou_int=array(); $tablou_raspuns=array(); $query = 'SELECT `id` , `nume_intrebare` FROM `jos_cunoastere_intrebari` WHERE `id_test` ='.$id_test.''; $result = $db->setQuery($query); $rows = $db->loadObjectList(); ?> <script type=quot;text/javascriptquot;> var radio=new Array(); var raspuns_dat=new Array(); var rasp_date=0; var total=0; function verifica(param, param2) { var diviz=quot;div[quot;+param2+quot;]quot;; if(radio[param2]==param.value) { //visibility:visible Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 24. Page 24 document.getElementById(diviz).style.visibility=quot;visiblequot;; document.getElementById(diviz).style.color=quot;greenquot;; document.getElementById(diviz).innerHTML=quot;Raspuns corectquot;; if(raspuns_dat[param2]==-1) { raspuns_dat[param2]=raspuns_dat[param2]+2; rasp_date=rasp_date+raspuns_dat[param2]; total++; document.getElementById(quot;div_raspunsquot;).innerHTML=quot;Total test: quot;+ rasp_date + quot; / quot; + total + quot; : quot;+ parseInt(rasp_date*100/total) +quot;%quot;; } } else { document.getElementById(diviz).style.visibility=quot;visiblequot;; document.getElementById(diviz).style.color=quot;redquot;; document.getElementById(diviz).innerHTML=quot;Raspuns incorectquot;; if(raspuns_dat[param2]==-1) { raspuns_dat[param2]=raspuns_dat[param2]+1; rasp_date=rasp_date+raspuns_dat[param2]; total++; document.getElementById(quot;div_raspunsquot;).innerHTML=quot;Total test: quot;+ rasp_date + quot; / quot; + total + quot; : quot;+ parseInt(rasp_date*100/total) +quot;%quot;; } } } </script> <?php if($user->usertype!=quot;Super Administratorquot;) { $doc =& JFactory::getDocument(); $params =&$mainframe- >getPageParameters('com_componentamea'); $zone = $params->get('zona1'); if($doc->countModules('publicitate') && $doc- >countModules('publicitate')>$zone) { jimport('joomla.application.module.helper'); $module = JModuleHelper::getModules('publicitate'); echo JModuleHelper::renderModule($module[$zone]); } } foreach($rows as $row) { print(quot;<h3>quot;.stripslashes($row->nume_intrebare).quot;</h3>quot;); $id_intreb=$row->id; $tablou_int[]=$id_intreb; Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 25. Page 25 $query='SELECT `id`,`nume_raspuns` FROM `jos_cunoastere_raspunsuri` WHERE `id_intrebari`='.$id_intreb.''; $result_ = $db->setQuery($query); $rows_ = $db->loadObjectList(); $tablou_rasp=array(); $tablou_rasp_indice=array(); foreach($rows_ as $row_) { $tablou_rasp_indice[]=$row_->id; $tablou_rasp[$row_->id]=stripslashes($row_- >nume_raspuns); } $tablou_raspuns[]=$tablou_rasp_indice[0]; print('<script type=quot;text/javascriptquot;>'); print('radio['.$id_intreb.']='.$tablou_rasp_indice[0].';'); print('raspuns_dat['.$id_intreb.']=-1;'); print('var test_id='.$id_test.';'); print('</script>'); srand((double)microtime()*1000000); shuffle($tablou_rasp_indice); foreach($tablou_rasp_indice as $value) { print('<input name=quot;radio'.$id_intreb.'quot; type=quot;radioquot; value=quot;'.$value.'quot; onclick=quot;verifica('.this.','.$id_intreb.')quot;>'); print($tablou_rasp[$value]); print(quot;<br/>quot;); } print('<div id=quot;div['.$id_intreb.']quot; style=quot;visibility:hidden; width:50%; border-width:1px; border-style:solid; background- color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px; margin-bottom:2pxquot;></div>'); print(quot;<br/>quot;); } } print('<script type=quot;text/javascriptquot;>'); print('var total_ver='.count($tablou_int).';'); print('</script>'); ?> <h3>Rezultat test</h3> <div id=quot;div_raspunsquot; style=quot;width:50%; border-width:1px; border- style:solid; background-color:#CCCCCC; padding-top:2px; padding- left:2px; padding-bottom:2px; margin-bottom:2pxquot;> Nici un rezultat inca. </div> <script type=quot;text/javascriptquot;> var tip_submit=null; function verifica_form() { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 26. Page 26 document.getElementById(quot;sirquot;).value=rasp_date+quot;:quot;+total+quot;:quot;+ test_id; if(tip_submit.value==quot;Reinitializeazaquot;) return true; if(tip_submit.value==quot;Inregistreazaquot;) { if(total_ver==total) { return true; } else return false; } } </script> <form action=quot;quot; method=quot;postquot; onSubmit=quot;return verifica_form();quot;> <input id=quot;sirquot; name=quot;sirquot; type=quot;hiddenquot; value=quot;quot;> <input name=quot;previzquot; type=quot;submitquot; value=quot;Inregistreazaquot; onClick=quot;tip_submit=this;quot;> sau <input name=quot;previzquot; type=quot;submitquot; value=quot;Reinitializeazaquot; onClick=quot;tip_submit=this;quot;> </form> <?php print(quot;<br/>quot;); $query='SELECT DISTINCT `id_test` FROM `jos_cunoastere_user` ORDER BY id DESC LIMIT 0, 10'; $result = $db->setQuery($query); $rows = $db->loadObjectList(); $teste_recom=array(); foreach($rows as $row) { $teste_recom[]=$row->id_test; } print(quot;<h3>Alte teste de cunostinte recomandate:</h3>quot;); foreach($teste_recom as $value) { $query='SELECT `id`,`nume_test` FROM `jos_cunoastere_test` WHERE id='.$value.' AND `published`=1 '; $result = $db->setQuery($query); $rows = $db->loadObjectList(); if(trim($rows[0]->nume_test.quot;quot;)==quot;quot;)continue; print('<a href=quot;index.php?option=com_componentamea&task=view_test&id='.($rows[0 ]->id).'quot; style=quot;text-decoration:nonequot; title=quot;Citeste mai mult...quot;>'); print($rows[0]->nume_test); print('</a><br/>'); } if(isset($user->name)) { print(quot;<h4>quot;); print(quot;Rezultate obtinute la test:quot;);print(quot;</h4>quot;); $id_test=0+$id_test; Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 27. Page 27 $query='SELECT `user` , `punctaj` FROM `jos_cunoastere_user` WHERE `id_test` ='.$id_test.' AND `user` LIKE quot;'.($user->name).'%quot; ORDER BY id DESC LIMIT 0 , 30'; $result = $db->setQuery($query); $rows = $db->loadObjectList(); foreach($rows as $row) { $user_data=explode(quot;::quot;,$row->user); print($user_data[1]); print(quot; quot;); $total_intreb=(int)($row->punctaj/1000); $total_dat=(int) ($row->punctaj- $total_intreb*1000); print(quot; quot;.$total_dat.quot;/quot;);print(quot;quot;.$total_intreb.quot; quot;); print(quot;Procentaj: quot;.(int)($total_dat*100/$total_intreb).quot;%quot;); print(quot;<br/>quot;); } } if($user->usertype!=quot;Super Administratorquot;) { $doc =& JFactory::getDocument(); $params =&$mainframe- >getPageParameters('com_componentamea'); $zone = $params->get('zona2'); if($doc->countModules('publicitate') && $doc- >countModules('publicitate')>$zone) { jimport('joomla.application.module.helper'); $module = JModuleHelper::getModules('publicitate'); echo JModuleHelper::renderModule($module[$zone]); } } ?> File xml_feed.php <?php defined(quot;_JEXECquot;) or exit(quot;Restricted accessquot;); ?> <?php /// Pasul 1 - stabileste linkul de baza $document = & JFactory::getDocument();; $document->setLink(JRoute::_('index.php?option=com_componentamea')); $db =& JFactory::getDBO(); $query=quot;SELECT * FROM `jos_cunoastere_test` WHERE `published`=1 ORDER BY `id` DESC LIMIT 0,30quot;; $db->setQuery($query); $rows = $db->loadObjectList(); $document->description=quot;Fluxul RSS pentru componenta de testequot;; foreach ($rows as $row) { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 28. Page 28 $item = new JFeedItem(); $item->description =stripslashes($row- >descriere_test).quot;<br/>quot;.quot;<br/>quot;; $item->link = JRoute::_('index.php?option=com_componentamea&task=view_test&id='.$ro w->id); $item->title = $row->nume_test; $document->addItem($item); } jimport('joomla.utilities.date'); $date1 = new JDate(); $item->description=$date1->toFormat('%d-%m-%Y'); $item->link = JRoute::_('index.php?option=com_componentamea'); $item->title = quot;Data de generare a fluxuluiquot;; $document->addItem($item); $document->render(); ?> File componenta mea.xml <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <!DOCTYPE install SYSTEM quot;http://dev.joomla.org/xml/1.5/component- install.dtdquot;> <install type=quot;componentquot; version=quot;1.5quot;> <name>Componenta mea</name> <creationDate>Martie 2009</creationDate> <author>Farcas Adrian</author> <authorEmail>farcas88@yahoo.com</authorEmail> <authorUrl>http://24secunde.com</authorUrl> <copyright>Copyright</copyright> <license>Licenta</license> <version>Versiunea 1.0</version> <description>Componenta de test</description> <administration> <menu>Admin Teste</menu> <submenu> <menu task=quot;rezult_testquot; img=quot;js/ThemeOffice/component.pngquot;>Administrare rezultate teste</menu> <menu task=quot;admin_testquot; img=quot;js/ThemeOffice/component.pngquot;>Administrare teste</menu> </submenu> <files> <filename>admin.componentamea.php</filename> <filename>admin.edit.php</filename> <filename>admin.principal.php</filename> <filename>admin.publish.php</filename> <filename>admin.remove.php</filename> <filename>admin.rezultate.php</filename> <filename>admin.unpublish.php</filename> <filename>componenta mea.xml</filename> <filename>config.xml</filename> <filename>index.php</filename> <filename>toolbar.componentamea.php</filename> Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 29. Page 29 <folder>imagini</folder> <folder>tables</folder> </files> </administration> <install> <queries> <query>DROP TABLE IF EXISTS `jos_cunoastere_intrebari`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_raspunsuri`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_test`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_user`;</query> <query>CREATE TABLE `jos_cunoastere_intrebari` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `nume_intrebare` TEXT NOT NULL ) </query> <query>CREATE TABLE `jos_cunoastere_raspunsuri` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_intrebari` INT NOT NULL, `nume_raspuns` TEXT NOT NULL ) </query> <query>CREATE TABLE `jos_cunoastere_test` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `nume_test` TEXT NOT NULL , `descriere_test` TEXT NOT NULL , `published` TINYINT( 1 ) NOT NULL DEFAULT 0 ) </query> <query>CREATE TABLE `jos_cunoastere_user` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `user` VARCHAR(255) NOT NULL, `punctaj` INT NOT NULL DEFAULT 0 ) </query> <query> <![CDATA[ INSERT INTO `jos_cunoastere_test` ( `id` , `nume_test` , `descriere_test` , `published` ) VALUES ( '', 'Primul tau test aici / Your first quiz here:', 'Log in as Administrator and click: <a href=quot;index.php?option=com_componentamea&task=adaugaquot; title=quot;quot;>index.php?option=com_componentamea&task=adauga</a>', '1' ) ]]> Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 30. Page 30 </query> </queries> </install> <uninstall> <queries> <query>DROP TABLE IF EXISTS `jos_cunoastere_intrebari`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_raspunsuri`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_test`;</query> <query>DROP TABLE IF EXISTS `jos_cunoastere_user`;</query> </queries> </uninstall> <files> <filename>adauga_test.php</filename> <filename>componentamea.php</filename> <filename>edit_articol.php</filename> <filename>index.php</filename> <filename>nu_publica.php</filename> <filename>principal.php</filename> <filename>publica.php</filename> <filename>sterge_articol.php</filename> <filename>vezi_test.php</filename> <filename>xml_feed.php</filename> <folder>imagini</folder> </files> </install> File config.xml <?xml version=quot;1.0quot; encoding=quot;utf-8quot;?> <config> <params> <param name=quot;zona1quot; type=quot;textquot; default=quot;quot; label=quot;Zona de publicitate 1quot; description=quot;Selecteaza modulul pentru zona de publicitate 1quot; size=quot;3quot; /> <param name=quot;zona2quot; type=quot;textquot; default=quot;quot; label=quot;Zona de publicitate 2quot; description=quot;Selecteaza modulul pentru zona de publicitate 2quot; size=quot;3quot; /> </params> </config> Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 31. Page 31 The folder imagini Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 32. Page 32 Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 33. Page 33 The folder tables File index.html Ooops! Nu e chiar ceea ce cauti! File cunoastere_intrebari.php <?php class Tablecunoastere_intrebari extends JTable { /* CREATE TABLE `jos_cunoastere_intrebari` ( Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 34. Page 34 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `nume_intrebare` TEXT NOT NULL ); */ // cream variabile pentru fiecare camp din tabel si dam fiecarei valori o valoare implicita var $id = null; var $id_test=NULL; var $nume_intrebare=NULL; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { parent::__construct('#__cunoastere_intrebari', 'id', $db); } // validarea datelor daca este cazul function check() { if(!$this->id_test) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela TEST.')); return false; } if(!$this->nume_intrebare) { $this->setError(JText::_('Eroare - intrebarea nu poate fi vida.')); return false; } return true; } } ?> File cunoastere_raspunsuri.php <?php class Tablecunoastere_raspunsuri extends JTable { /* CREATE TABLE `jos_cunoastere_raspunsuri` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_intrebari` INT NOT NULL, `nume_raspuns` TEXT NOT NULL ); */ // cream variabile pentru fiecare camp din tabel si dam fiecarei valori o valoare implicita Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 35. Page 35 var $id = null; var $id_intrebari=NULL; var $nume_raspuns=NULL; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { parent::__construct('#__cunoastere_raspunsuri', 'id', $db); } // validarea datelor daca este cazul; function check() { if(!$this->id_intrebari) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela INTREBARI.')); return false; } if(!$this->nume_raspuns) { $this->setError(JText::_('Eroare - testul nu are definit un raspuns.')); return false; } return true; } } ?> File cunoastere_test.php <?php class Tablecunoastere_test extends JTable { /* CREATE TABLE `jos_cunoastere_test` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `nume_test` TEXT NOT NULL , `descriere_test` TEXT NOT NULL , `published` TINYINT( 1 ) NOT NULL DEFAULT 0 ); */ // cream variabile pentru fiecare camp din tabel si dam fiecarei valori o valoare implicita var $id = null; var $nume_test=NULL; var $descriere_test=NULL; var $published = 0; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 36. Page 36 parent::__construct('#__cunoastere_test', 'id', $db); } // validarea datelor daca este cazul; verificam ca testul sa aiba un titlu si o descriere function check() { if(!$this->nume_test) { $this->setError(JText::_('Eroare - testul nu are definit un titlu.')); return false; } if(!$this->descriere_test) { $this->setError(JText::_('Eroare - testul nu are definita o descriere.')); return false; } return true; } } ?> File cunoastere_user.php <?php class Tablecunoastere_user extends JTable { /* CREATE TABLE `jos_cunoastere_user` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id_test` INT NOT NULL, `user` VARCHAR(255) NOT NULL, `punctaj` INT NOT NULL DEFAULT 0 ); */ // cream variabile pentru fiecare camp din tabel si dam fiecarei valori o valoare implicita var $id = null; var $id_test=NULL; var $user=NULL; var $punctaj = 0; // functia constructor are ca parametru o referinta la baza de date function __construct( &$db ) { parent::__construct('#__cunoastere_user', 'id', $db); } // validarea datelor daca este cazul; function check() Download http://24secunde.com/joomla/media/com_componentamea.zip
  • 37. Page 37 { if(!$this->id_test) { $this->setError(JText::_('Eroare - lipseste campul ID din tabela TEST.')); return false; } if(!$this->user) { $this->setError(JText::_('Eroare - testul nu are definit un USER.')); return false; } return true; } } ?> Download http://24secunde.com/joomla/media/com_componentamea.zip