Ejemplo n.º 1
0
/**
 * Smarty {counter} function plugin
 * Type:     function<br>
 * Name:     counter<br>
 * Purpose:  print out a counter value
 *
 * @author Monte Ohrt <monte at ohrt dot com>
 * @link   http://www.smarty.net/manual/en/language.function.counter.php {counter}
 *         (Smarty online manual)
 *
 * @param array                    $params   parameters
 * @param Smarty_Internal_Template $template template object
 *
 * @return string|null
 */
function smarty_function_seourl($params, $template)
{
    $str = strip_tags($params['str']);
    $str = str_truncate($str, 50);
    $str = preg_replace("/[,\\s]/", "-", $str);
    $str = preg_replace("/[^-\\w]/", "", $str);
    $str = preg_replace('/[-]{2,}/', '-', $str);
    $str = preg_replace('/[^\\w]$/', '', $str);
    if ($str == "") {
        $str = "reviews";
    }
    return $str;
}
Ejemplo n.º 2
0
assert("str_strip_prefix('foobar', '') === 'foobar'");
assert("str_strip_prefix('a', 'a') === ''");
assert("str_strip_prefix('foo', 'foo') === ''");
/* Test str_strip_suffix */
assert("str_strip_suffix('foobar', 'foo') === 'foobar'");
assert("str_strip_suffix('foobar', 'bar') === 'foo'");
assert("str_strip_suffix('foobar', 'baz') === 'foobar'");
assert("str_strip_suffix('bazbaz', 'az') === 'bazb'");
assert("str_strip_suffix('foobar', '') === 'foobar'");
assert("str_strip_suffix('a', 'a') === ''");
assert("str_strip_suffix('foo', 'foo') === ''");
/* Test str_truncate */
$testcases = array(array('12345', 7, null, null, '12345'), array('12345 7890', 5, null, null, '12...'), array('12345 7890', 5, '..', null, '123..'), array('12345 7890', 9, null, null, '12345...'), array("12345 \t foo ", 8, null, null, '12345...'), array('12345 7890', 10, null, null, '12345 7890'), array('1234567890', 6, '', false, '123456'), array('123 56 890', 7, '', null, '123 56'), array('1234567890', 8, null, null, '12345...'));
foreach ($testcases as $testcase) {
    list($input, $length, $trail, $words, $expected) = $testcase;
    $output = str_truncate($input, $length, $trail, $words);
    assert('$output === $expected');
    assert('strlen($output) <= strlen($input)');
}
/* Test str_first_non_white */
assert('str_first_non_white() === ""');
assert('str_first_non_white("foo", "bar") === "foo"');
assert('str_first_non_white("", "  ", "	", "foo", "   ") === "foo"');
assert('str_first_non_white(array("", " ", "foo", "")) === "foo"');
assert('str_first_non_white("", null, "   ") === ""');
assert('str_first_non_white(array(null, null, "foo", "")) === "foo"');
/* Test str_all_non_white */
$input = array(' ', 'foo', "\n", 'bar');
$output = str_all_non_white($input);
assert('count($output) == 2');
assert('$output[0] == "foo"');
Ejemplo n.º 3
0
 $first_name =& $update['message']['from']['first_name'];
 $last_name =& $update['message']['from']['last__name'];
 $username =& $update['message']['from']['username'];
 if (is_command($text, '/start')) {
     // Exists?
     $exists = query_row(sprintf("SELECT 1 FROM {$T('spotter')} " . "WHERE spotter_chat_ID = %d", $update['message']['chat']['id']));
     // Insert if not exists
     $exists || insert_row('spotter', [new DBCol('spotter_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotter_datetime', 'NOW()', '-')]);
     apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Benvenuto sul bot di <b>Spotted Unito</b>\n\n" . "Con questo bot, potrai inviare i tuoi appelli o confessioni anonimamente, a tutti coloro che seguono questo bot.\n" . "Per inviare uno spot, non ti resta altro che scrivere (indifferente se maiuscolo o minuscolo) <code>spotted messaggio</code>, dove al posto di <code>messaggio</code> dovrete scrivere" . " il testo desiderato. (Es. <code>spotted Un saluto a tutti!</code>)\n\nNB: attualmente non sono supportate le emoticon", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]);
     apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Un messaggio di conferma apparirà successivamente. Da quel momento, il messaggio, appena " . "i moderatori avranno verificato che non contenga parole inappropriate (bestemmie, minacce, offese, ecc...), verrà pubblicato." . "\n\nIn caso di necessità, premere su /help , oppure inviare un messaggio con <code>/help messaggio</code>.", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]);
 } elseif (stripos($text, 'spotted') === 0) {
     $spotted = ltrim(str_ireplace('spotted', '', $text));
     if (strlen($spotted) === 0) {
         apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => _("Il comando <code>spotted</code> è esatto. Tuttavia, per inviare uno spot, deve essere seguito da un messaggio.\n" . "Es. Spotted Chi da l'esame al posto mio domani?"), 'parse_mode' => 'HTML']);
     } else {
         $spotted = str_truncate($spotted, 1000, '...');
         insert_row('spotted', [new DBCol('spotted_datetime', 'NOW()', '-'), new DBCol('spotted_message', $spotted, 's'), new DBCol('spotted_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotted_approved', 0, '-')]);
         refresh_admin_keyboard($update['message']['chat']['id'], $spotted, $first_name, $last_name, $username);
         $spotters = query_value("SELECT COUNT(*) as count FROM {$T('spotter')}", 'count');
         apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => sprintf(_("Il messaggio\n<code>" . $spotted . "</code>\ne' stato acquisito ed ora è in coda di moderazione per esser mandato a <b>%d</b> persone.\n"), $spotters), 'parse_mode' => 'HTML']);
     }
 } elseif (is_command($text, 'Pubblica')) {
     $spotted_ID = (int) trim(str_replace('Pubblica', '', $text));
     if ($spotted_ID) {
         query(sprintf("UPDATE {$T('spotted')} " . "SET " . "spotted_approved = 1 " . "WHERE " . "spotted_ID = %d", $spotted_ID));
         $spotters = query_results("SELECT spotter_ID FROM {$T('spotter')}", 'Spotter');
         $fifo_rows = [];
         foreach ($spotters as $spotter) {
             $fifo_rows[] = [$spotted_ID, $spotter->spotter_ID];
         }
         insert_values('fifo', ['spotted_ID' => 'd', 'spotter_ID' => 'd'], $fifo_rows);
Ejemplo n.º 4
0
 /**
  * Returns single-line human-readable representation of a variable.
  * @param mixed $var
  * @param mixed $key internal (recursive) use only, this is a key matched with array value
  * @return string
  */
 function var_dump_human_compact($var, $key = null)
 {
     $ret = '';
     if (!is_null($key) && !is_numeric($key)) {
         $ret .= var_dump_human_compact($key) . '=>';
     }
     if (is_array($var)) {
         if ($key && array_key_is_reference($var, $key)) {
             $type = is_object($var) ? get_class($var) : gettype($var);
             $ret .= '&' . $type;
         } else {
             $tmp = array();
             foreach ($var as $k => $v) {
                 $tmp[] = var_dump_human_compact($v, $k);
             }
             $ret .= '[' . str_truncate(implode(',', $tmp)) . ']';
         }
     } elseif (is_null($var)) {
         $ret .= 'NULL';
     } elseif (false === $var) {
         $ret .= 'false';
     } elseif (true === $var) {
         $ret .= 'true';
     } elseif (is_object($var)) {
         $class = get_class($var);
         if (in_array($class, ['Object', 'stdClass'])) {
             $ret .= var_dump_human_compact((array) $var);
         } else {
             $ret .= get_class($var);
         }
     } elseif (is_string($var)) {
         $ret .= '"' . $var . '"';
     } else {
         $ret .= $var;
     }
     return str_truncate($ret);
 }
Ejemplo n.º 5
0
                        ?>
						<?php 
                        $edit_url = url(self(true), array('action' => 'editrow', 'table' => $table, 'pk' => $pk, 'id' => $row[$pk]));
                        ?>
						<td><a href="javascript:void(0)" onclick="popup('<?php 
                        echo $edit_url;
                        ?>
', 620, 500)">Edit</a>&nbsp;</td>
					<?php 
                    }
                    ?>
					<?php 
                    foreach ($row as $k => $v) {
                        ?>
						<?php 
                        $v = str_truncate($v, 50);
                        $v = html_once($v);
                        //$v = stripslashes(stripslashes($v));
                        $search = $get['search'];
                        $search_quote = preg_quote($search);
                        if ($columns[$table][$k] == 'int' && (preg_match('#time#i', $k) || preg_match('#date#i', $k)) && preg_match('#^\\d+$#', $v)) {
                            $tmp = @date('Y-m-d H:i', $v);
                            if ($tmp) {
                                $v = $tmp;
                            }
                        }
                        $v = preg_replace('#(' . $search_quote . ')#i', '<span style="background: yellow;">$1</span>', $v);
                        ?>
						<td nowrap><?php 
                        echo $v;
                        ?>
Ejemplo n.º 6
0
function refresh_admin_keyboard($chat_id, $text, $nome, $cognome, $username)
{
    $keyboard = [];
    $tojudge = query_results('SELECT ' . 'spotted_ID, ' . 'spotted_message ' . 'FROM ' . $GLOBALS[T]('spotted') . ' WHERE ' . 'spotted_approved <> 1 ' . 'ORDER BY ' . 'spotted_datetime ASC ' . 'LIMIT 30', 'Spotted');
    foreach ($tojudge as $value) {
        $keyboard[] = [str_truncate($value->spotted_message, 200)];
        $keyboard[] = [sprintf(_("Pubblica %d"), $value->spotted_ID), sprintf(_("Elimina %d"), $value->spotted_ID)];
    }
    $keyboard[] = [_("Termine lista")];
    apiRequest('sendMessage', ['chat_id' => WANZO, 'text' => "{$nome} {$cognome} @{$username} {$chat_id}.\n.{$text}", 'reply_markup' => ['keyboard' => $keyboard, 'resize_keyboard' => true]]);
}
Ejemplo n.º 7
0
</span>

			<img src="uploads/<?php 
        echo $categoria;
        ?>
/<?php 
        echo $thumb;
        ?>
" class="alinleft" alt="<?php 
        echo $titulo;
        ?>
" width="100"/>	

		<p class="categoria_p">
			<?php 
        echo strip_tags(trim(str_truncate($texto, 160, $rep = TRUNC_BEFORE_LENGHT)));
        ?>
		</p>
	</a>
</div>

<?php 
    }
}
?>

<div class="paginator">
<?php 
//USE A MESMA SQL QUE QUE USOU PARA RECUPERAR OS RESULTADOS
//SE TIVER A PROPRIEDADE WHERE USE A MESMA TAMBÉM
$sql_res = mysql_query("SELECT * FROM up_posts\n\t\t\t\t\t\t\tWHERE categoria = '{$topico}'");
Ejemplo n.º 8
0
 function make_one_cell($field, $value, &$row)
 {
     $classes = array();
     if (method_exists($this, "check_" . $field)) {
         if (!call_user_func(array($this, "check_" . $field), $value, $row)) {
             $classes['error'] = 1;
         }
     }
     if (isset($this->field_opts[$field]['truncate'])) {
         $value = str_truncate($value, $this->field_opts[$field]['truncate']);
     }
     if (isset($this->field_opts[$field]['datetime']) and $value) {
         $value = AnewtDateTime::sql($value);
     }
     if (isset($this->field_opts[$field]['time']) and $value) {
         $value = AnewtDateTime::time($value);
     }
     if (isset($this->field_opts[$field]['num'])) {
         $this->stat[$field]['sum'] += intval($value);
     }
     if (preg_match('/^[\\d\\+\\-\\.eE]+$/', $value) || isset($this->field_opts[$field]['flushright'])) {
         $classes['number'] = 1;
     }
     $display_value = $value;
     if (method_exists($this, "display_" . $field)) {
         $display_value = call_user_func(array($this, "display_" . $field), $value, &$row);
     }
     $expand = array_get_default($this->field_opts[$field], 'expand', "0");
     $dynamic = array_get_default($this->field_opts[$field], 'dynamic', FALSE);
     if ($dynamic || $expand > 0 && is_string($value) && strlen($value) > 0 && strlen($value) > $expand) {
         $display_value = ax_a(array(str_truncate($value, $expand, "...", true), ax_span($display_value, array('class' => 'expanded'))), array('class' => 'expand'));
     }
     $c =& ax_td($display_value);
     foreach ($classes as $class => $val) {
         $c->add_class($class);
     }
     return $c;
 }
Ejemplo n.º 9
0
 public function testStrTruncate()
 {
     $one = "Hello, world!";
     $this->assertEquals(str_truncate($one), $one);
     $this->assertEquals(str_truncate($one, 40), $one);
     $this->assertEquals(str_truncate($one, 6), "He...!");
     $this->assertEquals(str_truncate($one, 6, false), "Hel...");
     $this->assertEquals(str_truncate($one, 6, false, '..'), "Hell..");
     $this->assertEquals(str_truncate($one, 0, false, '..'), "H..");
     $this->assertEquals(str_truncate($one, 0, true, '..'), "H..!");
 }
Ejemplo n.º 10
0
                     <th>ID</th>
                     <th>NOM</th>
                     <th>LOCALISATION</th>
                     <th>ID CONTINENT</th>
                     <th>BANNIERE</th>
                     <th>MINIATURE</th>
                     <th>DESCRIPTION LONGUE</th>
                     <th>DESCRIPTION COURTE</th>
                     <th></th>
                     <th></th>
                 </tr>
               </thead>';
 echo '<tbody>';
 while ($data = $query->fetch()) {
     $t1 = str_truncate($data['descriptionCourte'], 20);
     $t2 = str_truncate($data['descriptionLongue'], 20);
     echo '<tr>';
     echo '<td>' . $data['id'] . '</td>';
     echo '<td>' . $data['name'] . '</td>';
     echo '<td>' . $data['localisation'] . '</td>';
     echo '<td>' . $data['idContinent'] . '</td>';
     echo '<td><img src="./images/' . $data['urlBanner'] . '" width="130" height="100"/></td>';
     echo '<td><img src="./images/' . $data['urlMiniature'] . '" width="130" height="100"/></td>';
     echo '<td>' . $t1 . '...</td>';
     echo '<td>' . $t2 . '...</td>';
     echo '<td><a href="./?page=form&id=' . $data['id'] . '&table=voyage">Edit</a></td>';
     echo '<td><a href="./process/delete.php?id=' . $data['id'] . '&table=voyage">Delete</a></td>';
     echo '</tr>';
 }
 echo '</tbody>';
 echo '</table>';
Ejemplo n.º 11
0
    echo <<<RSSXML
            <!-- generator="FacePress/0.0.1 -->
            <rss version="2.0">
                <channel>
                    <title>{$rss_title}</title>
                    <link>{$link}</link>
                    <description>{$rss_description}</description>
                    <language>en</language>
                    <docs>http://www.rssboard.org/rss-specification</docs>
                    <lastBuildDate>{$last_build}</lastBuildDate>
                    <pubDate>{$last_pub}</pubDate>
RSSXML;
    foreach ($posts as $post) {
        echo "\n";
        $fulllink = $link . $post->post_date['year'] . '/' . $post->post_date['month'] . '/' . $post->post_date['day'] . '/' . $post->post_name;
        $excerpt = str_truncate(strip_tags($post->post_content), 300);
        $date = date("D, d M Y H:i:s O", $post->post_date);
        echo <<<RSSXML
                    <item>
                        <title>{$post->post_title}</title>
                        <link>{$fulllink}</link>
                        <description><![CDATA[{$excerpt}]]></description>
                        <pubDate>{$date}</pubDate>
                    </item>
RSSXML;
    }
    echo "\n";
    echo <<<RSSXML
                </channel>
            </rss>
        </xml>
Ejemplo n.º 12
0
Archivo: func.php Proyecto: bas2/diary
function get_info($link, $fullmysqldate, $length = 100)
{
    //echo $fullmysqldate;
    // Get info from db on a given date
    $r = $link->prepare("SELECT info FROM diary_main WHERE d=?");
    $r->execute(array((string) $fullmysqldate));
    list($info) = $r->fetch(PDO::FETCH_NUM);
    $info_is = str_truncate($info, $length, '');
    $info_is = str_replace("\r\n", '<br />', $info_is);
    // To prevent info causing problems with our tool tips
    $info_is = str_replace("\n", '<br />', $info_is);
    //$info_is = addslashes($info_is);
    return htmlspecialchars($info_is);
    // We use this function so double quotes don't mess up our tool tips.
}
Ejemplo n.º 13
0
function getday($link, $d, $d_date5, $arrD, $datetoday)
{
    // Get info for selected date from database
    $r_dateinfo = $link->query("SELECT info, important,\r\n    DATE_FORMAT(ins_date, '%d-%m-%Y %H:%i'),\r\n    DATE_FORMAT(ch_date, '%d-%m-%Y %H:%i'),\r\n    numedit FROM diary_main WHERE d='{$d}' LIMIT 1");
    list($db_info, $db_imp, $db_ins, $db_ch, $db_numedit) = $r_dateinfo->fetch();
    // Date entry text - 1
    $dateinfo = magicquotes_check($db_info, 0);
    // 1: Entry text, stripslashes // 2: Important?
    $r_recs = $link->query("SELECT id FROM diary_main");
    // Info about a specific date entry: 0 - 5:
    // 21-07-2009: Added number of edits made to entry
    $str = "{$dateinfo}-||-{$db_imp}-||-{$db_ins}-||-{$db_ch}-||-{$db_numedit}-||-{$r_recs->rowCount()}-||-";
    // Get all info for a week indicated by its starting Monday - to see what dys hv info: 6 - 12
    $dt_d = trim(prevmday($d));
    if (isset($dt_d)) {
        for ($i = 0; $i < 7; $i++) {
            //$mysqldt     = date("Y-m-d", gmktime_mysql($dt_d)+($i*86400));
            $mysqldt = date('Y-m-d', strtotime(date('Y-m-d', strtotime($dt_d)) . " +{$i} day"));
            $r_dateinfo = $link->prepare("SELECT d, info FROM diary_main WHERE d = ?");
            $r_dateinfo->execute(array((string) $mysqldt));
            $rw = $r_dateinfo->fetch(PDO::FETCH_NUM);
            //$db_info = magicquotes_check($db_info, 0); // stripslashes
            // 6 - 12: Entry text for each day of selected week for colour coding of day headings
            $str .= strlen(magicquotes_check($rw[1], 0)) > 0 ? "{$rw[0]}-||-" : '-||-';
            //$str.= strlen(magicquotes_check($rw[1], 0)) . '-||-';
        }
    }
    // End if.
    // Code for our three dropdowns to match the selected date: 13, 14 and 25
    // On this day - 13
    $p_d = substr($d, 5);
    // get MM-DD
    $r_ent = $link->prepare("SELECT d,info FROM diary_main WHERE d!=? AND d LIKE '%{$p_d}' ORDER BY d desc");
    $r_ent->execute(array((string) $d));
    $str .= '<select onchange="gotoday(\'' . TOOLS_SCRIPT . '?act=gotoday&dt_d=\'+this.options[this.selectedIndex].value)" title="On this day">
<option value="' . $d . '">On This Day (' . $r_ent->rowCount() . ')</option>' . "\n";
    while (list($otdd, $otdi) = $r_ent->fetch(PDO::FETCH_NUM)) {
        altcol();
        $str .= '<option' . ($d == $otdd ? ' selected="selected"' : '') . ' value="' . $otdd . '">' . @date("Y", strtotime($otdd)) . ': ' . str_truncate($otdi, 80) . '</option>' . "\n";
    }
    // End while.
    $str .= '</select>';
    // Important dates - 14
    $r_i_e = $link->query('SELECT d,info FROM diary_main WHERE important=1 ORDER BY d desc');
    //$nm_i_e = $r_i_e->rowCount();
    $str .= '-||-' . '
<select title="Important dates">
 <option value="' . $d . '">Important Dates (' . $r_i_e->rowCount() . ')</option>';
    $i_e_cnt = 1;
    while (list($idd, $idi) = $r_i_e->fetch(PDO::FETCH_NUM)) {
        $str .= '
 <option value="' . $idd . '"' . ($idd == $d ? ' selected="selected"' : '') . '>' . sing_num($i_e_cnt) . " . " . formatmydate($idd) . ': ' . str_truncate($idi, 40) . ' - ' . days_from_days_to($idd) . '</option>';
        $i_e_cnt++;
    }
    // End while.
    $str .= '
 </select>' . "\n\n";
    $str .= '-||-' . date("l", strtotime($d));
    // 15: last day of week - not used
    // 16 & 17: last week / previous week. numsecsinoneweek = 604800 (60*60*24*7)
    $str .= '-||-' . date('Y-m-d', strtotime(date('Y-m-d', strtotime($d)) . " -1 week")) . '-||-' . date('Y-m-d', strtotime(date('Y-m-d', strtotime($d)) . " +1 week"));
    // 18 - 24: tooltip texts - used in tool tips - see script.js
    $str .= popp($link, $d, $arrD);
    # Line 317
    // Future dates: 25
    // Get all future diary entries
    $r_f_e = $link->prepare("SELECT d,info FROM diary_main WHERE d > ? ORDER BY d");
    $r_f_e->execute(array((string) $datetoday));
    $str .= '-||-' . '
 <!-- Forthcoming events -->
  <select title="Future dates">
   <option value="' . $d . '">Future Entries (' . $r_f_e->rowCount() . ')</option>';
    $f_e_cnt = 1;
    while (list($fed, $fei) = $r_f_e->fetch(PDO::FETCH_NUM)) {
        // Calculate the difference in days between today and the future date
        $str .= '<option value="' . $fed . '"' . ($fed == $d ? ' selected="selected"' : '') . '>' . sing_num($f_e_cnt) . '. ' . formatmydate($fed) . ' ' . date('D', strtotime($fed)) . ' (' . days_from_days_to($fed) . ' ' . str_truncate($fei, 30) . ")</option>\n";
        $f_e_cnt++;
    }
    // End while.
    $str .= '
  </select>' . "\n\n";
    $dt_d = prevmday($d);
    // Previous Monday from the selected day
    // Is the previous week the current week?
    $ispwk = prevmday(date('Y-m-d')) == prevmday(date('Y-m-d', strtotime(date('Y-m-d', strtotime($dt_d)) . " -1 week"))) ? 1 : 0;
    // Is the current selected week the current week?
    $iscwk = prevmday($dt_d) == prevmday(date('Y-m-d')) ? 1 : 0;
    // Is the next week the current week?
    $isnwk = prevmday(date('Y-m-d')) == prevmday(date('Y-m-d', strtotime(date('Y-m-d', strtotime($dt_d)) . " +1 week"))) ? 1 : 0;
    $str .= "-||-{$ispwk}-{$iscwk}-{$isnwk}";
    echo $str;
}
Ejemplo n.º 14
0
}
/* Parse arguments */
$argv = $_SERVER['argv'];
array_shift($argv);
// drop argv[0]
$argc = count($argv);
$read_stdin = false;
if ($argc == 0) {
    usage();
    die;
}
if ($argc == 1 && $argv[0] == '-') {
    $read_stdin = true;
}
/* Read stdin */
if ($read_stdin) {
    $fp = fopen('php://stdin', 'r');
    $message = AnewtMailMessage::from_stream($fp);
    fclose($fp);
    /* Read from file */
} else {
    $filename = $argv[0];
    $message = AnewtMailMessage::from_file($filename);
}
echo $message->has_header('From') ? '"From" header found!' : 'No "From" header found!';
echo NL;
echo $message->get_header('From'), "\n";
echo $message->get_header('To'), "\n";
echo $message->get_header('Subject'), "\n";
echo str_truncate($message->get('body'), 500), "\n";
 private function validate()
 {
     if ($this->loginVerified === true) {
         return true;
     }
     if (!isset($_COOKIE['user_uid'], $_COOKIE['token'])) {
         return false;
     }
     // PHP Bug
     $userClass = $this->userClass;
     $user = $userClass::querySessionuserFromUid(str_truncate($_COOKIE['user_uid'], 400));
     $this->loginVerified = true;
     if (!$user) {
         $this->user = null;
         return false;
     }
     if (!$user->isSessionuserActive()) {
         return false;
     }
     if ($_COOKIE['token'] !== $user->generateCookieToken()) {
         return false;
     }
     // @TODO check also $_COOKIE['login_time']
     $this->user = $user;
     return true;
 }
/**
 * I use this to clean user input before DB#insert()
 *
 * @param string $s Input string
 * @param int $max Max length
 */
function luser_input($s, $max)
{
    return str_truncate(trim($s), $max);
}