├── uploads ├── default.jpg ├── 2d4b1439f8ce16be1541397c55d8810b.jpg └── a6ccafaf9d519ca756914778daf93414.jpg ├── css ├── fonts │ ├── icomoon.eot │ ├── icomoon.ttf │ ├── icomoon.woff │ └── icomoon.svg ├── jcrop.css └── style.css ├── .htaccess ├── sys ├── muda_aba.php ├── follows.php ├── logar.php ├── longPolling.php ├── tweetar.php ├── edita_cadastra.php └── load_more.php ├── config.php ├── inc ├── footer.php ├── functions.php ├── lib │ ├── Exception.php │ ├── Mapper │ │ ├── JPEG.php │ │ ├── GD2.php │ │ ├── GD.php │ │ ├── PNG.php │ │ ├── TGA.php │ │ ├── BMP.php │ │ └── GIF.php │ ├── Font │ │ ├── GDF.php │ │ ├── PS.php │ │ └── TTF.php │ ├── Operation │ │ ├── AsGrayscale.php │ │ ├── CorrectGamma.php │ │ ├── ApplyConvolution.php │ │ ├── Flip.php │ │ ├── Mirror.php │ │ ├── Rotate.php │ │ ├── CopyChannelsTrueColor.php │ │ ├── AsNegative.php │ │ ├── GetMask.php │ │ ├── ApplyFilter.php │ │ ├── Merge.php │ │ ├── CopyChannelsPalette.php │ │ ├── Crop.php │ │ ├── ApplyMask.php │ │ ├── ResizeCanvas.php │ │ ├── AddNoise.php │ │ ├── Unsharp.php │ │ ├── RoundCorners.php │ │ ├── AutoCrop.php │ │ └── Resize.php │ ├── OperationFactory.php │ ├── MapperFactory.php │ ├── PaletteImage.php │ ├── vendor │ │ └── de77 │ │ │ ├── TGA.php │ │ │ └── BMP.php │ ├── Canvas.php │ ├── Coordinate.php │ ├── TrueColorImage.php │ └── WideImage.php ├── header.php └── sidebar.php ├── js ├── long_polling.js ├── functions.js └── jcrop.js ├── index.php ├── pages ├── perfil.php ├── hashtag.php ├── seguidores.php ├── seguindo.php ├── busca.php ├── home.php └── minha-conta.php ├── logar.php └── mini_twitter.sql /uploads/default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/uploads/default.jpg -------------------------------------------------------------------------------- /css/fonts/icomoon.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/css/fonts/icomoon.eot -------------------------------------------------------------------------------- /css/fonts/icomoon.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/css/fonts/icomoon.ttf -------------------------------------------------------------------------------- /css/fonts/icomoon.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/css/fonts/icomoon.woff -------------------------------------------------------------------------------- /uploads/2d4b1439f8ce16be1541397c55d8810b.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/uploads/2d4b1439f8ce16be1541397c55d8810b.jpg -------------------------------------------------------------------------------- /uploads/a6ccafaf9d519ca756914778daf93414.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lukasdev/mini-twitter/HEAD/uploads/a6ccafaf9d519ca756914778daf93414.jpg -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | RewriteCond %{SCRIPT_FILENAME} !-f 3 | RewriteCond %{SCRIPT_FILENAME} !-d 4 | RewriteRule ^(.*)$ index.php?url=$1 [QSA] 5 | Options -Indexes -------------------------------------------------------------------------------- /sys/muda_aba.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config.php: -------------------------------------------------------------------------------- 1 | exec("set names utf8"); 7 | ?> -------------------------------------------------------------------------------- /inc/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /inc/functions.php: -------------------------------------------------------------------------------- 1 | id.'.jpg')){ 24 | unlink('uploads/temp_'.$logado->id.'.jpg'); 25 | } 26 | } 27 | } 28 | ?> -------------------------------------------------------------------------------- /js/long_polling.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var base = $('.base').attr('id'); 3 | 4 | function longPolling(timestamp){ 5 | var user_id = localStorage.user_id; 6 | $.ajax({ 7 | method: 'GET', 8 | url: base+'/sys/longPolling.php', 9 | data: {user_id: user_id, timestamp: timestamp}, 10 | dataType: 'json', 11 | success: function(retorno){ 12 | if(retorno.results != ''){ 13 | $.each(retorno.results, function(i, val){ 14 | var tweet = '
'; 15 | tweet += ''+retorno.results[i].nome+' disse:'; 16 | tweet += '

'+retorno.results[i].tweet+'

'; 17 | tweet += ''+retorno.results[i].date+'
'; 18 | $('#content').prepend(tweet); 19 | }); 20 | } 21 | 22 | longPolling(retorno.timestamp); 23 | } 24 | }); 25 | } 26 | 27 | longPolling(); 28 | }); -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | prepare("SELECT * FROM `usuarios` WHERE `nickname` = :nickname"); 8 | $verifica_user->bindValue(':nickname', strip_tags($explode[0]), PDO::PARAM_STR); 9 | $verifica_user->execute(); 10 | 11 | $nao_permitidas = ['perfil', 'seguindo', 'seguidores', 'busca']; 12 | $perfil = false; 13 | if(isset($_GET['s'])){ 14 | include_once "pages/busca.php"; 15 | }elseif($verifica_user->rowCount() == 1){ 16 | $perfil = true; 17 | $dados_perfil = $verifica_user->fetchObject(); 18 | 19 | include_once "pages/perfil.php"; 20 | }elseif(file_exists('pages/'.$explode[0].'.php') && !in_array($explode[0], $nao_permitidas)){ 21 | include_once 'pages/'.$explode[0].'.php'; 22 | }else{ 23 | echo 'Pagina não existente Voltar'; 24 | } 25 | ?> 26 |
27 | -------------------------------------------------------------------------------- /sys/follows.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `usuarios` WHERE `nickname` = ?"); 7 | $pega_logado->execute(array($_SESSION['nickname'])); 8 | $logado = $pega_logado->fetchObject(); 9 | 10 | $follow_unfollow = (int)$_POST['follow_unfollow']; 11 | 12 | $verifica = $pdo->prepare("SELECT `id` FROM `follows` WHERE `seguidor` = ? AND `usuario` = ?"); 13 | $verifica->execute(array($logado->id, $follow_unfollow)); 14 | if($verifica->rowCount() == 1){ 15 | $registro = $verifica->fetchObject(); 16 | 17 | $apagar = $pdo->prepare("DELETE FROM `follows` WHERE `id` = ?"); 18 | if($apagar->execute(array($registro->id))){ 19 | echo 'ok'; 20 | }else{ 21 | echo 'no'; 22 | } 23 | }else{ 24 | $seguir = $pdo->prepare("INSERT INTO `follows` SET `seguidor` = ?, `usuario` = ?"); 25 | if($seguir->execute(array($logado->id, $follow_unfollow))){ 26 | echo 'ok'; 27 | }else{ 28 | echo 'no'; 29 | } 30 | } 31 | } 32 | ?> -------------------------------------------------------------------------------- /sys/logar.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `usuarios` WHERE (`email` = ? OR `nickname` = ?) AND `senha` = ?"); 11 | $verifica->execute(array($login, $login, $senha)); 12 | $retorno = array(); 13 | if($verifica->rowCount() == 1){ 14 | $logado = $verifica->fetchObject(); 15 | $_SESSION['nickname'] = $logado->nickname; 16 | 17 | 18 | sleep(1); 19 | if(isset($_SESSION['nickname'])){ 20 | $retorno['status'] = 'ok'; 21 | $retorno['user_id'] = $logado->id; 22 | }else{ 23 | $retorno['status'] = 'no'; 24 | } 25 | }else{ 26 | $retorno['status'] = 'no'; 27 | } 28 | }else{ 29 | $retorno['status'] = 'no'; 30 | } 31 | die(json_encode($retorno)); 32 | } 33 | ?> -------------------------------------------------------------------------------- /inc/lib/Exception.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Generated by IcoMoon 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /inc/lib/Mapper/JPEG.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 9 |

Timeline

10 | 11 |
12 |
13 | prepare("SELECT * FROM `tweets` WHERE `user_id` = ? ORDER BY `id` DESC"); 15 | $twt->execute(array($dados_perfil->id)); 16 | $_SESSION['ids_carregados'] = array(); 17 | 18 | $pega_mencoes = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` = ? ORDER BY `id` DESC LIMIT 1"); 19 | $pega_mencoes->execute(array($dados_perfil->id)); 20 | while($tweet = $pega_mencoes->fetchObject()){ 21 | $_SESSION['ids_carregados'][] = $tweet->id 22 | ?> 23 |
24 | nome;?> disse: 25 |

tweet;?>

26 | data));?> 27 |
28 | 29 |
30 | rowCount() > 1){ 32 | echo 'Carregar Mais'; 33 | } 34 | ?> 35 |
36 | 37 |
-------------------------------------------------------------------------------- /pages/hashtag.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 6 |

Menções a

7 | 8 |
9 |
10 | prepare("SELECT * FROM `tweets` WHERE `tweet` LIKE '%$hashtag%'"); 12 | $twt->execute(); 13 | 14 | $pega_mencoes = $pdo->prepare("SELECT * FROM `tweets` WHERE `tweet` LIKE '%$hashtag%' ORDER BY `id` DESC LIMIT 1"); 15 | $pega_mencoes->execute(); 16 | 17 | $_SESSION['ids_carregados'] = array(); 18 | while($tweet = $pega_mencoes->fetchObject()){ 19 | 20 | $user_tweet = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 21 | $user_tweet->execute(array($tweet->user_id)); 22 | $user_dados = $user_tweet->fetchObject(); 23 | 24 | $_SESSION['ids_carregados'][] = $tweet->id; 25 | ?> 26 |
27 | 28 | nome;?> disse: 29 | 30 |

tweet;?>

31 | data));?> 32 |
33 | 34 |
35 | rowCount() > 1){ 37 | echo 'Carregar Mais'; 38 | } 39 | ?> 40 |
41 |
-------------------------------------------------------------------------------- /inc/lib/Font/GDF.php: -------------------------------------------------------------------------------- 1 | = 1 && $face <= 5) 38 | $this->font = $face; 39 | else 40 | $this->font = imageloadfont($face); 41 | $this->color = $color; 42 | } 43 | 44 | function writeText($image, $x, $y, $text) 45 | { 46 | imagestring($image->getHandle(), $this->font, $x, $y, $text, $this->color); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /inc/lib/Mapper/TGA.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `follows` WHERE `seguidor` = ?"); 8 | $pega_follows->execute(array($logado_id)); 9 | 10 | $ids_seguindo = array(); 11 | while($usr = $pega_follows->fetchObject()){ 12 | $ids_seguindo[] = $usr->usuario; 13 | } 14 | $str_seguindo = implode(', ', $ids_seguindo); 15 | 16 | while($t <= 30){ 17 | $tweets = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` IN ($str_seguindo) 18 | AND `timestamp` >= ? ORDER BY `id` DESC"); 19 | $tweets->execute(array($time)); 20 | if($tweets->rowCount() >= 1){ 21 | $retorno = array('timestamp' => time()+1, 'results' => array()); 22 | while($tweet = $tweets->fetchObject()){ 23 | $user_tweet = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 24 | $user_tweet->execute(array($tweet->user_id)); 25 | $user_dados = $user_tweet->fetchObject(); 26 | 27 | $retorno['results'][] = array( 28 | 'nickname' => $user_dados->nickname, 29 | 'nome' => $user_dados->nome, 30 | 'tweet' => $tweet->tweet, 31 | 'date' => date('d/m/Y H:i:s', strtotime($tweet->data)), 32 | ); 33 | } 34 | die(json_encode($retorno)); 35 | break; 36 | }else{ 37 | sleep(1); 38 | $t++; 39 | 40 | if($t >= 30){ 41 | die(json_encode(array('timestamp' => time(), 'results' => ''))); 42 | break; 43 | } 44 | continue; 45 | } 46 | } 47 | } 48 | ?> -------------------------------------------------------------------------------- /inc/lib/Operation/AsGrayscale.php: -------------------------------------------------------------------------------- 1 | asTrueColor(); 41 | if (!imagefilter($new->getHandle(), IMG_FILTER_GRAYSCALE)) 42 | throw new WideImage_GDFunctionResultException("imagefilter() returned false"); 43 | 44 | if (!$image->isTrueColor()) 45 | $new = $new->asPalette(); 46 | 47 | return $new; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /inc/header.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `usuarios` WHERE `nickname` = ?"); 9 | $pega_logado->execute(array($_SESSION['nickname'])); 10 | $logado = $pega_logado->fetchObject(); 11 | 12 | if(isset($_GET['sair'])){ 13 | unset($_SESSION['nickname']); 14 | session_destroy(); 15 | header("Location: ".BASE); 16 | } 17 | } 18 | include_once "inc/functions.php"; 19 | check_temp($logado); 20 | ?> 21 | 22 | 23 | 24 | 25 | Mini Twitter 26 | 27 | 28 | 29 | 30 | 31 | 48 | 49 | -------------------------------------------------------------------------------- /inc/lib/Mapper/BMP.php: -------------------------------------------------------------------------------- 1 | copy(); 43 | if (!imagegammacorrect($new->getHandle(), $input_gamma, $output_gamma)) 44 | throw new WideImage_GDFunctionResultException("imagegammacorrect() returned false"); 45 | 46 | return $new; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /inc/lib/Operation/ApplyConvolution.php: -------------------------------------------------------------------------------- 1 | asTrueColor(); 44 | if (!imageconvolution($new->getHandle(), $matrix, $div, $offset)) 45 | throw new WideImage_GDFunctionResultException("imageconvolution() returned false"); 46 | return $new; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /inc/lib/Mapper/GIF.php: -------------------------------------------------------------------------------- 1 | Seguidores 2 | 3 | prepare("SELECT `id` FROM `usuarios` WHERE `nickname` = ?"); 6 | $pega_id->execute(array($nickname)); 7 | $id_user = $pega_id->fetchObject(); 8 | 9 | $pega_follows = $pdo->prepare("SELECT * FROM `follows` WHERE `usuario` = ? ORDER BY `id` DESC"); 10 | $pega_follows->execute(array($id_user->id)); 11 | while($follow = $pega_follows->fetchObject()){ 12 | $pega_user_followed = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 13 | $pega_user_followed->execute(array($follow->seguidor)); 14 | $user = $pega_user_followed->fetchObject(); 15 | 16 | $foto = ($user->foto == '') ? BASE.'/uploads/default.jpg' : BASE.'/uploads/'.$user->foto; 17 | 18 | //verifica se sigo de volta ou não 19 | $verifica_follow = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ? AND `usuario` = ? ORDER BY `id` DESC"); 20 | $verifica_follow->execute(array($logado->id, $user->id)); 21 | if($verifica_follow->rowCount() == 1){ 22 | $texto = 'Desseguir'; 23 | }else{ 24 | $texto = 'Seguir'; 25 | } 26 | ?> 27 |
28 |
29 |
30 | id != $logado->id){?> 31 | 32 | 33 |
34 | 35 | 36 | nome;?> 37 |

@nickname;?>

38 |
39 |
40 |

descricao;?>

41 |
42 |
43 | -------------------------------------------------------------------------------- /inc/lib/Operation/Flip.php: -------------------------------------------------------------------------------- 1 | copy(); 41 | 42 | $width = $image->getWidth(); 43 | $height = $image->getHeight(); 44 | 45 | if ($new->isTransparent()) 46 | imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); 47 | 48 | for ($y = 0; $y < $height; $y++) 49 | if (!imagecopy($new->getHandle(), $image->getHandle(), 0, $y, 0, $height - $y - 1, $width, 1)) 50 | throw new WideImage_GDFunctionResultException("imagecopy() returned false"); 51 | 52 | return $new; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /pages/seguindo.php: -------------------------------------------------------------------------------- 1 |

Seguindo

2 | 3 | prepare("SELECT `id` FROM `usuarios` WHERE `nickname` = ?"); 6 | $pega_id->execute(array($nickname)); 7 | $id_user = $pega_id->fetchObject(); 8 | 9 | $pega_follows = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ? ORDER BY `id` DESC"); 10 | $pega_follows->execute(array($id_user->id)); 11 | while($follow = $pega_follows->fetchObject()){ 12 | $pega_user_followed = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 13 | $pega_user_followed->execute(array($follow->usuario)); 14 | $user = $pega_user_followed->fetchObject(); 15 | 16 | $foto = ($user->foto == '') ? BASE.'/uploads/default.jpg' : BASE.'/uploads/'.$user->foto; 17 | 18 | if($id_user->id == $logado->id){ 19 | $texto = 'Desseguir'; 20 | }else{ 21 | $verifica_follow = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ? AND `usuario` = ? ORDER BY `id` DESC"); 22 | $verifica_follow->execute(array($logado->id, $user->id)); 23 | if($verifica_follow->rowCount() == 1){ 24 | $texto = 'Desseguir'; 25 | }else{ 26 | $texto = 'Seguir'; 27 | } 28 | } 29 | ?> 30 |
31 |
32 |
33 | id != $logado->id){?> 34 | 35 | 36 |
37 | 38 | nome;?> 39 |

@nickname;?>

40 |
41 |
42 |

descricao;?>

43 |
44 |
45 | -------------------------------------------------------------------------------- /inc/lib/Operation/Mirror.php: -------------------------------------------------------------------------------- 1 | copy(); 41 | 42 | $width = $image->getWidth(); 43 | $height = $image->getHeight(); 44 | 45 | if ($new->isTransparent()) 46 | imagefilledrectangle($new->getHandle(), 0, 0, $width, $height, $new->getTransparentColor()); 47 | 48 | for ($x = 0; $x < $width; $x++) 49 | { 50 | if (!imagecopy($new->getHandle(), $image->getHandle(), $x, 0, $width - $x - 1, 0, 1, $height)) 51 | throw new WideImage_GDFunctionResultException("imagecopy() returned false"); 52 | } 53 | return $new; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /inc/lib/Font/PS.php: -------------------------------------------------------------------------------- 1 | handle = imagepsloadfont($file); 39 | $this->size = $size; 40 | $this->color = $color; 41 | if ($bgcolor === null) 42 | $this->bgcolor = $color; 43 | else 44 | $this->color = $color; 45 | } 46 | 47 | function writeText($image, $x, $y, $text, $angle = 0) 48 | { 49 | if ($image->isTrueColor()) 50 | $image->alphaBlending(true); 51 | 52 | imagepstext($image->getHandle(), $text, $this->handle, $this->size, $this->color, $this->bgcolor, $x, $y, 0, 0, $angle, 4); 53 | } 54 | 55 | function __destruct() 56 | { 57 | imagepsfreefont($this->handle); 58 | $this->handle = null; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /inc/lib/OperationFactory.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

Busca

5 |
6 | prepare("SELECT * FROM `usuarios` WHERE `nome` LIKE '%$busca%'"); 9 | $usrs->execute(); 10 | 11 | $pega_result = $pdo->prepare("SELECT * FROM `usuarios` WHERE `nome` LIKE '%$busca%' AND `id` != ? ORDER BY `id` DESC LIMIT 1"); 12 | $pega_result->execute(array($logado->id)); 13 | $_SESSION['ids_carregados'] = array(); 14 | 15 | while($user = $pega_result->fetchObject()){ 16 | 17 | $foto = ($user->foto == '') ? BASE.'/uploads/default.jpg' : BASE.'/uploads/'.$user->foto; 18 | 19 | //verifica se sigo de volta ou não 20 | $verifica_follow = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ? AND `usuario` = ? ORDER BY `id` DESC"); 21 | $verifica_follow->execute(array($logado->id, $user->id)); 22 | if($verifica_follow->rowCount() == 1){ 23 | $texto = 'Desseguir'; 24 | }else{ 25 | $texto = 'Seguir'; 26 | } 27 | 28 | $_SESSION['ids_carregados'][] = $user->id; 29 | ?> 30 |
31 |
32 |
33 | 34 |
35 | 36 | 37 | nome;?> 38 |

@nickname;?>

39 |
40 |
41 |

descricao;?>

42 |
43 |
44 | 45 |
46 | rowCount() > 1){ 48 | echo 'Carregar Mais'; 49 | } 50 | ?> 51 |
52 |
-------------------------------------------------------------------------------- /pages/home.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | 11 |
12 |
13 | 14 |
15 |
16 | prepare("SELECT * FROM `follows` WHERE `seguidor` = ?"); 19 | $pega_follows->execute(array($logado->id)); 20 | 21 | $ids_seguindo = array($logado->id); 22 | while($usr = $pega_follows->fetchObject()){ 23 | $ids_seguindo[] = $usr->usuario; 24 | } 25 | $str_seguindo = implode(', ', $ids_seguindo); 26 | $twt = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` IN ($str_seguindo) ORDER BY `id` DESC"); 27 | $twt->execute(); 28 | 29 | $tweets = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` IN ($str_seguindo) ORDER BY `id` DESC LIMIT 1"); 30 | $tweets->execute(); 31 | $_SESSION['ids_carregados'] = array(); 32 | 33 | while($tweet = $tweets->fetchObject()){ 34 | $user_tweet = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 35 | $user_tweet->execute(array($tweet->user_id)); 36 | $user_dados = $user_tweet->fetchObject(); 37 | 38 | $_SESSION['ids_carregados'][] = $tweet->id; 39 | ?> 40 |
41 | 42 | nome;?> disse: 43 | 44 |

tweet;?>

45 | data));?> 46 |
47 | 48 |
49 | rowCount() > 1){ 51 | echo 'Carregar Mais'; 52 | } 53 | ?> 54 |
55 |
-------------------------------------------------------------------------------- /inc/lib/Operation/Rotate.php: -------------------------------------------------------------------------------- 1 | copy(); 50 | 51 | $image = $image->asTrueColor(); 52 | 53 | if ($bgColor === null) 54 | { 55 | $bgColor = $image->getTransparentColor(); 56 | if ($bgColor == -1) 57 | { 58 | $bgColor = $image->allocateColorAlpha(255, 255, 255, 127); 59 | imagecolortransparent($image->getHandle(), $bgColor); 60 | } 61 | } 62 | return new WideImage_TrueColorImage(imagerotate($image->getHandle(), $angle, $bgColor, $ignoreTransparent)); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /sys/tweetar.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `usuarios` WHERE `nickname` = ?"); 6 | $pega_logado->execute(array($_SESSION['nickname'])); 7 | $logado = $pega_logado->fetchObject(); 8 | 9 | $tweet = strip_tags($_POST['tweet']); 10 | $tweet_sem_link = $tweet; 11 | 12 | $tweet = preg_replace('/\B#([\d\w_]+)/i', '$0', $tweet); 13 | $retorno = array(); 14 | $retorno['user_id'] = $logado->id; 15 | $retorno['nome'] = $logado->nome; 16 | $retorno['tweet'] = $tweet; 17 | $retorno['date'] = date('d/m/Y H:i:s'); 18 | 19 | //codigo para mensoes de hashtags 20 | $palavras_tweet = explode(' ', $tweet_sem_link); 21 | $hashtags = array(); 22 | foreach($palavras_tweet as $in => $palavra){ 23 | if(preg_match('/^#+[a-z0-9_]/i', $palavra)){ 24 | $hashtags[] = $palavra; 25 | } 26 | } 27 | $contagem_hashtags = count($hashtags); 28 | $n_tags = 0; 29 | if($contagem_hashtags >= 1){ 30 | foreach($hashtags as $ind => $tag){ 31 | $verifica_tag = $pdo->prepare("SELECT * FROM `trending` WHERE `hashtag` = ?"); 32 | $verifica_tag->execute(array($tag)); 33 | 34 | if($verifica_tag->rowCount() == 1){ 35 | $tag_trending = $verifica_tag->fetchObject(); 36 | 37 | $novo_valor = $tag_trending->mencoes+1; 38 | $update_mencoes = $pdo->prepare("UPDATE `trending` SET `mencoes` = ? WHERE `id` = ?"); 39 | if($update_mencoes->execute(array($novo_valor, $tag_trending->id))){ 40 | $n_tags += 1; 41 | } 42 | }else{ 43 | $insert_tag = $pdo->prepare("INSERT INTO `trending` SET `hashtag` = ?, `mencoes` = 1"); 44 | if($insert_tag->execute(array($tag))){ 45 | $n_tags += 1; 46 | } 47 | } 48 | } 49 | } 50 | 51 | if($contagem_hashtags == $n_tags){ 52 | $insert = $pdo->prepare("INSERT INTO `tweets` SET `user_id` = ?, `tweet` = ?, `data` = ?, `timestamp` = ?"); 53 | $dados = array($retorno['user_id'], $retorno['tweet'], date('Y-m-d H:i:s'), time()); 54 | if($insert->execute($dados)){ 55 | $retorno['status'] = 'ok'; 56 | }else{ 57 | $retorno['status'] = 'no'; 58 | } 59 | } 60 | 61 | die(json_encode($retorno)); 62 | } 63 | ?> -------------------------------------------------------------------------------- /logar.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Mini Twitter 6 | 7 | 8 | 9 | 10 | 11 |
12 | X 13 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod 14 | tempor incididunt ut labore et dolore magna aliqua.

15 |
16 |
17 | 21 | 25 | 29 | 33 | 38 | 39 | 40 |
41 |
42 | 43 |
44 |
45 |
46 |
47 | 51 | 55 | 56 | 57 |
58 |

Não possui conta? Cadastre-se

59 |
60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /inc/lib/Operation/CopyChannelsTrueColor.php: -------------------------------------------------------------------------------- 1 | 0, 'green' => 0, 'blue' => 0, 'alpha' => 0); 44 | 45 | $width = $img->getWidth(); 46 | $height = $img->getHeight(); 47 | $copy = WideImage_TrueColorImage::create($width, $height); 48 | 49 | if (count($channels) > 0) 50 | for ($x = 0; $x < $width; $x++) 51 | for ($y = 0; $y < $height; $y++) 52 | { 53 | $RGBA = $img->getRGBAt($x, $y); 54 | $newRGBA = $blank; 55 | foreach ($channels as $channel) 56 | $newRGBA[$channel] = $RGBA[$channel]; 57 | 58 | $color = $copy->getExactColorAlpha($newRGBA); 59 | if ($color == -1) 60 | $color = $copy->allocateColorAlpha($newRGBA); 61 | 62 | $copy->setColorAt($x, $y, $color); 63 | } 64 | 65 | return $copy; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /inc/lib/Operation/AsNegative.php: -------------------------------------------------------------------------------- 1 | isTrueColor(); 41 | $transparent = $image->isTransparent(); 42 | 43 | if ($palette && $transparent) 44 | $tcrgb = $image->getTransparentColorRGB(); 45 | 46 | $new = $image->asTrueColor(); 47 | if (!imagefilter($new->getHandle(), IMG_FILTER_NEGATE)) 48 | throw new WideImage_GDFunctionResultException("imagefilter() returned false"); 49 | 50 | if ($palette) 51 | { 52 | $new = $new->asPalette(); 53 | if ($transparent) 54 | { 55 | $irgb = array('red' => 255 - $tcrgb['red'], 'green' => 255 - $tcrgb['green'], 'blue' => 255 - $tcrgb['blue'], 'alpha' => 127); 56 | // needs imagecolorexactalpha instead of imagecolorexact, otherwise doesn't work on some transparent GIF images 57 | $new_tci = imagecolorexactalpha($new->getHandle(), $irgb['red'], $irgb['green'], $irgb['blue'], 127); 58 | $new->setTransparentColor($new_tci); 59 | } 60 | } 61 | return $new; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /inc/lib/Operation/GetMask.php: -------------------------------------------------------------------------------- 1 | getWidth(); 41 | $height = $image->getHeight(); 42 | 43 | $mask = WideImage_TrueColorImage::create($width, $height); 44 | $mask->setTransparentColor(-1); 45 | $mask->alphaBlending(false); 46 | $mask->saveAlpha(false); 47 | 48 | for ($i = 0; $i <= 255; $i++) 49 | $greyscale[$i] = ImageColorAllocate($mask->getHandle(), $i, $i, $i); 50 | 51 | imagefilledrectangle($mask->getHandle(), 0, 0, $width, $height, $greyscale[255]); 52 | 53 | $transparentColor = $image->getTransparentColor(); 54 | $alphaToGreyRatio = 255 / 127; 55 | for ($x = 0; $x < $width; $x++) 56 | for ($y = 0; $y < $height; $y++) 57 | { 58 | $color = $image->getColorAt($x, $y); 59 | if ($color == $transparentColor) 60 | $rgba['alpha'] = 127; 61 | else 62 | $rgba = $image->getColorRGB($color); 63 | imagesetpixel($mask->getHandle(), $x, $y, $greyscale[255 - round($rgba['alpha'] * $alphaToGreyRatio)]); 64 | } 65 | return $mask; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /inc/lib/Operation/ApplyFilter.php: -------------------------------------------------------------------------------- 1 | asTrueColor(); 52 | 53 | if (in_array($filter, self::$one_arg_filters)) 54 | $res = imagefilter($new->getHandle(), $filter, $arg1); 55 | elseif (defined('IMG_FILTER_PIXELATE') && $filter == IMG_FILTER_PIXELATE) 56 | $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2); 57 | elseif ($filter == IMG_FILTER_COLORIZE) 58 | $res = imagefilter($new->getHandle(), $filter, $arg1, $arg2, $arg3, $arg4); 59 | else 60 | $res = imagefilter($new->getHandle(), $filter); 61 | 62 | if (!$res) 63 | throw new WideImage_GDFunctionResultException("imagefilter() returned false"); 64 | 65 | return $new; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /inc/lib/Operation/Merge.php: -------------------------------------------------------------------------------- 1 | getWidth(), $overlay->getWidth()); 45 | $y = WideImage_Coordinate::fix($top, $base->getHeight(), $overlay->getHeight()); 46 | 47 | $result = $base->asTrueColor(); 48 | $result->alphaBlending(true); 49 | $result->saveAlpha(true); 50 | 51 | if ($pct <= 0) 52 | return $result; 53 | 54 | if ($pct < 100) 55 | { 56 | if (!imagecopymerge( 57 | $result->getHandle(), 58 | $overlay->getHandle(), 59 | $x, $y, 0, 0, 60 | $overlay->getWidth(), 61 | $overlay->getHeight(), 62 | $pct)) 63 | throw new WideImage_GDFunctionResultException("imagecopymerge() returned false"); 64 | } 65 | else 66 | { 67 | if (!imagecopy( 68 | $result->getHandle(), 69 | $overlay->getHandle(), 70 | $x, $y, 0, 0, 71 | $overlay->getWidth(), 72 | $overlay->getHeight())) 73 | throw new WideImage_GDFunctionResultException("imagecopy() returned false"); 74 | } 75 | 76 | return $result; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /inc/lib/Font/TTF.php: -------------------------------------------------------------------------------- 1 | face = $face; 39 | $this->size = $size; 40 | $this->color = $color; 41 | } 42 | 43 | /** 44 | * Writes text onto an image 45 | * 46 | * @param WideImage_Image $image 47 | * @param mixed $x smart coordinate 48 | * @param mixed $y smart coordinate 49 | * @param string $text 50 | * @param int $angle Angle in degrees clockwise 51 | */ 52 | function writeText($image, $x, $y, $text, $angle = 0) 53 | { 54 | if ($image->isTrueColor()) 55 | $image->alphaBlending(true); 56 | 57 | $box = imageftbbox($this->size, $angle, $this->face, $text); 58 | $obox = array( 59 | 'left' => min($box[0], $box[2], $box[4], $box[6]), 60 | 'top' => min($box[1], $box[3], $box[5], $box[7]), 61 | 'right' => max($box[0], $box[2], $box[4], $box[6]) - 1, 62 | 'bottom' => max($box[1], $box[3], $box[5], $box[7]) - 1 63 | ); 64 | $obox['width'] = abs($obox['left']) + abs($obox['right']); 65 | $obox['height'] = abs($obox['top']) + abs($obox['bottom']); 66 | 67 | $x = WideImage_Coordinate::fix($x, $image->getWidth(), $obox['width']); 68 | $y = WideImage_Coordinate::fix($y, $image->getHeight(), $obox['height']); 69 | 70 | $fixed_x = $x - $obox['left']; 71 | $fixed_y = $y - $obox['top']; 72 | 73 | imagettftext($image->getHandle(), $this->size, $angle, $fixed_x, $fixed_y, $this->color, $this->face, $text); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /sys/edita_cadastra.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT `id` FROM `usuarios` WHERE `email` = ?"); 13 | $verifica_email->execute(array($email)); 14 | 15 | $verifica_nick = $pdo->prepare("SELECT `id` FROM `usuarios` WHERE `nickname` = ?"); 16 | $verifica_nick->execute(array($nickname)); 17 | if($_POST['acao'] == 'efetuar_cadastro'){ 18 | if($verifica_email->rowCount() >= 1){ 19 | echo 'email'; 20 | die; 21 | }elseif($verifica_nick->rowCount() >= 1){ 22 | echo 'nickname'; 23 | die; 24 | }else{ 25 | $cadastra = $pdo->prepare("INSERT INTO `usuarios` SET `nome` = ?, `nickname` = ?, `email` = ?, `senha`= ?, `descricao` = ?"); 26 | $data_insert = [$nome, $nickname, $email, $senha, $descricao]; 27 | if($cadastra->execute($data_insert)){ 28 | echo 'ok'; 29 | }else{ 30 | echo 'no'; 31 | } 32 | } 33 | }elseif($_POST['acao'] == 'editar_perfil'){ 34 | $pega_logado = $pdo->prepare("SELECT * FROM `usuarios` WHERE `nickname` = ?"); 35 | $pega_logado->execute(array($_SESSION['nickname'])); 36 | $logado = $pega_logado->fetchObject(); 37 | 38 | $verifica_email = $pdo->prepare("SELECT `id` FROM `usuarios` WHERE `email` = ? AND `email` != ?"); 39 | $verifica_email->execute(array($email, $logado->email)); 40 | 41 | $verifica_nick = $pdo->prepare("SELECT `id` FROM `usuarios` WHERE `nickname` = ? AND `nickname` != ?"); 42 | $verifica_nick->execute(array($nickname, $logado->nickname)); 43 | if($verifica_email->rowCount() >= 1){ 44 | echo 'email'; 45 | die; 46 | }elseif($verifica_nick->rowCount() >= 1){ 47 | echo 'nickname'; 48 | die; 49 | }else{ 50 | if($nickname != $logado->nickname){ 51 | $_SESSION['nickname'] = $nickname; 52 | } 53 | 54 | $update_perfil = $pdo->prepare("UPDATE `usuarios` SET `nome` = ?, `nickname` = ?, `email` = ?, `senha` = ?, `descricao` = ? WHERE `id` = ?"); 55 | $data_upd = [$nome, $nickname, $email, $senha, $descricao, $logado->id]; 56 | if($update_perfil->execute($data_upd)){ 57 | echo 'ok'; 58 | die; 59 | }else{ 60 | echo 'no'; 61 | die; 62 | } 63 | } 64 | } 65 | } 66 | ?> -------------------------------------------------------------------------------- /inc/lib/Operation/CopyChannelsPalette.php: -------------------------------------------------------------------------------- 1 | 0, 'green' => 0, 'blue' => 0); 44 | if (isset($channels['alpha'])) 45 | unset($channels['alpha']); 46 | 47 | $width = $img->getWidth(); 48 | $height = $img->getHeight(); 49 | $copy = WideImage_PaletteImage::create($width, $height); 50 | 51 | if ($img->isTransparent()) 52 | { 53 | $otci = $img->getTransparentColor(); 54 | $TRGB = $img->getColorRGB($otci); 55 | $tci = $copy->allocateColor($TRGB); 56 | } 57 | else 58 | { 59 | $otci = null; 60 | $tci = null; 61 | } 62 | 63 | for ($x = 0; $x < $width; $x++) 64 | for ($y = 0; $y < $height; $y++) 65 | { 66 | $ci = $img->getColorAt($x, $y); 67 | if ($ci === $otci) 68 | { 69 | $copy->setColorAt($x, $y, $tci); 70 | continue; 71 | } 72 | $RGB = $img->getColorRGB($ci); 73 | 74 | $newRGB = $blank; 75 | foreach ($channels as $channel) 76 | $newRGB[$channel] = $RGB[$channel]; 77 | 78 | $color = $copy->getExactColor($newRGB); 79 | if ($color == -1) 80 | $color = $copy->allocateColor($newRGB); 81 | 82 | $copy->setColorAt($x, $y, $color); 83 | } 84 | 85 | if ($img->isTransparent()) 86 | $copy->setTransparentColor($tci); 87 | 88 | return $copy; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /inc/sidebar.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /inc/lib/Operation/Crop.php: -------------------------------------------------------------------------------- 1 | getWidth(), $width); 45 | $height = WideImage_Coordinate::fix($height, $img->getHeight(), $height); 46 | $left = WideImage_Coordinate::fix($left, $img->getWidth(), $width); 47 | $top = WideImage_Coordinate::fix($top, $img->getHeight(), $height); 48 | if ($left < 0) 49 | { 50 | $width = $left + $width; 51 | $left = 0; 52 | } 53 | 54 | if ($width > $img->getWidth() - $left) 55 | $width = $img->getWidth() - $left; 56 | 57 | if ($top < 0) 58 | { 59 | $height = $top + $height; 60 | $top = 0; 61 | } 62 | 63 | if ($height > $img->getHeight() - $top) 64 | $height = $img->getHeight() - $top; 65 | 66 | if ($width <= 0 || $height <= 0) 67 | throw new WideImage_Exception("Can't crop outside of an image."); 68 | 69 | $new = $img->doCreate($width, $height); 70 | 71 | if ($img->isTransparent() || $img instanceof WideImage_PaletteImage) 72 | { 73 | $new->copyTransparencyFrom($img); 74 | if (!imagecopyresized($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) 75 | throw new WideImage_GDFunctionResultException("imagecopyresized() returned false"); 76 | } 77 | else 78 | { 79 | $new->alphaBlending(false); 80 | $new->saveAlpha(true); 81 | if (!imagecopyresampled($new->getHandle(), $img->getHandle(), 0, 0, $left, $top, $width, $height, $width, $height)) 82 | throw new WideImage_GDFunctionResultException("imagecopyresampled() returned false"); 83 | } 84 | return $new; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /inc/lib/Operation/ApplyMask.php: -------------------------------------------------------------------------------- 1 | getWidth(), $mask->getWidth()); 44 | $top = WideImage_Coordinate::fix($top, $image->getHeight(), $mask->getHeight()); 45 | 46 | $width = $image->getWidth(); 47 | $mask_width = $mask->getWidth(); 48 | 49 | $height = $image->getHeight(); 50 | $mask_height = $mask->getHeight(); 51 | 52 | $result = $image->asTrueColor(); 53 | 54 | $result->alphaBlending(false); 55 | $result->saveAlpha(true); 56 | 57 | $srcTransparentColor = $result->getTransparentColor(); 58 | if ($srcTransparentColor >= 0) 59 | { 60 | # this was here. works without. 61 | #$trgb = $image->getColorRGB($srcTransparentColor); 62 | #$trgb['alpha'] = 127; 63 | #$destTransparentColor = $result->allocateColorAlpha($trgb); 64 | #$result->setTransparentColor($destTransparentColor); 65 | $destTransparentColor = $srcTransparentColor; 66 | } 67 | else 68 | { 69 | $destTransparentColor = $result->allocateColorAlpha(255, 255, 255, 127); 70 | } 71 | 72 | for ($x = 0; $x < $width; $x++) 73 | for ($y = 0; $y < $height; $y++) 74 | { 75 | $mx = $x - $left; 76 | $my = $y - $top; 77 | if ($mx >= 0 && $mx < $mask_width && $my >= 0 && $my < $mask_height) 78 | { 79 | $srcColor = $image->getColorAt($x, $y); 80 | if ($srcColor == $srcTransparentColor) 81 | $destColor = $destTransparentColor; 82 | else 83 | { 84 | $maskRGB = $mask->getRGBAt($mx, $my); 85 | if ($maskRGB['red'] == 0) 86 | $destColor = $destTransparentColor; 87 | elseif ($srcColor >= 0) 88 | { 89 | $imageRGB = $image->getRGBAt($x, $y); 90 | $level = ($maskRGB['red'] / 255) * (1 - $imageRGB['alpha'] / 127); 91 | $imageRGB['alpha'] = 127 - round($level * 127); 92 | if ($imageRGB['alpha'] == 127) 93 | $destColor = $destTransparentColor; 94 | else 95 | $destColor = $result->allocateColorAlpha($imageRGB); 96 | } 97 | else 98 | $destColor = $destTransparentColor; 99 | } 100 | $result->setColorAt($x, $y, $destColor); 101 | } 102 | } 103 | return $result; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /inc/lib/Operation/ResizeCanvas.php: -------------------------------------------------------------------------------- 1 | getWidth()); 50 | $new_height = WideImage_Coordinate::fix($height, $img->getHeight()); 51 | 52 | if ($scale == 'down') 53 | { 54 | $new_width = min($new_width, $img->getWidth()); 55 | $new_height = min($new_height, $img->getHeight()); 56 | } 57 | elseif ($scale == 'up') 58 | { 59 | $new_width = max($new_width, $img->getWidth()); 60 | $new_height = max($new_height, $img->getHeight()); 61 | } 62 | 63 | $new = WideImage::createTrueColorImage($new_width, $new_height); 64 | if ($img->isTrueColor()) 65 | { 66 | if ($color === null) 67 | $color = $new->allocateColorAlpha(0, 0, 0, 127); 68 | } 69 | else 70 | { 71 | imagepalettecopy($new->getHandle(), $img->getHandle()); 72 | 73 | if ($img->isTransparent()) 74 | { 75 | $new->copyTransparencyFrom($img); 76 | $tc_rgb = $img->getTransparentColorRGB(); 77 | $t_color = $new->allocateColorAlpha($tc_rgb); 78 | } 79 | 80 | if ($color === null) 81 | { 82 | if ($img->isTransparent()) 83 | $color = $t_color; 84 | else 85 | $color = $new->allocateColorAlpha(255, 0, 127, 127); 86 | 87 | imagecolortransparent($new->getHandle(), $color); 88 | } 89 | } 90 | $new->fill(0, 0, $color); 91 | 92 | 93 | $x = WideImage_Coordinate::fix($left, $new->getWidth(), $img->getWidth()); 94 | $y = WideImage_Coordinate::fix($top, $new->getHeight(), $img->getHeight()); 95 | 96 | // blending for truecolor images 97 | if ($img->isTrueColor()) 98 | $new->alphaBlending($merge); 99 | 100 | // not-blending for palette images 101 | if (!$merge && !$img->isTrueColor() && isset($t_color)) 102 | $new->getCanvas()->filledRectangle($x, $y, $x + $img->getWidth(), $y + $img->getHeight(), $t_color); 103 | 104 | $img->copyTo($new, $x, $y); 105 | return $new; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /mini_twitter.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.1.14 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: 127.0.0.1 6 | -- Generation Time: 06-Dez-2015 às 00:51 7 | -- Versão do servidor: 5.6.17 8 | -- PHP Version: 5.5.12 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | SET time_zone = "+00:00"; 12 | 13 | 14 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 15 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 16 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 17 | /*!40101 SET NAMES utf8 */; 18 | 19 | -- 20 | -- Database: `mini_twitter` 21 | -- 22 | 23 | -- -------------------------------------------------------- 24 | 25 | -- 26 | -- Estrutura da tabela `follows` 27 | -- 28 | 29 | CREATE TABLE IF NOT EXISTS `follows` ( 30 | `id` int(11) NOT NULL AUTO_INCREMENT, 31 | `seguidor` int(11) NOT NULL, 32 | `usuario` int(11) NOT NULL, 33 | PRIMARY KEY (`id`) 34 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; 35 | 36 | -- 37 | -- Extraindo dados da tabela `follows` 38 | -- 39 | 40 | INSERT INTO `follows` (`id`, `seguidor`, `usuario`) VALUES 41 | (1, 1, 4), 42 | (2, 4, 1); 43 | 44 | -- -------------------------------------------------------- 45 | 46 | -- 47 | -- Estrutura da tabela `trending` 48 | -- 49 | 50 | CREATE TABLE IF NOT EXISTS `trending` ( 51 | `id` int(11) NOT NULL AUTO_INCREMENT, 52 | `hashtag` varchar(100) NOT NULL, 53 | `mencoes` int(11) NOT NULL, 54 | PRIMARY KEY (`id`) 55 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; 56 | 57 | -- 58 | -- Extraindo dados da tabela `trending` 59 | -- 60 | 61 | INSERT INTO `trending` (`id`, `hashtag`, `mencoes`) VALUES 62 | (1, '#downs_master', 3), 63 | (2, '#tweet', 1), 64 | (3, '#sou_demais', 1); 65 | 66 | -- -------------------------------------------------------- 67 | 68 | -- 69 | -- Estrutura da tabela `tweets` 70 | -- 71 | 72 | CREATE TABLE IF NOT EXISTS `tweets` ( 73 | `id` int(11) NOT NULL AUTO_INCREMENT, 74 | `user_id` int(11) NOT NULL, 75 | `tweet` varchar(250) NOT NULL, 76 | `data` datetime NOT NULL, 77 | `timestamp` varchar(200) NOT NULL, 78 | PRIMARY KEY (`id`) 79 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 80 | 81 | -- 82 | -- Extraindo dados da tabela `tweets` 83 | -- 84 | 85 | INSERT INTO `tweets` (`id`, `user_id`, `tweet`, `data`, `timestamp`) VALUES 86 | (1, 4, 'Olá Zezin', '2015-12-05 15:26:12', '1449336372'), 87 | (2, 1, 'E ae', '2015-12-05 15:26:36', '1449336396'), 88 | (3, 4, 'Tudo beleza', '2015-12-05 15:26:50', '1449336410'), 89 | (4, 4, 'msg', '2015-12-05 15:27:38', '1449336458'); 90 | 91 | -- -------------------------------------------------------- 92 | 93 | -- 94 | -- Estrutura da tabela `usuarios` 95 | -- 96 | 97 | CREATE TABLE IF NOT EXISTS `usuarios` ( 98 | `id` int(11) NOT NULL AUTO_INCREMENT, 99 | `foto` varchar(200) NOT NULL, 100 | `nome` varchar(200) NOT NULL, 101 | `nickname` varchar(200) NOT NULL, 102 | `email` varchar(150) NOT NULL, 103 | `senha` varchar(100) NOT NULL, 104 | `descricao` varchar(100) NOT NULL, 105 | PRIMARY KEY (`id`) 106 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; 107 | 108 | -- 109 | -- Extraindo dados da tabela `usuarios` 110 | -- 111 | 112 | INSERT INTO `usuarios` (`id`, `foto`, `nome`, `nickname`, `email`, `senha`, `descricao`) VALUES 113 | (1, 'a6ccafaf9d519ca756914778daf93414.jpg', 'Zézinho da Silva', 'zezin_santos', 'zezin@gmei.com', '123zezin', 'Esta é a descrição do zezin do santos, ele é muito legal!'), 114 | (4, '2d4b1439f8ce16be1541397c55d8810b.jpg', 'Lucas Silva', 'lukas_dev', 'lukasdev@hotmail.com', '123456', 'Esta é a descrição do lucas silva'); 115 | 116 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 117 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 118 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 119 | -------------------------------------------------------------------------------- /inc/lib/MapperFactory.php: -------------------------------------------------------------------------------- 1 | 'JPEG', 44 | 'image/jpeg' => 'JPEG', 45 | 'image/pjpeg' => 'JPEG', 46 | 'image/gif' => 'GIF', 47 | 'image/png' => 'PNG' 48 | ); 49 | 50 | /** 51 | * Returns a mapper, based on the $uri and $format 52 | * 53 | * @param string $uri File URI 54 | * @param string $format File format (extension or mime-type) or null 55 | * @return WideImage_Mapper 56 | **/ 57 | static function selectMapper($uri, $format = null) 58 | { 59 | $format = self::determineFormat($uri, $format); 60 | 61 | if (array_key_exists($format, self::$mappers)) 62 | return self::$mappers[$format]; 63 | 64 | $mapperClassName = 'WideImage_Mapper_' . $format; 65 | 66 | if (!class_exists($mapperClassName, false)) 67 | { 68 | $mapperFileName = WideImage::path() . 'Mapper/' . $format . '.php'; 69 | if (file_exists($mapperFileName)) 70 | require_once $mapperFileName; 71 | } 72 | 73 | if (class_exists($mapperClassName)) 74 | { 75 | self::$mappers[$format] = new $mapperClassName(); 76 | return self::$mappers[$format]; 77 | } 78 | 79 | throw new WideImage_UnsupportedFormatException("Format '{$format}' is not supported."); 80 | } 81 | 82 | static function registerMapper($mapper_class_name, $mime_type, $extension) 83 | { 84 | self::$customMappers[$mime_type] = $mapper_class_name; 85 | self::$mimeTable[$mime_type] = $extension; 86 | } 87 | 88 | static function getCustomMappers() 89 | { 90 | return self::$customMappers; 91 | } 92 | 93 | static function determineFormat($uri, $format = null) 94 | { 95 | if ($format == null) 96 | $format = self::extractExtension($uri); 97 | 98 | // mime-type match 99 | if (preg_match('~[a-z]*/[a-z-]*~i', $format)) 100 | if (isset(self::$mimeTable[strtolower($format)])) 101 | { 102 | return self::$mimeTable[strtolower($format)]; 103 | } 104 | 105 | // clean the string 106 | $format = strtoupper(preg_replace('/[^a-z0-9_-]/i', '', $format)); 107 | if ($format == 'JPG') 108 | $format = 'JPEG'; 109 | 110 | return $format; 111 | } 112 | 113 | static function mimeType($format) 114 | { 115 | return array_search(strtoupper($format), self::$mimeTable); 116 | } 117 | 118 | static function extractExtension($uri) 119 | { 120 | $p = strrpos($uri, '.'); 121 | if ($p === false) 122 | return ''; 123 | else 124 | return substr($uri, $p + 1); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /css/jcrop.css: -------------------------------------------------------------------------------- 1 | /* jquery.Jcrop.css v0.9.12 - MIT License */ 2 | /* 3 | The outer-most container in a typical Jcrop instance 4 | If you are having difficulty with formatting related to styles 5 | on a parent element, place any fixes here or in a like selector 6 | 7 | You can also style this element if you want to add a border, etc 8 | A better method for styling can be seen below with .jcrop-light 9 | (Add a class to the holder and style elements for that extended class) 10 | */ 11 | .jcrop-holder { 12 | direction: ltr; 13 | text-align: left; 14 | } 15 | /* Selection Border */ 16 | .jcrop-vline, 17 | .jcrop-hline { 18 | background: #ffffff url("Jcrop.gif"); 19 | font-size: 0; 20 | position: absolute; 21 | } 22 | .jcrop-vline { 23 | height: 100%; 24 | width: 1px !important; 25 | } 26 | .jcrop-vline.right { 27 | right: 0; 28 | } 29 | .jcrop-hline { 30 | height: 1px !important; 31 | width: 100%; 32 | } 33 | .jcrop-hline.bottom { 34 | bottom: 0; 35 | } 36 | /* Invisible click targets */ 37 | .jcrop-tracker { 38 | height: 100%; 39 | width: 100%; 40 | /* "turn off" link highlight */ 41 | -webkit-tap-highlight-color: transparent; 42 | /* disable callout, image save panel */ 43 | -webkit-touch-callout: none; 44 | /* disable cut copy paste */ 45 | -webkit-user-select: none; 46 | } 47 | /* Selection Handles */ 48 | .jcrop-handle { 49 | background-color: #333333; 50 | border: 1px #eeeeee solid; 51 | width: 7px; 52 | height: 7px; 53 | font-size: 1px; 54 | } 55 | .jcrop-handle.ord-n { 56 | left: 50%; 57 | margin-left: -4px; 58 | margin-top: -4px; 59 | top: 0; 60 | } 61 | .jcrop-handle.ord-s { 62 | bottom: 0; 63 | left: 50%; 64 | margin-bottom: -4px; 65 | margin-left: -4px; 66 | } 67 | .jcrop-handle.ord-e { 68 | margin-right: -4px; 69 | margin-top: -4px; 70 | right: 0; 71 | top: 50%; 72 | } 73 | .jcrop-handle.ord-w { 74 | left: 0; 75 | margin-left: -4px; 76 | margin-top: -4px; 77 | top: 50%; 78 | } 79 | .jcrop-handle.ord-nw { 80 | left: 0; 81 | margin-left: -4px; 82 | margin-top: -4px; 83 | top: 0; 84 | } 85 | .jcrop-handle.ord-ne { 86 | margin-right: -4px; 87 | margin-top: -4px; 88 | right: 0; 89 | top: 0; 90 | } 91 | .jcrop-handle.ord-se { 92 | bottom: 0; 93 | margin-bottom: -4px; 94 | margin-right: -4px; 95 | right: 0; 96 | } 97 | .jcrop-handle.ord-sw { 98 | bottom: 0; 99 | left: 0; 100 | margin-bottom: -4px; 101 | margin-left: -4px; 102 | } 103 | /* Dragbars */ 104 | .jcrop-dragbar.ord-n, 105 | .jcrop-dragbar.ord-s { 106 | height: 7px; 107 | width: 100%; 108 | } 109 | .jcrop-dragbar.ord-e, 110 | .jcrop-dragbar.ord-w { 111 | height: 100%; 112 | width: 7px; 113 | } 114 | .jcrop-dragbar.ord-n { 115 | margin-top: -4px; 116 | } 117 | .jcrop-dragbar.ord-s { 118 | bottom: 0; 119 | margin-bottom: -4px; 120 | } 121 | .jcrop-dragbar.ord-e { 122 | margin-right: -4px; 123 | right: 0; 124 | } 125 | .jcrop-dragbar.ord-w { 126 | margin-left: -4px; 127 | } 128 | /* The "jcrop-light" class/extension */ 129 | .jcrop-light .jcrop-vline, 130 | .jcrop-light .jcrop-hline { 131 | background: #ffffff; 132 | filter: alpha(opacity=70) !important; 133 | opacity: .70!important; 134 | } 135 | .jcrop-light .jcrop-handle { 136 | -moz-border-radius: 3px; 137 | -webkit-border-radius: 3px; 138 | background-color: #000000; 139 | border-color: #ffffff; 140 | border-radius: 3px; 141 | } 142 | /* The "jcrop-dark" class/extension */ 143 | .jcrop-dark .jcrop-vline, 144 | .jcrop-dark .jcrop-hline { 145 | background: #000000; 146 | filter: alpha(opacity=70) !important; 147 | opacity: 0.7 !important; 148 | } 149 | .jcrop-dark .jcrop-handle { 150 | -moz-border-radius: 3px; 151 | -webkit-border-radius: 3px; 152 | background-color: #ffffff; 153 | border-color: #000000; 154 | border-radius: 3px; 155 | } 156 | /* Simple macro to turn off the antlines */ 157 | .solid-line .jcrop-vline, 158 | .solid-line .jcrop-hline { 159 | background: #ffffff; 160 | } 161 | /* Fix for twitter bootstrap et al. */ 162 | .jcrop-holder img, 163 | img.jcrop-preview { 164 | max-width: none; 165 | } 166 | -------------------------------------------------------------------------------- /inc/lib/PaletteImage.php: -------------------------------------------------------------------------------- 1 | copy(); 66 | } 67 | 68 | /** 69 | * Returns a copy of the image 70 | * 71 | * @param $trueColor True if the new image should be truecolor 72 | * @return WideImage_Image 73 | */ 74 | protected function copyAsNew($trueColor = false) 75 | { 76 | $width = $this->getWidth(); 77 | $height = $this->getHeight(); 78 | 79 | if ($trueColor) 80 | $new = WideImage_TrueColorImage::create($width, $height); 81 | else 82 | $new = WideImage_PaletteImage::create($width, $height); 83 | 84 | // copy transparency of source to target 85 | if ($this->isTransparent()) 86 | { 87 | $rgb = $this->getTransparentColorRGB(); 88 | if (is_array($rgb)) 89 | { 90 | $tci = $new->allocateColor($rgb['red'], $rgb['green'], $rgb['blue']); 91 | $new->fill(0, 0, $tci); 92 | $new->setTransparentColor($tci); 93 | } 94 | } 95 | 96 | imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height); 97 | return $new; 98 | } 99 | 100 | /** 101 | * (non-PHPdoc) 102 | * @see WideImage_Image#asTrueColor() 103 | */ 104 | function asTrueColor() 105 | { 106 | $width = $this->getWidth(); 107 | $height = $this->getHeight(); 108 | $new = WideImage::createTrueColorImage($width, $height); 109 | if ($this->isTransparent()) 110 | $new->copyTransparencyFrom($this); 111 | if (!imageCopy($new->getHandle(), $this->handle, 0, 0, 0, 0, $width, $height)) 112 | throw new WideImage_GDFunctionResultException("imagecopy() returned false"); 113 | return $new; 114 | } 115 | 116 | /** 117 | * (non-PHPdoc) 118 | * @see WideImage_Image#getChannels() 119 | */ 120 | function getChannels() 121 | { 122 | $args = func_get_args(); 123 | if (count($args) == 1 && is_array($args[0])) 124 | $args = $args[0]; 125 | return WideImage_OperationFactory::get('CopyChannelsPalette')->execute($this, $args); 126 | } 127 | 128 | /** 129 | * (non-PHPdoc) 130 | * @see WideImage_Image#copyNoAlpha() 131 | */ 132 | function copyNoAlpha() 133 | { 134 | return WideImage_Image::loadFromString($this->asString('png')); 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /inc/lib/Operation/AddNoise.php: -------------------------------------------------------------------------------- 1 | asTrueColor(), $fun, $amount); 54 | } 55 | 56 | /** 57 | * Returns image with every pixel changed by specififed function 58 | * 59 | * @param WideImage_Image $image 60 | * @param str $function 61 | * @param int $value 62 | * @return WideImage_Image 63 | */ 64 | function filter($image, $function, $value) 65 | { 66 | for ($y = 0; $y < $image->getHeight(); $y++) 67 | { 68 | for ($x = 0; $x< $image->getWidth(); $x++) 69 | { 70 | $rgb = imagecolorat($image->getHandle(), $x, $y); 71 | 72 | $a = ($rgb >> 24) & 0xFF; 73 | $r = ($rgb >> 16) & 0xFF; 74 | $g = ($rgb >> 8) & 0xFF; 75 | $b = $rgb & 0xFF; 76 | 77 | 78 | self::$function($r, $g, $b, $value); 79 | 80 | $color = imagecolorallocatealpha($image->getHandle(), $r, $g, $b, $a); 81 | imagesetpixel($image->getHandle(), $x, $y, $color); 82 | } 83 | } 84 | return $image; 85 | } 86 | /** 87 | * Adds color noise by altering given R,G,B values using specififed amount 88 | * 89 | * @param int $r 90 | * @param int $g 91 | * @param int $b 92 | * @param int $value 93 | * @return void 94 | */ 95 | function colorNoise_fun(&$r, &$g, &$b, $amount) 96 | { 97 | $r = self::byte($r + mt_rand(0, $amount) - ($amount >> 1) ); 98 | $g = self::byte($g + mt_rand(0, $amount) - ($amount >> 1) ); 99 | $b = self::byte($b + mt_rand(0, $amount) - ($amount >> 1) ); 100 | } 101 | /** 102 | * Adds mono noise by altering given R,G,B values using specififed amount 103 | * 104 | * @param int $r 105 | * @param int $g 106 | * @param int $b 107 | * @param int $value 108 | * @return void 109 | */ 110 | function monoNoise_fun(&$r, &$g, &$b, $amount) 111 | { 112 | $rand = mt_rand(0, $amount) - ($amount >> 1); 113 | 114 | $r = self::byte($r + $rand); 115 | $g = self::byte($g + $rand); 116 | $b = self::byte($b + $rand); 117 | } 118 | /** 119 | * Adds salt&pepper noise by altering given R,G,B values using specififed amount 120 | * 121 | * @param int $r 122 | * @param int $g 123 | * @param int $b 124 | * @param int $value 125 | * @return void 126 | */ 127 | function saltPepperNoise_fun(&$r, &$g, &$b, $amount) 128 | { 129 | if (mt_rand(0, 255 - $amount) != 0) return; 130 | 131 | $rand = mt_rand(0, 1); 132 | switch ($rand) 133 | { 134 | case 0 : $r = $g = $b = 0; 135 | break; 136 | case 1 : $r = $g = $b = 255; 137 | break; 138 | } 139 | } 140 | /** 141 | * Returns value within (0,255) 142 | * 143 | * @param int $b 144 | * @return int 145 | */ 146 | function byte($b) 147 | { 148 | if ($b > 255) return 255; 149 | if ($b < 0) return 0; 150 | return (int) $b; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /pages/minha-conta.php: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |

Minha conta

5 | 19 | Meus dados 20 | Mudar Foto 21 | 22 | 23 |
24 |
25 |
26 | 30 | 34 | 38 | 42 | 47 | 48 | 49 |
50 |
51 |
52 | foto != ''){ 64 | unlink('uploads/'.$logado->foto); 65 | $upd_foto = $pdo->prepare("UPDATE `usuarios` SET `foto` = ? WHERE `id` = ?"); 66 | if($upd_foto->execute(array($crop, $logado->id))){ 67 | echo '
Imagem cortada com sucesso
'; 68 | } 69 | }else{ 70 | $upd_foto = $pdo->prepare("UPDATE `usuarios` SET `foto` = ? WHERE `id` = ?"); 71 | if($upd_foto->execute(array($crop, $logado->id))){ 72 | echo '
Imagem cortada com sucesso
'; 73 | } 74 | } 75 | unlink('uploads/'.$_SESSION['temp_img']); 76 | unset($_SESSION['temp_img']); 77 | }else{ 78 | echo '
Não foi possível fazer o crop
'; 79 | unlink('uploads/'.$_SESSION['temp_img']); 80 | unset($_SESSION['temp_img']); 81 | } 82 | }elseif(isset($_POST['upl_foto'])){ 83 | include_once "inc/lib/WideImage.php"; 84 | $tamanhos = getimagesize($_FILES['foto']['tmp_name']); 85 | if($tamanhos[0] < 500){ 86 | echo '
A imagem precisa ter no mínimo 500px de largura!
'; 87 | }else{ 88 | $wide = WideImage::load($_FILES['foto']['tmp_name']); 89 | $resized = $wide->resize(500); 90 | $resize = $resized->saveToFile("uploads/temp_".$logado->id.".jpg"); 91 | if(is_object($resized)){ 92 | $_SESSION['temp_img'] = 'temp_'.$logado->id.'.jpg'; 93 | } 94 | } 95 | } 96 | } 97 | ?> 98 | 99 | 100 |
101 | 102 |
103 | 104 |
105 | 106 | 107 | 108 | 109 | 110 | 111 |
112 | 113 |
114 | 115 | 116 |
117 | 118 |
119 |
120 |
-------------------------------------------------------------------------------- /inc/lib/Operation/Unsharp.php: -------------------------------------------------------------------------------- 1 | 500) $amount = 500; 48 | $amount = $amount * 0.016; 49 | if ($radius > 50) $radius = 50; 50 | $radius = $radius * 2; 51 | if ($threshold > 255) $threshold = 255; 52 | 53 | $radius = abs(round($radius)); // Only integers make sense. 54 | if ($radius == 0) { 55 | return $image; 56 | } 57 | 58 | // Gaussian blur matrix 59 | 60 | $matrix = array( 61 | array(1, 2, 1), 62 | array(2, 4, 2), 63 | array(1, 2, 1) 64 | ); 65 | 66 | $blurred = $image->applyConvolution($matrix, 16, 0); 67 | 68 | if($threshold > 0) { 69 | // Calculate the difference between the blurred pixels and the original 70 | // and set the pixels 71 | for ($x = 0; $x < $image->getWidth(); $x++) { 72 | for ($y = 0; $y < $image->getHeight(); $y++) { 73 | $rgbOrig = $image->getRGBAt($x, $y); 74 | $rOrig = $rgbOrig["red"]; 75 | $gOrig = $rgbOrig["green"]; 76 | $bOrig = $rgbOrig["blue"]; 77 | 78 | $rgbBlur = $blurred->getRGBAt($x, $y); 79 | $rBlur = $rgbBlur["red"]; 80 | $gBlur = $rgbBlur["green"]; 81 | $bBlur = $rgbBlur["blue"]; 82 | 83 | // When the masked pixels differ less from the original 84 | // than the threshold specifies, they are set to their original value. 85 | $rNew = (abs($rOrig - $rBlur) >= $threshold) 86 | ? max(0, min(255, ($amount * ($rOrig - $rBlur)) + $rOrig)) 87 | : $rOrig; 88 | $gNew = (abs($gOrig - $gBlur) >= $threshold) 89 | ? max(0, min(255, ($amount * ($gOrig - $gBlur)) + $gOrig)) 90 | : $gOrig; 91 | $bNew = (abs($bOrig - $bBlur) >= $threshold) 92 | ? max(0, min(255, ($amount * ($bOrig - $bBlur)) + $bOrig)) 93 | : $bOrig; 94 | $rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0); 95 | 96 | if (($rOrig != $rNew) || ($gOrig != $gNew) || ($bOrig != $bNew)) { 97 | $image->setRGBAt($x, $y, $rgbNew); 98 | } 99 | } 100 | } 101 | } 102 | else { 103 | $w = $image->getWidth(); 104 | $h = $image->getHeight(); 105 | for ($x = 0; $x < $w; $x++) { 106 | for ($y = 0; $y < $h; $y++) { 107 | $rgbOrig = $image->getRGBAt($x, $y); 108 | $rOrig = $rgbOrig["red"]; 109 | $gOrig = $rgbOrig["green"]; 110 | $bOrig = $rgbOrig["blue"]; 111 | 112 | $rgbBlur = $blurred->getRGBAt($x, $y); 113 | $rBlur = $rgbBlur["red"]; 114 | $gBlur = $rgbBlur["green"]; 115 | $bBlur = $rgbBlur["blue"]; 116 | 117 | $rNew = ($amount * ($rOrig - $rBlur)) + $rOrig; 118 | if($rNew>255){$rNew=255;} 119 | elseif($rNew<0){$rNew=0;} 120 | $gNew = ($amount * ($gOrig - $gBlur)) + $gOrig; 121 | if($gNew>255){$gNew=255;} 122 | elseif($gNew<0){$gNew=0;} 123 | $bNew = ($amount * ($bOrig - $bBlur)) + $bOrig; 124 | if($bNew>255){$bNew=255;} 125 | elseif($bNew<0){$bNew=0;} 126 | $rgbNew = array("red" => $rNew, "green" => $gNew, "blue" => $bNew, "alpha" => 0); 127 | 128 | $image->setRGBAt($x, $y, $rgbNew); 129 | } 130 | } 131 | } 132 | 133 | return $image; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /inc/lib/Operation/RoundCorners.php: -------------------------------------------------------------------------------- 1 | 16) 44 | $sample_ratio = 16; 45 | else 46 | $sample_ratio = $smoothness; 47 | 48 | $corner = WideImage::createTrueColorImage($radius * $sample_ratio, $radius * $sample_ratio); 49 | if ($color === null) 50 | { 51 | imagepalettecopy($corner->getHandle(), $image->getHandle()); 52 | $bg_color = $corner->allocateColor(0, 0, 0); 53 | 54 | $corner->fill(0, 0, $bg_color); 55 | $fg_color = $corner->allocateColor(255, 255, 255); 56 | $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); 57 | $corner = $corner->resize($radius, $radius); 58 | 59 | $result = $image->asTrueColor(); 60 | 61 | $tc = $result->getTransparentColor(); 62 | if ($tc == -1) 63 | { 64 | $tc = $result->allocateColorAlpha(255, 255, 255, 127); 65 | imagecolortransparent($result->getHandle(), $tc); 66 | $result->setTransparentColor($tc); 67 | } 68 | 69 | if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) 70 | $result = $result->applyMask($corner, -1, -1); 71 | 72 | $corner = $corner->rotate(90); 73 | if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) 74 | $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); 75 | 76 | $corner = $corner->rotate(90); 77 | if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) 78 | $result = $result->applyMask($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); 79 | 80 | $corner = $corner->rotate(90); 81 | if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) 82 | $result = $result->applyMask($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); 83 | 84 | return $result; 85 | } 86 | else 87 | { 88 | $bg_color = $color; 89 | 90 | $corner->fill(0, 0, $bg_color); 91 | $fg_color = $corner->allocateColorAlpha(127, 127, 127, 127); 92 | $corner->getCanvas()->filledEllipse($radius * $sample_ratio, $radius * $sample_ratio, $radius * 2 * $sample_ratio, $radius * 2 * $sample_ratio, $fg_color); 93 | $corner = $corner->resize($radius, $radius); 94 | 95 | $result = $image->copy(); 96 | if ($corners & WideImage::SIDE_TOP_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_TOP) 97 | $result = $result->merge($corner, -1, -1, 100); 98 | 99 | $corner = $corner->rotate(90); 100 | if ($corners & WideImage::SIDE_TOP_RIGHT || $corners & WideImage::SIDE_TOP || $corners & WideImage::SIDE_RIGHT) 101 | $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, -1, 100); 102 | 103 | $corner = $corner->rotate(90); 104 | if ($corners & WideImage::SIDE_BOTTOM_RIGHT || $corners & WideImage::SIDE_RIGHT || $corners & WideImage::SIDE_BOTTOM) 105 | $result = $result->merge($corner, $result->getWidth() - $corner->getWidth() + 1, $result->getHeight() - $corner->getHeight() + 1, 100); 106 | 107 | $corner = $corner->rotate(90); 108 | if ($corners & WideImage::SIDE_BOTTOM_LEFT || $corners & WideImage::SIDE_LEFT || $corners & WideImage::SIDE_BOTTOM) 109 | $result = $result->merge($corner, -1, $result->getHeight() - $corner->getHeight() + 1, 100); 110 | 111 | return $result; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /inc/lib/Operation/AutoCrop.php: -------------------------------------------------------------------------------- 1 | getRGBAt(0, 0); 55 | else 56 | { 57 | if ($base_color < 0) 58 | return $img->copy(); 59 | 60 | $rgb_base = $img->getColorRGB($base_color); 61 | } 62 | 63 | $cut_rect = array('left' => 0, 'top' => 0, 'right' => $img->getWidth() - 1, 'bottom' => $img->getHeight() - 1); 64 | 65 | for ($y = 0; $y <= $cut_rect['bottom']; $y++) 66 | { 67 | $count = 0; 68 | for ($x = 0; $x <= $cut_rect['right']; $x++) 69 | { 70 | $rgb = $img->getRGBAt($x, $y); 71 | $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']); 72 | if ($diff > $rgb_threshold) 73 | { 74 | $count++; 75 | if ($count >= $pixel_cutoff) 76 | { 77 | $cut_rect['top'] = $y; 78 | break 2; 79 | } 80 | } 81 | } 82 | } 83 | 84 | for ($y = $img->getHeight() - 1; $y >= $cut_rect['top']; $y--) 85 | { 86 | $count = 0; 87 | for ($x = 0; $x <= $cut_rect['right']; $x++) 88 | { 89 | $rgb = $img->getRGBAt($x, $y); 90 | $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']); 91 | if ($diff > $rgb_threshold) 92 | { 93 | $count++; 94 | if ($count >= $pixel_cutoff) 95 | { 96 | $cut_rect['bottom'] = $y; 97 | break 2; 98 | } 99 | } 100 | } 101 | } 102 | 103 | for ($x = 0; $x <= $cut_rect['right']; $x++) 104 | { 105 | $count = 0; 106 | for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++) 107 | { 108 | $rgb = $img->getRGBAt($x, $y); 109 | $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']); 110 | if ($diff > $rgb_threshold) 111 | { 112 | $count++; 113 | if ($count >= $pixel_cutoff) 114 | { 115 | $cut_rect['left'] = $x; 116 | break 2; 117 | } 118 | } 119 | } 120 | } 121 | 122 | for ($x = $cut_rect['right']; $x >= $cut_rect['left']; $x--) 123 | { 124 | $count = 0; 125 | for ($y = $cut_rect['top']; $y <= $cut_rect['bottom']; $y++) 126 | { 127 | $rgb = $img->getRGBAt($x, $y); 128 | $diff = abs($rgb['red'] - $rgb_base['red']) + abs($rgb['green'] - $rgb_base['green']) + abs($rgb['blue'] - $rgb_base['blue']); 129 | if ($diff > $rgb_threshold) 130 | { 131 | $count++; 132 | if ($count >= $pixel_cutoff) 133 | { 134 | $cut_rect['right'] = $x; 135 | break 2; 136 | } 137 | } 138 | } 139 | } 140 | 141 | $cut_rect = array( 142 | 'left' => $cut_rect['left'] - $margin, 143 | 'top' => $cut_rect['top'] - $margin, 144 | 'right' => $cut_rect['right'] + $margin, 145 | 'bottom' => $cut_rect['bottom'] + $margin 146 | ); 147 | 148 | if ($cut_rect['left'] < 0) 149 | $cut_rect['left'] = 0; 150 | 151 | if ($cut_rect['top'] < 0) 152 | $cut_rect['top'] = 0; 153 | 154 | if ($cut_rect['right'] >= $img->getWidth()) 155 | $cut_rect['right'] = $img->getWidth() - 1; 156 | 157 | if ($cut_rect['bottom'] >= $img->getHeight()) 158 | $cut_rect['bottom'] = $img->getHeight() - 1; 159 | 160 | return $img->crop($cut_rect['left'], $cut_rect['top'], $cut_rect['right'] - $cut_rect['left'] + 1, $cut_rect['bottom'] - $cut_rect['top'] + 1); 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /inc/lib/Operation/Resize.php: -------------------------------------------------------------------------------- 1 | getWidth(); 59 | $height = $img->getHeight(); 60 | } 61 | 62 | if ($width !== null) 63 | $width = WideImage_Coordinate::fix($width, $img->getWidth()); 64 | 65 | if ($height !== null) 66 | $height = WideImage_Coordinate::fix($height, $img->getHeight()); 67 | 68 | if ($width === null) 69 | $width = floor($img->getWidth() * $height / $img->getHeight()); 70 | 71 | if ($height === null) 72 | $height = floor($img->getHeight() * $width / $img->getWidth()); 73 | 74 | if ($width === 0 || $height === 0) 75 | return array('width' => 0, 'height' => 0); 76 | 77 | if ($fit == null) 78 | $fit = 'inside'; 79 | 80 | $dim = array(); 81 | if ($fit == 'fill') 82 | { 83 | $dim['width'] = $width; 84 | $dim['height'] = $height; 85 | } 86 | elseif ($fit == 'inside' || $fit == 'outside') 87 | { 88 | $rx = $img->getWidth() / $width; 89 | $ry = $img->getHeight() / $height; 90 | 91 | if ($fit == 'inside') 92 | $ratio = ($rx > $ry) ? $rx : $ry; 93 | else 94 | $ratio = ($rx < $ry) ? $rx : $ry; 95 | 96 | $dim['width'] = round($img->getWidth() / $ratio); 97 | $dim['height'] = round($img->getHeight() / $ratio); 98 | } 99 | else 100 | throw new WideImage_Operation_InvalidFitMethodException("{$fit} is not a valid resize-fit method."); 101 | 102 | return $dim; 103 | } 104 | 105 | /** 106 | * Returns a resized image 107 | * 108 | * @param WideImage_Image $img 109 | * @param smart_coordinate $width 110 | * @param smart_coordinate $height 111 | * @param string $fit 112 | * @param string $scale 113 | * @return WideImage_Image 114 | */ 115 | function execute($img, $width, $height, $fit, $scale) 116 | { 117 | $dim = $this->prepareDimensions($img, $width, $height, $fit); 118 | if (($scale === 'down' && ($dim['width'] >= $img->getWidth() && $dim['height'] >= $img->getHeight())) || 119 | ($scale === 'up' && ($dim['width'] <= $img->getWidth() && $dim['height'] <= $img->getHeight()))) 120 | $dim = array('width' => $img->getWidth(), 'height' => $img->getHeight()); 121 | 122 | if ($dim['width'] <= 0 || $dim['height'] <= 0) 123 | throw new WideImage_Operation_InvalidResizeDimensionException("Both dimensions must be larger than 0."); 124 | 125 | if ($img->isTransparent() || $img instanceof WideImage_PaletteImage) 126 | { 127 | $new = WideImage_PaletteImage::create($dim['width'], $dim['height']); 128 | $new->copyTransparencyFrom($img); 129 | if (!imagecopyresized( 130 | $new->getHandle(), 131 | $img->getHandle(), 132 | 0, 0, 0, 0, 133 | $new->getWidth(), 134 | $new->getHeight(), 135 | $img->getWidth(), 136 | $img->getHeight())) 137 | throw new WideImage_GDFunctionResultException("imagecopyresized() returned false"); 138 | } 139 | else 140 | { 141 | $new = WideImage_TrueColorImage::create($dim['width'], $dim['height']); 142 | $new->alphaBlending(false); 143 | $new->saveAlpha(true); 144 | if (!imagecopyresampled( 145 | $new->getHandle(), 146 | $img->getHandle(), 147 | 0, 0, 0, 0, 148 | $new->getWidth(), 149 | $new->getHeight(), 150 | $img->getWidth(), 151 | $img->getHeight())) 152 | throw new WideImage_GDFunctionResultException("imagecopyresampled() returned false"); 153 | $new->alphaBlending(true); 154 | } 155 | return $new; 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /inc/lib/vendor/de77/TGA.php: -------------------------------------------------------------------------------- 1 | = $datalen) 52 | { 53 | break; 54 | } 55 | 56 | $i++; 57 | 58 | if ($type == 0) //raw 59 | { 60 | for ($j=0; $j<3*$value; $j++) 61 | { 62 | $out .= $data[$j+$i]; 63 | $k++; 64 | } 65 | $i += $value*3; 66 | } 67 | else //rle 68 | { 69 | for ($j=0; $j<$value; $j++) 70 | { 71 | $out .= $data[$i] . $data[$i+1] . $data[$i+2]; 72 | $k++; 73 | } 74 | $i += 3; 75 | } 76 | } 77 | return $out; 78 | } 79 | 80 | static function dec_bits($byte, &$type, &$value) 81 | { 82 | $type = ($byte & 0x80) >> 7; 83 | $value = 1 + ($byte & 0x7F); 84 | } 85 | 86 | static function imagecreatefromstring($bin_data) 87 | { 88 | $bin_pos = 0; 89 | $header = substr($bin_data, $bin_pos, 18); 90 | $bin_pos += 18; 91 | $header = unpack( "cimage_id_len/ccolor_map_type/cimage_type/vcolor_map_origin/vcolor_map_len/" . 92 | "ccolor_map_entry_size/vx_origin/vy_origin/vwidth/vheight/" . 93 | "cpixel_size/cdescriptor", $header); 94 | 95 | switch ($header['image_type']) 96 | { 97 | case 2: //no palette, uncompressed 98 | case 10: //no palette, rle 99 | break; 100 | default: return false; //die('Unsupported TGA format'); 101 | } 102 | 103 | if ($header['pixel_size'] != 24) 104 | { 105 | return false; 106 | //die('Unsupported TGA color depth'); 107 | } 108 | 109 | $bytes = $header['pixel_size'] / 8; 110 | 111 | if ($header['image_id_len'] > 0) 112 | { 113 | $header['image_id'] = substr($bin_data, $bin_pos, $header['image_id_len']); 114 | $bin_pos += $header['image_id_len']; 115 | } 116 | else 117 | { 118 | $header['image_id'] = ''; 119 | } 120 | 121 | $im = imagecreatetruecolor($header['width'], $header['height']); 122 | 123 | $size = $header['width'] * $header['height'] * 3; 124 | 125 | //-- check whether this is NEW TGA or not 126 | $pos = $bin_pos; 127 | $bin_pos = strlen($bin_data) - 26; 128 | $newtga = substr($bin_data, $bin_pos, 26); 129 | if (substr($newtga, 8, 16) != 'TRUEVISION-XFILE') 130 | { 131 | $newtga = false; 132 | } 133 | 134 | $bin_pos = strlen($bin_data); 135 | $datasize = $bin_pos - $pos; 136 | if ($newtga) 137 | { 138 | $datasize -= 26; 139 | } 140 | 141 | $bin_pos = $pos; 142 | 143 | //-- end of check 144 | $data = substr($bin_data, $bin_pos, $datasize); 145 | $bin_pos += $datasize; 146 | if ($header['image_type'] == 10) 147 | { 148 | $data = self::rle_decode($data, $size); 149 | } 150 | if (self::bit5($header['descriptor']) == 1) 151 | { 152 | $reverse = true; 153 | } 154 | else 155 | { 156 | $reverse = false; 157 | } 158 | 159 | $pixels = str_split($data, 3); 160 | $i = 0; 161 | 162 | //read pixels 163 | if ($reverse) 164 | { 165 | for ($y=0; $y<$header['height']; $y++) 166 | { 167 | for ($x=0; $x<$header['width']; $x++) 168 | { 169 | imagesetpixel($im, $x, $y, self::dwordize($pixels[$i])); 170 | $i++; 171 | } 172 | } 173 | } 174 | else 175 | { 176 | for ($y=$header['height']-1; $y>=0; $y--) 177 | { 178 | for ($x=0; $x<$header['width']; $x++) 179 | { 180 | imagesetpixel($im, $x, $y, self::dwordize($pixels[$i])); 181 | $i++; 182 | } 183 | } 184 | } 185 | 186 | return $im; 187 | } 188 | 189 | static function imagecreatefromtga($filename) 190 | { 191 | return self::imagecreatefromstring(file_get_contents($filename)); 192 | } 193 | 194 | static function dwordize($str) 195 | { 196 | $a = ord($str[0]); 197 | $b = ord($str[1]); 198 | $c = ord($str[2]); 199 | return $c*256*256 + $b*256 + $a; 200 | } 201 | 202 | static function bit5($x) 203 | { 204 | return ($x & 32) >> 5; 205 | } 206 | } -------------------------------------------------------------------------------- /sys/load_more.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT * FROM `usuarios` WHERE `nickname` = ?"); 6 | $pega_logado->execute(array($_SESSION['nickname'])); 7 | $logado = $pega_logado->fetchObject(); 8 | 9 | $tipo = $_POST['tipo']; 10 | $implode_ids = implode(', ', $_SESSION['ids_carregados']); 11 | $limite = 1; 12 | switch ($tipo) { 13 | case 'tweets_home': 14 | case 'tweets_timeline': 15 | if($_POST['user_id'] != ''){ 16 | $user_id = $_POST['user_id']; 17 | } 18 | 19 | if($_POST['user_id'] == ''){ 20 | $pega_follows = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ?"); 21 | $pega_follows->execute(array($logado->id)); 22 | 23 | $ids_seguindo = array($logado->id); 24 | while($usr = $pega_follows->fetchObject()){ 25 | $ids_seguindo[] = $usr->usuario; 26 | } 27 | $str_seguindo = implode(', ', $ids_seguindo); 28 | } 29 | $ultimo_id = count($_SESSION['ids_carregados'])-1; 30 | $ultimo_id = $_SESSION['ids_carregados'][$ultimo_id]; 31 | 32 | if($_POST['user_id'] == ''){ 33 | $tweets = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` IN ($str_seguindo) 34 | AND (`id` < $ultimo_id AND `id` NOT IN ($implode_ids)) ORDER BY `id` DESC LIMIT $limite"); 35 | $tweets->execute(); 36 | 37 | $twt = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` IN ($str_seguindo)"); 38 | $twt->execute(); 39 | }else{ 40 | $tweets = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` = ? 41 | AND (`id` < $ultimo_id AND `id` NOT IN ($implode_ids)) ORDER BY `id` DESC LIMIT $limite"); 42 | $tweets->execute(array($user_id)); 43 | 44 | $twt = $pdo->prepare("SELECT * FROM `tweets` WHERE `user_id` = ?"); 45 | $twt->execute(array($user_id)); 46 | } 47 | 48 | 49 | $retorno = array('load_more' => 'sim', 'results' => array()); 50 | 51 | 52 | if(count($_SESSION['ids_carregados'])+$limite >= $twt->rowCount()){ 53 | $retorno['load_more'] = 'nao'; 54 | } 55 | while($tweet = $tweets->fetchObject()){ 56 | $user_tweet = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 57 | $user_tweet->execute(array($tweet->user_id)); 58 | $user_dados = $user_tweet->fetchObject(); 59 | 60 | $_SESSION['ids_carregados'][] = $tweet->id; 61 | $retorno['results'][] = array( 62 | 'nickname' => $user_dados->nickname, 63 | 'nome' => $user_dados->nome, 64 | 'tweet' => $tweet->tweet, 65 | 'date' => date('d/m/Y H:i:s', strtotime($tweet->data)), 66 | ); 67 | } 68 | die(json_encode($retorno)); 69 | break; 70 | case 'perfis_busca': 71 | $busca = strip_tags(trim($_POST['data_search'])); 72 | $retorno = array('load_more' => 'sim', 'results' => array()); 73 | 74 | $usrs = $pdo->prepare("SELECT * FROM `usuarios` WHERE `nome` LIKE '%$busca%'"); 75 | $usrs->execute(); 76 | $pega_result = $pdo->prepare("SELECT * FROM `usuarios` WHERE `nome` LIKE '%$busca%' 77 | AND (`id` != ? AND `id` NOT IN ($implode_ids)) ORDER BY `id` DESC LIMIT $limite"); 78 | 79 | $pega_result->execute(array($logado->id)); 80 | while($user = $pega_result->fetchObject()){ 81 | 82 | $foto = ($user->foto == '') ? BASE.'/uploads/default.jpg' : BASE.'/uploads/'.$user->foto; 83 | 84 | //verifica se sigo de volta ou não 85 | $verifica_follow = $pdo->prepare("SELECT * FROM `follows` WHERE `seguidor` = ? AND `usuario` = ? ORDER BY `id` DESC"); 86 | $verifica_follow->execute(array($logado->id, $user->id)); 87 | if($verifica_follow->rowCount() == 1){ 88 | $texto = 'Desseguir'; 89 | }else{ 90 | $texto = 'Seguir'; 91 | } 92 | $retorno['results'][] = array( 93 | 'foto' => $foto, 94 | 'id' => $user->id, 95 | 'texto' => $texto, 96 | 'nome' => $user->nome, 97 | 'nickname' => $user->nickname, 98 | 'descricao' => $user->descricao 99 | ); 100 | $_SESSION['ids_carregados'][] = $user->id; 101 | } 102 | if(count($_SESSION['ids_carregados'])+$limite >= $usrs->rowCount()){ 103 | $retorno['load_more'] = 'nao'; 104 | } 105 | die(json_encode($retorno)); 106 | break; 107 | case 'tweets_hashtag': 108 | $hashtag = strip_tags($_POST['hashtag']); 109 | $twt = $pdo->prepare("SELECT * FROM `tweets` WHERE `tweet` LIKE '%$hashtag%'"); 110 | $twt->execute(); 111 | 112 | $pega_mencoes = $pdo->prepare("SELECT * FROM `tweets` WHERE `tweet` LIKE '%$hashtag%' 113 | AND `id` NOT IN ($implode_ids) ORDER BY `id` DESC LIMIT $limite"); 114 | $pega_mencoes->execute(); 115 | 116 | $retorno = array('load_more' => 'sim', 'results' => array()); 117 | 118 | if(count($_SESSION['ids_carregados'])+$limite >= $twt->rowCount()){ 119 | $retorno['load_more'] = 'nao'; 120 | } 121 | while($tweet = $pega_mencoes->fetchObject()){ 122 | 123 | $user_tweet = $pdo->prepare("SELECT * FROM `usuarios` WHERE `id` = ?"); 124 | $user_tweet->execute(array($tweet->user_id)); 125 | $user_dados = $user_tweet->fetchObject(); 126 | 127 | $_SESSION['ids_carregados'][] = $tweet->id; 128 | $retorno['results'][] = array( 129 | 'nickname' => $user_dados->nickname, 130 | 'nome' => $user_dados->nome, 131 | 'tweet' => $tweet->tweet, 132 | 'date' => date('d/m/Y H:i:s', strtotime($tweet->data)), 133 | ); 134 | } 135 | die(json_encode($retorno)); 136 | break; 137 | } 138 | } 139 | ?> -------------------------------------------------------------------------------- /inc/lib/Canvas.php: -------------------------------------------------------------------------------- 1 | handle = $img->getHandle(); 59 | $this->image = $img; 60 | } 61 | 62 | /** 63 | * Sets the active font. Can be an instance of 64 | * WideImage_Font_TTF, WideImage_Font_PS, or WideImage_Font_GDF. 65 | * 66 | * 67 | * 68 | * 69 | * @param object $font Font object to set for writeText() 70 | */ 71 | function setFont($font) 72 | { 73 | $this->font = $font; 74 | } 75 | 76 | /** 77 | * Creates and sets the current font 78 | * 79 | * The supported font types are: TTF/OTF, PS, and GDF. 80 | * Font type is detected from the extension. If the $file parameter doesn't have an extension, TTF font is presumed. 81 | * 82 | * Note: not all parameters are supported by all fonts. 83 | * 84 | * @param string $file Font file name (string) 85 | * @param int $size Font size (supported for TTF/OTF and PS fonts, ignored for GDF) 86 | * @param int $color Text color 87 | * @param int $bgcolor Background color (supported only for PS font, ignored for TTF and PS) 88 | * @return mixed One of the WideImage_Font_* objects 89 | */ 90 | function useFont($file, $size = 12, $color = 0, $bgcolor = null) 91 | { 92 | $p = strrpos($file, '.'); 93 | if ($p === false || $p < strlen($file) - 4) 94 | $ext = 'ttf'; 95 | else 96 | $ext = strtolower(substr($file, $p + 1)); 97 | 98 | if ($ext == 'ttf' || $ext == 'otf') 99 | $font = new WideImage_Font_TTF($file, $size, $color); 100 | elseif ($ext == 'ps') 101 | $font = new WideImage_Font_PS($file, $size, $color, $bgcolor); 102 | elseif ($ext == 'gdf') 103 | $font = new WideImage_Font_GDF($file, $color); 104 | else 105 | throw new WideImage_InvalidFontFileException("'$file' appears to be an invalid font file."); 106 | 107 | $this->setFont($font); 108 | return $font; 109 | } 110 | 111 | /** 112 | * Write text on the image at specified position 113 | * 114 | * You must set a font with a call to WideImage_Canvas::setFont() prior to writing text to the image. 115 | * 116 | * Smart coordinates are supported for $x and $y arguments, but currently only for TTF/OTF fonts. 117 | * 118 | * Example: 119 | * 120 | * $img = WideImage::load('pic.jpg'); 121 | * $canvas = $img->getCanvas(); 122 | * $canvas->useFont('Verdana.ttf', 16, $img->allocateColor(255, 0, 0)); 123 | * $canvas->writeText('right', 'bottom', 'www.website.com'); 124 | * 125 | * 126 | * @param int $x Left 127 | * @param int $y Top 128 | * @param string $text Text to write 129 | * @param int $angle The angle, defaults to 0 130 | */ 131 | function writeText($x, $y, $text, $angle = 0) 132 | { 133 | if ($this->font === null) 134 | throw new WideImage_NoFontException("Can't write text without a font."); 135 | 136 | $angle = - floatval($angle); 137 | if ($angle < 0) 138 | $angle = 360 + $angle; 139 | $angle = $angle % 360; 140 | 141 | $this->font->writeText($this->image, $x, $y, $text, $angle); 142 | } 143 | 144 | /** 145 | * A magic method that allows you to call any PHP function that starts with "image". 146 | * 147 | * This is a shortcut to call custom functions on the image handle. 148 | * 149 | * Example: 150 | * 151 | * $img = WideImage::load('pic.jpg'); 152 | * $canvas = $img->getCanvas(); 153 | * $canvas->filledRect(10, 10, 20, 30, $img->allocateColor(0, 0, 0)); 154 | * $canvas->line(60, 80, 30, 100, $img->allocateColor(255, 0, 0)); 155 | * 156 | */ 157 | function __call($method, $params) 158 | { 159 | if (function_exists('image' . $method)) 160 | { 161 | array_unshift($params, $this->handle); 162 | call_user_func_array('image' . $method, $params); 163 | } 164 | else 165 | throw new WideImage_InvalidCanvasMethodException("Function doesn't exist: image{$method}."); 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /inc/lib/Coordinate.php: -------------------------------------------------------------------------------- 1 | 'operand', 'value' => trim($current_operand)); 80 | 81 | $current_operand = ''; 82 | $flush_operand = false; 83 | } 84 | 85 | if ($flush_operator) 86 | { 87 | $tokens[] = array('type' => 'operator', 'value' => $char); 88 | $flush_operator = false; 89 | } 90 | } 91 | return $tokens; 92 | } 93 | 94 | /** 95 | * Evaluates the $coord relatively to $dim 96 | * 97 | * @param string $coord A numeric value or percent string 98 | * @param int $dim Dimension 99 | * @param int $sec_dim Secondary dimension (for align) 100 | * @return int Calculated value 101 | */ 102 | static function evaluate($coord, $dim, $sec_dim = null) 103 | { 104 | $comp_regex = implode('|', self::$coord_align) . '|' . implode('|', self::$coord_numeric); 105 | if (preg_match("/^([+-])?({$comp_regex})$/", $coord, $matches)) 106 | { 107 | $sign = intval($matches[1] . "1"); 108 | $val = $matches[2]; 109 | if (in_array($val, self::$coord_align)) 110 | { 111 | if ($sec_dim === null) 112 | { 113 | switch ($val) 114 | { 115 | case 'left': 116 | case 'top': 117 | return 0; 118 | break; 119 | case 'center': 120 | case 'middle': 121 | return $sign * intval($dim / 2); 122 | break; 123 | case 'right': 124 | case 'bottom': 125 | return $sign * $dim; 126 | break; 127 | default: 128 | return null; 129 | } 130 | } 131 | else 132 | { 133 | switch ($val) 134 | { 135 | case 'left': 136 | case 'top': 137 | return 0; 138 | break; 139 | case 'center': 140 | case 'middle': 141 | return $sign * intval($dim / 2 - $sec_dim / 2); 142 | break; 143 | case 'right': 144 | case 'bottom': 145 | return $sign * ($dim - $sec_dim); 146 | break; 147 | default: 148 | return null; 149 | } 150 | } 151 | } 152 | elseif (substr($val, -1) === '%') 153 | return intval(round($sign * $dim * floatval(str_replace('%', '', $val)) / 100)); 154 | else 155 | return $sign * intval(round($val)); 156 | } 157 | } 158 | 159 | /** 160 | * Calculates and fixes a smart coordinate into a numeric value 161 | * 162 | * @param mixed $value Smart coordinate, relative to $dim 163 | * @param int $dim Coordinate to which $value is relative 164 | * @param int $sec_dim Secondary dimension (for align) 165 | * @return int Calculated value 166 | */ 167 | static function fix($value, $dim, $sec_dim = null) 168 | { 169 | $coord_tokens = self::parse($value); 170 | 171 | if (count($coord_tokens) == 0 || $coord_tokens[count($coord_tokens) - 1]['type'] != 'operand') 172 | throw new WideImage_InvalidCoordinateException("Couldn't parse coordinate '$value' properly."); 173 | 174 | $value = 0; 175 | $operation = 1; 176 | foreach ($coord_tokens as $token) 177 | { 178 | if ($token['type'] == 'operand') 179 | { 180 | $operand_value = self::evaluate($token['value'], $dim, $sec_dim); 181 | if ($operation == 1) 182 | $value = $value + $operand_value; 183 | elseif ($operation == -1) 184 | $value = $value - $operand_value; 185 | else 186 | throw new WideImage_InvalidCoordinateException("Invalid coordinate syntax."); 187 | 188 | $operation = 0; 189 | } 190 | elseif ($token['type'] == 'operator') 191 | { 192 | if ($token['value'] == '-') 193 | { 194 | if ($operation == 0) 195 | $operation = -1; 196 | else 197 | $operation = $operation * -1; 198 | } 199 | elseif ($token['value'] == '+') 200 | { 201 | if ($operation == 0) 202 | $operation = '1'; 203 | } 204 | } 205 | } 206 | return $value; 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /inc/lib/TrueColorImage.php: -------------------------------------------------------------------------------- 1 | alphaBlending(false); 39 | $this->saveAlpha(true); 40 | } 41 | 42 | /** 43 | * Factory method that creates a true-color image object 44 | * 45 | * @param int $width 46 | * @param int $height 47 | * @return WideImage_TrueColorImage 48 | */ 49 | static function create($width, $height) 50 | { 51 | if ($width * $height <= 0 || $width < 0) 52 | throw new WideImage_InvalidImageDimensionException("Can't create an image with dimensions [$width, $height]."); 53 | 54 | return new WideImage_TrueColorImage(imagecreatetruecolor($width, $height)); 55 | } 56 | 57 | function doCreate($width, $height) 58 | { 59 | return self::create($width, $height); 60 | } 61 | 62 | function isTrueColor() 63 | { 64 | return true; 65 | } 66 | 67 | /** 68 | * Sets alpha blending mode via imagealphablending() 69 | * 70 | * @param bool $mode 71 | * @return bool 72 | */ 73 | function alphaBlending($mode) 74 | { 75 | return imagealphablending($this->handle, $mode); 76 | } 77 | 78 | /** 79 | * Toggle if alpha channel should be saved with the image via imagesavealpha() 80 | * 81 | * @param bool $on 82 | * @return bool 83 | */ 84 | function saveAlpha($on) 85 | { 86 | return imagesavealpha($this->handle, $on); 87 | } 88 | 89 | /** 90 | * Allocates a color and returns its index 91 | * 92 | * This method accepts either each component as an integer value, 93 | * or an associative array that holds the color's components in keys 94 | * 'red', 'green', 'blue', 'alpha'. 95 | * 96 | * @param mixed $R 97 | * @param int $G 98 | * @param int $B 99 | * @param int $A 100 | * @return int 101 | */ 102 | function allocateColorAlpha($R, $G = null, $B = null, $A = null) 103 | { 104 | if (is_array($R)) 105 | return imageColorAllocateAlpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); 106 | else 107 | return imageColorAllocateAlpha($this->handle, $R, $G, $B, $A); 108 | } 109 | 110 | /** 111 | * @see WideImage_Image#asPalette($nColors, $dither, $matchPalette) 112 | */ 113 | function asPalette($nColors = 255, $dither = null, $matchPalette = true) 114 | { 115 | $nColors = intval($nColors); 116 | if ($nColors < 1) 117 | $nColors = 1; 118 | elseif ($nColors > 255) 119 | $nColors = 255; 120 | 121 | if ($dither === null) 122 | $dither = $this->isTransparent(); 123 | 124 | $temp = $this->copy(); 125 | imagetruecolortopalette($temp->handle, $dither, $nColors); 126 | if ($matchPalette == true && function_exists('imagecolormatch')) 127 | imagecolormatch($this->handle, $temp->handle); 128 | 129 | // The code below isn't working properly; it corrupts transparency on some palette->tc->palette conversions. 130 | // Why is this code here? 131 | /* 132 | if ($this->isTransparent()) 133 | { 134 | $trgb = $this->getTransparentColorRGB(); 135 | $tci = $temp->getClosestColor($trgb); 136 | $temp->setTransparentColor($tci); 137 | } 138 | /**/ 139 | 140 | $temp->releaseHandle(); 141 | return new WideImage_PaletteImage($temp->handle); 142 | } 143 | 144 | /** 145 | * Returns the index of the color that best match the given color components 146 | * 147 | * This method accepts either each component as an integer value, 148 | * or an associative array that holds the color's components in keys 149 | * 'red', 'green', 'blue', 'alpha'. 150 | * 151 | * @param mixed $R Red component value or an associative array 152 | * @param int $G Green component 153 | * @param int $B Blue component 154 | * @param int $A Alpha component 155 | * @return int The color index 156 | */ 157 | function getClosestColorAlpha($R, $G = null, $B = null, $A = null) 158 | { 159 | if (is_array($R)) 160 | return imagecolorclosestalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); 161 | else 162 | return imagecolorclosestalpha($this->handle, $R, $G, $B, $A); 163 | } 164 | 165 | /** 166 | * Returns the index of the color that exactly match the given color components 167 | * 168 | * This method accepts either each component as an integer value, 169 | * or an associative array that holds the color's components in keys 170 | * 'red', 'green', 'blue', 'alpha'. 171 | * 172 | * @param mixed $R Red component value or an associative array 173 | * @param int $G Green component 174 | * @param int $B Blue component 175 | * @param int $A Alpha component 176 | * @return int The color index 177 | */ 178 | function getExactColorAlpha($R, $G = null, $B = null, $A = null) 179 | { 180 | if (is_array($R)) 181 | return imagecolorexactalpha($this->handle, $R['red'], $R['green'], $R['blue'], $R['alpha']); 182 | else 183 | return imagecolorexactalpha($this->handle, $R, $G, $B, $A); 184 | } 185 | 186 | /** 187 | * @see WideImage_Image#getChannels() 188 | */ 189 | function getChannels() 190 | { 191 | $args = func_get_args(); 192 | if (count($args) == 1 && is_array($args[0])) 193 | $args = $args[0]; 194 | return WideImage_OperationFactory::get('CopyChannelsTrueColor')->execute($this, $args); 195 | } 196 | 197 | /** 198 | * (non-PHPdoc) 199 | * @see WideImage_Image#copyNoAlpha() 200 | */ 201 | function copyNoAlpha() 202 | { 203 | $prev = $this->saveAlpha(false); 204 | $result = WideImage_Image::loadFromString($this->asString('png')); 205 | $this->saveAlpha($prev); 206 | //$result->releaseHandle(); 207 | return $result; 208 | } 209 | 210 | /** 211 | * (non-PHPdoc) 212 | * @see WideImage_Image#asTrueColor() 213 | */ 214 | function asTrueColor() 215 | { 216 | return $this->copy(); 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /inc/lib/vendor/de77/BMP.php: -------------------------------------------------------------------------------- 1 | =0; $y--) 75 | { 76 | for ($x=0; $x<$wid; $x++) 77 | { 78 | $rgb = imagecolorat($img, $x, $y); 79 | fwrite($f, self::byte3($rgb)); 80 | } 81 | fwrite($f, $wid_pad); 82 | } 83 | fclose($f); 84 | } 85 | else 86 | { 87 | foreach ($header AS $h) 88 | { 89 | echo $h; 90 | } 91 | 92 | //save pixels 93 | for ($y=$hei-1; $y>=0; $y--) 94 | { 95 | for ($x=0; $x<$wid; $x++) 96 | { 97 | $rgb = imagecolorat($img, $x, $y); 98 | echo self::byte3($rgb); 99 | } 100 | echo $wid_pad; 101 | } 102 | } 103 | return true; 104 | } 105 | 106 | public static function imagecreatefromstring($data) 107 | { 108 | //read header 109 | $pos = 0; 110 | $header = substr($data, 0, 54); 111 | $pos = 54; 112 | 113 | if (strlen($header) < 54) 114 | return false; 115 | 116 | $header = unpack( 'c2identifier/Vfile_size/Vreserved/Vbitmap_data/Vheader_size/' . 117 | 'Vwidth/Vheight/vplanes/vbits_per_pixel/Vcompression/Vdata_size/'. 118 | 'Vh_resolution/Vv_resolution/Vcolors/Vimportant_colors', $header); 119 | 120 | if ($header['identifier1'] != 66 or $header['identifier2'] != 77) 121 | { 122 | return false; 123 | //die('Not a valid bmp file'); 124 | } 125 | 126 | if (!in_array($header['bits_per_pixel'], array(24, 32, 8, 4, 1))) 127 | { 128 | return false; 129 | //die('Only 1, 4, 8, 24 and 32 bit BMP images are supported'); 130 | } 131 | 132 | $bps = $header['bits_per_pixel']; //bits per pixel 133 | $wid2 = ceil(($bps/8 * $header['width']) / 4) * 4; 134 | $colors = pow(2, $bps); 135 | 136 | $wid = $header['width']; 137 | $hei = $header['height']; 138 | 139 | $img = imagecreatetruecolor($header['width'], $header['height']); 140 | 141 | //read palette 142 | if ($bps < 9) 143 | { 144 | for ($i=0; $i<$colors; $i++) 145 | { 146 | $palette[] = self::undword(substr($data, $pos, 4)); 147 | $pos += 4; 148 | } 149 | } 150 | else 151 | { 152 | if ($bps == 32) 153 | { 154 | imagealphablending($img, false); 155 | imagesavealpha($img, true); 156 | } 157 | $palette = array(); 158 | } 159 | 160 | //read pixels 161 | for ($y=$hei-1; $y>=0; $y--) 162 | { 163 | $row = substr($data, $pos, $wid2); 164 | $pos += $wid2; 165 | $pixels = self::str_split2($row, $bps, $palette); 166 | for ($x=0; $x<$wid; $x++) 167 | { 168 | self::makepixel($img, $x, $y, $pixels[$x], $bps); 169 | } 170 | } 171 | 172 | return $img; 173 | } 174 | 175 | public static function imagecreatefrombmp($filename) 176 | { 177 | return self::imagecreatefromstring(file_get_contents($filename)); 178 | } 179 | 180 | private static function str_split2($row, $bps, $palette) 181 | { 182 | switch ($bps) 183 | { 184 | case 32: 185 | case 24: return str_split($row, $bps/8); 186 | case 8: $out = array(); 187 | $count = strlen($row); 188 | for ($i=0; $i<$count; $i++) 189 | { 190 | $out[] = $palette[ ord($row[$i]) ]; 191 | } 192 | return $out; 193 | case 4: $out = array(); 194 | $count = strlen($row); 195 | for ($i=0; $i<$count; $i++) 196 | { 197 | $roww = ord($row[$i]); 198 | $out[] = $palette[ ($roww & 240) >> 4 ]; 199 | $out[] = $palette[ ($roww & 15) ]; 200 | } 201 | return $out; 202 | case 1: $out = array(); 203 | $count = strlen($row); 204 | for ($i=0; $i<$count; $i++) 205 | { 206 | $roww = ord($row[$i]); 207 | $out[] = $palette[ ($roww & 128) >> 7 ]; 208 | $out[] = $palette[ ($roww & 64) >> 6 ]; 209 | $out[] = $palette[ ($roww & 32) >> 5 ]; 210 | $out[] = $palette[ ($roww & 16) >> 4 ]; 211 | $out[] = $palette[ ($roww & 8) >> 3 ]; 212 | $out[] = $palette[ ($roww & 4) >> 2 ]; 213 | $out[] = $palette[ ($roww & 2) >> 1 ]; 214 | $out[] = $palette[ ($roww & 1) ]; 215 | } 216 | return $out; 217 | } 218 | } 219 | 220 | private static function makepixel($img, $x, $y, $str, $bps) 221 | { 222 | switch ($bps) 223 | { 224 | case 32 : $a = ord($str[0]); 225 | $b = ord($str[1]); 226 | $c = ord($str[2]); 227 | $d = 256 - ord($str[3]); //TODO: gives imperfect results 228 | $pixel = $d*256*256*256 + $c*256*256 + $b*256 + $a; 229 | imagesetpixel($img, $x, $y, $pixel); 230 | break; 231 | case 24 : $a = ord($str[0]); 232 | $b = ord($str[1]); 233 | $c = ord($str[2]); 234 | $pixel = $c*256*256 + $b*256 + $a; 235 | imagesetpixel($img, $x, $y, $pixel); 236 | break; 237 | case 8 : 238 | case 4 : 239 | case 1 : imagesetpixel($img, $x, $y, $str); 240 | break; 241 | } 242 | } 243 | 244 | private static function byte3($n) 245 | { 246 | return chr($n & 255) . chr(($n >> 8) & 255) . chr(($n >> 16) & 255); 247 | } 248 | 249 | private static function undword($n) 250 | { 251 | $r = unpack("V", $n); 252 | return $r[1]; 253 | } 254 | 255 | private static function dword($n) 256 | { 257 | return pack("V", $n); 258 | } 259 | 260 | private static function word($n) 261 | { 262 | return pack("v", $n); 263 | } 264 | } 265 | -------------------------------------------------------------------------------- /js/functions.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var base = $('.base').attr('id'); 3 | 4 | function hidemessage(div){ 5 | setTimeout(function(){ 6 | $(div).find('div').fadeOut(); 7 | }, 3000); 8 | } 9 | 10 | $('body').on('click', '.cad_btn', function(e){ 11 | e.preventDefault(); 12 | $('#cadastrar').animate({marginLeft:'+='+550}, 200); 13 | $(this).removeClass('cad_btn'); 14 | return false; 15 | }); 16 | 17 | $('.close').on('click', function(){ 18 | $('#cadastrar').animate({marginLeft:'-='+550}, 200); 19 | $('.cadastre_se').addClass('cad_btn'); 20 | }); 21 | 22 | $('.button_aba').on('click', function(e){ 23 | e.preventDefault(); 24 | var abrir = $(this).attr('id'); 25 | $('.button_aba').removeClass('ativo'); 26 | $(this).addClass('ativo'); 27 | 28 | $('.aba').hide(); 29 | $('.aba.'+abrir).show(); 30 | 31 | $.ajax({ 32 | method: 'POST', 33 | url: base+'/sys/muda_aba.php', 34 | data: {aba: abrir}, 35 | success: function(r){} 36 | }); 37 | return false; 38 | }); 39 | 40 | function limitaCaracteres(textarea, counter, limit){ 41 | $('.'+counter).text(limit+' restantes'); 42 | var left; 43 | $('.'+textarea).on('keyup', function(e){ 44 | var qtdCaracteres = $(this).val().length; 45 | left = limit-qtdCaracteres; 46 | if(left <= 0){ 47 | left = 0; 48 | var textoAtual = $(this).val(); 49 | var novoTexto = ''; 50 | for(var n = 0; n < limit; n++){ 51 | novoTexto += textoAtual[n]; 52 | } 53 | $(this).val(novoTexto); 54 | } 55 | $('.'+counter).text(left+' restantes'); 56 | }); 57 | } 58 | limitaCaracteres('msg', 'counter', 140); 59 | limitaCaracteres('desc_limit', 'desccount', 100); 60 | 61 | $('.send_message').on('click', function(e){ 62 | e.preventDefault(); 63 | var texto_digitado = $('.msg').val(); 64 | if(texto_digitado == ''){ 65 | alert('Informe um texto para o seu tweet'); 66 | }else{ 67 | $.ajax({ 68 | method: 'POST', 69 | url: 'sys/tweetar.php', 70 | data: {tweet: texto_digitado}, 71 | dataType: 'json', 72 | success: function(retorno){ 73 | /* 74 | retorno.nome 75 | retorno.tweet 76 | retorno.date 77 | retorno.status 78 | */ 79 | 80 | if(retorno.status == 'ok'){ 81 | $('.msg').val(''); 82 | 83 | var tweet = ''; 87 | 88 | $('#content').prepend(tweet); 89 | $('#content .tweet.hidden').slideDown().promise().done(function(){ 90 | $(this).removeClass('hidden'); 91 | }); 92 | }else{ 93 | alert('ocorreu um erro ao enviar seu tweet'); 94 | } 95 | } 96 | }); 97 | } 98 | 99 | return false; 100 | }); 101 | 102 | $('#logar').on('click', function(e){ 103 | e.preventDefault(); 104 | var login = $('input[name=login]').val(); 105 | var senha = $('input[name=senha]').val(); 106 | if(login == '' || senha == ''){ 107 | $('.retorno_log').html('
Preencha todos os campos
'); 108 | hidemessage('.retorno_log'); 109 | }else{ 110 | $.ajax({ 111 | method: 'POST', 112 | url: 'sys/logar.php', 113 | data: {login:login, senha:senha}, 114 | dataType: 'json', 115 | success:function(retorno){ 116 | //console.log(retorno); 117 | if(retorno.status == 'ok'){ 118 | localStorage.setItem('user_id', retorno.user_id); 119 | location.reload(); 120 | }else{ 121 | $('.retorno_log').html('
Ocorreu um erro ao tentar logar, ou login e senha não encontrados
'); 122 | hidemessage('.retorno_log'); 123 | } 124 | } 125 | }); 126 | } 127 | return false; 128 | }); 129 | 130 | $('body').on('click', '.seguir', function(e){ 131 | e.preventDefault(); 132 | var elemento = $(this); 133 | var usuario = $(this).attr('data-user'); 134 | var texto = $(this).text(); 135 | 136 | $(this).html(' aguarde...').removeClass('seguir'); 137 | $.ajax({ 138 | method: 'POST', 139 | url: base+'/sys/follows.php', 140 | data: {follow_unfollow: usuario}, 141 | success: function(retorno){ 142 | console.log(retorno); 143 | if(retorno == 'ok'){ 144 | if(texto == 'Desseguir' || texto == ' Desseguir'){ 145 | elemento.html(' Seguir'); 146 | elemento.addClass('seguir'); 147 | }else{ 148 | elemento.html(' Desseguir'); 149 | elemento.addClass('seguir'); 150 | } 151 | }else{ 152 | alert('Ocorreu um erro, por favor, tente mais tarde!'); 153 | } 154 | }, 155 | error: function(){ 156 | alert('Ocorreu um erro, por favor, tente mais tarde!'); 157 | } 158 | }); 159 | return false; 160 | }); 161 | 162 | //código para o cadastro 163 | $('#efetuar_cadastro, #editar_perfil').on('click', function(e){ 164 | e.preventDefault(); 165 | var nome = $('#nome').val(); 166 | var email = $('#email').val(); 167 | var nickname = $('#nickname').val(); 168 | var senha = $('#senha').val(); 169 | var descricao = $('#descricao').val(); 170 | var acao = $(this).attr('id'); 171 | 172 | if(nome == '' || email == '' || nickname == '' || senha == '' || descricao == ''){ 173 | $('.retorno_cadastro').html('
Preencha todos os campos
'); 174 | hidemessage('.retorno_cadastro'); 175 | }else{ 176 | $.ajax({ 177 | method: 'POST', 178 | url: 'sys/edita_cadastra.php', 179 | data:{acao: acao, nome:nome, email:email, nickname:nickname, senha:senha, descricao:descricao}, 180 | success:function(retorno){ 181 | if(retorno == 'nickname'){ 182 | $('.retorno_cadastro').html('
O nickname informado já está sendo utilizado por outra conta!
'); 183 | }else if(retorno == 'email'){ 184 | $('.retorno_cadastro').html('
Já existe uma conta cadastrada utilizando este e-mail!
'); 185 | }else if(retorno == 'ok'){ 186 | if(acao == 'efetuar_cadastro'){ 187 | $('.retorno_cadastro').html('
Cadastro realizado com sucesso
'); 188 | }else if(acao == 'editar_perfil'){ 189 | $('.retorno_cadastro').html('
Dados editados com sucesso!
'); 190 | } 191 | $('#cadastrar textarea').val(''); 192 | $('#cadastrar input[type=password]').val(''); 193 | $('#cadastrar input[type=text]').each(function(){ 194 | $(this).val(''); 195 | }); 196 | }else{ 197 | if(acao == 'efetuar_cadastro'){ 198 | $('.retorno_cadastro').html('
Houve um problema no cadastro, tente mais tarde!
'); 199 | }else if(acao == 'editar_perfil'){ 200 | $('.retorno_cadastro').html('
Houve um problema na edição de perfil, tente mais tarde!
'); 201 | } 202 | } 203 | hidemessage('.retorno_cadastro'); 204 | }, 205 | error: function(){ 206 | $('.retorno_cadastro').html('
Houve um erro na comunicação com o servidor, tente mais tarde!
'); 207 | hidemessage('.retorno_cadastro'); 208 | } 209 | }); 210 | } 211 | return false; 212 | }); 213 | 214 | $('body').on('click', '.load_more', function(e){ 215 | e.preventDefault(); 216 | var type = $(this).attr('id'); 217 | var id_user = ''; 218 | var hashtag = ''; 219 | var data_search = ''; 220 | if(type == 'tweets_timeline'){ 221 | id_user = $(this).attr('data-id'); 222 | } 223 | if(type == 'perfis_busca'){ 224 | data_search = $(this).attr('data-search'); 225 | } 226 | 227 | if(type == 'tweets_hashtag'){ 228 | hashtag = $(this).attr('data-tag'); 229 | } 230 | $.ajax({ 231 | method:'POST', 232 | url: base+'/sys/load_more.php', 233 | data: {tipo: type, user_id: id_user, data_search: data_search, hashtag: hashtag}, 234 | dataType: 'json', 235 | success: function(retorno){ 236 | if(retorno.load_more == 'nao'){ 237 | $('.load_more').hide(); 238 | } 239 | /* 240 | retorno.nome 241 | retorno.tweet 242 | retorno.date 243 | retorno.status 244 | */ 245 | if(type == 'tweets_home' || type == 'tweets_timeline' || type == 'tweets_hashtag'){ 246 | 247 | $.each(retorno.results, function(i, val){ 248 | 249 | var tweet = '
'; 250 | tweet += ''+retorno.results[i].nome+' disse:'; 251 | tweet += '

'+retorno.results[i].tweet+'

'; 252 | tweet += ''+retorno.results[i].date+'
'; 253 | $('.content_tweets').append(tweet); 254 | }); 255 | }else if(type == 'perfis_busca'){ 256 | $.each(retorno.results, function(i, val){ 257 | var dados = retorno.results[i]; 258 | var perfil = '
'; 259 | perfil += '
'; 260 | perfil += ' '+dados.texto+''; 261 | perfil += '
'; 262 | perfil += ''+dados.nome+''; 263 | perfil += '

@'+dados.nickname+'

'; 264 | perfil += '

'+dados.descricao+'

'; 265 | 266 | $('.content_perfis').append(perfil); 267 | }); 268 | } 269 | } 270 | }); 271 | return false; 272 | }); 273 | $('#target').Jcrop({ 274 | aspectRatio: 1, 275 | minSize: [160,160], 276 | setSelect: [0,0,160,160], 277 | onChange: showCoords, 278 | onSelect: showCoords 279 | }); 280 | 281 | function showCoords(c){ 282 | $('#x').val(c.x); 283 | $('#y').val(c.y); 284 | $('#w').val(c.w); 285 | $('#h').val(c.h); 286 | }; 287 | }); 288 | 289 | -------------------------------------------------------------------------------- /css/style.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin:0; 3 | padding:0; 4 | box-sizing:border-box; 5 | list-style-type:none; 6 | text-decoration:none; 7 | font-family:Roboto; 8 | } 9 | body{background:#eee;} 10 | @font-face { 11 | font-family: 'icomoon'; 12 | src:url('fonts/icomoon.eot?ng2q1j'); 13 | src:url('fonts/icomoon.eot?ng2q1j#iefix') format('embedded-opentype'), 14 | url('fonts/icomoon.ttf?ng2q1j') format('truetype'), 15 | url('fonts/icomoon.woff?ng2q1j') format('woff'), 16 | url('fonts/icomoon.svg?ng2q1j#icomoon') format('svg'); 17 | font-weight: normal; 18 | font-style: normal; 19 | } 20 | 21 | [class^="icon-"], [class*=" icon-"] { 22 | font-family: 'icomoon'; 23 | speak: none; 24 | font-style: normal; 25 | font-weight: normal; 26 | font-variant: normal; 27 | text-transform: none; 28 | line-height: 1; 29 | 30 | /* Better Font Rendering =========== */ 31 | -webkit-font-smoothing: antialiased; 32 | -moz-osx-font-smoothing: grayscale; 33 | } 34 | 35 | .icon-user:before { 36 | content: "\e900"; 37 | } 38 | .icon-search:before { 39 | content: "\e901"; 40 | } 41 | 42 | .aviso{ 43 | padding:6px; 44 | width:100%; 45 | float:left; 46 | color:white; 47 | font-weight:normal; 48 | } 49 | 50 | .aviso.green{background:#009966; border:1px solid #093;} 51 | .aviso.yellow{background:#F2F200; border:1px solid #CCCC00; color:#333;} 52 | 53 | .hidden{display:none;} 54 | a:hover{text-decoration:underline;} 55 | 56 | #header{ 57 | position:fixed; 58 | top:0; 59 | left:0; 60 | width:100%; 61 | z-index:9999; 62 | background:white; 63 | border-bottom:1px solid #ccc; 64 | } 65 | .left{float:left;} 66 | .right{float:right;} 67 | #header ul.left li{ 68 | float:left; 69 | } 70 | #header ul.right li{ 71 | float:right; 72 | } 73 | #header ul li a{ 74 | float:left; 75 | display:inline-block; 76 | padding:0 8px; 77 | color:#333; 78 | font-size:16px; 79 | line-height:45px; 80 | } 81 | #header ul li a:hover{ 82 | text-decoration:none; 83 | background:linear-gradient(to bottom, #fff, #ccc 130%); 84 | } 85 | #header .search{ 86 | float:left; 87 | width:250px; 88 | position:relative; 89 | background:#f5f6f7; 90 | margin-left:10px; 91 | margin-top:5px; 92 | border-radius:15px; 93 | border:1px solid #C5CBD1; 94 | } 95 | #header .search .icon-search{ 96 | position:absolute; 97 | top:8px; 98 | left:10px; 99 | color:#999; 100 | } 101 | #header .search input{ 102 | float:left; 103 | width:100%; 104 | padding:7px; 105 | border:none; 106 | outline:none; 107 | background:none; 108 | padding-left:30px; 109 | font-size:16px; 110 | color:#666; 111 | } 112 | .center{margin:0 auto; width:1000px;} 113 | 114 | #wrapper{ 115 | width:1000px; 116 | margin:70px auto; 117 | } 118 | #sidebar{ 119 | float:left; 120 | width:29%; 121 | } 122 | .box_sidebar{ 123 | background:#fff; 124 | padding:8px; 125 | border-radius:6px; 126 | border:1px solid #ccc; 127 | margin-bottom:10px; 128 | position:relative; 129 | float:left; 130 | width:100%; 131 | } 132 | .box_sidebar h2{ 133 | float:left; 134 | width:100%; 135 | font-size:20px; 136 | color:#6675A7; 137 | font-weight:lighter; 138 | margin-bottom:10px; 139 | } 140 | .box_sidebar li{ 141 | float:left; 142 | width:100%; 143 | margin-bottom:10px; 144 | font-size:17px; 145 | } 146 | .box_sidebar li:last-child{background:none;} 147 | .box_sidebar li a{color:#000;} 148 | 149 | .box_sidebar.perfil .img_perfil{ 150 | position:absolute; 151 | top:-20px; 152 | width:80px; 153 | height:80px; 154 | overflow:hidden; 155 | border:1px solid white; 156 | border-radius:5px; 157 | } 158 | .box_sidebar.perfil .img_perfil img{ 159 | width:100%; 160 | } 161 | .box_sidebar.perfil .dados_user{ 162 | float:right; 163 | width:70%; 164 | padding-left:5px; 165 | } 166 | .box_sidebar.perfil .dados_user .nome_perfil{ 167 | float:left; 168 | width:100%; 169 | font-size:19px; 170 | margin-bottom:6px; 171 | } 172 | .box_sidebar.perfil .dados_user .nome_perfil a{ 173 | color:black; 174 | } 175 | .box_sidebar.perfil .dados_user a.nickname{ 176 | color:#666; 177 | } 178 | 179 | .box_sidebar.perfil .stats{ 180 | float:left; 181 | width:100%; 182 | margin-top:5px; 183 | } 184 | .box_sidebar.perfil .stats .box_stats{ 185 | float:left; 186 | width:33.33%; 187 | padding:8px 0; 188 | } 189 | .box_sidebar.perfil .stats .box_stats span{ 190 | text-transform:uppercase; 191 | font-size:14px; 192 | } 193 | .box_sidebar.perfil .stats .box_stats p{font-size:18px;} 194 | .box_sidebar.perfil .stats .box_stats p a{color:black;} 195 | .box_sidebar.perfil .descricao{ 196 | float:left; 197 | width:100%; 198 | } 199 | #content_wrapper{ 200 | float:right; 201 | width:70%; 202 | } 203 | #content_wrapper #envio_mensagem{ 204 | float:left; 205 | width:100%; 206 | padding:15px; 207 | background:#0099FF; 208 | border-top-left-radius:8px; 209 | border-top-right-radius:8px; 210 | } 211 | #envio_mensagem .title{ 212 | float:left; 213 | width:100%; 214 | font-size:16px; 215 | color:white; 216 | margin-bottom:10px; 217 | } 218 | #envio_mensagem textarea{ 219 | float:left; 220 | width:100%; 221 | resize:vertical; 222 | border:none; 223 | outline:none; 224 | padding:8px; 225 | border-radius:5px; 226 | } 227 | #envio_mensagem .counter{ 228 | float:left; 229 | margin-top:10px; 230 | color:white; 231 | font-size:16px; 232 | } 233 | .send_message{ 234 | float:right; 235 | margin-top:10px; 236 | font-size:16px; 237 | padding:8px 10px; 238 | background:#333; 239 | color:white; 240 | border-radius:5px; 241 | border:0; 242 | border-bottom:2px solid #000; 243 | } 244 | .send_message:hover{background:#000; cursor:pointer;} 245 | 246 | #content{ 247 | float:left; 248 | width:100%; 249 | } 250 | h1.title-page{ 251 | float:left; 252 | width:100%; 253 | font-size:23px; 254 | color:#6675A7; 255 | margin-bottom:10px; 256 | } 257 | #content .tweet{ 258 | float:left; 259 | width:100%; 260 | padding:10px; 261 | border-bottom:1px solid #ccc; 262 | color:#666; 263 | background:white; 264 | transition:all ease-in .3s; 265 | } 266 | #content .tweet a{color:#09f;} 267 | 268 | #content .tweet:hover{background:#f5f6f7;} 269 | #content .tweet .nome{ 270 | font-size:16px; 271 | float:left; 272 | width:100%; 273 | margin-bottom:8px; 274 | } 275 | #content .tweet .nome a{color:#333; font-weight:bold;} 276 | #content .tweet p{font-size:15px;} 277 | #content .tweet .date{font-size:13px; color:#999; float:left; margin-top:8px;} 278 | .button_aba{ 279 | float:left; 280 | padding:6px 8px; 281 | background:#fff; 282 | color:#999; 283 | margin-right:5px; 284 | cursor:pointer; 285 | } 286 | .button_aba.ativo{background:#069; color:white;} 287 | .button_aba.hidden{display:block;} 288 | #content .aba{ 289 | background:#fff; 290 | float:left; 291 | width:100%; 292 | padding:10px; 293 | } 294 | .aba .img_crop{ 295 | width:500px; 296 | float:left; 297 | padding:5px; 298 | border:1px solid #ccc; 299 | } 300 | .aba .coord{float:right; width:100px; margin-bottom:5px;} 301 | .edicao_perfil {float:left; width:100%;} 302 | .edicao_perfil label{ 303 | float:left; 304 | width:100%; 305 | margin-bottom:10px; 306 | } 307 | .edicao_perfil label span{ 308 | float:left; 309 | width:100%; 310 | font-size:16px; 311 | color:#666; 312 | margin-bottom:12px; 313 | } 314 | .edicao_perfil label input, .edicao_perfil textarea{ 315 | float:left; 316 | width:100%; 317 | padding:8px; 318 | background:white; 319 | outline:none; 320 | border:1px solid #ccc; 321 | font-size:16px; 322 | color:#666; 323 | } 324 | .edicao_perfil textarea{ 325 | resize:vertical; 326 | } 327 | /***AQUI COMEÇA O CSS DAS LISTAGENS DE PERFIS**/ 328 | .box_perfil{ 329 | float:left; 330 | padding:10px; 331 | background:white; 332 | width:32%; 333 | max-height:168px; 334 | border:1px solid #ccc; 335 | position:relative; 336 | margin-right:2%; 337 | margin-bottom:30px; 338 | border-radius:5px; 339 | } 340 | .box_perfil:nth-child(3n+1){margin-right:0;} 341 | .box_perfil .img{ 342 | position:absolute; 343 | top:-20px; 344 | width:60px; 345 | height:60px; 346 | overflow:hidden; 347 | border:2px solid white; 348 | border-radius:5px; 349 | } 350 | .box_perfil .img img{width:100%;} 351 | h1.title-page.seg{margin-bottom:30px;} 352 | .box_perfil .perfil_nick{ 353 | float:left; 354 | width:100%; 355 | margin-top:5px; 356 | } 357 | .box_perfil .perfil_nick span{font-size:19px;} 358 | .box_perfil .perfil_nick span a{color:black;} 359 | .box_perfil .perfil_nick p{float:left; width:100%; margin-top:6px;} 360 | .box_perfil .perfil_nick p a{color:#666;} 361 | .box_perfil .desc{ 362 | float:left; 363 | width:100%; 364 | height:66px; 365 | overflow:hidden; 366 | padding:5px 0 0 0; 367 | } 368 | .box_perfil .fix{ 369 | float:left; 370 | width:100%; 371 | height:30px; 372 | } 373 | .button{ 374 | display:inline-block; 375 | padding:6px 8px; 376 | color:#666; 377 | border:1px solid #ccc; 378 | border-radius:4px; 379 | float:right; 380 | background:white; 381 | } 382 | .button:hover{text-decoration:none; background:linear-gradient(to bottom, #fff, #ccc 130%); cursor:pointer;} 383 | .button.seguir{ 384 | background:white; 385 | } 386 | .button.seguir:hover{background:linear-gradient(to bottom, #fff, #ccc 130%);} 387 | 388 | .button.seguir.side{ 389 | float:left; 390 | width:100%; 391 | margin-top:10px; 392 | } 393 | 394 | 395 | /****PAGINA DE LOGIN***/ 396 | #cadastrar{ 397 | position:fixed; 398 | top:0; 399 | left:-550px; 400 | width:550px; 401 | background:white; 402 | padding:20px; 403 | height:100%; 404 | z-index:999; 405 | border-right:2px solid #ccc; 406 | overflow-y:scroll; 407 | } 408 | #cadastrar .close{ 409 | position:absolute; 410 | top:10px; 411 | right:10px; 412 | line-height:30px; 413 | width:30px; 414 | text-align:center; 415 | color:#333; 416 | background:#f5f6f7; 417 | border:1px solid #ccc; 418 | border-radius:50%; 419 | } 420 | #cadastrar .close:hover{background:#fff; text-decoration:none;} 421 | #cadastrar p{ 422 | float:left; 423 | width:100%; 424 | margin-bottom:25px; 425 | font-size:16px; 426 | color:#666; 427 | } 428 | 429 | #cadastrar label{ 430 | float:left; 431 | width:100%; 432 | margin-bottom:15px; 433 | } 434 | 435 | #cadastrar label span{ 436 | float:left; 437 | width:100%; 438 | font-size:17px; 439 | color:#666; 440 | margin-bottom:10px; 441 | float:left; 442 | } 443 | #cadastrar label input, #cadastrar textarea{ 444 | float:left; 445 | width:100%; 446 | padding:10px; 447 | background:white; 448 | border:1px solid #ccc; 449 | outline:none; 450 | font-size:16px; 451 | color:#666; 452 | transition:all ease-in .3s; 453 | } 454 | #cadastrar label input:focus{border-color:#333;} 455 | #cadastrar textarea{ 456 | resize:vertical; 457 | } 458 | #cadastrar .retorno_cadastro{ 459 | float:left; 460 | width:100%; 461 | margin-bottom:10px; 462 | } 463 | .content_perfis{float:left; width:100%;} 464 | #logar_box{ 465 | width:500px; 466 | height:220px; 467 | padding:15px; 468 | background:#fff; 469 | display:inline-block; 470 | position:absolute; 471 | top:0; 472 | left:0; 473 | bottom:0; 474 | right:0; 475 | margin:auto; 476 | border-radius:6px; 477 | box-shadow:#666 1px 1px 6px; 478 | } 479 | #logar_box .retorno_log{ 480 | position:absolute; 481 | width:500px; 482 | left:0; 483 | top:-45px; 484 | height:40px; 485 | } 486 | #logar_box .cadastre-se{ 487 | position:absolute; 488 | bottom:-30px; 489 | width:100%; 490 | left:0; 491 | } 492 | 493 | #logar_box .cadastre-se p{float:left; width:100%;} 494 | #logar_box .cadastre-se p a{color:#333;} 495 | #logar_box label{ 496 | float:left; 497 | width:100%; 498 | margin-bottom:15px; 499 | } 500 | #logar_box label span{ 501 | font-size:16px; 502 | color:#666; 503 | float:left; 504 | width:100%; 505 | margin-bottom:10px; 506 | } 507 | #logar_box label input[type=text], #logar_box label input[type=password]{ 508 | padding:8px; 509 | float:left; 510 | width:100%; 511 | outline:none; 512 | border:1px solid #ccc; 513 | border-radius:6px; 514 | transition:all ease-in .3s; 515 | } 516 | #logar_box label input[type=text]:focus, #logar_box label input[type=password]:focus{ 517 | border-color:#069; 518 | } 519 | .btn_submit { 520 | float:right; 521 | padding:8px 10px; 522 | background:#333; 523 | color:white; 524 | border-radius:4px; 525 | border:0; 526 | font-size:17px; 527 | border-bottom:2px solid #000; 528 | } 529 | .btn_submit:hover{background:black; cursor:pointer;} -------------------------------------------------------------------------------- /inc/lib/WideImage.php: -------------------------------------------------------------------------------- 1 | 113 | * WideImage::registerCustomMapper('WideImage_Mapper_TGA', 'image/tga', 'tga'); 114 | * 115 | * 116 | * @param string $mapper_class_name 117 | * @param string $mime_type 118 | * @param string $extension 119 | */ 120 | static function registerCustomMapper($mapper_class_name, $mime_type, $extension) 121 | { 122 | WideImage_MapperFactory::registerMapper($mapper_class_name, $mime_type, strtoupper($extension)); 123 | } 124 | 125 | /** 126 | * Loads an image from a file, URL, HTML input file field, binary string, or a valid image handle. 127 | * The image format is auto-detected. 128 | * 129 | * Currently supported formats: PNG, GIF, JPG, BMP, TGA, GD, GD2. 130 | * 131 | * This function analyzes the input and decides whether to use WideImage::loadFromHandle(), 132 | * WideImage::loadFromFile(), WideImage::loadFromUpload() or WideImage::loadFromString(), 133 | * all of which you can also call directly to spare WideImage some guessing. 134 | * 135 | * Arrays are supported for upload fields; it returns an array of loaded images. 136 | * To load only a single image from an array field, use WideImage::loadFromUpload('img', $i), 137 | * where $i is the index of the image you want to load. 138 | * 139 | * 140 | * $img = WideImage::load('http://url/image.png'); // image URL 141 | * $img = WideImage::load('/path/to/image.png'); // local file path 142 | * $img = WideImage::load('img'); // upload field name 143 | * $img = WideImage::load(imagecreatetruecolor(10, 10)); // a GD resource 144 | * $img = WideImage::load($image_data); // binary string containing image data 145 | * 146 | * 147 | * @param mixed $source File name, url, HTML file input field name, binary string, or a GD image resource 148 | * @return WideImage_Image WideImage_PaletteImage or WideImage_TrueColorImage instance 149 | */ 150 | static function load($source) 151 | { 152 | $predictedSourceType = ''; 153 | 154 | if ($source == '') 155 | $predictedSourceType = 'String'; 156 | 157 | // Creating image via a valid resource 158 | if (!$predictedSourceType && self::isValidImageHandle($source)) 159 | $predictedSourceType = 'Handle'; 160 | 161 | // Check for binary string 162 | if (!$predictedSourceType) 163 | { 164 | // search first $binLength bytes (at a maximum) for ord<32 characters (binary image data) 165 | $binLength = 64; 166 | $sourceLength = strlen($source); 167 | $maxlen = ($sourceLength > $binLength) ? $binLength : $sourceLength; 168 | for ($i = 0; $i < $maxlen; $i++) 169 | if (ord($source[$i]) < 32) 170 | { 171 | $predictedSourceType = 'String'; 172 | break; 173 | } 174 | } 175 | 176 | // Uploaded image (array uploads not supported) 177 | if (isset($_FILES[$source]) && isset($_FILES[$source]['tmp_name'])) 178 | $predictedSourceType = 'Upload'; 179 | 180 | // Otherwise, must be a file or an URL 181 | if (!$predictedSourceType) 182 | $predictedSourceType = 'File'; 183 | 184 | return call_user_func(array('WideImage', 'loadFrom' . $predictedSourceType), $source); 185 | } 186 | 187 | /** 188 | * Create and load an image from a file or URL. The image format is auto-detected. 189 | * 190 | * @param string $uri File or url 191 | * @return WideImage_Image WideImage_PaletteImage or WideImage_TrueColorImage instance 192 | */ 193 | static function loadFromFile($uri) 194 | { 195 | $data = file_get_contents($uri); 196 | $handle = @imagecreatefromstring($data); 197 | if (!self::isValidImageHandle($handle)) 198 | { 199 | try 200 | { 201 | // try to find a mapper first 202 | $mapper = WideImage_MapperFactory::selectMapper($uri); 203 | if ($mapper) 204 | $handle = $mapper->load($uri); 205 | } 206 | catch (WideImage_UnsupportedFormatException $e) 207 | { 208 | // mapper not found 209 | } 210 | 211 | // try all custom mappers 212 | if (!self::isValidImageHandle($handle)) 213 | { 214 | $custom_mappers = WideImage_MapperFactory::getCustomMappers(); 215 | foreach ($custom_mappers as $mime_type => $mapper_class) 216 | { 217 | $mapper = WideImage_MapperFactory::selectMapper(null, $mime_type); 218 | $handle = $mapper->loadFromString($data); 219 | if (self::isValidImageHandle($handle)) 220 | break; 221 | } 222 | } 223 | } 224 | 225 | if (!self::isValidImageHandle($handle)) 226 | throw new WideImage_InvalidImageSourceException("File '{$uri}' appears to be an invalid image source."); 227 | 228 | return self::loadFromHandle($handle); 229 | } 230 | 231 | /** 232 | * Create and load an image from a string. Format is auto-detected. 233 | * 234 | * @param string $string Binary data, i.e. from BLOB field in the database 235 | * @return WideImage_Image WideImage_PaletteImage or WideImage_TrueColorImage instance 236 | */ 237 | static function loadFromString($string) 238 | { 239 | if (strlen($string) < 128) 240 | throw new WideImage_InvalidImageSourceException("String doesn't contain image data."); 241 | 242 | $handle = @imagecreatefromstring($string); 243 | if (!self::isValidImageHandle($handle)) 244 | { 245 | $custom_mappers = WideImage_MapperFactory::getCustomMappers(); 246 | foreach ($custom_mappers as $mime_type => $mapper_class) 247 | { 248 | $mapper = WideImage_MapperFactory::selectMapper(null, $mime_type); 249 | $handle = $mapper->loadFromString($string); 250 | if (self::isValidImageHandle($handle)) 251 | break; 252 | } 253 | } 254 | 255 | if (!self::isValidImageHandle($handle)) 256 | throw new WideImage_InvalidImageSourceException("String doesn't contain valid image data."); 257 | 258 | return self::loadFromHandle($handle); 259 | } 260 | 261 | /** 262 | * Create and load an image from an image handle. 263 | * 264 | * Note: the resulting image object takes ownership of the passed 265 | * handle. When the newly-created image object is destroyed, the handle is 266 | * destroyed too, so it's not a valid image handle anymore. In order to 267 | * preserve the handle for use after object destruction, you have to call 268 | * WideImage_Image::releaseHandle() on the created image instance prior to its 269 | * destruction. 270 | * 271 | * 272 | * $handle = imagecreatefrompng('file.png'); 273 | * $image = WideImage::loadFromHandle($handle); 274 | * 275 | * 276 | * @param resource $handle A valid GD image resource 277 | * @return WideImage_Image WideImage_PaletteImage or WideImage_TrueColorImage instance 278 | */ 279 | static function loadFromHandle($handle) 280 | { 281 | if (!self::isValidImageHandle($handle)) 282 | throw new WideImage_InvalidImageSourceException("Handle is not a valid GD image resource."); 283 | 284 | if (imageistruecolor($handle)) 285 | return new WideImage_TrueColorImage($handle); 286 | else 287 | return new WideImage_PaletteImage($handle); 288 | } 289 | 290 | /** 291 | * This method loads a file from the $_FILES array. The image format is auto-detected. 292 | * 293 | * You only have to pass the field name as the parameter. For array fields, this function will 294 | * return an array of image objects, unless you specify the $index parameter, which will 295 | * load the desired image. 296 | * 297 | * @param $field_name Name of the key in $_FILES array 298 | * @param int $index The index of the file to load (if the input field is an array) 299 | * @return WideImage_Image The loaded image 300 | */ 301 | static function loadFromUpload($field_name, $index = null) 302 | { 303 | if (!array_key_exists($field_name, $_FILES)) 304 | throw new WideImage_InvalidImageSourceException("Upload field '{$field_name}' doesn't exist."); 305 | 306 | if (is_array($_FILES[$field_name]['tmp_name'])) 307 | { 308 | if (isset($_FILES[$field_name]['tmp_name'][$index])) 309 | $filename = $_FILES[$field_name]['tmp_name'][$index]; 310 | else 311 | { 312 | $result = array(); 313 | foreach ($_FILES[$field_name]['tmp_name'] as $idx => $tmp_name) 314 | $result[$idx] = self::loadFromFile($tmp_name); 315 | return $result; 316 | } 317 | } 318 | else 319 | $filename = $_FILES[$field_name]['tmp_name']; 320 | 321 | if (!file_exists($filename)) 322 | throw new WideImage_InvalidImageSourceException("Uploaded file doesn't exist."); 323 | return self::loadFromFile($filename); 324 | } 325 | 326 | /** 327 | * Factory method for creating a palette image 328 | * 329 | * @param int $width 330 | * @param int $height 331 | * @return WideImage_PaletteImage 332 | */ 333 | static function createPaletteImage($width, $height) 334 | { 335 | return WideImage_PaletteImage::create($width, $height); 336 | } 337 | 338 | /** 339 | * Factory method for creating a true-color image 340 | * 341 | * @param int $width 342 | * @param int $height 343 | * @return WideImage_TrueColorImage 344 | */ 345 | static function createTrueColorImage($width, $height) 346 | { 347 | return WideImage_TrueColorImage::create($width, $height); 348 | } 349 | 350 | /** 351 | * Check whether the given handle is a valid GD resource 352 | * 353 | * @param mixed $handle The variable to check 354 | * @return bool 355 | */ 356 | static function isValidImageHandle($handle) 357 | { 358 | return (is_resource($handle) && get_resource_type($handle) == 'gd'); 359 | } 360 | 361 | /** 362 | * Throws exception if the handle isn't a valid GD resource 363 | * 364 | * @param mixed $handle The variable to check 365 | */ 366 | static function assertValidImageHandle($handle) 367 | { 368 | if (!self::isValidImageHandle($handle)) 369 | throw new WideImage_InvalidImageHandleException("{$handle} is not a valid image handle."); 370 | } 371 | } 372 | 373 | WideImage::checkGD(); 374 | 375 | WideImage::registerCustomMapper('WideImage_Mapper_BMP', 'image/bmp', 'bmp'); 376 | WideImage::registerCustomMapper('WideImage_Mapper_TGA', 'image/tga', 'tga'); 377 | -------------------------------------------------------------------------------- /js/jcrop.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jquery.Jcrop.min.js v0.9.12 (build:20130202) 3 | * jQuery Image Cropping Plugin - released under MIT License 4 | * Copyright (c) 2008-2013 Tapmodo Interactive LLC 5 | * https://github.com/tapmodo/Jcrop 6 | */ 7 | (function(a){a.Jcrop=function(b,c){function i(a){return Math.round(a)+"px"}function j(a){return d.baseClass+"-"+a}function k(){return a.fx.step.hasOwnProperty("backgroundColor")}function l(b){var c=a(b).offset();return[c.left,c.top]}function m(a){return[a.pageX-e[0],a.pageY-e[1]]}function n(b){typeof b!="object"&&(b={}),d=a.extend(d,b),a.each(["onChange","onSelect","onRelease","onDblClick"],function(a,b){typeof d[b]!="function"&&(d[b]=function(){})})}function o(a,b,c){e=l(D),bc.setCursor(a==="move"?a:a+"-resize");if(a==="move")return bc.activateHandlers(q(b),v,c);var d=_.getFixed(),f=r(a),g=_.getCorner(r(f));_.setPressed(_.getCorner(f)),_.setCurrent(g),bc.activateHandlers(p(a,d),v,c)}function p(a,b){return function(c){if(!d.aspectRatio)switch(a){case"e":c[1]=b.y2;break;case"w":c[1]=b.y2;break;case"n":c[0]=b.x2;break;case"s":c[0]=b.x2}else switch(a){case"e":c[1]=b.y+1;break;case"w":c[1]=b.y+1;break;case"n":c[0]=b.x+1;break;case"s":c[0]=b.x+1}_.setCurrent(c),bb.update()}}function q(a){var b=a;return bd.watchKeys 8 | (),function(a){_.moveOffset([a[0]-b[0],a[1]-b[1]]),b=a,bb.update()}}function r(a){switch(a){case"n":return"sw";case"s":return"nw";case"e":return"nw";case"w":return"ne";case"ne":return"sw";case"nw":return"se";case"se":return"nw";case"sw":return"ne"}}function s(a){return function(b){return d.disabled?!1:a==="move"&&!d.allowMove?!1:(e=l(D),W=!0,o(a,m(b)),b.stopPropagation(),b.preventDefault(),!1)}}function t(a,b,c){var d=a.width(),e=a.height();d>b&&b>0&&(d=b,e=b/a.width()*a.height()),e>c&&c>0&&(e=c,d=c/a.height()*a.width()),T=a.width()/d,U=a.height()/e,a.width(d).height(e)}function u(a){return{x:a.x*T,y:a.y*U,x2:a.x2*T,y2:a.y2*U,w:a.w*T,h:a.h*U}}function v(a){var b=_.getFixed();b.w>d.minSelect[0]&&b.h>d.minSelect[1]?(bb.enableHandles(),bb.done()):bb.release(),bc.setCursor(d.allowSelect?"crosshair":"default")}function w(a){if(d.disabled)return!1;if(!d.allowSelect)return!1;W=!0,e=l(D),bb.disableHandles(),bc.setCursor("crosshair");var b=m(a);return _.setPressed(b),bb.update(),bc.activateHandlers(x,v,a.type.substring 9 | (0,5)==="touch"),bd.watchKeys(),a.stopPropagation(),a.preventDefault(),!1}function x(a){_.setCurrent(a),bb.update()}function y(){var b=a("
").addClass(j("tracker"));return g&&b.css({opacity:0,backgroundColor:"white"}),b}function be(a){G.removeClass().addClass(j("holder")).addClass(a)}function bf(a,b){function t(){window.setTimeout(u,l)}var c=a[0]/T,e=a[1]/U,f=a[2]/T,g=a[3]/U;if(X)return;var h=_.flipCoords(c,e,f,g),i=_.getFixed(),j=[i.x,i.y,i.x2,i.y2],k=j,l=d.animationDelay,m=h[0]-j[0],n=h[1]-j[1],o=h[2]-j[2],p=h[3]-j[3],q=0,r=d.swingSpeed;c=k[0],e=k[1],f=k[2],g=k[3],bb.animMode(!0);var s,u=function(){return function(){q+=(100-q)/r,k[0]=Math.round(c+q/100*m),k[1]=Math.round(e+q/100*n),k[2]=Math.round(f+q/100*o),k[3]=Math.round(g+q/100*p),q>=99.8&&(q=100),q<100?(bh(k),t()):(bb.done(),bb.animMode(!1),typeof b=="function"&&b.call(bs))}}();t()}function bg(a){bh([a[0]/T,a[1]/U,a[2]/T,a[3]/U]),d.onSelect.call(bs,u(_.getFixed())),bb.enableHandles()}function bh(a){_.setPressed([a[0],a[1]]),_.setCurrent([a[2], 10 | a[3]]),bb.update()}function bi(){return u(_.getFixed())}function bj(){return _.getFixed()}function bk(a){n(a),br()}function bl(){d.disabled=!0,bb.disableHandles(),bb.setCursor("default"),bc.setCursor("default")}function bm(){d.disabled=!1,br()}function bn(){bb.done(),bc.activateHandlers(null,null)}function bo(){G.remove(),A.show(),A.css("visibility","visible"),a(b).removeData("Jcrop")}function bp(a,b){bb.release(),bl();var c=new Image;c.onload=function(){var e=c.width,f=c.height,g=d.boxWidth,h=d.boxHeight;D.width(e).height(f),D.attr("src",a),H.attr("src",a),t(D,g,h),E=D.width(),F=D.height(),H.width(E).height(F),M.width(E+L*2).height(F+L*2),G.width(E).height(F),ba.resize(E,F),bm(),typeof b=="function"&&b.call(bs)},c.src=a}function bq(a,b,c){var e=b||d.bgColor;d.bgFade&&k()&&d.fadeTime&&!c?a.animate({backgroundColor:e},{queue:!1,duration:d.fadeTime}):a.css("backgroundColor",e)}function br(a){d.allowResize?a?bb.enableOnly():bb.enableHandles():bb.disableHandles(),bc.setCursor(d.allowSelect?"crosshair":"default"),bb 11 | .setCursor(d.allowMove?"move":"default"),d.hasOwnProperty("trueSize")&&(T=d.trueSize[0]/E,U=d.trueSize[1]/F),d.hasOwnProperty("setSelect")&&(bg(d.setSelect),bb.done(),delete d.setSelect),ba.refresh(),d.bgColor!=N&&(bq(d.shade?ba.getShades():G,d.shade?d.shadeColor||d.bgColor:d.bgColor),N=d.bgColor),O!=d.bgOpacity&&(O=d.bgOpacity,d.shade?ba.refresh():bb.setBgOpacity(O)),P=d.maxSize[0]||0,Q=d.maxSize[1]||0,R=d.minSize[0]||0,S=d.minSize[1]||0,d.hasOwnProperty("outerImage")&&(D.attr("src",d.outerImage),delete d.outerImage),bb.refresh()}var d=a.extend({},a.Jcrop.defaults),e,f=navigator.userAgent.toLowerCase(),g=/msie/.test(f),h=/msie [1-6]\./.test(f);typeof b!="object"&&(b=a(b)[0]),typeof c!="object"&&(c={}),n(c);var z={border:"none",visibility:"visible",margin:0,padding:0,position:"absolute",top:0,left:0},A=a(b),B=!0;if(b.tagName=="IMG"){if(A[0].width!=0&&A[0].height!=0)A.width(A[0].width),A.height(A[0].height);else{var C=new Image;C.src=A[0].src,A.width(C.width),A.height(C.height)}var D=A.clone().removeAttr("id"). 12 | css(z).show();D.width(A.width()),D.height(A.height()),A.after(D).hide()}else D=A.css(z).show(),B=!1,d.shade===null&&(d.shade=!0);t(D,d.boxWidth,d.boxHeight);var E=D.width(),F=D.height(),G=a("
").width(E).height(F).addClass(j("holder")).css({position:"relative",backgroundColor:d.bgColor}).insertAfter(A).append(D);d.addClass&&G.addClass(d.addClass);var H=a("
"),I=a("
").width("100%").height("100%").css({zIndex:310,position:"absolute",overflow:"hidden"}),J=a("
").width("100%").height("100%").css("zIndex",320),K=a("
").css({position:"absolute",zIndex:600}).dblclick(function(){var a=_.getFixed();d.onDblClick.call(bs,a)}).insertBefore(D).append(I,J);B&&(H=a("").attr("src",D.attr("src")).css(z).width(E).height(F),I.append(H)),h&&K.css({overflowY:"hidden"});var L=d.boundary,M=y().width(E+L*2).height(F+L*2).css({position:"absolute",top:i(-L),left:i(-L),zIndex:290}).mousedown(w),N=d.bgColor,O=d.bgOpacity,P,Q,R,S,T,U,V=!0,W,X,Y;e=l(D);var Z=function(){function a(){var a={},b=["touchstart" 13 | ,"touchmove","touchend"],c=document.createElement("div"),d;try{for(d=0;da+f&&(f-=f+a),0>b+g&&(g-=g+b),FE&&(r=E,u=Math.abs((r-a)/f),s=k<0?b-u:u+b)):(r=c,u=l/f,s=k<0?b-u:b+u,s<0?(s=0,t=Math.abs((s-b)*f),r=j<0?a-t:t+a):s>F&&(s=F,t=Math.abs(s-b)*f,r=j<0?a-t:t+a)),r>a?(r-ah&&(r=a+h),s>b?s=b+(r-a)/f:s=b-(r-a)/f):rh&&(r=a-h),s>b?s=b+(a-r)/f:s=b-(a-r)/f),r<0?(a-=r,r=0):r>E&&(a-=r-E,r=E),s<0?(b-=s,s=0):s>F&&(b-=s-F,s=F),q(o(a,b,r,s))}function n(a){return a[0]<0&&(a[0]=0),a[1]<0&&(a[1]=0),a[0]>E&&(a[0]=E),a[1]>F&&(a[1]=F),[Math.round(a[0]),Math.round(a[1])]}function o(a,b,c,d){var e=a,f=c,g=b,h=d;return cP&&(c=d>0?a+P:a-P),Q&&Math.abs 15 | (f)>Q&&(e=f>0?b+Q:b-Q),S/U&&Math.abs(f)0?b+S/U:b-S/U),R/T&&Math.abs(d)0?a+R/T:a-R/T),a<0&&(c-=a,a-=a),b<0&&(e-=b,b-=b),c<0&&(a-=c,c-=c),e<0&&(b-=e,e-=e),c>E&&(g=c-E,a-=g,c-=g),e>F&&(g=e-F,b-=g,e-=g),a>E&&(g=a-F,e-=g,b-=g),b>F&&(g=b-F,e-=g,b-=g),q(o(a,b,c,e))}function q(a){return{x:a[0],y:a[1],x2:a[2],y2:a[3],w:a[2]-a[0],h:a[3]-a[1]}}var a=0,b=0,c=0,e=0,f,g;return{flipCoords:o,setPressed:h,setCurrent:i,getOffset:j,moveOffset:k,getCorner:l,getFixed:m}}(),ba=function(){function f(a,b){e.left.css({height:i(b)}),e.right.css({height:i(b)})}function g(){return h(_.getFixed())}function h(a){e.top.css({left:i(a.x),width:i(a.w),height:i(a.y)}),e.bottom.css({top:i(a.y2),left:i(a.x),width:i(a.w),height:i(F-a.y2)}),e.right.css({left:i(a.x2),width:i(E-a.x2)}),e.left.css({width:i(a.x)})}function j(){return a("
").css({position:"absolute",backgroundColor:d.shadeColor||d.bgColor}).appendTo(c)}function k(){b||(b=!0,c.insertBefore(D),g(),bb.setBgOpacity(1,0,1),H.hide(),l(d.shadeColor||d.bgColor,1),bb. 16 | isAwake()?n(d.bgOpacity,1):n(1,1))}function l(a,b){bq(p(),a,b)}function m(){b&&(c.remove(),H.show(),b=!1,bb.isAwake()?bb.setBgOpacity(d.bgOpacity,1,1):(bb.setBgOpacity(1,1,1),bb.disableHandles()),bq(G,0,1))}function n(a,e){b&&(d.bgFade&&!e?c.animate({opacity:1-a},{queue:!1,duration:d.fadeTime}):c.css({opacity:1-a}))}function o(){d.shade?k():m(),bb.isAwake()&&n(d.bgOpacity)}function p(){return c.children()}var b=!1,c=a("
").css({position:"absolute",zIndex:240,opacity:0}),e={top:j(),left:j().height(F),right:j().height(F),bottom:j()};return{update:g,updateRaw:h,getShades:p,setBgColor:l,enable:k,disable:m,resize:f,refresh:o,opacity:n}}(),bb=function(){function k(b){var c=a("
").css({position:"absolute",opacity:d.borderOpacity}).addClass(j(b));return I.append(c),c}function l(b,c){var d=a("
").mousedown(s(b)).css({cursor:b+"-resize",position:"absolute",zIndex:c}).addClass("ord-"+b);return Z.support&&d.bind("touchstart.jcrop",Z.createDragger(b)),J.append(d),d}function m(a){var b=d.handleSize,e=l(a,c++ 17 | ).css({opacity:d.handleOpacity}).addClass(j("handle"));return b&&e.width(b).height(b),e}function n(a){return l(a,c++).addClass("jcrop-dragbar")}function o(a){var b;for(b=0;b').css({position:"fixed",left:"-120px",width:"12px"}).addClass("jcrop-keymgr"),c=a("
").css({position:"absolute",overflow:"hidden"}).append(b);return d.keySupport&&(b.keydown(i).blur(f),h||!d.fixedSupport?(b.css({position:"absolute",left:"-20px"}),c.append(b).insertBefore(D)):b.insertBefore(D)),{watchKeys:e}}();Z.support&&M.bind("touchstart.jcrop",Z.newSelection),J.hide(),br(!0);var bs={setImage:bp,animateTo:bf,setSelect:bg,setOptions:bk,tellSelect:bi,tellScaled:bj,setClass:be,disable:bl,enable:bm,cancel:bn,release:bb.release,destroy:bo,focus:bd.watchKeys,getBounds:function(){return[E*T,F*U]},getWidgetSize:function(){return[E,F]},getScaleFactor:function(){return[T,U]},getOptions:function(){return d},ui:{holder:G,selection:K}};return g&&G.bind("selectstart",function(){return!1}),A.data("Jcrop",bs),bs},a.fn.Jcrop=function(b,c){var d;return this.each(function(){if(a(this).data("Jcrop")){if( 21 | b==="api")return a(this).data("Jcrop");a(this).data("Jcrop").setOptions(b)}else this.tagName=="IMG"?a.Jcrop.Loader(this,function(){a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d)}):(a(this).css({display:"block",visibility:"hidden"}),d=a.Jcrop(this,b),a.isFunction(c)&&c.call(d))}),this},a.Jcrop.Loader=function(b,c,d){function g(){f.complete?(e.unbind(".jcloader"),a.isFunction(c)&&c.call(f)):window.setTimeout(g,50)}var e=a(b),f=e[0];e.bind("load.jcloader",g).bind("error.jcloader",function(b){e.unbind(".jcloader"),a.isFunction(d)&&d.call(f)}),f.complete&&a.isFunction(c)&&(e.unbind(".jcloader"),c.call(f))},a.Jcrop.defaults={allowSelect:!0,allowMove:!0,allowResize:!0,trackDocument:!0,baseClass:"jcrop",addClass:null,bgColor:"black",bgOpacity:.6,bgFade:!1,borderOpacity:.4,handleOpacity:.5,handleSize:null,aspectRatio:0,keySupport:!0,createHandles:["n","s","e","w","nw","ne","se","sw"],createDragbars:["n","s","e","w"],createBorders:["n","s","e","w"],drawBorders:!0,dragEdges 22 | :!0,fixedSupport:!0,touchSupport:null,shade:null,boxWidth:0,boxHeight:0,boundary:2,fadeTime:400,animationDelay:20,swingSpeed:3,minSelect:[0,0],maxSize:[0,0],minSize:[0,0],onChange:function(){},onSelect:function(){},onDblClick:function(){},onRelease:function(){}}})(jQuery); --------------------------------------------------------------------------------