diff --git a/locale/function.php b/locale/function.php index bb8d96d02c..8a53d7fe84 100644 --- a/locale/function.php +++ b/locale/function.php @@ -1,5 +1,5 @@ [:space:]'\"]+[[:alnum:]/]~", "\\0", $string); + "~[[:alpha:]]+://[^<>[:space:]'\"]+[[:alnum:]/]~", "\\0", + $string + ); } diff --git a/objects/Object.php b/objects/Object.php index 584505f3b0..41678669d8 100644 --- a/objects/Object.php +++ b/objects/Object.php @@ -1,7 +1,6 @@ load($id); } } - + static protected function getFromDb($id) { global $global; $id = intval($id); @@ -36,13 +34,13 @@ abstract class Object{ } return $user; } - + static function getAll() { global $global; $sql = "SELECT * FROM ".static::getTableName()." WHERE 1=1 "; $sql .= self::getSqlFromPost(); - + $res = $global['mysqli']->query($sql); $rows = array(); if ($res) { @@ -54,10 +52,9 @@ abstract class Object{ } return $rows; } - - + static function getTotal() { - //will receive + //will receive //current=1&rowCount=10&sort[sender]=asc&searchPhrase= global $global; $sql = "SELECT id FROM ".static::getTableName()." WHERE 1=1 "; @@ -70,82 +67,82 @@ abstract class Object{ return $res->num_rows; } - + static function getSqlFromPost() { $sql = self::getSqlSearchFromPost(); - - if(!empty($_POST['sort'])){ + + if (!empty($_POST['sort'])) { $orderBy = array(); foreach ($_POST['sort'] as $key => $value) { $orderBy[] = " {$key} {$value} "; } $sql .= " ORDER BY ".implode(",", $orderBy); - }else{ + } else { //$sql .= " ORDER BY CREATED DESC "; } - - if(!empty($_POST['rowCount']) && !empty($_POST['current']) && $_POST['rowCount']>0){ + + if (!empty($_POST['rowCount']) && !empty($_POST['current']) && $_POST['rowCount']>0) { $current = ($_POST['current']-1)*$_POST['rowCount']; $sql .= " LIMIT $current, {$_POST['rowCount']} "; - }else{ + } else { $_POST['current'] = 0; $_POST['rowCount'] = 0; $sql .= " LIMIT 12 "; } return $sql; } - + static function getSqlSearchFromPost() { $sql = ""; - if(!empty($_POST['searchPhrase'])){ + if (!empty($_POST['searchPhrase'])) { $_GET['q'] = $_POST['searchPhrase']; } - if(!empty($_GET['q'])){ + if (!empty($_GET['q'])) { global $global; $search = $global['mysqli']->real_escape_string($_GET['q']); - + $like = array(); $searchFields = static::getSearchFieldsNames(); foreach ($searchFields as $value) { $like[] = " {$value} LIKE '%{$search}%' "; } if(!empty($like)){ - $sql .= " AND (". implode(" OR ", $like).")"; + $sql .= " AND (". implode(" OR ", $like).")"; }else{ $sql .= " AND 1=1 "; } } - + return $sql; } - - function save(){ + + function save() { global $global; $fieldsName = $this->getAllFields(); if (!empty($this->id)) { $sql = "UPDATE ".static::getTableName()." SET "; $fields = array(); foreach ($fieldsName as $value) { - if(strtolower($value) == 'created' ){ + if (strtolower($value) == 'created') { // do nothing - }else if(strtolower($value) == 'modified' ){ + } elseif (strtolower($value) == 'modified') { $fields[] = " {$value} = now() "; - }else { + } else { $fields[] = " {$value} = '{$this->$value}' "; - } + } } $sql .= implode(", ", $fields); $sql .= " WHERE id = {$this->id}"; } else { $sql = "INSERT INTO ".static::getTableName()." ( "; - $sql .= implode(",", $fieldsName). " )"; + $sql .= implode(",", $fieldsName). " )"; $fields = array(); foreach ($fieldsName as $value) { - if(strtolower($value) == 'created' || strtolower($value) == 'modified' ){ + if (strtolower($value) == 'created' || strtolower($value) == 'modified') { $fields[] = " now() "; - }else if(!isset($this->$value)){ + } elseif (!isset($this->$value)) { $fields[] = " NULL "; - }else{ + } else { $fields[] = " '{$this->$value}' "; } } @@ -153,7 +150,7 @@ abstract class Object{ } //echo $sql; $insert_row = $global['mysqli']->query($sql); - + if ($insert_row) { if (empty($this->id)) { $id = $global['mysqli']->insert_id; @@ -165,11 +162,11 @@ abstract class Object{ die($sql . ' Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } } - - private function getAllFields(){ + + private function getAllFields() { global $global, $mysqlDatabase; $sql = "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '{$mysqlDatabase}' AND TABLE_NAME = '".static::getTableName()."'"; - + $res = $global['mysqli']->query($sql); $rows = array(); if ($res) { @@ -182,4 +179,3 @@ abstract class Object{ return $rows; } } - diff --git a/objects/bootGrid.php b/objects/bootGrid.php index 78f44b7cd2..71a3920afb 100644 --- a/objects/bootGrid.php +++ b/objects/bootGrid.php @@ -1,20 +1,19 @@ $value) { $orderBy[] = " {$keyPrefix}{$key} {$value} "; } $sql .= " ORDER BY ".implode(",", $orderBy); - }else{ + } else { //$sql .= " ORDER BY CREATED DESC "; } - + if(!empty($_POST['rowCount']) && !empty($_POST['current']) && $_POST['rowCount']>0){ $current = ($_POST['current']-1)*$_POST['rowCount']; $sql .= " LIMIT $current, {$_POST['rowCount']} "; @@ -24,27 +23,25 @@ class BootGrid { } return $sql; } - + static function getSqlSearchFromPost($searchFieldsNames = array()) { $sql = ""; if(!empty($_POST['searchPhrase'])){ global $global; $search = $global['mysqli']->real_escape_string($_POST['searchPhrase']); - + $like = array(); foreach ($searchFieldsNames as $value) { $like[] = " {$value} LIKE '%{$search}%' "; } if(!empty($like)){ - $sql .= " AND (". implode(" OR ", $like).")"; + $sql .= " AND (". implode(" OR ", $like).")"; }else{ $sql .= " AND 1=1 "; } } - + return $sql; } - - } diff --git a/objects/captcha.php b/objects/captcha.php index 37fff1d2eb..36184f2cbc 100644 --- a/objects/captcha.php +++ b/objects/captcha.php @@ -1,12 +1,11 @@ quantidade_letras = $quantidade_letras; } - - public function getCaptchaImage(){ + + public function getCaptchaImage() { global $global; - header("Content-type: image/jpeg"); + header('Content-type: image/jpeg'); $imagem = imagecreate($this->largura,$this->altura); // define a largura e a altura da imagem - $fonte = $global['systemRootPath'] . "objects/monof55.ttf"; //voce deve ter essa ou outra fonte de sua preferencia em sua pasta - $preto = imagecolorallocate($imagem,0,0,0); // define a cor preta - $branco = imagecolorallocate($imagem,255,255,255); // define a cor branca - + $fonte = $global['systemRootPath'] . 'objects/monof55.ttf'; //voce deve ter essa ou outra fonte de sua preferencia em sua pasta + $preto = imagecolorallocate($imagem, 0, 0, 0); // define a cor preta + $branco = imagecolorallocate($imagem, 255, 255, 255); // define a cor branca + // define a palavra conforme a quantidade de letras definidas no parametro $quantidade_letras - //$letters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789"; - $letters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789"; - $palavra = substr(str_shuffle($letters),0,($this->quantidade_letras)); + //$letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789'; + $letters = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtUuVvYyXxWwZz23456789'; + $palavra = substr(str_shuffle($letters), 0, ($this->quantidade_letras)); $_SESSION["palavra"] = $palavra; // atribui para a sessao a palavra gerada - for($i = 1; $i <= $this->quantidade_letras; $i++){ - imagettftext($imagem,$this->tamanho_fonte,rand(-10,10),($this->tamanho_fonte*$i),($this->tamanho_fonte + 10),$branco,$fonte,substr($palavra,($i-1),1)); // atribui as letras a imagem + for ($i = 1; $i <= $this->quantidade_letras; $i++) { + imagettftext( + $imagem, + $this->tamanho_fonte, + rand(-10, 10), + ($this->tamanho_fonte*$i), + ($this->tamanho_fonte + 10), + $branco, + $fonte, + substr($palavra, ($i - 1), 1) + ); // atribui as letras a imagem } imagejpeg($imagem); // gera a imagem imagedestroy($imagem); // limpa a imagem da memoria } - - static public function validation($word){ + + static public function validation($word) { if (session_status() == PHP_SESSION_NONE) { session_start(); } - if (strcasecmp($word, $_SESSION["palavra"])==0){ - return true; - }else{ - return false; - } - } - - -} \ No newline at end of file + return (strcasecmp($word, $_SESSION["palavra"]) == 0); + } + +} diff --git a/objects/categories.json.php b/objects/categories.json.php index b9e436d1d6..5ce045017e 100644 --- a/objects/categories.json.php +++ b/objects/categories.json.php @@ -1,5 +1,4 @@ $value) { $categories[$key]['iconHtml'] = ""; } -echo '{ "current": '.$_POST['current'].',"rowCount": '.$_POST['rowCount'].', "total": '.$total.', "rows":'. json_encode($categories).'}'; \ No newline at end of file +echo '{ "current": '.$_POST['current'].',"rowCount": '.$_POST['rowCount'].', "total": '.$total.', "rows":'. json_encode($categories).'}'; diff --git a/objects/category.php b/objects/category.php index 3c87a6c483..e1fe59e2fc 100644 --- a/objects/category.php +++ b/objects/category.php @@ -1,7 +1,6 @@ clean_name = $clean_name; } - function __construct($id, $name = "") { + function __construct($id, $name = '') { if (empty($id)) { // get the category data from category and pass $this->name = $name; @@ -87,12 +86,7 @@ class Category { $id = intval($id); $sql = "SELECT * FROM categories WHERE id = $id LIMIT 1"; $res = $global['mysqli']->query($sql); - if ($res) { - $category = $res->fetch_assoc(); - } else { - $category = false; - } - return $category; + return ($res) ? $res->fetch_assoc() : false; } static function getAllCategories() { @@ -118,12 +112,10 @@ class Category { static function getTotalCategories() { global $global; $sql = "SELECT id FROM categories WHERE 1=1 "; - $sql .= BootGrid::getSqlSearchFromPost(array('name')); $res = $global['mysqli']->query($sql); - return $res->num_rows; } diff --git a/objects/categoryAddNew.json.php b/objects/categoryAddNew.json.php index af72a080c3..6e56842269 100644 --- a/objects/categoryAddNew.json.php +++ b/objects/categoryAddNew.json.php @@ -1,10 +1,9 @@ setName($_POST['name']); $obj->setClean_name($_POST['clean_name']); $obj->setIconClass($_POST['iconClass']); -echo '{"status":"'.$obj->save().'"}'; \ No newline at end of file +echo '{"status":"'.$obj->save().'"}'; diff --git a/objects/categoryDelete.json.php b/objects/categoryDelete.json.php index a4539ad6df..2bd4c303b2 100644 --- a/objects/categoryDelete.json.php +++ b/objects/categoryDelete.json.php @@ -1,7 +1,7 @@ comment = $comment; $this->videos_id = $videos_id; $this->users_id = User::getId(); - }else{ + } else { // get data from id $this->load($id); } - + } - - private function load($id){ + + private function load($id) { $comment = $this->getComment($id); $this->id = $comment['id']; $this->comment = $comment['comment']; @@ -32,7 +32,7 @@ class Comment{ $this->users_id = $comment['user_id']; } - function save(){ + function save() { global $global; if(!User::isLogged()){ header('Content-Type: application/json'); @@ -40,11 +40,11 @@ class Comment{ } $this->comment = htmlentities($this->comment); $this->comment = $global['mysqli']->real_escape_string($this->comment); - if(!empty($this->id)){ + if (!empty($this->id)) { $sql = "UPDATE comments SET comment = '{$this->comment}', modified = now() WHERE id = {$this->id}"; - }else{ + } else { $id = User::getId(); - $sql = "INSERT INTO comments ( comment,users_id, videos_id, created, modified) VALUES ('{$this->comment}', {$id}, {$this->videos_id}, now(), now())"; + $sql = "INSERT INTO comments ( comment,users_id, videos_id, created, modified) VALUES ('{$this->comment}', {$id}, {$this->videos_id}, now(), now())"; } $resp = $global['mysqli']->query($sql); if(empty($resp)){ @@ -52,49 +52,44 @@ class Comment{ } return $resp; } - - - function delete(){ + + + function delete() { if(!User::isAdmin()){ return false; } - + global $global; - if(!empty($this->id)){ + if (!empty($this->id)) { $sql = "DELETE FROM comments WHERE id = {$this->id}"; - }else{ + } else { return false; } $resp = $global['mysqli']->query($sql); - if(empty($resp)){ + if (empty($resp)) { die('Error : (' . $global['mysqli']->errno . ') ' . $global['mysqli']->error); } return $resp; - } + } private function getComment($id) { global $global; $id = intval($id); $sql = "SELECT * FROM comments WHERE id = $id LIMIT 1"; $res = $global['mysqli']->query($sql); - if ($res) { - $comment = $res->fetch_assoc(); - } else { - $comment = false; - } - return $comment; + return ($res) ? $res->fetch_assoc() : false; } - - static function getAllComments($videoId=0){ + + static function getAllComments($videoId = 0) { global $global; $sql = "SELECT c.*, u.name as name, u.user as user FROM comments c LEFT JOIN users as u ON u.id = users_id WHERE 1=1 "; - - if(!empty($videoId)){ + + if (!empty($videoId)) { $sql .= " AND videos_id = {$videoId} "; } - + $sql .= BootGrid::getSqlFromPost(array('name')); - + $res = $global['mysqli']->query($sql); $comment = array(); if ($res) { @@ -108,22 +103,19 @@ class Comment{ } return $comment; } - - static function getTotalComments($videoId=0){ + + static function getTotalComments($videoId = 0) { global $global; $sql = "SELECT id FROM comments WHERE 1=1 "; - - if(!empty($videoId)){ + + if (!empty($videoId)) { $sql .= " AND videos_id = {$videoId} "; } - $sql .= BootGrid::getSqlSearchFromPost(array('name')); - + $res = $global['mysqli']->query($sql); - - + return $res->num_rows; } - -} \ No newline at end of file +} diff --git a/objects/commentAddNew.json.php b/objects/commentAddNew.json.php index a417e87ff6..0237d25f5d 100644 --- a/objects/commentAddNew.json.php +++ b/objects/commentAddNew.json.php @@ -1,9 +1,9 @@ save().'"}'; \ No newline at end of file +echo '{"status":"'.$obj->save().'"}'; diff --git a/objects/comments.json.php b/objects/comments.json.php index 64a78c1559..34b855d7dc 100644 --- a/objects/comments.json.php +++ b/objects/comments.json.php @@ -11,5 +11,4 @@ foreach ($comments as $key => $value) { $comments[$key]['comment'] = '
/etc/init.d/apache2 restart
-
+
@@ -206,7 +206,7 @@ require_once $global['systemRootPath'] . 'objects/functions.php';
sudo chmod -R 777
-
+
Your post_max_size is
-
+
@@ -253,11 +253,11 @@ require_once $global['systemRootPath'] . 'objects/functions.php';
Your post_max_size is , it must be at least 100M
php.ini
file
+ Edit the php.ini
file
sudo nano
php.ini
file
+ Edit the php.ini
file
sudo nano
{message} | -
- |