*/
private $_data;
+ /**
+ * Show private links too
+ * @var bool
+ */
+ private $_showPrivate = false;
+
public function __construct($databaseConnectionObject) {
$this->DB = $databaseConnectionObject;
}
+ /**
+ * Show private links or not
+ * @param $bool
+ */
+ public function setShowPrivate($bool) {
+ if(is_bool($bool)) {
+ $this->_showPrivate = $bool;
+ }
+ }
+
/**
* load all the info we have about a link by given hash
* @param string $hash
any_value(`hash`) as hash
FROM `".DB_PREFIX."_link`
WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+ if($this->_showPrivate === true) {
+ $queryStr .= " AND `status` IN (2,1)";
+ }
+ else {
+ $queryStr .= " AND `status` = 2";
+ }
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows == 1) {
$this->_data = $query->fetch_assoc();
any_value(`hash`) as hash
FROM `".DB_PREFIX."_link`
WHERE `hash` = '".$this->DB->real_escape_string($hash)."'";
+ if($this->_showPrivate === true) {
+ $queryStr .= " AND `status` IN (2,1)";
+ }
+ else {
+ $queryStr .= " AND `status` = 2";
+ }
$query = $this->DB->query($queryStr);
if(!empty($query) && $query->num_rows == 1) {
$this->_data = $query->fetch_assoc();
return $ret;
}
- /**
- * check if the given URL exists in the DB
- * if so return the hash. If not, return false
- * @param string $link
- * @return string
- */
- public function exists($link) {
- $ret = false;
-
- if(!empty($link)) {
- $queryStr = "SELECT
- any_value(`hash`) as hash
- FROM `".DB_PREFIX."_link`
- WHERE `link` = '".$this->DB->real_escape_string($link)."'";
- $query = $this->DB->query($queryStr);
- if(!empty($query) && $query->num_rows > 0) {
- $result = $query->fetch_assoc();
- $ret = $result['hash'];
- }
- }
-
- return $ret;
- }
-
/**
* load all the tags we have to the already loaded link
* needs $this->load called first
*/
private $DB;
+ /**
+ * Show private links too
+ * @var bool
+ */
private $_showPrivate = false;
protected $COMBINED_SELECT_VALUES = "any_value(`id`) as id,
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
$linkObj = new Link($this->DB);
+ $linkObj->setShowPrivate($this->_showPrivate);
$ret['results'][] = $linkObj->loadShortInfo($result['hash']);
unset($linkObj);
}
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
$linkObj = new Link($this->DB);
+ $linkObj->setShowPrivate($this->_showPrivate);
$ret['results'][] = $linkObj->loadShortInfo($result['hash']);
unset($linkObj);
}
if(!empty($query) && $query->num_rows > 0) {
while($result = $query->fetch_assoc()) {
$linkObj = new Link($this->DB);
+ $linkObj->setShowPrivate($this->_showPrivate);
$ret['results'][] = $linkObj->loadShortInfo($result['hash']);
unset($linkObj);
}
if(!empty($allLinks)) {
foreach($allLinks as $link) {
$LinkObj = new Link($this->DB);
+ $LinkObj->setShowPrivate($this->_showPrivate);
$l = $LinkObj->load($link['hash']);
$searchStr = $l['title'];
* along with this program. If not, see http://www.gnu.org/licenses/gpl-3.0.
*
*/
+
$submitFeedback = false;
$formData = false;
# can/should be extended in the future.
Summoner::simpleAuth();
-
$_id = false;
if(isset($_GET['id']) && !empty($_GET['id'])) {
$_id = trim($_GET['id']);
}
$linkObj = new Link($DB);
+$linkObj->setShowPrivate(Summoner::simpleAuthCheck());
$linkObj->load($_id);
$linkData = $linkObj->getData();
if(empty($linkData)) {
* Insipid
* Personal web-bookmark-system
*
- * Copyright 2016-2017 Johannes Keßler
+ * Copyright 2016-2019 Johannes Keßler
*
* Development starting from 2011: Johannes Keßler
* https://www.bananas-playground.net/projekt/insipid/
}
$linkObj = new Link($DB);
+$linkObj->setShowPrivate(Summoner::simpleAuthCheck());
$linkData = $linkObj->load($_id);
if(empty($linkData)) {
header("HTTP/1.0 404 Not Found");