Exemplo n.º 1
0
function generate_new_key()
{
    $result = "";
    for ($i = 0; $i < 9; $i += 1) {
        $result .= chr(rand(0, 160));
    }
    $result .= chr(137);
    //Ending suffix
    $GLOBALS['CURRENT_KEY'] = base64_encode(encode_key($result, $GLOBALS['TRANSFORM_KEY']));
}
Exemplo n.º 2
0
 # Insert the row.
 #
 $url = sqlite_escape_string($_GET['save']);
 $title = isset($_GET['title']) ? sqlite_escape_string($_GET['title']) : '';
 $key = '';
 $now = time();
 $q = $db->query('INSERT INTO links (url, title, created, last_access) VALUES ("' . $url . '", "' . $title . '", ' . $now . ', ' . $now . ')');
 if ($q === false) {
     create_table($db);
     $db->query('INSERT INTO links (url, title, created, last_access) VALUES ("' . $url . '", "' . $title . '", ' . $now . ', ' . $now . ')');
 }
 #
 # Create the key.
 #
 $id = $db->lastInsertRowid();
 $key = encode_key($id, $codeset);
 $db->query('UPDATE links SET key="' . $key . '" WHERE id=' . $id);
 #
 # Get the title.
 #
 if ($title === '') {
     $lines = array();
     exec($curl_path . ' ' . $url, $lines);
     $html_string = implode('', $lines);
     preg_match('/<title>(.*?)<\\/title>/im', $html_string, $matches);
     if ($matches && sizeof($matches) > 1) {
         $title = sqlite_escape_string($matches[1]);
     }
     if ($title != '') {
         $db->query('UPDATE links SET title="' . $title . '" WHERE id=' . $id);
     }