From: <pan...@us...> - 2008-12-07 22:02:07
|
Revision: 437 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=437&view=rev Author: panzaboi Date: 2008-12-07 21:57:19 +0000 (Sun, 07 Dec 2008) Log Message: ----------- Archive: Added results, moved form info into the form class User: Created register and activate actions with email activation Tester: Added methods to communicate with tester, send and receive data Mail: Added setBodyTemplate to add bodyHtml as rendered file DB: Updated Skeleton. Modified Paths: -------------- website/application/modules/acm/controllers/ArchieveController.php website/application/modules/acm/controllers/IndexController.php website/application/modules/acm/models/Archieve.php website/application/modules/acm/models/Form/Login.php website/application/modules/acm/models/Form/Submit.php website/config/config.ini website/library/Application.php website/library/Ostacium/Controller/Action.php website/library/Ostacium/Controller/Plugin/ErrorHandler.php website/library/Ostacium/Controller/Router/Route/Language.php Added Paths: ----------- website/application/modules/acm/controllers/TesterController.php website/application/modules/acm/controllers/UserController.php website/application/modules/acm/models/Form/Register.php website/application/modules/acm/models/Tester.php website/application/modules/acm/models/User.php website/application/modules/acm/views/helpers/State.php website/application/modules/acm/views/scripts/archieve/result.phtml website/application/modules/acm/views/scripts/archieve/results.phtml website/application/modules/acm/views/scripts/emails/ website/application/modules/acm/views/scripts/emails/register.phtml website/application/modules/acm/views/scripts/tester/ website/application/modules/acm/views/scripts/tester/entry.phtml website/application/modules/acm/views/scripts/tester/submits.phtml website/application/modules/acm/views/scripts/user/ website/application/modules/acm/views/scripts/user/activated.phtml website/application/modules/acm/views/scripts/user/notactivated.phtml website/application/modules/acm/views/scripts/user/registered.phtml website/library/Ostacium/Mail.php website/library/Ostacium/View/Helper/Date.php website/other/dq.sql website/other/submits/3 website/other/submits/4 website/other/submits/5 Removed Paths: ------------- website/application/modules/acm/views/scripts/archieve/submit.phtml website/other/db.sql Modified: website/application/modules/acm/controllers/ArchieveController.php =================================================================== --- website/application/modules/acm/controllers/ArchieveController.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/controllers/ArchieveController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -22,11 +22,7 @@ { $this->_helper->getHelper('viewRenderer')->setNoRender(true); - $form = $this->_model->getSubmitForm(array( - 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), - 'method' => 'post', - 'name' => 'submitform', - )); + $form = new Form_Submit(); $this->view->dojo()->addOnLoad('function(){ changeEditor('.$form->type->getValue().'); }'); @@ -36,11 +32,7 @@ public function uploadAction() { $this->_helper->getHelper('viewRenderer')->setNoRender(true); - $form = $this->_model->getSubmitForm(array( - 'action' => $this->view->url(array('action' => 'upload', 'id' => $this->_getParam('id')), null), - 'method' => 'post', - 'name' => 'submitform', - )); + $form = new Form_Submit(); if (!$this->getRequest()->isPost()) { @@ -80,11 +72,16 @@ if ($values['type'] == 0) { - file_put_contents(Application::getDocRoot().'/other/submits/'.$id.'.cpp', $values['code']); + file_put_contents(Application::getDocRoot().'/other/submits/'.$id, $values['code']); } elseif ($values['type'] == 1) { - rename($form->codefile->getFileName(), Application::getDocRoot().'/other/submits/'.$id.'.cpp'); + rename($form->codefile->getFileName(), Application::getDocRoot().'/other/submits/'.$id); } } + + public function resultsAction() + { + $this->view->submits = $this->_model->getSubmits(); + } } \ No newline at end of file Modified: website/application/modules/acm/controllers/IndexController.php =================================================================== --- website/application/modules/acm/controllers/IndexController.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/controllers/IndexController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -4,12 +4,13 @@ { public function indexAction() { - echo $this->getLoginForm(); + $form = new Form_Login(); + echo $form; } public function loginAction() { - $form = $this->getLoginForm(); + $form = new Form_Login(); if (!$this->getRequest()->isPost()) { @@ -54,13 +55,4 @@ { Zend_Auth::getInstance()->clearIdentity(); } - - protected function getLoginForm() - { - return new Form_Login(array( - 'action' => $this->view->url(array('action' => 'login'), null), - 'method' => 'post', - 'name' => 'loginform', - )); - } } \ No newline at end of file Added: website/application/modules/acm/controllers/TesterController.php =================================================================== --- website/application/modules/acm/controllers/TesterController.php (rev 0) +++ website/application/modules/acm/controllers/TesterController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,36 @@ +<?php + +class Acm_TesterController extends Ostacium_Controller_Action +{ + public function init() + { + parent::init(); + $this->_helper->getHelper('Layout')->disableLayout(); + } + + public function submitsAction() + { + $this->getResponse()->setHeader('Content-Type', 'application/xml'); + $this->view->submits = $this->_model->getSubmits(); + } + + public function resultAction() + { + $id = $this->_getParam('id'); + $data['tests'] = (int)$this->_getParam('tests'); + $data['runtime'] = (int)$this->_getParam('runtime'); + $data['memory'] = (int)$this->_getParam('memory'); + $data['state'] = (int)$this->_getParam('state'); + + if ($data['tests'] && $data['runtime'] && $data['memory'] && $data['state']) + { + echo ($this->_model->updateSubmit($id, $data) ? "success" : "error"); + } + else + { + echo "error"; + } + + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + } +} \ No newline at end of file Added: website/application/modules/acm/controllers/UserController.php =================================================================== --- website/application/modules/acm/controllers/UserController.php (rev 0) +++ website/application/modules/acm/controllers/UserController.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,76 @@ +<?php + +class Acm_UserController extends Ostacium_Controller_Action +{ + public function registerAction() + { + $this->_helper->getHelper('viewRenderer')->setNoRender(true); + + $form = new Form_Register(); + + if (!$this->getRequest()->isPost()) + { + echo $form; + return; + } + + if (!$form->isValid($this->getRequest()->getPost())) + { + echo $form; + return; + } + + // check cpassword == password + + $values = $form->getValues(); + $values['ip'] = $this->getRequest()->getIp(); + $code = substr(md5(time()), mt_rand(0, 27), 5); + $result = $this->_model->registerUser($values, $code); + + if (!$result) + { + $form->setDescription($this->view->translate('wrongEmailPwd')); + + echo $form; + } + else + { + $arguments = array('code' => $code, 'fullname' => $values['name'].' '.$values['surname'], 'username' => $values['username']); + $mail = new Ostacium_Mail(); + $mail->setFrom($this->_config->email->from.'@'.$_SERVER["SERVER_NAME"], $this->_config->general->title.' Staff') + ->addTo($values['email'], $values['name'].' '.$values['surname']) + ->setSubject($this->_('registration_email')) + ->setBodyTemplate(array('template' => 'register.phtml', 'arguments' => $arguments)) + ->send(); + + return $this->_redirect($this->view->url(array('action' => 'registered'))); + } + } + + public function registeredAction() + { + + } + + public function activateAction() + { + $username = $this->_getParam('username'); + $code = $this->_getParam('code'); + + $result = $this->_model->activateUser($username, $code); + + if ($result) + { + return $this->render('activated'); + } + else + { + return $this->render('notactivated'); + } + } + + public function viewAction() + { + + } +} \ No newline at end of file Modified: website/application/modules/acm/models/Archieve.php =================================================================== --- website/application/modules/acm/models/Archieve.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Archieve.php 2008-12-07 21:57:19 UTC (rev 437) @@ -8,42 +8,34 @@ return $challenges->getAll(); } + public function getSubmits() + { + $submits = new Submits(); + return $submits->getAll(); + } + public function get($id) { $challenges = new Challenges(); return $challenges->get($id); } - public function getCodeLanguages() - { - return $this->_db->fetchPairs($this->_db->select()->from('code_languages', array('id', 'name'))); - } - public function addSubmit($values) { $data = array( 'username' => Zend_Auth::getInstance()->getStorage()->read()->username, - 'challengeid' => $values['id'], - 'languageid' => $values['languageid'], + 'challengeid' => (int)$values['id'], + 'codelangid' => $values['languageid'], 'firsttest' => $values['firsttest'], 'when' => time() ); + $challenges = new Challenges(); + $challenges->update(array('tries' => 'tries + 1'), $this->_db->quoteInto('id = ?', $data['challengeid'])); + $submits = new Submits(); return $submits->insert($data); } - - public function getSubmitForm($options = array()) - { - $form = new Form_Submit($options); - $user = Zend_Auth::getInstance()->getStorage()->read(); - - $languageid = $form->getElement('languageid'); - $languageid->addMultiOptions($this->getCodeLanguages()); - $languageid->setValue($user->codelangid); - - return $form; - } } class Challenges extends Ostacium_Db_Table @@ -66,4 +58,9 @@ { protected $_name = 'archieve_submits'; protected $_primary = 'id'; + + public function getAll() + { + return $this->select()->from($this)->setIntegrityCheck(false)->joinLeft('code_languages', 'code_languages.id = archieve_submits.codelangid', array('codelang' => 'name'))->order('id DESC')->query()->fetchAll(); + } } \ No newline at end of file Modified: website/application/modules/acm/models/Form/Login.php =================================================================== --- website/application/modules/acm/models/Form/Login.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Form/Login.php 2008-12-07 21:57:19 UTC (rev 437) @@ -16,8 +16,12 @@ public function init() { $translate = Zend_Registry::get('Zend_Translate'); - //$this->addElementPrefixPath('Ostacium_Form', 'Ostacium/Form/'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + $this->setAction($router->assemble(array('action' => 'login'), null)); + $this->setMethod('post'); + $this->setName('loginform'); + $this->addElement('ValidationTextBox', 'username', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim', 'StringToLower'), @@ -29,14 +33,12 @@ 'trim' => true, 'lowercase' => true, 'style' => 'height: 18px; width: 100px;', - 'regExp' => '[\S]{5,50}', - 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 50), + 'regExp' => '[\w]{5,50}', + 'invalidMessage' => sprintf($translate->_('wordErrorBetween'), 5, 50), 'title' => 'Username', 'label' => 'Username:', )); - - $this->addElement('PasswordTextBox', 'password', array( 'decorators' => $this->elementDecorators, 'filters' => array('StringTrim'), @@ -47,7 +49,7 @@ 'required' => true, 'trim' => true, 'style' => 'height: 18px; width: 100px;', - 'regExp' => '^[a-z0-9]{5,32}$', + 'regExp' => '[\S]{5,32}', 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), 'title' => 'Password', 'label' => 'Password:', Added: website/application/modules/acm/models/Form/Register.php =================================================================== --- website/application/modules/acm/models/Form/Register.php (rev 0) +++ website/application/modules/acm/models/Form/Register.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,314 @@ +<?php + +class Form_Register extends Zend_Dojo_Form +{ + public $elementDecorators = array( + 'DijitElement', + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $simpleDecorators = array( + 'Errors', + array('Label', array('class' => 'overlabel')), + array('HtmlTag', array('tag' => 'div', 'class' => 'elcontainer')) + ); + + public $buttonDecorators = array( + 'DijitElement', + ); + + public function init() + { + $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + + $this->setAction($router->assemble(array('action' => 'register'), null)); + $this->setMethod('post'); + $this->setName('registerform'); + + $this->addElement('ValidationTextBox', 'username', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => true, + 'regExp' => '[\w]{5,50}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 50), + 'title' => $translate->_('username'), + 'label' => $translate->_('username').': ', + )); + + $this->addElement('PasswordTextBox', 'password', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 32)), + ), + 'maxlength' => 32, + 'trim' => true, + 'required' => true, + 'regExp' => '[\S]{5,32}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), + 'title' => $translate->_('password'), + 'label' => $translate->_('password').': ', + )); + + $this->addElement('PasswordTextBox', 'cpassword', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(5, 32)), + ), + 'maxlength' => 32, + 'trim' => true, + 'propercase' => true, + 'required' => true, + 'regExp' => '[\S]{5,32}', + 'invalidMessage' => sprintf($translate->_('errorBetween'), 5, 32), + 'title' => $translate->_('confirm_password'), + 'label' => $translate->_('confirm_password').': ', + )); + + $this->addElement('ValidationTextBox', 'email', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + 'EmailAddress', + array('StringLength', false, 1) + ), + 'filters' => array('StringToLower'), + 'trim' => true, + 'lowercase' => true, + 'required' => true, + 'regExp' => '.{1,}', + 'invalidMessage' => $translate->_('errorEmpty'), + 'title' => $translate->_('email'), + 'label' => $translate->_('email').': ', + )); + + $this->addElement('Checkbox', 'hideemail', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('hideemail'), + 'label' => $translate->_('hideemail').': ', + 'multiOptions' => array($translate->_('no'), $translate->_('yes')), + )); + + $this->addElement('ValidationTextBox', 'name', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('name'), + 'label' => $translate->_('name').': ', + )); + + $this->addElement('ValidationTextBox', 'surname', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('surname'), + 'label' => $translate->_('surname').': ', + )); + + $this->addElement('ValidationTextBox', 'study', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\w ]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('study'), + 'label' => $translate->_('study').': ', + )); + + $this->addElement('DateTextBox', 'birthday', array( + 'decorators' => $this->elementDecorators, + 'required' => false, + 'invalidMessage' => $translate->_('invalidDate'), + 'title' => $translate->_('birthday'), + 'label' => $translate->_('birthday').': ', + 'formatLength' => 'short' + )); + + $this->addElement('ValidationTextBox', 'aim', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('aim'), + 'label' => $translate->_('aim').': ', + )); + + $this->addElement('ValidationTextBox', 'icq', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('icq'), + 'label' => $translate->_('icq').': ', + )); + + $this->addElement('ValidationTextBox', 'msn', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 100)), + ), + 'maxlength' => 100, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,100}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 100), + 'title' => $translate->_('msn'), + 'label' => $translate->_('msn').': ', + )); + + $this->addElement('ValidationTextBox', 'skype', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('skype'), + 'label' => $translate->_('skype').': ', + )); + + $this->addElement('ValidationTextBox', 'yahoo', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('yahoo'), + 'label' => $translate->_('yahoo').': ', + )); + + $this->addElement('ValidationTextBox', 'web', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 100)), + ), + 'maxlength' => 200, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,100}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 100), + 'title' => $translate->_('web'), + 'label' => $translate->_('web').': ', + )); + + $this->addElement('ValidationTextBox', 'topcoder', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('topcoder'), + 'label' => $translate->_('topcoder').': ', + )); + + $this->addElement('ValidationTextBox', 'timus', array( + 'decorators' => $this->elementDecorators, + 'validators' => array( + array('StringLength', false, array(0, 50)), + ), + 'maxlength' => 50, + 'trim' => true, + 'required' => false, + 'regExp' => '[\S]{0,50}', + 'invalidMessage' => sprintf($translate->_('errorMore'), 50), + 'title' => $translate->_('timus'), + 'label' => $translate->_('timus').': ', + )); + + $offset = array(-12 => -12, -11 => -11, -10 => -10, -9 => -9, -8 => -8, -7 => -7, -6 => -6, -5 => -5, -4 => -4, -3 => -3, -2 => -2, -1 => -1, 0 => 0, '+1' => '+1', '+2' => '+2', '+3' => '+3', '+4' => '+4', '+5' => '+5', '+6' => '+6', '+7' => '+7', '+8' => '+8', '+9' => '+9', '+10' => '+10', '+11' => '+11', '+12' => '+12', '+13' => '+13'); + + $this->addElement('FilteringSelect', 'timeoffset', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('timeoffset'), + 'label' => $translate->_('timeoffset').': ', + 'multiOptions' => $offset, + 'value' => 0 + )); + + $this->addElement('FilteringSelect', 'codelangid', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('code_language'), + 'label' => $translate->_('code_language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), + )); + + $this->addElement('FilteringSelect', 'language', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('language'), + 'label' => $translate->_('language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('languages', array('code', 'name'))), + 'value' => Zend_Registry::get('config')->lang->default + )); + + $this->addElement('FilteringSelect', 'tshirtsize', array( + 'decorators' => $this->elementDecorators, + 'required' => true, + 'title' => $translate->_('tshirtsize'), + 'label' => $translate->_('tshirtsize').': ', + 'multiOptions' => array('S' => 'Small', 'M' => 'Medium', 'L' => 'Large'), + )); + + $this->addElement('SubmitButton', 'registerbutton', array( + 'decorators' => $this->buttonDecorators, + 'required' => false, + 'ignore' => true, + 'label' => $translate->_('register'), + )); + } + + public function loadDefaultDecorators() + { + $this->setDecorators(array( + 'FormElements', + 'DijitForm', + array('Description', array('placement' => 'prepend', 'tag' => 'div', 'class' => 'error')), + )); + } +} \ No newline at end of file Modified: website/application/modules/acm/models/Form/Submit.php =================================================================== --- website/application/modules/acm/models/Form/Submit.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/application/modules/acm/models/Form/Submit.php 2008-12-07 21:57:19 UTC (rev 437) @@ -22,8 +22,14 @@ public function init() { $translate = Zend_Registry::get('Zend_Translate'); + $db = Zend_Registry::get('db'); + $router = Zend_Controller_Front::getInstance()->getRouter(); + $request = Zend_Controller_Front::getInstance()->getRequest(); $this->setAttrib('enctype', 'multipart/form-data'); + $this->setAction($router->assemble(array('action' => 'upload', 'id' => $request->getParam('id')), null)); + $this->setMethod('post'); + $this->setName('submitform'); $this->addElement('FilteringSelect', 'languageid', array( 'decorators' => $this->elementDecorators, @@ -31,6 +37,8 @@ 'style' => 'height: 18px; width: 100px;', 'title' => $translate->_('code_language'), 'label' => $translate->_('code_language').': ', + 'multiOptions' => $db->fetchPairs($db->select()->from('code_languages', array('id', 'name'))), + 'value' => (Zend_Auth::getInstance()->getStorage()->read()->codelangid) )); $this->addElement('RadioButton', 'type', array( Added: website/application/modules/acm/models/Tester.php =================================================================== --- website/application/modules/acm/models/Tester.php (rev 0) +++ website/application/modules/acm/models/Tester.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,27 @@ +<?php + +class Tester extends Ostacium_Model +{ + public function getSubmits() + { + $submits = new Submits(); + return $submits->getUntested(); + } + + public function updateSubmit($id, $data) + { + $submits = new Submits(); + return $submits->update($data, $this->_db->quoteInto('id = ? AND state = 0', $id)); + } +} + +class Submits extends Ostacium_Db_Table +{ + protected $_name = 'archieve_submits'; + protected $_primary = 'id'; + + public function getUntested() + { + return $this->select()->from($this)->setIntegrityCheck(false)->joinLeft('code_languages', 'code_languages.id = archieve_submits.codelangid', array('codelang' => 'name'))->where('state = 0')->order('id ASC')->query()->fetchAll(); + } +} \ No newline at end of file Added: website/application/modules/acm/models/User.php =================================================================== --- website/application/modules/acm/models/User.php (rev 0) +++ website/application/modules/acm/models/User.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,51 @@ +<?php + +class User extends Ostacium_Model +{ + public function registerUser($data, $code) + { + $data['registered'] = time(); + $data['online'] = $data['registered']; + $data['roleid'] = Zend_Registry::get('config')->general->roleid; + $data['activated'] = $code; + $data['password'] = md5($data['password']); + + $users = new Users(); + $users->insert($data); + + $usersdetails = new UsersDetails(); + $usersdetails->insert($data); + + $usersstats = new UsersStats(); + $usersstats->insert($data); + + return true; + } + + public function activateUser($username, $code) + { + $where = $this->_db->quoteInto('username = ?', $username).' AND activated = ?'; + $where = $this->_db->quoteInto($where, $code); + + $users = new Users(); + return $users->update(array('activated' => null), $where); + } +} + +class Users extends Ostacium_Db_Table +{ + protected $_name = 'users'; + protected $_primaty = 'username'; +} + +class UsersDetails extends Ostacium_Db_Table +{ + protected $_name = 'usersdetails'; + protected $_primaty = 'username'; +} + +class UsersStats extends Ostacium_Db_Table +{ + protected $_name = 'usersstats'; + protected $_primaty = 'username'; +} \ No newline at end of file Added: website/application/modules/acm/views/helpers/State.php =================================================================== --- website/application/modules/acm/views/helpers/State.php (rev 0) +++ website/application/modules/acm/views/helpers/State.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,39 @@ +<?php + +class Acm_View_Helper_State extends Zend_View_Helper_Abstract +{ + public function state($stateid) + { + switch ($stateid) { + case 0: + $return = 'in_que'; + break; + case 1: + $return = 'AC'; + break; + case 2: + $return = 'TL'; + break; + case 3: + $return = 'ML'; + break; + case 4: + $return = 'OL'; + break; + case 5: + $return = 'CE'; + break; + case 6: + $return = 'RE'; + break; + case 7: + $return = 'WA'; + break; + case 8: + $return = 'DF'; + break; + } + + return $this->view->translate($return); + } +} \ No newline at end of file Added: website/application/modules/acm/views/scripts/archieve/result.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/result.phtml (rev 0) +++ website/application/modules/acm/views/scripts/archieve/result.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,10 @@ +<tr> + <td align="center"><?= $this->id ?></td> + <td align="center"><?= $this->date($this->when) ?></td> + <td align="center"><?= $this->username ?></td> + <td align="center"><a href="<?= $this->url( array('action' => 'view', 'id' => $this->challengeid), null) ?>"><?= $this->challengeid ?></a></td> + <td align="center"><?= $this->codelang ?></td> + <td align="center"><?= $this->state($this->state) ?></td> + <td align="center"><?= ($this->tests == 0 ? '-' : $this->tests) ?></td> + <td align="center"><?= ($this->runtime == 0 ? '-' : $this->runtime) ?>/<?= ($this->memory == 0 ? '-' : $this->memory) ?></td> +</tr> \ No newline at end of file Added: website/application/modules/acm/views/scripts/archieve/results.phtml =================================================================== --- website/application/modules/acm/views/scripts/archieve/results.phtml (rev 0) +++ website/application/modules/acm/views/scripts/archieve/results.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,33 @@ +<table cellspacing="1" cellpadding="8" border="0" width="100%"><tbody><tr><td width="100%" valign="top" class="name"> + +<table cellspacing="0" cellpadding="0" border="0" width="100%"> +<tbody> +<tr> +<td nowrap="" bgcolor="#122a5b" width="*" class="name"> +<font color="#d4d0e2"><b><small>Набiр задач</small></b><small/></font> +</td> +<td nowrap="" bgcolor="#122a5b" align="right" class="name"> +<font color="#d4d0e2"><b><small> 05:26 23 березня 2007 року </small></b><small/></font> +</td> +</tr> +</tbody> +</table> + +<table cellspacing="0" cellpadding="0" border="0" summary="" align="center" width="80%"> +<tbody> +<tr><td bgcolor="#f4f3f8" align="middle" colspan="14"><b>Архів задач</b></td></tr> +<tr bgcolor="#e1e1e1" align="middle"> +<th>ID</th> +<th>Дата</th> +<th>Логін</th> +<th>Задача</th> +<th>Мова</th> +<th>Стан</th> +<th>Тест</th> +<th>Час/Пам'ять</th> +</tr> + +<?= $this->partialLoop('archieve/result.phtml', $this->submits) ?> +</table> + +</td></tr></table> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/emails ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/emails/register.phtml =================================================================== --- website/application/modules/acm/views/scripts/emails/register.phtml (rev 0) +++ website/application/modules/acm/views/scripts/emails/register.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,8 @@ +Dear <?= $this->fullname ?>, +<br /><br /> +Thank you for registering on <?= Zend_Registry::get('config')->general->title ?>. To activate your account please +<a href="<?= $_SERVER["SERVER_NAME"] ?><?= $this->url(array('action' => 'activate', 'username' => $this->username, 'code' => $this->code), null) ?>">click here</a>. +<br /><br /> +------------ +<?= Zend_Registry::get('config')->general->title ?> Staff<br /> +<?= $_SERVER["SERVER_NAME"] ?> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/tester ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/tester/entry.phtml =================================================================== --- website/application/modules/acm/views/scripts/tester/entry.phtml (rev 0) +++ website/application/modules/acm/views/scripts/tester/entry.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,3 @@ +<entry id="<?= $this->id ?>" problemid="<?= $this->challengeid ?>" language="<?= $this->codelang ?>"> +<?= htmlentities(file_get_contents(Application::getDocRoot().'/other/submits/'.$this->id)) ?> +</entry> \ No newline at end of file Added: website/application/modules/acm/views/scripts/tester/submits.phtml =================================================================== --- website/application/modules/acm/views/scripts/tester/submits.phtml (rev 0) +++ website/application/modules/acm/views/scripts/tester/submits.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,4 @@ +<?= '<?xml version="1.0" encoding="UTF-8"?>' ?> +<entries> +<?= $this->partialLoop('tester/entry.phtml', $this->submits) ?> +</entries> \ No newline at end of file Property changes on: website/application/modules/acm/views/scripts/user ___________________________________________________________________ Added: tsvn:logminsize + 5 Added: website/application/modules/acm/views/scripts/user/activated.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/activated.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/activated.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1 @@ +You have successfully activated your account. You can login now. \ No newline at end of file Added: website/application/modules/acm/views/scripts/user/notactivated.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/notactivated.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/notactivated.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,3 @@ +There's was an error activating your account. You could try following resolution:<br /> +1) Click here to resend your activation key, if you haven't recieved it.<br /> +2) Click here to manualy enter the activation key, if url in your email is deformed. \ No newline at end of file Added: website/application/modules/acm/views/scripts/user/registered.phtml =================================================================== --- website/application/modules/acm/views/scripts/user/registered.phtml (rev 0) +++ website/application/modules/acm/views/scripts/user/registered.phtml 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1 @@ +You have successfully registered account. Please check your mail. \ No newline at end of file Modified: website/config/config.ini =================================================================== --- website/config/config.ini 2008-12-06 23:14:20 UTC (rev 436) +++ website/config/config.ini 2008-12-07 21:57:19 UTC (rev 437) @@ -57,7 +57,7 @@ log.columnMap.when = "timestamp"; log.columnMap.ip = "ip"; -email.admin = "admin" +email.from = "admin" listtable.class = "crudtable" @@ -68,6 +68,7 @@ general.title = "ACM Contester" general.titlesep = " - " general.extention = "html" +general.roleid = "2" [development: general] Modified: website/library/Application.php =================================================================== --- website/library/Application.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Application.php 2008-12-07 21:57:19 UTC (rev 437) @@ -106,7 +106,8 @@ $this->_setupView(); // Setup Email - $mail = new Zend_Mail_Transport_Sendmail('-f'.$_config->email->admin.'@'.$_SERVER["SERVER_NAME"]); + //$mail = new Zend_Mail_Transport_Sendmail('-f'.$_config->email->from.'@'.$_SERVER["SERVER_NAME"]); + $mail = new Zend_Mail_Transport_Smtp('mail.ostacium.com', array('auth' => 'login', 'username' => 'ad...@os...', 'password' => 'g3n1u535')); Zend_Mail::setDefaultTransport($mail); // Setup Plugins @@ -236,7 +237,9 @@ $language = $_config->lang->default; $translate->setLocale($language); + Zend_Registry::set('Zend_Translate', $translate); + Zend_Registry::set('Zend_Locale', new Zend_Locale($language)); } protected function _setupRoutes(Zend_Controller_Front $frontController) Modified: website/library/Ostacium/Controller/Action.php =================================================================== --- website/library/Ostacium/Controller/Action.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Action.php 2008-12-07 21:57:19 UTC (rev 437) @@ -4,10 +4,12 @@ { protected $_model; protected $_translate; + protected $_config; public function init() { $this->_translate = Zend_Registry::get('Zend_Translate'); + $this->_config = Zend_Registry::get('config'); $name = ucfirst($this->getRequest()->getControllerName()); Modified: website/library/Ostacium/Controller/Plugin/ErrorHandler.php =================================================================== --- website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Plugin/ErrorHandler.php 2008-12-07 21:57:19 UTC (rev 437) @@ -25,6 +25,8 @@ $error = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); $error->exception = current($response->getException()); + $auth = Zend_Auth::getInstance(); + if (!$dispatcher->isDispatchable($request)) { $error->type = self::EXCEPTION_NO_CONTROLLER; if (!$error->exception) Modified: website/library/Ostacium/Controller/Router/Route/Language.php =================================================================== --- website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-06 23:14:20 UTC (rev 436) +++ website/library/Ostacium/Controller/Router/Route/Language.php 2008-12-07 21:57:19 UTC (rev 437) @@ -16,6 +16,7 @@ parent::__construct($defaults, $dispatcher, $request); $this->translate = Zend_Registry::get('Zend_Translate'); + $this->locale = Zend_Registry::get('Zend_Locale'); $this->config = Zend_Registry::get('config'); $this->extention = $extention; } @@ -53,6 +54,7 @@ if ($this->translate->isAvailable($path[0])) { $values[$this->_languageKey] = array_shift($path); $this->translate->setLocale($values[$this->_languageKey]); + $this->locale->setLocale($values[$this->_languageKey]); } if (count($path) && !empty($path[0]) && $this->_dispatcher && $this->_dispatcher->isValidModule($path[0])) { Added: website/library/Ostacium/Mail.php =================================================================== --- website/library/Ostacium/Mail.php (rev 0) +++ website/library/Ostacium/Mail.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,19 @@ +<?php + +class Ostacium_Mail extends Zend_Mail +{ + public function setBodyTemplate($options) + { + $template = $options['template']; + $arguments = $options['arguments']; + + $view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view; + $view->assign($arguments); + + $body = $view->render('emails/'.$template); + + $this->setBodyHtml($body); + + return $this; + } +} \ No newline at end of file Added: website/library/Ostacium/View/Helper/Date.php =================================================================== --- website/library/Ostacium/View/Helper/Date.php (rev 0) +++ website/library/Ostacium/View/Helper/Date.php 2008-12-07 21:57:19 UTC (rev 437) @@ -0,0 +1,17 @@ +<?php + +class Ostacium_View_Helper_Date extends Zend_View_Helper_Abstract +{ + public function date($date = null, $format = null, $part = null, $locale = null) + { + try + { + $d = new Zend_Date($date, $part, $locale); + return $d->toString($format); + } + catch (Exception $e) + { + return false; + } + } +} \ No newline at end of file Deleted: website/other/db.sql =================================================================== --- website/other/db.sql 2008-12-06 23:14:20 UTC (rev 436) +++ website/other/db.sql 2008-12-07 21:57:19 UTC (rev 437) @@ -1,759 +0,0 @@ --- phpMyAdmin SQL Dump --- version 2.11.7 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Oct 05, 2008 at 05:59 PM --- Server version: 5.0.51 --- PHP Version: 5.2.6 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; - --- --- Database: `acm` --- - --- -------------------------------------------------------- - --- --- Table structure for table `archieve_submits` --- - -CREATE TABLE IF NOT EXISTS `archieve_submits` ( - `id` int(11) NOT NULL, - `username` varchar(50) NOT NULL, - `challengeid` int(11) NOT NULL, - `languageid` int(11) NOT NULL, - `state` int(11) NOT NULL, - `tests` int(11) NOT NULL, - `firsttest` tinyint(1) NOT NULL default '0', - `runtime` double NOT NULL, - `memory` int(11) NOT NULL, - `when` int(11) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `archieve_submits` --- - - --- -------------------------------------------------------- - --- --- Table structure for table `challenges` --- - -CREATE TABLE IF NOT EXISTS `challenges` ( - `id` int(11) NOT NULL auto_increment, - `timelimit` double NOT NULL default '0', - `memorylimit` int(11) NOT NULL default '0', - `outputlimit` int(11) NOT NULL default '0', - `tries` int(11) NOT NULL default '0', - `accepted` int(11) NOT NULL default '0', - `author` varchar(50) character set latin1 NOT NULL, - `enabled` tinyint(1) NOT NULL default '1', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1195 ; - --- --- Dumping data for table `challenges` --- - -INSERT INTO `challenges` (`id`, `timelimit`, `memorylimit`, `outputlimit`, `tries`, `accepted`, `author`, `enabled`) VALUES -(1000, 1000, 5120000, 204800, 0, 0, '', 1), -(1001, 1000, 5120000, 204800, 0, 0, '', 1), -(1002, 1000, 5120000, 204800, 0, 0, '', 1), -(1003, 1000, 5120000, 204800, 0, 0, '', 1), -(1004, 1000, 3072000, 204800, 0, 0, '', 1), -(1005, 1000, 3072000, 2048, 0, 0, '', 1), -(1006, 1000, 3072000, 2048, 0, 0, '', 1), -(1007, 1000, 3072000, 2048, 0, 0, '', 1), -(1008, 1000, 5120000, 2048, 0, 0, '', 1), -(1009, 1000, 3072000, 2048, 0, 0, '', 1), -(1010, 1000, 3072000, 2048, 0, 0, '', 1), -(1011, 1500, 3072000, 204800, 0, 0, '', 1), -(1012, 500, 3072000, 2048, 0, 0, '', 1), -(1013, 500, 3072000, 204800, 0, 0, '', 1), -(1014, 500, 3072000, 2048, 0, 0, '', 1), -(1015, 500, 3072000, 204800, 0, 0, '', 1), -(1016, 1000, 3072000, 204800, 0, 0, '', 1), -(1017, 500, 3072000, 204800, 0, 0, '', 1), -(1018, 20000, 3072000, 2048, 0, 0, '', 1), -(1019, 1000, 3072000, 2048, 0, 0, '', 1), -(1020, 500, 3072000, 2048, 0, 0, '', 1), -(1021, 500, 3072000, 2048, 0, 0, '', 1), -(1022, 1000, 5120000, 2048, 0, 0, '', 1), -(1023, 1000, 3072000, 2048, 0, 0, '', 1), -(1024, 1000, 3072000, 2048, 0, 0, '', 1), -(1025, 1000, 2048000, 2048, 0, 0, '', 1), -(1026, 1000, 3072000, 2048, 0, 0, '', 1), -(1027, 1000, 3072000, 2048, 0, 0, '', 1), -(1028, 500, 3072000, 2048, 0, 0, '', 1), -(1029, 1000, 3072000, 2048, 0, 0, '', 1), -(1030, 500, 5120000, 204800, 0, 0, '', 1), -(1031, 1000, 2048000, 2048, 0, 0, '', 0), -(1032, 1000, 10240000, 2048, 0, 0, '', 1), -(1033, 500, 2048000, 2048, 0, 0, '', 1), -(1034, 2000, 2048000, 2048, 0, 0, '', 1), -(1035, 500, 2048000, 2048, 0, 0, '', 1), -(1036, 500, 2048000, 204800, 0, 0, '', 1), -(1037, 500, 20480000, 2048, 0, 0, '', 1), -(1038, 500, 20480000, 2048, 0, 0, '', 1), -(1039, 500, 20480000, 2048, 0, 0, '', 1), -(1040, 1000, 20480000, 2048, 0, 0, '', 1), -(1041, 1000, 20480000, 2048, 0, 0, '', 1), -(1042, 500, 20480000, 2048, 0, 0, '', 1), -(1043, 500, 20480000, 2048, 0, 0, '', 1), -(1044, 1000, 20480000, 2048, 0, 0, '', 1), -(1045, 1000, 20480000, 204800, 0, 0, '', 1), -(1046, 1000, 20480000, 512000, 0, 0, '', 1), -(1047, 1000, 20480000, 2048, 0, 0, '', 1), -(1048, 1000, 20480000, 2048, 0, 0, '', 1), -(1049, 1000, 20480000, 2048, 0, 0, '', 1), -(1050, 1000, 20480000, 2048, 0, 0, '', 1), -(1051, 500, 20480000, 1024, 0, 0, '', 1), -(1052, 500, 20480000, 1024, 0, 0, '', 0), -(1053, 500, 20480000, 1024, 0, 0, '', 1), -(1054, 500, 20480000, 1024, 0, 0, '', 1), -(1055, 500, 20480000, 1024, 0, 0, '', 1), -(1056, 500, 20480000, 1024, 0, 0, '', 1), -(1057, 500, 20480000, 1024, 0, 0, '', 1), -(1058, 1000, 5120000, 204800, 0, 0, '', 1), -(1059, 1000, 5120000, 204800, 0, 0, '', 1), -(1060, 1000, 3072000, 5120, 0, 0, '', 1), -(1061, 2000, 2048000, 2048000, 0, 0, '', 1), -(1062, 1000, 10240000, 2048, 0, 0, '', 1), -(1063, 3000, 20480000, 2048, 0, 0, '', 1), -(1064, 500, 20480000, 20480, 0, 0, '', 1), -(1065, 500, 3072000, 20480000, 0, 0, '', 1), -(1066, 1000, 102400000, 2048, 0, 0, '', 1), -(1067, 500, 20480000, 20480000, 0, 0, '', 1), -(1068, 1000, 5120000, 2048, 0, 0, '', 1), -(1069, 500, 5120000, 2048, 0, 0, '', 1), -(1070, 2000, 5120000, 2048, 0, 0, '', 1), -(1071, 1000, 5120000, 2048, 0, 0, '', 1), -(1072, 2000, 20480000, 2048, 0, 0, '', 1), -(1073, 250, 5120000, 2048, 0, 0, '', 1), -(1074, 500, 5120000, 2048, 0, 0, '', 1), -(1075, 1000, 5120000, 2048, 0, 0, '', 1), -(1076, 2000, 20480000, 2048, 0, 0, '', 1), -(1077, 1000, 5120000, 2048, 0, 0, '', 1), -(1078, 1000, 5120000, 2048, 0, 0, '', 1), -(1079, 1000, 5120000, 2048, 0, 0, '', 1), -(1080, 1000, 5120000, 2048, 0, 0, '', 1), -(1081, 1000, 2097152, 2048, 0, 0, '', 1), -(1082, 1000, 5120000, 2048, 0, 0, '', 1), -(1083, 1000, 5120000, 2048, 0, 0, '', 1), -(1084, 1000, 5120000, 2048, 0, 0, '', 1), -(1085, 500, 5120000, 2048, 0, 0, '', 1), -(1086, 1000, 2097152, 2048, 0, 0, '', 1), -(1087, 1000, 65536000, 2048, 0, 0, '', 1), -(1088, 1000, 65536000, 2048, 0, 0, '', 1), -(1089, 1000, 65536000, 2048, 0, 0, '', 1), -(1090, 1000, 65536000, 2048, 0, 0, '', 1), -(1091, 5000, 65536000, 2048, 0, 0, '', 1), -(1092, 1000, 65536000, 2048, 0, 0, '', 1), -(1093, 1000, 65536000, 2048, 0, 0, '', 1), -(1094, 1000, 5120000, 2048, 0, 0, '', 1), -(1095, 1000, 5120000, 2048, 0, 0, '', 1), -(1096, 1000, 16384000, 2048, 0, 0, '', 1), -(1097, 1000, 5120000, 2048, 0, 0, '', 1), -(1098, 1000, 5120000, 2048, 0, 0, '', 1), -(1099, 500, 5120000, 2048, 0, 0, '', 1), -(1100, 1500, 65536000, 10240000, 0, 0, '', 1), -(1101, 45000, 5120000, 2048, 0, 0, '', 1), -(1102, 5000, 20480000, 512, 0, 0, '', 1), -(1103, 5000, 20480000, 2048, 0, 0, '', 1), -(1104, 5000, 20480000, 2048, 0, 0, '', 1), -(1105, 5000, 20480000, 2048, 0, 0, '', 1), -(1106, 5000, 20480000, 2048, 0, 0, '', 1), -(1107, 1000, 5120000, 2048, 0, 0, '', 1), -(1108, 5000, 5120000, 2048, 0, 0, '', 1), -(1109, 1000, 5120000, 2048, 0, 0, '', 1), -(1110, 1000, 5120000, 2048, 0, 0, '', 1), -(1111, 1000, 5120000, 2048, 0, 0, '', 1), -(1112, 1000, 5120000, 2048, 0, 0, '', 1), -(1113, 1000, 5120000, 2048, 0, 0, '', 1), -(1114, 1000, 5120000, 51200, 0, 0, '', 1), -(1115, 1000, 5120000, 2048, 0, 0, '', 1), -(1116, 1000, 5120000, 2048, 0, 0, '', 1), -(1117, 1000, 5120000, 2048, 0, 0, '', 1), -(1118, 1000, 5120000, 2048, 0, 0, '', 1), -(1119, 1000, 5120000, 2048, 0, 0, '', 1), -(1120, 1000, 5120000, 2048, 0, 0, '', 1), -(1121, 1000, 5120000, 2048, 0, 0, '', 1), -(1122, 1000, 5120000, 2048, 0, 0, '', 1), -(1123, 1000, 5120000, 2048, 0, 0, '', 1), -(1124, 1000, 5120000, 2048, 0, 0, '', 1), -(1125, 1000, 5120000, 2048, 0, 0, '', 1), -(1126, 1000, 5120000, 2048, 0, 0, '', 1), -(1127, 1000, 5120000, 2048, 0, 0, '', 1), -(1128, 1000, 5120000, 256000, 0, 0, '', 1), -(1129, 1000, 5120000, 2048, 0, 0, '', 1), -(1130, 1000, 5120000, 2048, 0, 0, '', 1), -(1131, 1000, 5120000, 2048, 0, 0, '', 1), -(1132, 1000, 5120000, 2048, 0, 0, '', 1), -(1133, 1000, 5120000, 2048, 0, 0, '', 1), -(1134, 500, 5120000, 102400, 0, 0, '', 1), -(1135, 1000, 5120000, 2048, 0, 0, '', 1), -(1136, 1000, 5120000, 2048, 0, 0, '', 1), -(1137, 1000, 51200000, 5120000, 0, 0, '', 1), -(1138, 2000, 5120000, 2048000, 0, 0, '', 1), -(1139, 1000, 10240000, 2048, 0, 0, '', 1), -(1140, 1000, 10240000, 2048, 0, 0, '', 1), -(1141, 5000, 131072000, 2048, 0, 0, '', 1), -(1142, 5000, 131072000, 2048, 0, 0, '', 1), -(1143, 5000, 131072000, 2048, 0, 0, '', 1), -(1144, 5000, 131072000, 2048, 0, 0, '', 1), -(1145, 5000, 131072000, 2048, 0, 0, '', 1), -(1146, 1000, 16384000, 2048, 0, 0, '', 1), -(1147, 5000, 131072000, 2048, 0, 0, '', 1), -(1148, 1000, 5120000, 2048, 0, 0, '', 1), -(1149, 1000, 5120000, 2048, 0, 0, '', 1), -(1150, 1000, 5120000, 2048, 0, 0, '', 1), -(1151, 1000, 5120000, 2048, 0, 0, '', 1), -(1152, 1000, 5120000, 2048, 0, 0, '', 1), -(1153, 3000, 65536000, 5120000, 0, 0, '', 1), -(1154, 1000, 5120000, 2048, 0, 0, '', 1), -(1155, 2000, 65536000, 2048, 0, 0, '', 1), -(1156, 1000, 5120000, 2048, 0, 0, '', 1), -(1157, 500, 5120000, 204800, 0, 0, '', 1), -(1158, 1000, 5120000, 2048, 0, 0, '', 1), -(1159, 1000, 5120000, 2048, 0, 0, '', 1), -(1160, 1000, 5120000, 2048, 0, 0, '', 1), -(1161, 1000, 5120000, 2048000, 0, 0, '', 1), -(1162, 1000, 5120000, 2048, 0, 0, '', 1), -(1163, 1000, 5120000, 2048, 0, 0, '', 1), -(1164, 1000, 5120000, 2048, 0, 0, '', 1), -(1165, 1000, 5120000, 2048, 0, 0, '', 1), -(1166, 1000, 5120000, 2048, 0, 0, '', 1), -(1167, 1000, 5120000, 2048, 0, 0, '', 1), -(1168, 5000, 5120000, 2048, 0, 0, '', 1), -(1169, 1000, 5120000, 2048, 0, 0, '', 1), -(1170, 1000, 5120000, 2048, 0, 0, '', 1), -(1171, 1000, 5120000, 2048, 0, 0, '', 1), -(1172, 1000, 5120000, 2048, 0, 0, '', 1), -(1173, 250, 16384000, 16384, 0, 0, '', 1), -(1174, 1000, 5120000, 2048, 0, 0, '', 1), -(1175, 2000, 51200000, 5120, 0, 0, '', 1), -(1176, 1000, 51200000, 2048, 0, 0, '', 1), -(1177, 1000, 51200000, 2048000, 0, 0, '', 1), -(1178, 1000, 5120000, 2048, 0, 0, '', 1), -(1179, 500, 51200000, 2048, 0, 0, '', 1), -(1180, 1000, 5120000, 2048, 0, 0, '', 1), -(1181, 4000, 16384000, 2048, 0, 0, '', 1), -(1182, 250, 5120000, 2048, 0, 0, '', 1), -(1183, 1000, 20480000, 2048000, 0, 0, '', 1), -(1184, 1000, 20480000, 2048000, 0, 0, '', 1), -(1185, 1000, 5120000, 2048, 0, 0, '', 1), -(1186, 3000, 5120000, 2048, 0, 0, '', 1), -(1187, 1000, 5120000, 2048000, 0, 0, '', 1), -(1188, 2000, 5120000, 2048000, 0, 0, '', 1), -(1189, 1000, 5120000, 2048, 0, 0, '', 1), -(1190, 500, 5120000, 2048000, 0, 0, '', 1), -(1191, 1000, 5120000, 2048, 0, 0, '', 1), -(1192, 1000, 5120000, 2048, 0, 0, '', 1), -(1193, 10000, 5120000, 2048, 0, 0, '', 1), -(1194, 1000, 5120000, 2048, 0, 0, '', 1); - --- -------------------------------------------------------- - --- --- Table structure for table `challenges_lang` --- - -CREATE TABLE IF NOT EXISTS `challenges_lang` ( - `id` int(11) NOT NULL, - `langcode` varchar(2) NOT NULL, - `name` varchar(200) NOT NULL, - `description` text NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - --- --- Dumping data for table `challenges_lang` --- - -INSERT INTO `challenges_lang` (`id`, `langcode`, `name`, `description`) VALUES -(1000, 'uk', 'Swap', '<P align=left><B>Завдання</B></P><P>Дано два цілих числа a та b. Написати програму, яка б міняла їхні значення місцями. Тобто після виконання програми замість а значення b, а замість b - а. <P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа - а та b. (-32000 < a, b < 32000). <P><B>Вихідні дані</B></P><P>Вивести в єдиний рядок через пропуск два числа: спочатку b, а потім a. <P><B>Приклад введення 1</B></P><P><PRE>1 2</PRE><P><B>Приклад виведення 1</B></P><P><PRE>2 1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>3 2</PRE><BR>'), -(1001, 'uk', 'A in power k', '<P align=left><B>Завдання</B></P><P>Для заданого цілого а та натурального k обчислити a<SUP>k</SUP>.<P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа a та k (-32000 < a <= 32000, 0 < k < 32000).<P><B>Вихідні дані</B></P><P>Єдине число - відповідь. Гарантується, що відповідь не більша за 2*10<SUP>9</SUP>.<P><B>Приклад введення 1</B></P><P><PRE>1 1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>8</PRE><BR>'), -(1002, 'uk', 'Послідовність Фібоначчі', '<P align=left><B>Завдання</B></P><P>Послідовність фібоначчі визначається наступним чином:<BR></P><UL><LI>a<SUB>0</SUB>=0;<LI>a<SUB>1</SUB>=1;<LI>a<SUB>k</SUB>=a<SUB>k-1</SUB> + a<SUB>k-2</SUB></LI></UL><BR><BR>Для заданого n знайти значення n-го елемента послідовності Фібоначчі (a<SUB>n</SUB>).<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 40).<P><B>Вихідні дані</B></P><P>Єдине число - відповідь.<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>5</PRE><P><B>Приклад виведення 2</B></P><P><PRE>5</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>8</PRE><P><B>Приклад виведення 3</B></P><P><PRE>21</PRE><BR>'), -(1003, 'uk', 'Рукавички', '<P align=left><B>Завдання</B></P><P>Комірник видає по К рукавичок кожному робітнику. Тобто другий робітник отримає рукавички від (K+1)-шої до (2∙K)-ї включно, рукавички номер (2∙K+2) отримає третій робітник і для нього вони будуть другими.<P>Напишіть програму, яка за номером виданих рукавичок визначає номер робітника, якому їх видано та порядковий номер цих рукавичок в цього робітника<P><B>Вхідні дані</B></P><P>В єдиному рядку записано два числа - K та N. K - кількість рукавичок кожному робітнику, N - номер пари рукавичок (1 <= K <= 200, 1 <= N <= 20000) розділені пропуском.<P><B>Вихідні дані</B></P><P>Номер робітника та номер рукавичок в цього робітника, розділені пропуском.<P><B>Приклад введення 1</B></P><P><PRE>50 1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>1 1</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>20 25</PRE><P><B>Приклад виведення 2</B></P><P><PRE>2 5</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>15 43</PRE><P><B>Приклад виведення 3</B></P><P><PRE>3 13</PRE><BR>'), -(1004, 'uk', 'Супер проста проблема', '<P align=left><B>Завдання</B></P><P>Знайти квадрат N-го простого числа.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 100).<P><B>Вихідні дані</B></P><P>Єдине число - квадрат N-го простого числа<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>4</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2</PRE><P><B>Приклад виведення 2</B></P><P><PRE>9</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>5</PRE><P><B>Приклад виведення 3</B></P><P><PRE>121</PRE><BR>'), -(1005, 'uk', '0-1 проблема', '<P align=left><B>Завдання</B></P><P>Над рядочком 01 виконаємо наступні операції:<UL><LI>Скопіюємо в кінець рядочка самого себе (отримаємо 0101)<LI>В другій половині рядка всі 0 змінимо на 1, а всі 1 на 0 (отримаємо 0110)</LI></UL>Над рядочком 0110 виконаємо ті самі операції. Отримаємо 01101001. І т. д.Таким чином отримаємо нескінченний рядочок нулів та одиниць.Ваше завдання – знайти n-тий символ такого рядочка.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= N <= 2000000000).<P><B>Вихідні дані</B></P><P>Єдиний символ, який буде на N-й позиції.<P><B>Приклад введення 1</B></P><P><PRE>1</PRE><P><B>Приклад виведення 1</B></P><P><PRE>0</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>2</PRE><P><B>Приклад виведення 2</B></P><P><PRE>1</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>5</PRE><P><B>Приклад виведення 3</B></P><P><PRE>1</PRE><BR>'), -(1006, 'uk', 'Одинадцять', '<P align=left><B>Завдання</B></P><P>Ваше завдання – визначити чи ділиться дане число на 11.<P><B>Вхідні дані</B></P><P>В єдиному рядку записане єдине число N (1 <= n). Число має не більше тисячі знаків.<P><B>Вихідні дані</B></P><P>Вам потрібно вивести “Yes” – якщо число ділиться на 11, і “No” – в протилежному випадку.<P><B>Приклад введення 1</B></P><P><PRE>323455693</PRE><P><B>Приклад виведення 1</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>5038297</PRE><P><B>Приклад виведення 2</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>112234</PRE><P><B>Приклад виведення 3</B></P><P><PRE>No</PRE><BR>'), -(1007, 'uk', 'Супер послідовність', '<P align=left><B>Завдання</B></P><P>Послідовність чисел a1, a2, … an називається супер послідовністю, якщо виконуються наступні умови:<UL><LI>0 < a1 < a2 < … < an<LI>жодне з чисел не є сумою двох або більше інших чисел</LI></UL><P><B>Вхідні дані</B></P><P>В єдиному рядку записане число N (1 <= n <= 50), далі задано N чисел, кожне з яких не менше 1 і не більше 1000.<P><B>Вихідні дані</B></P><P>Вам необхідно вивести “Yes” – якщо дано супер послідовність, “No” – в протилежному випадку.<P><B>Приклад введення 1</B></P><P><PRE>2 1 2</PRE><P><B>Приклад виведення 1</B></P><P><PRE>Yes</PRE><BR><P><B>Приклад введення 2</B></P><P><PRE>3 1 2 3</PRE><P><B>Приклад виведення 2</B></P><P><PRE>No</PRE><BR><P><B>Приклад введення 3</B></P><P><PRE>10 1 3 16 19 25 70 100 243 245 306</PRE><P><B>Приклад виведення 3</B></... [truncated message content] |