예제 #1
0
 /** Indica si un proceso esta activo, dado por su nombre
  * 
  * @param type $name El nombre del proceso
  * @return boolean
  */
 static function isActived($name)
 {
     if (is_null($process = AutoProcess::searchByName($name))) {
         return false;
     }
     return Util::convertIntToBoolean($process->activated);
 }
 function setImageProduction($production_id)
 {
     if (!isset($_GET["poster"])) {
         return "Sin poster";
     }
     /**
      *  MODIFICAR LA IMAGEN DE UNA PRODUCCION
      */
     $production = Production::find($production_id);
     $data[Production::ATTR_IMAGE] = "";
     $data[Production::ATTR_POSTER] = "http://" . $_GET["poster"];
     $path_image = public_path("assets/db/images/") . md5($production->title_original . $production->year);
     copy($data[Production::ATTR_POSTER], $path_image . "-poster.jpg");
     $production->poster = Util::convertPathToUrl($path_image . "-poster.jpg");
     if (strlen($data[Production::ATTR_IMAGE]) > 9) {
         copy($data[Production::ATTR_IMAGE], $path_image . ".jpg");
         $production->image = Util::convertPathToUrl($path_image . ".jpg");
     } else {
         $title_md5 = md5($production->title_original . $production->year);
         $image = new Image($production->poster);
         $production->image = $image->createCopy(214, 334, $title_md5, public_path("assets/db/images/"), false);
     }
     $production->save();
     return "REALIZADO EXITOSAMENTE";
 }
예제 #3
0
 function postReportProblem(Request $request)
 {
     $extensions = array("png", "jpg", "jpeg");
     $data = $request->all();
     if (!isset($data[Report::ATTR_TYPE]) || !isset($data[Report::ATTR_DESCRIPTION])) {
         return redirect()->back();
     }
     $report = new Report();
     $report->user_id = Auth::user()->id;
     $report->type = $data[Report::ATTR_TYPE];
     $report->date = DateUtil::getCurrentTime();
     $report->description = Util::trimText(strip_tags($data[Report::ATTR_DESCRIPTION]), 500);
     $report->image = null;
     if ($request->hasFile(Report::ATTR_IMAGE)) {
         $image = $request->file(Report::ATTR_IMAGE);
         $extension = strtolower($image->getClientOriginalExtension());
         //Valida la extension del archivo
         if (!in_array($extension, $extensions)) {
             return redirect()->back()->with(UI::message(UI::MESSAGE_TYPE_ERROR, "Extension de archivo no permitida, no es una imagen valida."));
         }
         //Valida el tamaño del archivo
         if ($image->getSize() > 2000000) {
             return redirect()->back()->with(UI::message(UI::MESSAGE_TYPE_ERROR, "Tamaño del archivo excesivo. Maximo 2MB"));
         }
         //Almacena la imagen subida por el usuario en la carpeta temporal
         $filename = DateUtil::getTimeStamp() . "." . $extension;
         $image->move(Auth::user()->getPathUploads(), $filename);
         $report->image = url(Auth::user()->getPathUploads() . $filename);
     }
     $report->save();
     return redirect("browser")->with(UI::modalMessage("¡Gracias por tu reporte!", "Tus comentarios acerca de tu experencia ayudan a mejorar la plataforma de Bandicot. Nos pondremos en contacto contigo por correo electrónico si necesitamos saber más detalles del problema.", "Cerrar"));
 }
예제 #4
0
 public function save()
 {
     $person = Person::where(Person::ATTR_NAME, $this->getName())->get()[0];
     $person->slug = Util::createSlug($person->name);
     $person->biography = $this->getBiography();
     $person->image = $this->getImage();
     $person->save();
 }
예제 #5
0
 static function newRecord($token, $payer_id, $transaction_id, $quantity)
 {
     $current_time = DateUtil::getCurrentTime();
     $user = Auth::user();
     $pay = new Payment();
     $pay->user_id = $user->id;
     $pay->method = Payment::METHOD_PAYPAL;
     $pay->mount = Payment::PAY_PRICE_PER_DAY * $quantity;
     $pay->quantity = $quantity;
     $pay->transaction_id = $transaction_id;
     $pay->ip = Util::getIP();
     $pay->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $pay->date = $current_time;
     $pay->token = $token;
     $pay->payer_id = $payer_id;
     $pay->save();
     $user->role = User::ROLE_SUSCRIPTOR_PREMIUM;
     $user->premium_to = is_null($user->premium_to) ? (new DateUtil($current_time))->addDays($quantity) : (new DateUtil($user->premium_to))->addDays($quantity);
     $user->save();
 }
예제 #6
0
 /**
  * Carga los datos de las producciones que se pondran en cola en la propiedad $dataRepository del objeto
  */
 public function loadRepository()
 {
     if ($this->skip >= self::MAX_NUM_QUERY) {
         return;
     }
     parent::loadContent(self::URL_SOURCE . $this->skip);
     //Selecciona y divide en secciones HTML el contenido relevante de cada produccion obtenida de la fuente
     preg_match_all('/<td[^>]*class=["\']title*["\']\\>(.*?)<\\/td>/i', $this->htmlContent, $sections, PREG_SET_ORDER);
     foreach ($sections as $section) {
         $data = $section[0];
         if (preg_match_all('/<a\\s+.*?href=[\\"\']?([^\\"\' >]*)[\\"\']?[^>]*>(.*?)<\\/a>/i', $data, $matches, PREG_SET_ORDER)) {
             foreach ($matches as $match) {
                 if (!Util::isUrl(self::WEB_SITE_SOURCE . $match[1])) {
                     continue;
                 }
                 //Array(titulo, Enlace)
                 $this->dataRepository[] = array(strip_tags($match[0]), self::WEB_SITE_SOURCE . $match[1]);
                 break;
             }
         }
     }
 }
예제 #7
0
 /** Crea una copy redimensionada y recortada adecuadamente sin defases de la image original y la almacena en el servidor con nuevo name
  * 
  * @param type $width Width de la copy
  * @param type $height Height de la copy
  * @param type $name Name de la copy
  * @param type $route La route donde se almacenara la copy
  * @param boolean $includeName Indica si debe adjuntar el antiguo nombre con el nuevo nombre 
  */
 public function createCopy($width, $height, $name, $route, $includeName = true)
 {
     $this->objectImage = $this->createImageFromOriginal();
     //Calcula los valores optimos a redimensioar sin desfasarse en los tamaños requeridos
     list($width_redim, $height_redim) = $this->calculateResizeMinProporcionate($width, $height);
     $copy_redim = imagecreatetruecolor($width_redim, $height_redim);
     $background = imagecolorallocate($copy_redim, 50, 255, 0);
     imagefilledrectangle($copy_redim, 0, 0, $width_redim, $height_redim, $background);
     imagecolortransparent($copy_redim, $background);
     //Redimensiona la image al proporcion adecuada
     imagecopyresized($copy_redim, $this->objectImage, 0, 0, 0, 0, $width_redim, $height_redim, $this->width, $this->height);
     //Almacenara la copy de la image redimensiona y recortada adecuadamente
     $copy_rec = imagecreatetruecolor($width, $height);
     $background = imagecolorallocate($copy_rec, 50, 255, 0);
     imagefilledrectangle($copy_rec, 0, 0, $width, $height, $background);
     imagecolortransparent($copy_rec, $background);
     list($x_recorte, $y_recorte) = $this->calculateCutPosition($width_redim, $height_redim, $width, $height);
     //Genera el recorte adecuado de la image
     imagecopy($copy_rec, $copy_redim, 0, 0, $x_recorte, $y_recorte, $width_redim, $height_redim);
     $destination = $includeName ? $route . $this->name . $name . "." . $this->extension : $route . $name . "." . $this->extension;
     $this->saveImage($copy_rec, $destination);
     return Util::convertPathToUrl($destination);
 }
예제 #8
0
 /** Obtiene un html en un formato standar para mostrar la produccion
  * 
  * @param type $production (Production) El objeto de production
  * @return type
  */
 static function getVisualHtml(Production $production, $classname = "production", $classimage = "img-rounded")
 {
     $isVideoMain = $production->haveVideoMain();
     $html = "<div class='" . $classname . "'>";
     $html .= "<a ";
     if (Auth::check()) {
         $html .= "onClick='modalProduction(\"" . $production->id . "\");'";
     } else {
         $html .= "href='" . url("production/" . $production->slug) . "'";
     }
     $html .= ">";
     //Si la produccion es una serie incrustar la información de los capitulos
     if (!$isVideoMain) {
         $chapters = Chapter::where(Chapter::ATTR_PRODUCTION_ID, $production->id)->get();
         $json = array();
         foreach ($chapters as $chapter) {
             $json[] = array($chapter->name, url("production/" . $production->slug . "/play/" . urlencode(\App\System\Library\Security\Hash::encrypt($chapter->id))));
         }
         $html .= "<span class='hidden' id='chapters-" . $production->id . "'>" . json_encode($json) . "</span>";
     }
     $html .= "<span class='hidden' id='url-" . $production->id . "'>" . url("production/" . $production->slug) . "</span><img id='img-production-" . $production->id . "' title='" . $production->title . "' class='" . $classimage;
     $html .= $production->state != Production::STATE_ACTIVE ? " production-not-available" : "";
     $html .= "' src='" . Util::convertToSecureUrl($production->image) . "'><div class='over'><span class='glyphicon glyphicon-play-circle'></span>" . $production->title . "</div>" . "</a>" . "</div>";
     return $html;
 }
예제 #9
0
<?php

use App\System\Library\Complements\Util;
use App\System\Library\Media\Image;
use Illuminate\Support\Facades\Storage;
use App\System\Models\User;
$isPremium = Auth::user()->role == User::ROLE_SUSCRIPTOR_PREMIUM;
$url = Util::getCurrentUrl();
?>
<div id="menu" class="col-xs-2">

    <div id="role-account" class="{{(Auth::user()->role==User::ROLE_SUSCRIPTOR)?"free":"premium"}}">
        {{(Auth::user()->role==User::ROLE_SUSCRIPTOR)?"Cuenta gratis":"Cuenta Premium"}}
    </div>
    <div id="avatar">
        <div id="content-avatar">
            <img class="img-rounded" src="{{(is_null(Auth::user()->avatar))?URL::to("assets/images/user_icon.png"):Auth::user()->avatar}}"/>

            <div id="action-edit-avatar">
                <div id="icon-edit-avatar">
                    <span class="glyphicon glyphicon-camera"></span>
                    <label>Actualizar foto de perfil</label>
                </div>
            </div>
        </div>     
    </div>
    <div id="name-account">
        {{Auth::user()->name}} {{Auth::user()->lastname}}
    </div>

 function ajaxChapterCreator(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     $chapter = isset($data[Chapter::ATTR_ID]) ? Chapter::findOrNew($data[Chapter::ATTR_ID]) : new Chapter();
     $chapter->production_id = $data[Chapter::ATTR_PRODUCTION_ID];
     $chapter->name = $data[Chapter::ATTR_NAME];
     $chapter->video = str_replace(array("\n", "\t", "\r", " "), "", $data[Chapter::ATTR_VIDEO]);
     $chapter->videocloud_id = VideoCloudAccount::getCurrentAccountId();
     $chapter->quality = $data[Chapter::ATTR_QUALITY];
     $chapter->languages = $data[Chapter::ATTR_LANGUAGES];
     $chapter->subtitles = isset($data[Chapter::ATTR_SUBTITLES]) ? $data[Chapter::ATTR_SUBTITLES] : null;
     $chapter->type = $data[Chapter::ATTR_TYPE];
     $chapter->state = $data[Chapter::ATTR_STATE];
     $chapter->save();
     return json_encode(array(Chapter::ATTR_ID => $chapter->id, Chapter::ATTR_NAME => $chapter->name, Chapter::ATTR_VIDEO => htmlentities($chapter->video), Chapter::ATTR_QUALITY => $chapter->quality, Chapter::ATTR_LANGUAGES => Util::formatResultArray($data[Chapter::ATTR_LANGUAGES], ",", "\"", "\""), Chapter::ATTR_SUBTITLES => Util::formatResultArray($chapter->subtitles, ",", "\"", "\""), Chapter::ATTR_STATE => $chapter->state));
 }
 function ajax_postComment(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     $comment = new Comment();
     $comment->user_id = Auth::user()->id;
     $comment->production_id = $data[Comment::ATTR_PRODUCTION_ID];
     $comment->content = Util::removeURLsFromText(strip_tags($data[Comment::ATTR_CONTENT]), "[Enlace bloqueado]");
     $comment->created_at = DateUtil::getCurrentTime();
     $comment->save();
     return json_encode(array("content" => $comment->content));
 }
예제 #12
0
 function ajax_getProductionsFromFavorites(Request $request)
 {
     if (!$request->ajax()) {
         return;
     }
     $data = $request->all();
     $favorites = Auth::user()->favorites()->orderBy("id", "DESC")->skip($data["skip"])->take(21)->get();
     if ($data["skip"] == 0) {
         $total_productions = Auth::user()->favorites()->count();
     }
     $response = array();
     foreach ($favorites as $production) {
         $data_fav = array("slug" => $production->slug, "id" => $production->id, "title" => $production->title, "image" => $production->image, "description" => Util::trimText($production->description, 150), "state" => $production->state);
         if ($data["skip"] == 0) {
             $data_fav["total"] = $total_productions;
         }
         $response[] = $data_fav;
     }
     if (count($favorites) == 0) {
         $response[] = array("total" => 0);
     }
     return json_encode($response);
 }
예제 #13
0
 private function getLatinTitle($title)
 {
     $url = "https://www.google.com.co/search?num=100&site=&source=hp&q=" . Util::convertTextToSearch($title) . "+wikipedia&oq=Straight+Outta+Compton+wi&gs_l=hp.3.0.35i39j0j0i22i30l8.7079.8305.0.9175.5.5.0.0.0.0.306.973.0j4j0j1.5.0....0...1c.1.64.hp..1.4.667.0.OJ2Ztj0KNyk";
     $contentHtml = new HTMLProvider();
     $contentHtml->loadContent($url);
     if (!preg_match_all('/<li[^>]*class=["\']g*["\']\\>(.*?)<\\/li>/i', $contentHtml->htmlContent, $match_result)) {
         return $title;
     }
     $link = Util::extractURLFromText($match_result[0][0]);
     $link = strip_tags($link[1]);
     //Pagina de wikipedia de la produccion
     if (strpos($link, "es.wikipedia") === false) {
         $contentHtml->loadContent($link);
         if (!preg_match_all('/<li[^>]*class=["\']interlanguage-link interwiki-es*["\']\\>(.*?)<\\/li>/i', $contentHtml->htmlContent, $match_result)) {
             return $title;
         }
         $regex = '/\\/\\/[^\\" ]+/i';
         preg_match_all($regex, $match_result[1][0], $link_es);
         $link = $link_es[0][0];
     }
     $contentHtml->loadContent(strpos($link, "https") === false ? "https:" . $link : $link);
     if (!preg_match_all('/<table\\s+.*?class=[\\"\']infobox plainlist plainlinks[\\"\']?[^>]*>(.*?)<\\/table>/i', $contentHtml->htmlContent, $match_result)) {
         return $title;
     }
     if (!preg_match_all('/Título<\\/th>(.*?)<\\/td>/i', $match_result[0][0], $match_info, PREG_SET_ORDER)) {
         return $title;
     }
     if (strpos($match_info[0][0], "España") !== false) {
         if (strpos($match_info[0][0], "<i>") !== false) {
             preg_match_all('/<i>(.*?)<\\/i>/i', $match_info[0][0], $match_title, PREG_SET_ORDER);
             if (strpos($match_info[0][0], "Latinoamérica") !== false) {
                 if (strpos($match_info[0][0], "España") > strpos($match_info[0][0], "Latinoamérica")) {
                     return isset($match_title[0][0]) ? strip_tags($match_title[0][0]) : $title;
                 } else {
                     return isset($match_title[1][0]) ? strip_tags($match_title[1][0]) : $title;
                 }
             }
             if (strpos($match_info[0][0], "Hispanoamérica") !== false) {
                 if (strpos($match_info[0][0], "España") > strpos($match_info[0][0], "Hispanoamérica")) {
                     return isset($match_title[0][0]) ? strip_tags($match_title[0][0]) : $title;
                 } else {
                     return isset($match_title[1][0]) ? strip_tags($match_title[1][0]) : $title;
                 }
             }
             return isset($match_title[0][0]) ? strip_tags($match_title[0][0]) : $title;
         } else {
             $hispanoamerica = 'Hispanoam' . utf8_decode("é") . 'rica';
             $latinoamerica = 'Latinoam' . utf8_decode("é") . 'rica';
             $espana = '(Espa' . utf8_decode("ñ") . 'a)';
             $search_title = str_replace('T' . utf8_decode("í") . 'tulo', "", strip_tags(utf8_decode($match_info[0][0])));
             if (strpos($search_title, $espana) < strpos($search_title, $hispanoamerica) || strpos($search_title, $espana) < strpos($search_title, $latinoamerica)) {
                 $match_title = preg_replace('/.+\\(' . $espana . '\\)/i', "", $search_title);
             } else {
                 $match_title = $search_title;
             }
             if (strpos($match_title, $hispanoamerica) !== false) {
                 $match_title = str_replace("(" . $hispanoamerica . ")", "", preg_replace('/\\(' . $hispanoamerica . '\\)(.+)?/i', "", $match_title));
             }
             if (strpos($match_title, $latinoamerica) !== false) {
                 $match_title = str_replace("(" . $latinoamerica . ")", "", preg_replace('/\\(' . $latinoamerica . '\\)(.+)?/i', "", $match_title));
             }
             return utf8_encode($match_title);
         }
     } else {
         if (!preg_match_all('/<i>(.*?)<\\/i>/i', $match_info[0][0], $match_title, PREG_SET_ORDER)) {
             return strip_tags(str_replace("Título</th>", "", $match_info[0][0]));
         }
         return Util::traslateText(strip_tags($match_title[0][0]));
     }
 }
예제 #14
0
 public function postSetResetPassword(Request $request)
 {
     $data = $request->all();
     if (!isset($data[PasswordReset::ATTR_TOKEN]) || !isset($data[User::ATTR_EMAIL]) || strlen($data[PasswordReset::ATTR_TOKEN]) == 0 || strlen($data[User::ATTR_EMAIL]) == 0 || !isset($data["password"])) {
         return redirect("user/auth/recovery?request=send-mail&form=token")->with(User::ATTR_EMAIL, $data[User::ATTR_EMAIL])->with(UI::message(UI::MESSAGE_TYPE_ERROR, "Error: Solicitud invalida"));
     }
     $email = $data[PasswordReset::ATTR_EMAIL];
     $token = $data[PasswordReset::ATTR_TOKEN];
     if (is_null($pet = PasswordReset::where(PasswordReset::ATTR_EMAIL, $email)->where(PasswordReset::ATTR_TOKEN, $token)->where(PasswordReset::ATTR_ACTIVE, Util::convertBooleanToInt(true))->get())) {
         return redirect("user/auth/recovery?request=send-mail&form=token")->with(User::ATTR_EMAIL, $data[User::ATTR_EMAIL])->with(UI::message(UI::MESSAGE_TYPE_ERROR, "Error: Solicitud invalida"));
     }
     if (DateUtil::difSec($pet[0]->created_at, DateUtil::getCurrentTime()) > 60 * 60 * 2) {
         $pet[0]->active = Util::convertBooleanToInt(false);
         $pet->save();
         return redirect("user/auth/recovery?request=send-mail&form=token")->with(User::ATTR_EMAIL, $data[User::ATTR_EMAIL])->with(UI::message(UI::MESSAGE_TYPE_ERROR, "Error: El código de seguridad ha expirado. <a href='" . url("user/auth/recovery") . "'>¿Realizar una nueva solicitud?</a>"));
     }
     $user = User::where(User::ATTR_EMAIL, $email)->get()[0];
     $user->password = bcrypt($data["password"]);
     $user->save();
     return redirect("user/auth/login")->withInput()->with(UI::message(UI::MESSAGE_TYPE_SUCCESS, "Tu nueva contraseña ha sido establecida, ya puedes iniciar sesión"))->with(User::ATTR_EMAIL, $data[User::ATTR_EMAIL]);
 }
예제 #15
0
            </tr>
            @endforeach
            @endif
        </table>
    </div>
</div>


@stop


@section("script")
<script>

                                            var id_chapters = [<?php 
echo Util::formatResultObjects($chapters, "id");
?>
];</script>

<script>
                                            function deleteChapter(id){
                                            resetVideo();
                                                    $("#chapter-" + id).fadeOut(function(){$("#chapter-" + id).remove()});
                                                    var data = {
                                                    "_token": "{{ Session::token() }}",
                                                            "{{Chapter::ATTR_ID}}":id
                                                    };
                                                    $.ajax({
                                                    url: "{{URL::to('manager/productions/ajax/chapter/delete')}}",
                                                            type: 'POST',
                                                            dataType: 'json',