Beispiel #1
0
 public function nuevaPublicacion($params, $monto, $fecha, $fotos)
 {
     $bd = new bd();
     $foto = new fotos();
     $idVisita = $this->setVisitas();
     $params["visitas_publicaciones_id"] = $idVisita;
     $params["monto"] = $monto;
     $largo = strlen($params["titulo"]);
     $params["titulo"] = strtoupper(substr($params["titulo"], 0, 1)) . strtolower(substr($params["titulo"], 1, $largo - 1));
     // ucwords(strtolower($params["titulo"]));
     $result = $bd->doInsert($this->table, $params);
     //return $result;
     if ($result) {
         $this->id = $bd->lastInsertId();
         $hso = new Handler_Soat();
         $soat_params = array("u" => "http://apreciodepana.com/detalle.php?id=" . $this->id, "abid" => $params['usuarios_id'], "absid" => "0");
         $short_url = $hso->encode($soat_params);
         $this->setMonto($monto);
         $this->setStatus(1, 1, $fecha);
         $foto->path = "../../" . $foto->path;
         foreach ($fotos as $data) {
             $foto->crearFotoPublicacion($this->id, $data);
         }
         $result = $bd->doUpdate($this->table, array("short_id" => $short_url), "id={$this->id}");
         return $this->id;
     } else {
         return false;
     }
 }
Beispiel #2
0
function cleanMessage($message, $max_chars, $userid)
{
    $message = trim($message);
    $message = str_replace(array("<", ">"), array("&lt;", "&gt;"), $message);
    $chars = $max_chars;
    $links = Handler_Message::$LINKSRX;
    $texto = $message;
    if ($num = preg_match_all($links, $texto, $matches, PREG_SET_ORDER) > 0) {
        $chars = $chars - 23 * $num;
        $texto = preg_replace($links, "", $texto);
    }
    $chars = $chars - strlen($texto);
    if ($chars > $max_chars - 10) {
        //mensaje muy corto
        return 4;
    } else {
        if ($chars < 0) {
            //mensaje muy largo
            return 5;
        } else {
            if (count($matches) > 0) {
                $new_urls = array();
                $old_urls = array();
                $hso = new Handler_Soat();
                $soat = array("abid" => $userid, "absid" => 0);
                foreach ($matches as $match) {
                    if (preg_match_all("/(https?:\\/\\/1so\\.at\\/[A-Za-z0-9&ntilde;&Ntilde;_\\-]+)/", $match[0]) == 0) {
                        $old_urls[] = "/" . str_replace("/", "\\/", preg_quote($match[0])) . "/";
                        $soat['u'] = "" . $match[0];
                        $new = "http://1so.at/" . $hso->encode($soat);
                        $new_urls[] = $new != '' ? $new : $match[0];
                    }
                }
                $message = preg_replace($old_urls, $new_urls, $message);
            }
        }
    }
    return $message;
}