forked from wallabag/wallabag
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b1fa4c2fe | |||
| df89c6f71a | |||
| aa245deedc | |||
| d61e86a3d3 | |||
| 336797f309 | |||
| cdee5e6570 | |||
| 467503fb2a |
@ -411,12 +411,14 @@ class Database {
|
|||||||
|
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
public function getRandomId($row, $user_id) {
|
public function getRandomId($user_id) {
|
||||||
$sql = "SELECT id FROM entries WHERE user_id=? LIMIT 1 OFFSET ? ";
|
$random = (STORAGE == 'mysql') ? 'RAND()' : 'RANDOM()';
|
||||||
$params = array($user_id, $row);
|
$sql = "SELECT id FROM entries WHERE user_id=? ORDER BY ". $random . " LIMIT 1";
|
||||||
$query = $this->executeQuery($sql, $params);
|
$params = array($user_id);
|
||||||
|
$query = $this->executeQuery($sql, $params);
|
||||||
|
$id = $query->fetchAll();
|
||||||
|
|
||||||
return $query->fetchAll();
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -393,13 +393,13 @@ class Poche
|
|||||||
|
|
||||||
/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
|
/* For some unknown reason I can't get displayView() to work here (it redirects to home view afterwards). So here's a dirty fix which redirects directly to URL */
|
||||||
case 'random':
|
case 'random':
|
||||||
$count = $this->store->getEntriesByViewCount($view, $this->user->getId());
|
|
||||||
$id_query = $this->store->getRandomId(rand(1,$count)-1, $this->user->getId());
|
|
||||||
$id = $id_query[0];
|
|
||||||
Tools::logm('get a random article');
|
Tools::logm('get a random article');
|
||||||
Tools::redirect('?view=view&id=' . $id[0]);
|
if ($this->store->getRandomId($this->user->getId())) {
|
||||||
|
$id_array = $this->store->getRandomId($this->user->getId());
|
||||||
//$this->displayView('view', $id);
|
$id = $id_array[0];
|
||||||
|
Tools::redirect('?view=view&id=' . $id[0]);
|
||||||
|
Tools::logm('got the article with id ' . $id[0]);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -754,7 +754,7 @@ class Poche
|
|||||||
Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).');
|
Tools::logm('Import of articles finished: '.$i.' articles added (w/o content if not provided).');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->messages->add('s', _('Did you forget to select a file?'));
|
$this->messages->add('e', _('Did you forget to select a file?'));
|
||||||
}
|
}
|
||||||
// file parsing finished here
|
// file parsing finished here
|
||||||
// now download article contents if any
|
// now download article contents if any
|
||||||
|
|||||||
@ -12,6 +12,7 @@ $errors = array();
|
|||||||
$successes = array();
|
$successes = array();
|
||||||
|
|
||||||
$final = false;
|
$final = false;
|
||||||
|
$email = "";
|
||||||
|
|
||||||
require_once('install_functions.php');
|
require_once('install_functions.php');
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ else if (isset($_POST['install'])) {
|
|||||||
// User informations
|
// User informations
|
||||||
$username = trim($_POST['username']);
|
$username = trim($_POST['username']);
|
||||||
$password = trim($_POST['password']);
|
$password = trim($_POST['password']);
|
||||||
|
$email = trim($_POST['email']);
|
||||||
$salted_password = sha1($password . $username . $salt);
|
$salted_password = sha1($password . $username . $salt);
|
||||||
|
|
||||||
// Database informations
|
// Database informations
|
||||||
@ -68,7 +70,7 @@ else if (isset($_POST['install'])) {
|
|||||||
|
|
||||||
if ($_POST['db_engine'] == 'sqlite') {
|
if ($_POST['db_engine'] == 'sqlite') {
|
||||||
if (!copy('install/poche.sqlite', 'db/poche.sqlite')) {
|
if (!copy('install/poche.sqlite', 'db/poche.sqlite')) {
|
||||||
$errors[] = 'Impossible to create the SQLite database file.';
|
$errors[] = 'Impossible to create the SQLite database file. Please check your file permissions.';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
|
$db_path = 'sqlite:' . realpath('') . '/db/poche.sqlite';
|
||||||
@ -140,8 +142,8 @@ else if (isset($_POST['install'])) {
|
|||||||
|
|
||||||
|
|
||||||
if ($continue) {
|
if ($continue) {
|
||||||
$sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, '')";
|
$sql = "INSERT INTO users (username, password, name, email) VALUES (?, ?, ?, ?)";
|
||||||
$params = array($username, $salted_password, $username);
|
$params = array($username, $salted_password, $username, $email);
|
||||||
$query = executeQuery($handle, $sql, $params);
|
$query = executeQuery($handle, $sql, $params);
|
||||||
|
|
||||||
$id_user = (int)$handle->lastInsertId('users_id_seq');
|
$id_user = (int)$handle->lastInsertId('users_id_seq');
|
||||||
@ -160,7 +162,7 @@ else if (isset($_POST['install'])) {
|
|||||||
|
|
||||||
|
|
||||||
if (!copy('inc/poche/config.inc.default.php', 'inc/poche/config.inc.php')) {
|
if (!copy('inc/poche/config.inc.default.php', 'inc/poche/config.inc.php')) {
|
||||||
$errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it.';
|
$errors[] = 'Installation aborted, impossible to create inc/poche/config.inc.php file. Maybe you don\'t have write access to create it. Check your file permissions.';
|
||||||
} else {
|
} else {
|
||||||
if ($_POST['db_engine'] != 'sqlite') {
|
if ($_POST['db_engine'] != 'sqlite') {
|
||||||
$content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content);
|
$content = str_replace("define ('STORAGE', 'sqlite');", "define ('STORAGE', '".$_POST['db_engine']."');", $content);
|
||||||
@ -407,7 +409,7 @@ border: 1px solid #000;
|
|||||||
<div class='messages success install'>
|
<div class='messages success install'>
|
||||||
<p>
|
<p>
|
||||||
<a href="index.php?clean=0">Click here to finish update.</a><br>
|
<a href="index.php?clean=0">Click here to finish update.</a><br>
|
||||||
If it fails, just delete the install directory.
|
If it fails, check your file permissions or just delete the install directory.
|
||||||
</p>
|
</p>
|
||||||
<p>You may have to clear cache (by going into config screen) after update.</p>
|
<p>You may have to clear cache (by going into config screen) after update.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user