Professional Documents
Culture Documents
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 2
You can use HTML code in questions or in answers. You CAN’T use
newline “\n” in questions or answers. The newline is used to break the
quiz in questions and answers and is reserved. The newline is the last
escape character in every row. Usually, you push ENTER to introduce a
newline.
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 3
File adauga_test.php:
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $mainframe-
>redirect('index.php');
?>
<?php
$previz=JRequest::getVar('previz',null);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 4
if($previz=="Previzualizare")
{
$titlu_test=JRequest::getVar('titlu_test','');
$editor_test=JRequest::getString('editor_test', '', 'POST',
JREQUEST_ALLOWRAW);
$descriere_test=JRequest::getString('descriere_test', '', 'POST',
JREQUEST_ALLOWRAW);
print("<h1>".$titlu_test."</h1>"); print("<br/>");
print("".$descriere_test.""); print("<br/>"); print("<br/>");
$intrebari_teste=explode("<intrebare/>", $editor_test);
foreach($intrebari_teste as $intrebare)
{
$intrebare=trim($intrebare);
$intrebare1=explode("\n", $intrebare);
$i=1;
foreach($intrebare1 as $raspuns)
{
if($i==1)
{
print("<h3>".$raspuns."</h3>");
$i++; continue;
}
print('<input name=""
type="radio" value="">');
print($raspuns);
print("<br/>");
}
print("<br/>");
}
print("<br/>");
}
if($previz=="Inregistreaza")
{
$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("");
$table_test->set('nume_test', $uniqid);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 5
$db = &JFactory::getDBO();
$query = 'SELECT id FROM #__cunoastere_test WHERE
nume_test="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ;
$db->setQuery($query);
$id_test=$db->loadResult();
$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("<intrebare/>", $editor_test);
$j=1;
foreach($intrebari_teste as $intrebare)
{
$intrebare=trim($intrebare);
$intrebare1=explode("\n", $intrebare);
$i=1;
foreach($intrebare1 as $raspuns)
if($i==1)
{
if(trim($raspuns)=="")
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="'.$uniqid.'"'.'ORDER BY
id DESC LIMIT 1' ;
$db->setQuery($query);
$id_intrebare=$db-
>loadResult();
$table_intreb-
>load($id_intrebare);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 6
$table_intreb-
>set('id_test', $id_test);
$table_intreb-
>set('nume_intrebare', addslashes( $raspuns));
if ($table_intreb->check())
{
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)=="") 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="'.$uniqid.'"'.'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');
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 7
if($previz=="Reinitializeaza")
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=adauga');
}
?>
<script type="text/javascript">
function introduceti_entitate(tip)
{
if(tip=="intrebare")
document.getElementById("editor_test").value=document.getElementById(
"editor_test").value+"<intrebare/>";
if(tip=="raspuns")
document.getElementById("editor_test").value=document.getElementById(
"editor_test").value+"<raspuns/>";
if(tip=="break")
document.getElementById("editor_test").value=document.getElementById(
"editor_test").value+"<break/>";
}
</script>
<form method="post" action="">
<strong>Introduceti un titlu pentru testul dumneavoastra:
</strong>
<input name="titlu_test" type="text" id="titlu_test"
style="width:98%" value="<?php print($titlu_test); ?>"
maxlength="255">
<strong>Introduceti o descriere pentru testul dumneavoastra:
</strong>
<textarea id="descriere_test" name="descriere_test" rows="3" cols="1"
style="width:98%"><?php print($descriere_test); ?></textarea>
<strong>Introduceti intrebarile care compun testul dumneavoastra:
</strong>
<div style="border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2px">
<a href="javascript: void(0);"
onClick='introduceti_entitate("intrebare")'>Intrebare</a>
<a href="javascript: void(0);"
onClick='introduceti_entitate("raspuns")'>Raspuns</a>
<a href="javascript: void(0);"
onClick='introduceti_entitate("break")'>Break</a>
</div>
<textarea id="editor_test" name="editor_test" rows="20" cols="1"
style="width:98%"><?php print($editor_test); ?></textarea>
<input name="previz" type="submit" value="Previzualizare">
<input name="previz" type="submit" value="Inregistreaza">
<input name="previz" type="submit" value="Reinitializeaza">
</form>
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 8
<intrebare/>
Care este capitala Romaniei?
Bucuresti
Budapesta
Sofia
<intrebare/>
Care este capitala Turciei?
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)."";
if(!isset($task) || trim($task)=="")
JRequest::setVar('task','admin_test');
$task=JRequest::getVar('task',null)."";
if($task=="admin_test") include_once("admin.principal.php");
if($task=="publish") include_once("admin.publish.php");
if($task=="unpublish") include_once("admin.unpublish.php");
if($task=="edit") include_once("admin.edit.php");
if($task=="apply") include_once("admin.edit.php");
if($task=="cancel") include_once("admin.edit.php");
if($task=="rezult_test") include_once("admin.rezultate.php");
if($task=="remove") include_once("admin.remove.php");
?>
File admin.edit.php:
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
if($task== "apply")
{
$titlu_test=JRequest::getVar('titlu_test','');
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 9
$descriere_test=JRequest::getString('descriere_test', '',
'POST', JREQUEST_ALLOWRAW);
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables
');
$table_test = JTable::getInstance('cunoastere_test', 'Table');
$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== "cancel")
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=admin_test');
}
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 10
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="DESC";
?>
<script type="text/javascript">
function stabileste_ordinea(param)
{
document.getElementById("ord_txt").value=param;
document.getElementById("ord_txt").form.submit();
}
</script>
<table class="adminlist">
<thead>
<tr>
<th width="20" class='title'>#</th>
<th width="20" class='title'>
<input type="checkbox" name="toggle" value=""
onclick="checkAll(nr_chk);" /></th>
<th class='title'>Numele testului</th>
<th class='title'>Descrierea testului</th>
<th width="30" class='title'>Publicare test</th>
<th width="30" class='title'>
<a href="javascript: void(0);" onClick="stabileste_ordinea('ASC')"
title="Ascendent">[I</a><a href="javascript: void(0);"
onClick="stabileste_ordinea('DESC')" title="Descendent">d]</a>
</th>
</tr>
</thead>
<?php
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 11
$limit = $mainframe-
>getUserStateFromRequest("limit",'limit',$mainframe-
>getCfg('list_limit'));
if($limit==0)$limit=500;
$limitstart = $mainframe-
>getUserStateFromRequest("$option.view.limitstart",'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="row<?php print($int_j%2);?>">
<td align="center"><?php print($int_j);?></td>
<td><input type="checkbox" id="cb<?php print($int_j);?>" name="cid[]"
value="<?php print($row->id);?>" onclick="isChecked(this.checked);"
/></td>
<td><?php print('<a
href="index.php?option=com_componentamea&task=edit&cid[]='.$row-
>id.'">'.$row->nume_test.'</a>');?></td>
<td><?php print(stripslashes($row->descriere_test));?></td>
<td>
<?php
if($row->published==1)
print('<a href="javascript:void(0);" onclick="return
listItemTask(\'cb'.$int_j.'\',\'unpublish\')" title="Unpublish Item">
<img src="images/tick.png" width="16" height="16" border="0"
alt="No" /></a>');
if($row->published==0)
print('<a href="javascript:void(0);" onclick="return
listItemTask(\'cb'.$int_j.'\',\'publish\')" title="Publish Item">
<img src="images/publish_x.png" width="16" height="16" border="0"
alt="No" /></a>');
?>
</td>
<td><?php print($row->id);?></td>
</tr>
<?php
$int_j++;
}
print('<script type="text/javascript">');
print('var nr_chk='.$int_j);
print('</script>');
?>
<tfoot>
<td colspan="10">
<?php
jimport('joomla.html.pagination');
if($limit==500)$limit=0;
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 12
</table>
</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
File admin.remove.php
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 13
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
$db =& JFactory::getDBO();
$user=JRequest::getVar('user_del','');
$user=$user.'';
if(trim($user)=="")$user='[{<##>}]';
$test=JRequest::getVar('test_del',0);
$test=0+$test;
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
$table_user = JTable::getInstance('cunoastere_user', 'Table');
File admin.rezultate.php
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<form action="" method="post" name="adminForm">
<h4>Sterge rezultatele utilizatorului: </h4>
<input type="text" name="user_del" id="user_del" class="text_area" />
(Ex: Ion, Rizache, John) % - sterge tot
<br/>
<h4>Sterge rezultatele care includ testul:</h4>
<input type="text" name="test_del" id="test_del" class="text_area" />
(Ex: 1, 100, 2000)
<br/><br/>
<button onclick="this.form.submit();">Go</button><br/>
<input id="id_txt" type="hidden" name="id" value="" />
<input id="task_txt" type="hidden" name="task" value="remove" />
<input type="hidden" name="boxchecked" value="1" />
</form>
File admin.unpublish.php
<?php
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 14
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=="adauga") include_once("adauga_test.php");
if($task=="view_test") include_once("vezi_test.php");
if($task=="nu_publica") include_once("nu_publica.php");
if($task=="publica") include_once("publica.php");
if($task=="sterge_articol") include_once("sterge_articol.php");
if($task=="edit_articol") include_once("edit_articol.php");
if($task=="xml_feed") include_once("xml_feed.php");
if(!isset($task)) include_once("principal.php");
?>
File edit_articol.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 15
foreach($rows as $row)
{
$editor_test=$editor_test."<intrebare/>"."\n";
$editor_test=$editor_test.$row->nume_intrebare."\n";
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=="Inregistreaza")
{
$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("");
$table_test->set('nume_test', $uniqid);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 16
$db = &JFactory::getDBO();
$query = 'SELECT id FROM #__cunoastere_test WHERE
nume_test="'.$uniqid.'"'.'ORDER BY id DESC LIMIT 1' ;
$db->setQuery($query);
$id_test=$db->loadResult();
$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("<intrebare/>", $editor_test);
$j=1;
foreach($intrebari_teste as $intrebare)
{
$intrebare=trim($intrebare);
$intrebare1=explode("\n", $intrebare);
$i=1;
foreach($intrebare1 as $raspuns)
if($i==1)
{
if(trim($raspuns)=="")
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="'.$uniqid.'"'.'ORDER BY
id DESC LIMIT 1' ;
$db->setQuery($query);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 17
$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())
{
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)=="") 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="'.$uniqid.'"'.'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);
}
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 18
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
_test.'');
}
include_once("adauga_test.php");
?>
File index.php
<?php
print("Componenta mea");
?>
File nu_publica.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $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("_JEXEC") or exit("Restricted access");
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 19
?>
<?php
print('<div style="clear:both;"></div>');
$url_partaj=JURI::base()."index.php?option=com_componentamea%26task=x
ml_feed%26format=feed";
jimport('joomla.utilities.date');
$date1 = new JDate();
$date1=$date1->toFormat('%d-%m-%Y %H:%M:%S EET');
print('<div style="background-color:#e1e1e1; padding:3px 3px 3px 3px;
margin-bottom:5px; font-weight:bold">');
print('<div style="float:left;">Ora vizitei: '.$date1.'</div>');
$tip_user="Super Administrator";
// setam titlul ce apare in browser
$document =& JFactory::getDocument();
$document->setTitle("Teste de cunoastere");
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 20
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
jimport('joomla.html.pagination');
$_pagination = new JPagination($total, $limitstart, $limit);
?>
<div style="clear:both"></div>
<div class="pagenav" style="text-align:center; margin-top:10px; ">
<?php print($_pagination->getPagesLinks()); ?>
<br/>
<?php print($_pagination->getPagesCounter()); ?>
</div>
File publica.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $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);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 21
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 sterge_articol.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
if($user->usertype!="Super Administrator") $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
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 22
<?php
// nu permite accesul direct la acest fisier
defined('_JEXEC') or die('<center>Restricted access.</center>');
?>
<?php
if($task=="admin_test")
{
JToolBarHelper::title('Administrare teste');
JToolBarHelper::editList();
JToolBarHelper::divider();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::divider();
JToolBarHelper::preferences('com_componentamea');
}
if($task=="edit" || $task=="apply" )
{
JToolBarHelper::title('Editare test');
JToolBarHelper::apply();
JToolBarHelper::cancel();
}
if($task=="rezult_test")
{
JToolBarHelper::title('Rezultate teste');
JToolBarHelper::deleteList();
}
?>
File vezi_test.php
<?php
defined("_JEXEC") or exit("Restricted access");
?>
<?php
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$id=JRequest::getVar('id',0);
$id=$id+0;
$previz=JRequest::getVar('previz',null);
if($previz=="Reinitializeaza")
{
$mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&id='.$id
.'');
}
if($previz=="Inregistreaza")
{
if(!isset($user->name)) $mainframe-
>redirect('index.php?option=com_componentamea&task=view_test&alert_us
er=not&id='.$id.'');
$sir="".JRequest::getVar('sir','');
$sir_array=explode(":",$sir);
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 23
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');
$table_user = JTable::getInstance('cunoastere_user', 'Table');
$table_user->reset();
$table_user->set('id_test', $sir_array[2]);
$table_user->set('user', $user->name." :: ".$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.'');
}
$url_partaj=JURI::base()."index.php?option=com_componentamea%26task=v
iew_test%26id=".$id;
foreach($rows as $row)
{
if($user->usertype!="Super Administrator")
{
print('<div style="float:right;">');
print('<a
href="http://www.facebook.com/sharer.php?u='.$url_partaj.'"
title="Partajeaza pe Facebook"><img
src="components/com_hello/imagini/facebook.gif"
alt="Facebook"></a>');
print('<a
href="http://digg.com/submit?phase=2&url='.$url_partaj.'"
title="Partajeaza pe Digg"><img
src="components/com_hello/imagini/diggit.gif" alt="Diggit"></a>');
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 24
print('<a
href="http://del.icio.us/post?url='.$url_partaj.'&title='.$row-
>title.'" title="Partajeaza pe Delicious"><img
src="components/com_hello/imagini/delicious.gif"
alt="Delicious"></a>');
print('<a
href="https://favorites.live.com/quickadd.aspx?marklet=1&top=1&url='.
$url_partaj.'" title="Partajeaza pe Live"><img
src="components/com_hello/imagini/live.gif" alt="Live"></a>');
print('<a
href="http://blogmarks.net/my/new.php?mini=1&simple=1&url='.$url_part
aj.'&title='.$row->nume_test.'" title="Partajeaza pe Blogmarks"><img
src="components/com_hello/imagini/blogmarks.gif"
alt="Blogmarks"></a>');
print('<a
href="http://www.technorati.com/faves?add='.$url_partaj.'"
title="Partajeaza pe Technorati"><img
src="components/com_hello/imagini/technorati.gif"
alt="Technorati"></a>');
print('<a
href="http://www.myspace.com/Modules/PostTo/Pages/?c='.$url_partaj.'"
title="Partajeaza pe Myspace"><img
src="components/com_hello/imagini/myspace.gif" alt="Myspace"></a>');
print('<a
href="http://twitthis.com/twit?url='.$url_partaj.'&title='.$row-
>nume_test.'" title="Partajeaza pe Twitter"><img
src="components/com_hello/imagini/twitter.gif" alt="Twitter"></a>');
print('</div>');
}
if($user->usertype=="Super Administrator")
{
print('<div style="float:right;">');
if($row->published==1)
print('<a
href="index.php?option=com_componentamea&task=nu_publica&id='.$row-
>id.'" title="Nu publica acest articol"><img
src="components/com_componentamea/imagini/yes.png"
alt="yes.png"></a>');
if($row->published==0)
print('<a
href="index.php?option=com_componentamea&task=publica&id='.$row-
>id.'" title="Publica articol"><img
src="components/com_componentamea/imagini/no.png"
alt="no.png"></a>');
print('<a
href="index.php?option=com_componentamea&task=edit_articol&id='.$row-
>id.'" title="Editeaza articol"><img
src="components/com_componentamea/imagini/edit.png"
alt="edit.png"></a>');
print('<a
href="index.php?option=com_componentamea&task=sterge_articol&id='.$ro
w->id.'" title="Sterge articol"><img
src="components/com_componentamea/imagini/del.png"
alt="del.png"></a>');
print('</div>');
}
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 25
print('<div style="clear:both;"></div>');
$alert_user=JRequest::getVar('alert_user','');
$alert_user=$alert_user."";
if($alert_user=="not")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Trebuie sa va conectati ca sa puteti inregistra
rezultatele testelor.</h4>');
print('</div>');
}
if($alert_user=="script")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Programul necesita Javascript pentru a rula.</h4>');
print('</div>');
}
if($alert_user=="BD")
{
print('<div style="width:98%; border-width:1px; border-style:solid;
background-color:#CCCCCC; padding-top:2px; padding-left:2px; padding-
bottom:2px; margin-bottom:2px">');
print('<h4>Rezultatul testului a fost inregistrat in baza de
date.</h4>');
print('</div>');
}
print("<h1>".$row->nume_test."</h1>"); print("<br/>");
print("".stripslashes($row->descriere_test).""); print("<br/>");
print("<br/>");
$id_test=$row->id;
$tablou_int=array();
$tablou_raspuns=array();
var rasp_date=0;
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 26
var total=0;
function verifica(param, param2)
{
var diviz="div["+param2+"]";
if(radio[param2]==param.value)
{
//visibility:visible
document.getElementById(diviz).style.visibility="visible";
document.getElementById(diviz).style.color="green";
document.getElementById(diviz).innerHTML="Raspuns corect";
if(raspuns_dat[param2]==-1)
{
raspuns_dat[param2]=raspuns_dat[param2]+2;
rasp_date=rasp_date+raspuns_dat[param2];
total++;
document.getElementById("div_raspuns").innerHTML="Total test:
"+ rasp_date + " / " + total + " : "+ parseInt(rasp_date*100/total)
+"%";
}
}
else
{
document.getElementById(diviz).style.visibility="visible";
document.getElementById(diviz).style.color="red";
document.getElementById(diviz).innerHTML="Raspuns incorect";
if(raspuns_dat[param2]==-1)
{
raspuns_dat[param2]=raspuns_dat[param2]+1;
rasp_date=rasp_date+raspuns_dat[param2];
total++;
document.getElementById("div_raspuns").innerHTML="Total test:
"+ rasp_date + " / " + total + " : "+ parseInt(rasp_date*100/total)
+"%";
}
}
}
</script>
<?php
if($user->usertype!="Super Administrator")
{
$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]);
}
}
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 27
foreach($rows as $row)
{
print("<h3>".stripslashes($row->nume_intrebare)."</h3>");
$id_intreb=$row->id;
$tablou_int[]=$id_intreb;
$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="text/javascript">');
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="radio'.$id_intreb.'"
type="radio" value="'.$value.'"
onclick="verifica('.this.','.$id_intreb.')">');
print($tablou_rasp[$value]);
print("<br/>");
}
print('<div id="div['.$id_intreb.']" style="visibility:hidden;
width:50%; border-width:1px; border-style:solid; background-
color:#CCCCCC; padding-top:2px; padding-left:2px; padding-bottom:2px;
margin-bottom:2px"></div>');
print("<br/>");
}
}
print('<script type="text/javascript">');
print('var total_ver='.count($tablou_int).';');
print('</script>');
?>
<h3>Rezultat test</h3>
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 28
$teste_recom=array();
foreach($rows as $row)
{
$teste_recom[]=$row->id_test;
}
print("<h3>Alte teste de cunostinte recomandate:</h3>");
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."")=="")continue;
print('<a
href="index.php?option=com_componentamea&task=view_test&id='.($rows[0
]->id).'" style="text-decoration:none" title="Citeste mai
mult...">');
print($rows[0]->nume_test);
print('</a><br/>');
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 29
if(isset($user->name))
{
print("<h4>"); print("Rezultate obtinute la
test:");print("</h4>");
$id_test=0+$id_test;
$query='SELECT `user` , `punctaj` FROM
`jos_cunoastere_user` WHERE `id_test` ='.$id_test.' AND `user` LIKE
"'.($user->name).'%" ORDER BY id DESC LIMIT 0 , 30';
$result = $db->setQuery($query);
$rows = $db->loadObjectList();
foreach($rows as $row)
{
$user_data=explode("::",$row->user);
print($user_data[1]); print(" ");
$total_intreb=(int)($row->punctaj/1000);
$total_dat=(int) ($row->punctaj- $total_intreb*1000);
print(" ".$total_dat."/");print("".$total_intreb." ");
print("Procentaj:
".(int)($total_dat*100/$total_intreb)."%");
print("<br/>");
}
}
if($user->usertype!="Super Administrator")
{
$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("_JEXEC") or exit("Restricted access");
?>
<?php
/// Pasul 1 - stabileste linkul de baza
$document = & JFactory::getDocument();;
$document->setLink(JRoute::_('index.php?option=com_componentamea'));
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 30
$document->render();
?>
<administration>
<menu>Admin Teste</menu>
<submenu>
<menu task="rezult_test"
img="js/ThemeOffice/component.png">Administrare rezultate
teste</menu>
<menu task="admin_test"
img="js/ThemeOffice/component.png">Administrare teste</menu>
</submenu>
<files>
<filename>admin.componentamea.php</filename>
<filename>admin.edit.php</filename>
<filename>admin.principal.php</filename>
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 31
<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>
<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>
<![CDATA[
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 32
</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
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 33
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 34
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 35
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 36
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
);
*/
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 37
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
);
*/
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 38
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
);
*/
Download
http://24secunde.com/joomla/media/com_componentamea.zip
Page 39
{
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