Exemple #1
0
 public function insereFeeds($idUser)
 {
     $add_feed1 = new Crud();
     $add_feed1->setTabela('feeds');
     $add_feed1->inserir(array("nome" => "Terra - Tecnologia", "url" => "http://rss.terra.com.br/0,,EI12879,00.xml", "publico" => 1, "id_user" => $idUser));
     $add_feed2 = new Crud();
     $add_feed2->setTabela('feeds');
     $add_feed2->inserir(array("nome" => "BBC News - Latin America", "url" => "http://feeds.bbci.co.uk/news/world/latin_america/rss.xml", "publico" => 1, "id_user" => $idUser));
     $add_feed3 = new Crud();
     $add_feed3->setTabela('feeds');
     $add_feed3->inserir(array("nome" => "Folha Vitória - Entretenimento", "url" => "http://www.folhavitoria.com.br/feed/entretenimento", "publico" => 1, "id_user" => $idUser));
 }
Exemple #2
0
function add_feed()
{
    $app = Slim::getInstance();
    $count_erro = 0;
    $erro_url = 0;
    if (!$_POST['nome']) {
        $count_erro += 1;
    } elseif (!$_POST['url']) {
        $count_erro += 1;
    } elseif (!preg_match('|^http(s)?://[a-z0-9-]+(\\.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $_POST['url'])) {
        $erro_url = 1;
    }
    if ($count_erro > 0) {
        $app->flash('errors', 'Os campos <strong>NOME</strong> e <strong>URL</strong> são obrigatórios!');
        $app->redirect(URL_BASE . '/');
        exit;
    } elseif ($erro_url == 1) {
        $app->flash('errors', 'O campo <strong>URL</strong> deve ser um URL válido. (o prefixo http:// é obrigatório)!');
        $app->redirect(URL_BASE . '/');
        exit;
    }
    $nome = $_POST['nome'];
    $url = $_POST['url'];
    $user = $app->view()->getData('user');
    if (isset($_POST['publico'])) {
        $publico = 1;
    } else {
        $publico = 0;
    }
    $add_feed = new Crud();
    $add_feed->setTabela('feeds');
    $a_f = $add_feed->inserir(array("nome" => $nome, "url" => $url, "publico" => $publico, "id_user" => $user['id']));
    if ($a_f) {
        $app->flash('sucesso', 'Feed Adicionado com Sucesso');
        $app->redirect(URL_BASE . '/');
    } else {
        $app->flash('errors', 'O Feed não pode ser adicionado');
        $app->redirect(URL_BASE . '/');
    }
}