while ($r = mysql_fetch_array($result)) { $preguntas_disponibles = $r['num_preguntas_especificas'] + $r['num_preguntas_generales']; $margen_ultimoexamen = strtotime($r['fecha_ultimoexamen']) + $pol['config']['examen_repe']; if ((!$r['fecha_ultimoexamen'] or $margen_ultimoexamen < time()) and $pol['pols'] >= $pol['config']['pols_examen']) { // marca examen como hecho if ($r['fecha_ultimoexamen']) { //update mysql_query("UPDATE cargos_users SET time = '" . $date . "', nota = 0.0, aprobado = 'no' WHERE cargo_ID = '" . $r['cargo_ID'] . "' AND user_ID = '" . $pol['user_ID'] . "' LIMIT 1", $link); } else { //insert mysql_query("INSERT INTO cargos_users \r\n(cargo_ID, pais, user_ID, time, aprobado, nota) \r\nVALUES ('" . $r['cargo_ID'] . "', '" . PAIS . "', '" . $pol['user_ID'] . "', '" . $date . "', 'no', '0.0')", $link); } // Cobrar examen if ($pol['config']['pols_examen'] != '0') { include 'inc-functions-accion.php'; pols_transferir($pol['config']['pols_examen'], $pol['user_ID'], '-1', 'Examen: ' . $r['titulo']); } // EMPIEZA EXAMEN $txt_title = 'Examen'; $txt_nav = array('/examenes' => 'Exámenes', $r['titulo']); $txt_tab = array('/cargos' => 'Cargos'); $txt .= '<h1 class="quitar">Examen: ' . $r['titulo'] . '</h1> <p>Tienes <b><span class="seg"></span></b> segundos.</p> <table id="latabla" border="0"> <tr> <td style="background:red;" id="t_mas" width="12" height="1"></td>
while ($r = mysql_fetch_array($result)) { $grupo_nombre = $r['nombre']; } $result = mysql_query("SELECT ID AS user_ID, grupos FROM users WHERE estado = 'ciudadano' AND pais = '" . PAIS . "' AND grupos != '' AND grupos LIKE '%" . $_POST['grupo_ID'] . "%' LIMIT 1000", $link); while ($r = mysql_fetch_array($result)) { if ($r['user_ID'] != $pol['user_ID'] and in_array($_POST['grupo_ID'], explode(' ', $r['grupos']))) { mysql_query("INSERT INTO mensajes (envia_ID, recibe_ID, time, text, leido, cargo, recibe_masivo) VALUES ('" . $pol['user_ID'] . "', '" . $r['user_ID'] . "', '" . $date . "', '<b>Mensaje multiple: grupo " . $grupo_nombre . "</b><br />" . $text . "', '0', '" . $_POST['calidad'] . "', '" . $_POST['cargo_ID'] . "')", $link); evento_chat('<b>Nuevo mensaje privado</b> (<a href="http://' . strtolower(PAIS) . '.' . DOMAIN . '/msg"><b>Leer!</b></a>)', $r['user_ID'], -1, false, 'p'); notificacion($r['user_ID'], 'Mensaje privado del grupo ' . $grupo_nombre, '/msg'); } } $refer_url = 'msg/'; } elseif ($_POST['para'] == 'todos' and $pol['pols'] >= $pol['config']['pols_mensajetodos']) { // MENSAJE GLOBAL $text = '<b>Mensaje Global:</b> (' . pols($pol['config']['pols_mensajetodos']) . ' ' . MONEDA . ')<hr />' . $text; pols_transferir($pol['config']['pols_mensajetodos'], $pol['user_ID'], '-1', 'Mensaje Global'); $result = mysql_query("SELECT ID FROM users WHERE estado = 'ciudadano' AND pais = '" . PAIS . "'", $link); while ($r = mysql_fetch_array($result)) { mysql_query("INSERT INTO mensajes (envia_ID, recibe_ID, time, text, leido, cargo) VALUES ('" . $pol['user_ID'] . "', '" . $r['ID'] . "', '" . $date . "', '" . $text . "', '0', '" . $_POST['calidad'] . "')", $link); notificacion($r['ID'], 'Mensaje privado global', '/msg'); $refer_url = 'msg'; } } } break; case 'elecciones-generales': $ID_partido = $_POST['ID_partido']; if (!$_GET['b'] and $pol['config']['elecciones_estado'] == 'elecciones' and $pol['estado'] == 'ciudadano') { $fecha_24_antes = date('Y-m-d H:i:00', strtotime($pol['config']['elecciones_inicio']) - $pol['config']['elecciones_antiguedad']); //fecha registro? $result = mysql_query("SELECT fecha_registro FROM users WHERE ID = '" . $pol['user_ID'] . "' LIMIT 1", $link);
if ($pol['config']['impuestos_empresa'] > 0) { $result = mysql_query("SELECT COUNT(ID) AS num, user_ID FROM " . SQL . "empresas GROUP BY user_ID ORDER BY num DESC", $link); while ($r = mysql_fetch_array($result)) { // comprueba si existe el propietario de la empresa antes de ejecutar el impuesto $result2 = mysql_query("SELECT ID, pols FROM users WHERE ID = '" . $r['user_ID'] . "' AND pais = '" . PAIS . "' LIMIT 1", $link); while ($r2 = mysql_fetch_array($result2)) { $impuesto = round($pol['config']['impuestos_empresa'] * $r['num']); if ($r2['pols'] >= $impuesto) { $recaudacion_empresas += $impuesto; pols_transferir($impuesto, $r['user_ID'], '-1', 'IMPUESTO EMPRESAS ' . date('Y-m-d') . ': ' . $r['num'] . ' empresas'); } else { $result3 = mysql_query("SELECT ID, pols FROM " . SQL . "cuentas WHERE user_ID = '" . $r['user_ID'] . "' AND nivel = '0' ORDER BY pols DESC LIMIT 1", $link); while ($r3 = mysql_fetch_array($result3)) { if ($r3['pols'] >= $impuesto) { $recaudacion_empresas += $impuesto; pols_transferir($impuesto, '-' . $r3['ID'], '-1', 'IMPUESTO EMPRESAS ' . date('Y-m-d') . ': ' . $r['num'] . ' empresas'); } } } } } evento_chat('<b>[PROCESO] IMPUESTO EMPRESAS ' . date('Y-m-d') . '</b>, recaudado: ' . pols($recaudacion_empresas) . ' ' . MONEDA); } } // FIN if (ECONOMIA) { // NOTAS MEDIA $result = mysql_query("SELECT user_ID, AVG(nota) AS media FROM cargos_users WHERE pais = '" . PAIS . "' GROUP BY user_ID", $link); while ($r = mysql_fetch_array($result)) { if ($r['media']) { mysql_query("UPDATE users SET nota = '" . $r['media'] . "' WHERE ID = '" . round($r['user_ID'], 1) . "' LIMIT 1", $link); }
// Cuenta $_GET['destino'] = str_replace('-', '', $_GET['destino']); $result = mysql_query("SELECT ID FROM " . SQL . "cuentas WHERE ID = '" . $_GET['destino'] . "' LIMIT 1", $link); while ($row = mysql_fetch_array($result)) { $destino = '-' . $row['ID']; } } else { // NICK $result = mysql_query("SELECT ID FROM " . SQL_USERS . " WHERE nick = '" . $_GET['destino'] . "' LIMIT 1", $link); while ($row = mysql_fetch_array($result)) { $destino = $row['ID']; } } // ejecuta transferencia if ($origen and $destino) { pols_transferir($_GET['pols'], $origen, $destino, 'API: ' . $concepto); $txt = 'ok'; } } break; } } echo $txt; } else { ?> <html> <head> <title>API VirtualPol</title> <style type="text/css"> li em { color:green; font-size:18px; }
function eliminar_ciudadano($ID) { global $link, $pol; $user_ID = false; $result3 = mysql_query("SELECT IP, pols, nick, ID, ref, estado" . (ECONOMIA ? ",\r\n\t(SELECT SUM(pols) FROM " . SQL . "cuentas WHERE user_ID = '" . $ID . "') AS pols_cuentas" : "") . " \r\n\tFROM users \r\n\tWHERE ID = '" . $ID . "' \r\n\tLIMIT 1", $link); while ($r3 = mysql_fetch_array($result3)) { $user_ID = $r3['ID']; $estado = $r3['estado']; $pols = $r3['pols'] + $r3['pols_cuentas']; $nick = $r3['nick']; $ref = $r3['ref']; $IP = $r3['IP']; } if ($user_ID) { // ELIMINAR CIUDADANO if (ECONOMIA) { pols_transferir($pols, $user_ID, '-1', '† Defuncion: <em>' . $nick . '</em>'); } if (ECONOMIA and $ref != '0') { mysql_query("UPDATE users SET ref_num = ref_num - 1 WHERE ID = '" . $ref . "' LIMIT 1", $link); mysql_query("DELETE FROM " . SQL_REFERENCIAS . " WHERE IP = '" . $IP . "' OR user_ID = '" . $ref . "'", $link); } mysql_query("DELETE FROM users WHERE ID = '" . $user_ID . "' LIMIT 1", $link); mysql_query("DELETE FROM " . SQL . "partidos_listas WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "partidos WHERE ID_presidente = '" . $user_ID . "'", $link); mysql_query("DELETE FROM cargos_users WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "ban WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM chats WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM votos WHERE emisor_ID = '" . $user_ID . "' OR (tipo = 'confianza' AND item_ID = '" . $user_ID . "')", $link); mysql_query("DELETE FROM " . SQL . "foros_msg WHERE user_ID = '" . $user_ID . "' AND hilo_ID = '-1'", $link); if (ECONOMIA) { mysql_query("DELETE FROM " . SQL_REFERENCIAS . " WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "empresas WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "mercado WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "mapa WHERE user_ID = '" . $user_ID . "'", $link); mysql_query("DELETE FROM " . SQL . "cuentas WHERE user_ID = '" . $user_ID . "'", $link); } $img_root = RAIZ . '/img/a/' . $user_ID; if (file_exists($img_root . '.jpg')) { @unlink($img_root . '.jpg'); @unlink($img_root . '_40.jpg'); } // anula el posible voto en elecciones if ($pol['config']['elecciones_estado'] == 'elecciones') { mysql_query("UPDATE " . SQL . "elecciones SET ID_partido = '-1' WHERE user_ID = '" . $user_ID . "' LIMIT 1", $link); } // eliminar /* PENDIENTE DE ARREGLAR. CODIGO CORRECTO, EXCEPTO QUE NO DEBE BORRAR MENSAJES DE EXPULSADOS POR PETICION PROPIA. if ($estado == 'expulsado') { mysql_query("DELETE FROM ".SQL."foros_msg WHERE user_ID = '".$user_ID."'", $link); mysql_query("DELETE FROM ".SQL."foros_hilos WHERE user_ID = '".$user_ID."'", $link); } */ } }