From dac562b19f61514c0cedef1b4161eb02380a4926 Mon Sep 17 00:00:00 2001 From: Banana Date: Fri, 27 Dec 2019 12:07:49 +0100 Subject: [PATCH] updated documentation and some fixes --- ChangeLog | 6 ++++-- documentation/email-importer.txt | 2 ++ documentation/features.txt | 2 +- documentation/installation.txt | 15 +++++++++++--- documentation/requirements.txt | 5 +++-- documentation/usage.txt | 6 ++++++ webroot/job/email-import.php | 34 ++++++++++++++++++++----------- webroot/lib/simple-imap.class.php | 14 +++++++------ webroot/view/overview.inc.php | 21 ++++++++----------- 9 files changed, 67 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index 678b383..45ed821 100755 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,6 @@ version 2.2 - Guardian of Ice - (tba) * email import - * code cleanups * using mysql transactions if needed * pagination * authentication with an extra url now (index.php?m=auth) @@ -9,8 +8,11 @@ version 2.2 - Guardian of Ice - (tba) * small stats overview * links can now be deleted * awaiting moderation links can new be moderated - * Fixed an error in create sql file * clean up the local storage via stats page (if authenticated) + * Updated documentation + * Fixed an error in create sql file + * Fixed info when a tag or category has no links + * Fixed code cleanups version 2.1alpha - Guardian of Fire - (2019-09-29) diff --git a/documentation/email-importer.txt b/documentation/email-importer.txt index 20421d9..e22c332 100644 --- a/documentation/email-importer.txt +++ b/documentation/email-importer.txt @@ -26,3 +26,5 @@ Syntax of the E-Mail body: absolute-link|multiple,category,strings|multiple,tag,strings\n new-absolute-link|multiple,category,strings|multiple,tag,strings\n + +Create a cronjob to execute the email-import.php file. \ No newline at end of file diff --git a/documentation/features.txt b/documentation/features.txt index 4d6b3e0..0a871d7 100644 --- a/documentation/features.txt +++ b/documentation/features.txt @@ -1,6 +1,6 @@ Insipid is a web-based bookmark manager similar to the Delicious service. -It lets you manage and host your own bookmarks. No talking to other servervices or agencies. +It lets you manage and host your own bookmarks. No talking to other services or agencies. Your data is your data. Bookmarks are put into categories and should have tags. diff --git a/documentation/installation.txt b/documentation/installation.txt index 3b486fd..0ab884b 100644 --- a/documentation/installation.txt +++ b/documentation/installation.txt @@ -8,7 +8,16 @@ Read this first!! Unpack the archive 4. -Modify webroot/config.default.php and copy it to webroot/config.php +Create your config file. +Copy webroot/config.default.php to webroot/config.php + +Modify at least the following settings in this file: +- define('DB_HOST','127.0.0.1'); +- define('DB_USERNAME','user'); +- define('DB_PASSWORD','test'); +- define('FRONTEND_USERNAME','luke'); +- define('FRONTEND_PASSWORD','father'); +- define('ABSOLUTE_PATH', '/path/to/insipid/webroot'); 5. Copy and modify documentation/insipid-edit-me.sql and replace the placeholder. @@ -17,11 +26,11 @@ Open the file and make a search and replace: search for: `#REPLACE_ME# replace with: `tableprefix -The value tableprefix has to match with the value for DB_PREFIX in config.php +The value tableprefix has to match with the value for DB_PREFIX in your config.php file 6. Create a table if needed. -Import the sql file into your MySQL database +Import the edited from step 5 sql file into your MySQL database. 7. Edit the robots.txt file to your needs. diff --git a/documentation/requirements.txt b/documentation/requirements.txt index 57d997a..9c7541c 100644 --- a/documentation/requirements.txt +++ b/documentation/requirements.txt @@ -1,3 +1,4 @@ -Apache (2 and up) with PHP extension (+imap if you us the email importer) -PHP (7 and up) with MySQL extension -> mysqli; curl enabled +Apache (2.4 and up) with PHP extension enabled +PHP (7 and up) with MySQL extension -> mysqli; curl enabled; (+imap +ssl if you us the email importer) MySQL database 5.6.x and up +- DB user rights has to include create, alter a view diff --git a/documentation/usage.txt b/documentation/usage.txt index 09294a9..1939ee5 100644 --- a/documentation/usage.txt +++ b/documentation/usage.txt @@ -9,3 +9,9 @@ Call the following URL to trigger the authentication: http(s)://your.domain.tld/path/to/insipid/index.php?m=auth If successful you can now manage your items. Edit buttons are visible now. + +HowToAdd a new link: + +There is no special "add a new link" option. Just paste the link into the search bar. +If the link is already in your database the edit option will be shown. +If not the add field will be shown and the possibility to safe the new link. \ No newline at end of file diff --git a/webroot/job/email-import.php b/webroot/job/email-import.php index 3096d3d..25b524e 100644 --- a/webroot/job/email-import.php +++ b/webroot/job/email-import.php @@ -72,6 +72,16 @@ if(EMAIL_REPORT_BACK === true) { $phpmailer->setFrom(EMAIL_REPLY_BACK_ADDRESS); $phpmailer->Subject = EMAIL_REPLY_BACK_SUBJECT; $phpmailer->Timeout = 3; + + if(DEBUG === true) $phpmailer->SMTPDebug = SMTP::DEBUG_SERVER; + + $phpmailer->SMTPOptions = array( + 'ssl' => [ + 'verify_peer' => false, + 'verify_peer_name' => false, + 'allow_self_signed' => true + ], + ); } $DB = false; @@ -92,7 +102,7 @@ try { if(DEBUG === true) $EmailReader->mailboxStatus(); } catch (Exception $e) { - error_log('Email server connection failed: '.var_export($e->getMessage(),true)); + error_log('ERROR Email server connection failed: '.var_export($e->getMessage(),true)); exit(); } @@ -102,7 +112,7 @@ try { $emails = $EmailReader->messageWithValidSubject(EMAIL_MARKER); } catch (Exception $e) { - error_log('Can not process email messages: '.var_export($e->getMessage(),true)); + error_log('ERROR Can not process email messages: '.var_export($e->getMessage(),true)); exit(); } @@ -141,7 +151,7 @@ if(!empty($emails)) { $newdata['link'] = Summoner::addSchemeToURL($newdata['link']); if (!filter_var($newdata['link'], FILTER_VALIDATE_URL)) { - error_log("Invalid URL: ".var_export($newdata['link'],true)); + error_log("ERROR Invalid URL: ".var_export($newdata['link'],true)); if(DEBUG === true) var_dump($newdata['link']); continue; } @@ -160,8 +170,8 @@ if(!empty($emails)) { } } else { - error_log("No valid title for link found: ".var_export($newdata,true)); - if(DEBUG === true) var_dump("No valid title for link found: ".var_export($newdata,true)); + error_log("WARN No valid title for link found: ".var_export($newdata,true)); + if(DEBUG === true) var_dump("WARN No valid title for link found: ".var_export($newdata,true)); array_push($invalidProcessedEmails, $emailData); continue; } @@ -189,7 +199,7 @@ if(!empty($emails)) { ), true); } catch (Exception $e) { - $_m = "Can not create new link into DB. Duplicate? ".$e->getMessage(); + $_m = "WARN Can not create new link into DB. Duplicate? ".$e->getMessage(); error_log($_m); $emailData['importmessage'] = $_m; array_push($invalidProcessedEmails,$emailData); @@ -221,12 +231,12 @@ if(!empty($emails)) { $DB->commit(); - error_log("Link successfully added: ".$newdata['link']); + error_log("INFO Link successfully added: ".$newdata['link']); array_push($validProcessedEmails,$emailData); } else { $DB->rollback(); - error_log("Link could not be added. SQL problem: ".$newdata['link']); + error_log("ERROR Link could not be added. SQL problem: ".$newdata['link']); $emailData['importmessage'] = "Link could not be added"; array_push($invalidProcessedEmails,$emailData); } @@ -239,7 +249,7 @@ if(!empty($emails)) { # if we have invalid import mails, ignore them, just log em # if EMAIL_REPORT_BACK is true then report back with errors if EMAIL_REPLY_BACK_VALID if(!empty($invalidProcessedEmails)) { - error_log("We have invalid import messages."); + error_log("INFO We have invalid import messages."); foreach ($invalidProcessedEmails as $invalidMail) { if(EmailImportHelper::canSendReplyTo($invalidMail['header_rfc822']->reply_toaddress) && !EmailImportHelper::isAutoReplyMessage($invalidMail['header_array'])) { @@ -248,10 +258,10 @@ if(!empty($invalidProcessedEmails)) { $phpmailer->Body .= $invalidMail['body']; $phpmailer->addAddress($_address[0]['address']); $phpmailer->send(); - error_log("Report back email to: ".$_address[0]['address']); + error_log("INFO Report back email to: ".$_address[0]['address']); } else { - error_log("Invalid message: ".$invalidMail['header_rfc822']->subject); + error_log("WARN Invalid message: ".$invalidMail['header_rfc822']->subject); } } } @@ -259,7 +269,7 @@ if(!empty($invalidProcessedEmails)) { # move them to the processed / archive folder #$EmailReader->move() if(!empty($validProcessedEmails)) { - error_log("We have valid import messages."); + error_log("INFO We have valid import messages."); foreach ($validProcessedEmails as $validMail) { } } diff --git a/webroot/lib/simple-imap.class.php b/webroot/lib/simple-imap.class.php index bced020..8467025 100644 --- a/webroot/lib/simple-imap.class.php +++ b/webroot/lib/simple-imap.class.php @@ -126,11 +126,13 @@ class SimpleImap { if($this->_connection !== false) { $status = imap_status($this->_connection, $this->_connectionstring.$this->_mailbox, SA_ALL); - var_dump("messages ".$status->messages); - var_dump("recent ".$status->recent); - var_dump("unseen ".$status->unseen); - var_dump("uidnext ".$status->uidnext); - var_dump("uidvalidity ".$status->uidvalidity); + if(DEBUG === true) { + var_dump("messages " . $status->messages); + var_dump("recent " . $status->recent); + var_dump("unseen " . $status->unseen); + var_dump("uidnext " . $status->uidnext); + var_dump("uidvalidity " . $status->uidvalidity); + } $list = imap_getmailboxes($this->_connection, $this->_connectionstring, "*"); if (is_array($list)) { @@ -141,7 +143,7 @@ class SimpleImap { echo $val->attributes . "
\n"; } } else { - error_log("imap_getmailboxes failed: ".var_export(imap_last_error())); + error_log("ERROR imap_getmailboxes failed: ".var_export(imap_last_error())); } } } diff --git a/webroot/view/overview.inc.php b/webroot/view/overview.inc.php index 18ad320..fb90e6d 100644 --- a/webroot/view/overview.inc.php +++ b/webroot/view/overview.inc.php @@ -57,13 +57,12 @@ if(Summoner::simpleAuthCheck() === true) { switch($_requestMode) { case 'tag': if(!empty($_id)) { + $tagObj = new Tag($DB); + $tagObj->initbyid($_id); + $tagname = $tagObj->getData('name'); + $subHeadline = $tagname.' '; + $linkCollection = $Management->linksByTag($_id,false,RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1))); - if(!empty($linkCollection['results'])) { - $tagObj = new Tag($DB); - $tagObj->initbyid($_id); - $tagname = $tagObj->getData('name'); - $subHeadline = $tagname.' '; - } } else { # show all the tags we have @@ -73,13 +72,11 @@ switch($_requestMode) { break; case 'category': if(!empty($_id)) { + $catObj = new Category($DB); + $catObj->initbyid($_id); + $catname = $catObj->getData('name'); + $subHeadline = $catname.' '; $linkCollection = $Management->linksByCategory($_id,false,RESULTS_PER_PAGE, (RESULTS_PER_PAGE * ($_curPage-1))); - if(!empty($linkCollection['results'])) { - $catObj = new Category($DB); - $catObj->initbyid($_id); - $catname = $catObj->getData('name'); - $subHeadline = $catname.' '; - } } else { # show all the categories we have -- 2.39.5