Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions app/aluno/facebook/.bash_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ls
df -Th
l
sl -ls
ls -la
pwd
cd ..
ls
ls -la
rm saldo.php
ls -la
ls
pwd
ls
ls -la
cd ../
ls
cd ..
ls
cd ..
ls
cd ..
ls
cd ..
ls
cd ..
ls
cd
ls
cd -
cd ..
ls
cd home/
ls
cd wanderson/
ls
ls -la
cd /etc/
ls
cat at.deny
ls
ls -la
cd ..
ls
cd home/
ls
cd /home/
ls
cd ..
ls
cd /var/www/
ls
cd demo
ls
cd app
ls
cd alu
cd aluno
ls
cd vi
cd victor
ls
ls -la
id
who
7 changes: 7 additions & 0 deletions app/aluno/facebook/.bash_logout
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# ~/.bash_logout: executed by bash(1) when login shell exits.

# when leaving the console clear the screen to increase privacy

if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi
99 changes: 99 additions & 0 deletions app/aluno/facebook/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
Empty file.
24 changes: 24 additions & 0 deletions app/aluno/facebook/.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

umask 022
49 changes: 49 additions & 0 deletions app/aluno/facebook/AppInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* This class provides static methods that return pieces of data specific to
* your app
*/
class AppInfo {

/*****************************************************************************
*
* These functions provide the unique identifiers that your app users. These
* have been pre-populated for you, but you may need to change them at some
* point. They are currently being stored in 'Environment Variables'. To
* learn more about these, visit
* 'http://php.net/manual/en/function.getenv.php'
*
****************************************************************************/

/**
* @return the appID for this app
*/
public static function appID() {
return getenv('FACEBOOK_APP_ID');
}

/**
* @return the appSecret for this app
*/
public static function appSecret() {
return getenv('FACEBOOK_SECRET');
}

/**
* @return the url
*/
public static function getUrl($path = '/') {
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
|| isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
) {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}

return $protocol . $_SERVER['HTTP_HOST'] . $path;
}

}
141 changes: 141 additions & 0 deletions app/aluno/facebook/alert_facers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php
/*-------------------------------Todas as mudan�as neste documento foram realizadas pelo aluno Victor Ulisses Pugliese----------------------*/
//viktao@msn.com || (12)81071139
//Este arquivo envia as famosas requisi��es do facebook para os usu�rios do CIAWEB, cujo acesso esteja desatualizado ou apenas para informar a
//atualiza��o de uma not�cia.

//chama a classe de conex�o do facebook sdk;
require "src/facebook.php";
//instacia as vari�veis que identificam a app;
$AppID = "338115866266320";
$AppSecret = "3aeab59509c17ef4dfa32bf87a585211";
$facebook = new Facebook( array( "appId" => $AppID, "secret" => $AppSecret ) );

//Instancia a conexao com o banco de dados postgres
$str_conexao="host=localhost port=5432 user=ciaweb_demo_user password=aMwygpeGStWzuKxsTBIdEkl2Xq1f4r dbname=ciaweb_demo"; //Conex�o ao Demo
//$str_conexao="host=localhost port=5432 user=postgres password=1234 dbname=ciaweb_24042012"; //Conex�o no meu micro;
$conexao=pg_connect($str_conexao);

$today = date('d/m/Y');

$msg_erros_possiveis = "\n----------------Hist�rico do dia : $today-------------- \n";

//Verifica se a conex�o obteve sucesso ou n�o;
if (!$conexao){
echo "Houve erro ao conectar ao banco" . pg_last_error();
echo "<br><br>Informe a mensagem acima ao suporte pelo fone 9999 ou pelo e-mail suporte@suporte.com.br <br>" . $conexao;
$msg_erros_possiveis .= 'Houve erro ao conectar ao banco:' . pg_last_error() . '\n';
}
else
{
$msg_erros_possiveis .= 'Conex�o com o banco de dados efetuada com sucesso!';
//Sql para captura dos facebook ids e dias que se passaram desde o �ltimo acesso do usu�rio ao programa;
$sql_getFacebookIds =
'SELECT distinct(aa.facebook_id), age(aa.ultimo_acesso)
FROM matricula m, acesso_aluno as aa inner join diario_notas as dn on aa.ref_pessoa = dn.id_ref_pessoas
inner join periodos p on dn.id_ref_periodos = p.id
WHERE facebook_id IS NOT NULL AND m.ref_motivo_matricula=0';
$result = pg_query($sql_getFacebookIds);
//Verifica se houve erros durante a consulta;
if(!$result)
{
$msg_erros_possiveis .= 'Ocorreu um erro na consulta sql:\n
SELECT distinct(aa.facebook_id), age(aa.ultimo_acesso)\n
FROM matricula m, acesso_aluno as aa inner join diario_notas as dn on aa.ref_pessoa = dn.id_ref_pessoas\n
inner join periodos p on dn.id_ref_periodos = p.id\n
WHERE facebook_id IS NOT NULL AND m.ref_motivo_matricula=0\n';
}
else
{
$msg_erros_possiveis .= 'Consulta sql para captura de facebook ids e dias que se passaram desde o �ltimo acesso executada com sucesso!\n';
//Verifica se ela retornou mais de uma linha;
if(count($result) > 0)
{
//Varre a tabela retornada da consulta;
while ($row = pg_fetch_array($result)) {
$split = array();
//Separa a string com o resultado do tempo j� passado desde o �ltimo acesso ao boletim
$split = explode(' ',$row[1]);
//Se o vetor com o resultado do tempo tiver mais de duas posi��es significa que ele possui algo al�m do (<n�mero de dias> days)...
if(count($split) > 2)
{
//Logo obrigatoriamente j� se passaram mais que 15 dias e ele envia um alerta para o aluno;
$Log = $facebook->api( $row[0] . '/apprequests', 'POST',
array('message' => "$today : Aten&ccedil&atildeo j&aacute faz mais de 15 dias
que voce n&atildeo consulta o CIAWEB, por favor entre e verifique se houve alguma
mudan&ccedila em seu boletim!") );
}
else
{
//Quando n�o, ele verifica se a primeira posi��o que � referente apenas aos dias que se passaram � maior que 15.
if($split[0] > 15)
{
//Se sim, ele envia o alerta.
$Log = $facebook->api( $row[0] . '/apprequests', 'POST',
array('message' => "$today : Aten&ccedil&atildeo j&aacute faz mais de 15 dias
que voce n&atildeo consulta o CIAWEB, por favor entre e verifique se houve alguma
mudan&ccedila em seu boletim!") );
}
}
}
}
}
//Sql para capturar todos os usu�rios do facebook
$sql_getFacebookIds = 'SELECT distinct(facebook_id) FROM acesso_aluno WHERE facebook_id IS NOT NULL;';
$result = pg_query($sql_getFacebookIds);
//Verifica se houve erro na consulta;
if(!$result)
{
$msg_erros_possiveis .= 'Ocorreu um erro na consulta sql:\n
SELECT distinct(facebook_id) FROM acesso_aluno WHERE facebook_id IS NOT NULL;\n';
}
else
{
if(count($result) > 0)
{
$msg_erros_possiveis .= 'Consulta sql para capturar todos os usu�rios do facebook executada com sucesso!\n';
//Se n�o, varre a tabela atr�s dos valores retornados
while ($row = pg_fetch_array($result)) {
//Le o feed de not�cias do ifsp;
$feed = 'http://www.ifspcaraguatatuba.edu.br/feed/';
foreach ( simplexml_load_file($feed)->channel->item as $item ){
//Sql para verificar se o feed j� foi cadastrado no banco de dados;
$sql_getNews =
"SELECT id FROM avisos where id = 2 and descricao='$item->link'";
$res = pg_query($sql_getNews);
if(count($res) > 0)
{
$msg_erros_possiveis .= 'Consulta sql para verificar se o feed j� foi cadastrado no banco de dados executada com sucesso!\n';
if($r[0] == "")
{
//Se n�o foi, ele envia uma msg para todos os usu�rios cadastrados na base de dados;
$Log = $facebook->api( $row[0] . '/apprequests', 'POST',
array('message' => "$today : Aten&ccedil&atildeo nova not&iacutecia no IFSP Caraguatatuba, veja: <a href='$item->link'>". $item->title ."</a>") );
pg_query("UPDATE avisos SET descricao = '$item->link', data = '$item->pubDate' WHERE id = 2;");
}
break;
}
else
{
$msg_erros_possiveis .= 'Ocorreu um erro na consulta sql:\n
SELECT id FROM avisos where id = 2 and descricao=' . $item->link;
break;
}
}
}
}
}
}
pg_close($str_conexao);

//Salva as informa��es no hist�rico da app;
$nome_arquivo = 'historico.txt';

if ($fp = fopen($nome_arquivo,'a') ) {
fwrite($fp, $msg_erros_possiveis);
fclose($fp);
}
//Atualiza a cada 24horas a p�gina;
echo '<meta http-equiv="refresh" content="' . 60*60*24 . ';url=?http:ciaweb.ifspcaraguatatuba.edu.br/demo/app/aluno/facebook/alert_facers.php" />';

?>
1 change: 1 addition & 0 deletions app/aluno/facebook/channel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script src="//connect.facebook.net/en_US/all.js"></script>
Loading