$app->settings["ecAPI"]["TEMPLATE_DIR"], 'compileDir' => $app->settings["ecAPI"]["COMPILE_DIR"] ); include("auth.php"); if ( isset( $_REQUEST['index'] ) ) $index = (int)$_REQUEST['index']; $tpl->TITLE = 'Concursos'; if ( !isset($index) ) { $tpl->listado = true; $query = $app->do_query("SELECT * FROM concursos WHERE ACTIVO__CON = 'S' ORDER BY ID______CON DESC , ACTIVO__CON DESC LIMIT 7"); while( $reg = $query->fetchRow(DB_FETCHMODE_ASSOC) ) { $reg['CUERPO__CON'] = substr( $reg['CUERPO__CON'] , 0 , 250 ); if ( !isset( $tpl->concurso ) ) { $tpl->concurso = $reg; } else { $tpl->concursos[] = $reg; } } } else { // Contador del Concurso if ( !isset($_SESSION["contestVisited"][$index]) ) { $app->do_query(" UPDATE CONCURSOS SET visitas_con = visitas_con + 1 WHERE id______con = '".$app->quotesql( (int) $index )."' "); $_SESSION["contestVisited"][$index] = true; } $query = $app->do_query("SELECT * FROM concursos WHERE ACTIVO__CON = 'S' AND ID______CON = '".$app->quotesql($index)."'"); while( $reg = $query->fetchRow(DB_FETCHMODE_ASSOC) ) { $tpl->concurso = $reg; } if ( $tpl->concurso['ACTIVO__CON'] == 'S' ) { $require_login = array("inscrito"); include("auth.php"); $tpl->concurso['ACTIVO__CON'] = true; } else $tpl->concurso['ACTIVO__CON'] = false; if ( $tpl->concurso['ACTIVOGANADORES__CON'] == 'S' ) { $require_login = array("inscrito"); include("auth.php"); $tpl->concurso['ACTIVOGANADORES__CON'] = true; } else $tpl->concurso['ACTIVOGANADORES__CON'] = false; if ( $_REQUEST['ganadores'] ) { $query = $app->do_query("SELECT * FROM resultados , inscritos WHERE concursores = '".$app->quotesql($index)."' AND ganador_res = 'S' AND inscritores = id______ins ORDER BY ID______RES "); while( $reg = $query->fetchRow(DB_FETCHMODE_ASSOC) ) { if ( count( $tpl->ganadores )%2 == 0 ) $reg['CLASS'] = 'odd'; $tpl->ganadores[] = $reg; } } if ( !$_REQUEST['terminar'] ) { $tpl->mostrar_concurso = true; // Concurso Especifico $tpl->TITLE .= " - ".$tpl->concurso['TITULO__CON']; if ( isset($_REQUEST['participar']) ) { // Leemos Preguntas del Concurso $query = $app->do_query("SELECT * FROM preguntas WHERE concursopre = '".$app->quotesql($index)."' ORDER BY orden___pre ASC "); while( $reg = $query->fetchRow(DB_FETCHMODE_ASSOC) ) { $reg['RESPUESTPRE'] = unserialize( $reg['RESPUESTPRE'] ); if ( $reg['TIPO____PRE'] == 'S' ) $reg['SELECION'] = true; else $reg['DESARROLLO'] = true; $tpl->preguntas[] = $reg; } $tpl->participar = true; } } else { foreach ( $_POST as $k => $v ) { if ( $k != 'terminar' AND $k != 'ID______CON' ) { $text .= " ".str_replace("_"," ", $k )." : ".$v."
"; } } /* print_r( $_POST ); print_r( $text ); die(); */ $dataToStore = array( 'inscritores' => $_SESSION['ID______INS'], 'concursores' => $_POST['ID______CON'], 'respuestres' => $text, 'ip______res' => $_SERVER['REMOTE_ADDR'] ); // ¿ Ya Respondio ? $query = $app->do_query("SELECT COUNT(id______res) AS COUNT FROM resultados WHERE inscritores = '".$_SESSION['ID______INS']."' AND concursores = '".$app->quotesql( $index )."' "); while( $reg = $query->fetchRow(DB_FETCHMODE_ASSOC) ) { if ( $reg['COUNT'] == 0 ) { $app->addRecord("RESULTADOS" , $dataToStore ); $tpl->gracias = true; } else { //header("Location: /"); $tpl->TITLE = " Ya participaste "; $tpl->msg = " Ya has participado en nuestro concurso. "; $output = new HTML_Template_Flexy($options); $output->compile("msg.html"); $tpl->CONTENT=$output->bufferedOutputObject($tpl); include("container.php"); die(); } } } } $table = "INVITADOS"; $index = $_REQUEST["index"]; $model = new ecDDL(); include($app->settings["ecAPI"]["DATAMODEL"]); $model->createFromArray($modelArray); $tableDDL=$model->getTable($table); $fieldlist=array($table=>$tableDDL->getFieldNames()); $tablekey=$model->getTableKey($table); $tmp=new tpl(); $output = new HTML_Template_Flexy($options); $output->compile("concursos.html"); $tpl->CONTENT=$output->bufferedOutputObject($tpl); $tpl->username = $_SESSION['username']; include("container.php"); ?>