Beispiel #1
0
function insides($start, $end = "", $source = false)
{
    if ($source === false) {
        global $http_html;
        $source =& $http_html;
    }
    // Use set_source() default
    $r = array();
    $s = 0;
    if (is_array($source)) {
        foreach ($source as $line) {
            if ($start and $end) {
                array_push($r, insides($start, $end, $line));
            } else {
                $i = inside($start, $end, $line);
                if ($i) {
                    $r[] = $i;
                }
            }
        }
        re($r);
        return $r;
    }
    while (($s = strpos($source, $start, $s)) !== false) {
        $s += strlen($start);
        $e = strpos($source, $end, $s);
        if ($e !== false) {
            $r[] = trim(substr($source, $s, $e - $s));
            $s = $e + strlen($end);
        }
    }
    re($r);
    return $r;
}
Beispiel #2
0
         echo '</strong></p>';
     }
 }
 if ($tempo) {
     echo '
 <ul class="links">';
     if ($scuola == $result["scuola"] && !confronto($occupato, $result["quando"])) {
         echo '
     <li><a ';
         if (modo()) {
             echo 'id="iscriviti"';
         } else {
             echo 'href="' . $dati['info']['root'] . 'corsi/' . $result["id"] . '"';
         }
         echo ' class="btn btn-success"><i class="fa fa-check"></i> ';
         if (inside($interessato, $result["id"])) {
             echo 'Riabilita iscrizione';
         } else {
             echo 'Iscriviti';
         }
         echo '</a></li>';
     }
     if (isAdminUserAutenticate()) {
         echo '
     <li><a ';
         if (modo()) {
             echo 'id="stato"';
         } else {
             echo 'href="' . $dati['info']['root'] . 'stato/' . $result["id"] . '"';
         }
         echo ' class="btn btn-warning"><i class="fa fa-eye-slash"></i> Blocca</a></li>';
Beispiel #3
0
             <span class="hidden" id="value">' . $result["id"] . '</span>
             <blockquote>
                 ' . stripcslashes($result["descrizione"]) . '
                 <footer>';
 $prof = ricerca($profs, $result["prof"]);
 $utente = ricerca($utenti, $result["creatore"]);
 if ($prof != -1) {
     echo $profs[$prof]["nome"];
 }
 if ($utente != -1) {
     echo ', inserito da <cite title="' . $utenti[$utente]["nome"] . '">' . $utenti[$utente]["nome"] . '</cite>';
 }
 echo '</footer>
             </blockquote>
             <ul class="links">';
 if (!inside($iscrizioni, $result["id"])) {
     echo '
                 <li><a ';
     if (modo()) {
         echo 'id="like"';
     } else {
         echo 'href="' . $dati['info']['root'] . 'citazioni/' . $result["id"] . '"';
     }
     echo ' class="btn btn-success"><span id="text"><i class="fa fa-thumbs-o-up"></i></span> <span id="cont">' . $cont . '</span></a></li>';
 } else {
     echo '
                 <li><a ';
     if (modo()) {
         echo 'id="like"';
     } else {
         echo 'href="' . $dati['info']['root'] . 'citazioni/' . $result["id"] . '"';
Beispiel #4
0
<?php

// Sample TASK: get past-2015 movies from IMDB Top 250 and write to MySQL DB. Take cover images as well
// ----------------------------------------------------------------------------------------------------
require '../parsemx.php';
begin_debug();
// By default, localhost root/root MySQL user is used. Set $q_server, $q_user, $q_password to override
$q_database = 'imdb_sample';
q("CREATE TABLE IF NOT EXISTS films (title VARCHAR(250), year SMALLINT, cover VARCHAR(250))");
$http_cache = true;
http_get('http://www.imdb.com/chart/top/');
foreach (tags_html('.titleColumn') as $film) {
    set_source($film);
    $year = inside('(', ')', tag_text('.secondaryInfo'));
    if ($year < 2015) {
        continue;
    }
    http_get(tag_link('a'));
    // Open film link
    $title = q_escape(replace('(*)', '', tag_text('h1')));
    // Take title and remove year like (2015) from it
    if (q("SELECT * FROM films WHERE title={$title}")) {
        continue;
    }
    // If film already in DB, skip
    http_get(tag_link('.poster'));
    // Open poster link
    $cover = q_escape(http_get_file(tag_image('#primary-img'), 'covers/'));
    // Download primary image from slideshow
    q("INSERT INTO films SET title={$title}, year={$year}, cover={$cover}");
}
Beispiel #5
0
         echo '">
 <div class="container">
 <h1>Aule studio non frequentabili</h1>
 <p>Aule studio non frequentabili a causa dell\'iscrizione ad altri corsi nello stesso orario o per data passata...</p>
     <table class="table datatable table-borderless">
         <thead>
             <tr><th>Nome</th></tr>
         </thead>
         <tbody>';
         if ($results != null) {
             foreach ($results as $key => $result) {
                 $cont = 0;
                 if ($result["id"] - $numero[0] >= 0 && $numero[1] - $result["id"] >= 0 && $numero[2][$result["id"] - $numero[0]] != "") {
                     $cont = $numero[2][$result["id"] - $numero[0]];
                 }
                 if ($result["stato"] == 0 && (!inside($iscrizioni, $result["id"]) && $cont >= $result["max"] || strtotime($result["data"]) > strtotime("now"))) {
                     echo '
             <tr>
                 <td>
                     <div class="jumbo">
                         <h3><a href="' . $dati['info']['root'] . 'aula/' . $result["id"] . '">' . $result["nome"] . '</a></h3>';
                     if (isAdminUserAutenticate()) {
                         echo '
                         <a href="' . $dati['info']['root'] . 'cambia/aula/' . $result["id"] . '" class="label orange pull-right"><i class="fa fa-close"></i></a>';
                     }
                     echo '
                         <p><strong>Durata: ' . $result["quanto"] . ' ore</strong></p>
                         <p>Luogo: ' . $result["dove"] . '</p>
                         <div class="level">
                             <strong class="level-title">Iscritti<span class="text-green pull-right">' . $cont . '/' . $result["max"] . '</span></strong>
                             <div class="progress">
<?php

namespace Business;

class Document extends File
{
}
class MyDocuments extends Directory
{
}
/** ------------------------------------------------------------------------- */
use Business\Document;
use Business\MyDocuments;
use FileSystem\FileSystem;
when('i want to write a new document', then(apply(a(function (FileSystem $fileSystem, MyDocuments $myDocuments, Document $document) {
    $fileSystem->write($document, inside($myDocuments));
}))));