+ Now including update instructions
+ DB export only insipid tables and not the whole DB itself.
+ + Simple xml export and import
+ #2 Protection if the email-import.php file if it needs to be
in a web accessible folder
+ Fixed the search for words. See update instructions how to correct your data
+ Update config file with tow new settings. See config.default for more info
define('EMAIL_JOB_PROTECT', false);
-define('EMAIL_JOB_PROTECT_SECRET', 'SOME_SECRET_STRING');
\ No newline at end of file
+define('EMAIL_JOB_PROTECT_SECRET', 'SOME_SECRET_STRING');
+
++ All Files in webroot/asset/js/ EXCEPT the new editlink.js can be removed
\ No newline at end of file
--- /dev/null
+Any link can be exported as a xml file from the link info view.
+Login is required to trigger this function.
+The result can be used to import it again at the stats view.
+
+It exports all the link information, image and its tags and categories.
+
+The import can overwrite existing links and import non existing ones.
+
+A import xml file can contain multiple exports. Make sure the root is
+still there.
\ No newline at end of file
if(DEBUG === true) var_dump($newdata);
- $DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
-
$linkObj = new Link($DB);
$linkID = false;
# check for duplicate
$existing = $linkObj->load($newdata['hash']);
+
+ $DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
+
if(!empty($existing) && isset($existing['id'])) {
$linkID = $existing['id'];
error_log('INFO Updating existing link with tag or category '.$newdata['link']);
return $ret;
}
-
/**
* process the given xml file. Based on the export file
* options are overwrite => true|false
if(!empty($links)) {
$_amount = count($links);
foreach($links as $linkToImport) {
+ $do = false;
+
if($this->_linkExistsById($linkToImport['id'])) {
if(isset($options['overwrite']) && $options['overwrite'] === true) {
$linkObj = new Link($this->DB);
$_existing++;
}
else {
+ $linkObj = new Link($this->DB);
+
+ $this->DB->begin_transaction(MYSQLI_TRANS_START_READ_WRITE);
+ try{
+ $do = $linkObj->create(array(
+ 'hash' => $linkToImport['hash'],
+ 'link' => $linkToImport['link'],
+ 'status' => $linkToImport['private'],
+ 'description' => $linkToImport['description'],
+ 'title' => $linkToImport['title'],
+ 'search' => '',
+ 'image' => $linkToImport['image']
+ ), true);
+ } catch (Exception $e) {
+ continue;
+ }
+
+ if(!empty($do)) {
+
+ $linkToImport['catArr'] = Summoner::prepareTagOrCategoryStr($linkToImport['category']);
+ $linkToImport['tagArr'] = Summoner::prepareTagOrCategoryStr($linkToImport['tag']);
+
+ if(!empty($linkToImport['catArr'])) {
+ foreach($linkToImport['catArr'] as $c) {
+ $catObj = new Category($this->DB);
+ $catObj->initbystring($c);
+ $catObj->setRelation($do);
+
+ unset($catObj);
+ }
+ }
+ if(!empty($linkToImport['tagArr'])) {
+ foreach($linkToImport['tagArr'] as $t) {
+ $tagObj = new Tag($this->DB);
+ $tagObj->initbystring($t);
+ $tagObj->setRelation($do);
+
+ unset($tagObj);
+ }
+ }
+
+ $this->DB->commit();
+
+ $this->updateSearchIndex();
+ }
+ else {
+ $this->DB->rollback();
+ }
$_new++;
- var_dump('new one');
}
}
if(isset($options['overwrite']) && $options['overwrite'] === true) {
'status' => 'success',
'message' => $_msg
);
-
}
return $ret;