7456 [idsamigos] => Array ( [0] => 1520 ) [comentarios] => aasd ) */ global $user_ID; $post_ID = (int) $_REQUEST["post_ID"]; $post = get_post($post_ID); $user = get_user_by("id", $user_ID); //$idsamigos = $_POST["idsamigos"]; $emails = $_POST["email"]; $comentarios = $_POST["comentarios"]; $in = array(); if(!is_array($emails) || count($emails) == 0) { mensaje("No has seleccionado ningún amigo para enviar la tontería");//.print_r($emails,true) exit; } /*foreach($idsamigos as $k => $idamigo) { if($idamigo > 0) { $in[] = (int) $idamigo; } } $query = "select * from {$wpdb->prefix}friends where user_id = $user_ID and id in (".join(",",$in).")"; $amigos = $wpdb->get_results($query); foreach($idsamigos as $i => $idamigo) { if($idsamigos[$i] == (int) 0) { $amigo = new stdClass; $email = $emails[$i]; $amigo->nombre = $emails[$i]; $amigo->email = $emails[$i]; $amigo->display_name = $emails[$i]; $amigos[] = $amigo; } } */ foreach($emails as $amigo) { $from = 'Tonterias.com '; $nombre = $amigo; $email = $amigo; $nombre_completo = $user->display_name; $titulo = $post->post_title; // Version HTML $html_message = " ¡Hola $nombre!

$nombre_completo ha visto en tonterias.com algo que te va a gustar:
".$titulo."

" . (($comentarios) ? "\"$comentarios\"
" : '' ). "

 ". ""; if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail($post->ID)) ) { $html_message .= get_the_post_thumbnail( $post->ID, 'thumbnail' )."
"; } else { $html_message .= "".the_title(
"; } $html_message .= "Ver >>>
"; if(($fp = fopen($docroot."/wp-content/themes/tonterias/boletin_plantilla.php", "r"))) { $tmp="";while(!feof($fp)) { $tmp.=fgets($fp,1024); } $html_message = str_replace ("%CARTA%", $html_message, $tmp); } // Version txt $text_message = "¡Hola $nombre!\n". "ha visto en tonterias.com algo que te va a gustar: $titulo\n\n". "Ver en: ".get_permalink($post->ID)."\n"; $random_hash = md5(date('r', time())); //define the headers we want passed. Note that they are separated with \r\n $headers = "From: $from\n"; //add boundary string and mime type specification $headers .= "MIME-version: 1.0\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; $mensaje_completo = "--PHP-alt-$random_hash\n". "Content-Type: text/plain; charset=\"utf-8\"\n". "Content-Transfer-Encoding: 7bit\n\n". $text_message."\n". "--PHP-alt-$random_hash\n". "Content-Type: text/html; charset=\"utf-8\"\n". "Content-Transfer-Encoding: 7bit\n\n". $html_message."\n\n". "--PHP-alt-$random_hash--\n\n"; mail($email, mb_encode_mimeheader($titulo,"UTF-8", "B", "\n"), $mensaje_completo, $headers); /* $titulo = strip_tags($titulo); $html_message = htmlentities($html_message); $text_message = strip_tags($text_message); $f = fopen("http://".$_SERVER["SERVER_NAME"]."/beta/index.php/api/enviar_mail/$email/$titulo/$text_message/$html_message","r"); $html = stream_get_contents($f); */ } //$pais = $wpdb->get_var("select eup_pais from {$wpdb->prefix}eup where user_id = {$user_ID}"); // Guardar accion // if(count($amigos) > 0) { // $wpdb->query("INSERT INTO {$wpdb->prefix}acciones (tipo, rel_id, fecha, user_id, post_id, texto, pais) // VALUES ('E', '$id', now(), '$user_ID', '$post_ID', '".count($amigos)."', '$pais')"); //} mensaje("La tontería fué enviada"); if(function_exists("borrar_cache_actividades")) { borrar_cache_actividades(); borrar_cache_tonteria($post_ID); } exit; } $ajax = (bool) isset($_GET["ajax"])?$_GET["ajax"]:false; $accion = isset($_GET["accion"])?$_GET["accion"]:false; if($ajax) { if($accion == "lista-amigos") { $query = "select id, case length(name) when 0 then email else case name = email when true then email else concat(name, ' <', email, '> ') end end amigo from {$wpdb->prefix}friends where user_id = $user_ID order by amigo "; $result["amigos"] = $wpdb->get_results($query); echo json_encode($result); } elseif($accion == "agregar-amigo") { $resp = new stdClass; $resp->existe = false; $resp->error = false; $nombre = $_GET["nombre"]; $email = $_GET["email"]; if(!check_email_address($email)) { $resp->error = true; $resp->msg = "El email no es correcto"; } else { $query = "select count(*) cant from {$wpdb->prefix}friends where user_id = $user_ID and email = '$email'"; $existe = $wpdb->get_var($query); if($existe > 0) { $resp->error = true; $resp->msg = "Ya habías agregado a este amigo"; } else { $query = "insert into {$wpdb->prefix}friends (user_id, email, name, provider) values($user_ID, '$email', '$nombre', 'manual')"; $wpdb->query($query); } } echo json_encode($resp); } elseif($accion == "obtener-amigos") { $transporte = $_GET["transporte"]; $user = $_GET["user"]; $password = $_GET["password"]; $output = false; include $docroot."/wp-content/plugins/invitar/post.php"; $resp = new stdClass; $resp->error = $error; if($error) { $resp->msg = "No se obtuvieron amigos"; } else { if($cant_amigos == 0) { $resp->msg = "No se obtuvieron nuevos amigos"; } elseif($cant_amigos == 0) { $resp->msg = "Se obtuvo 1 nuevo amigo"; } else { $resp->msg = "Se obtuvieron $cant_amigos nuevos amigos"; } } $resp->cant_amigos = $cant_amigos; echo json_encode($resp); } exit; } function mensaje($mensaje) { ?>

load("fonts","reset","datatable","json","connection","autocomplete","tabview"); echo $loader->tags(); ?>
Añadir