Новости | FAQ | Авторы | Документация | В действии | Библиотека |
Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Beau 23.03.2006 21:07
Разбираю код опросника, который когда-то был на http://crimnet.invex.ru/poll/ (сейчас не работает).^if((def $params.request && $params.request is hash && def $params.request.$path_param) || $poll_info.status eq "closed"){ ## detecting restriction ^if(def $params.restrict && $params.restrict is hash){ ## cookie name defining ^if(def $params.restrict.cookie){ $cookie[${poll_id}_$params.restrict.cookie] }{ $cookie[${poll_id}_poll] } ## expire date defining ^if(def $params.restrict.expires){ $expires[^params.restrict.expires.int(1)] }{ $expires[session] } ## setting cookie ^if(!def $cookie:$cookie){ ^if($expires eq "session"){ $cookie:$cookie[$expires] }{ $cookie:$cookie($expires) } }{ ## voting restricted $restricted(1) } } ## updating vote counts ^if(!$restricted && def $params.request.$path_param && $params.request.$path_param is table && $poll_info.status ne "closed"){ ^params.request.$path_param.menu{ ^void:sql{ UPDATE $pa_table SET vote_count = vote_count+1 WHERE answer_id = '^params.request.$path_param.field.int(0)' AND poll_id = '$poll_id' } } } ## user voted or poll closed $action[result] }{ ## active poll, no vote submitted $action[answer] }