connect_errno) exit('Can not connect to MySQL Server'); #$DB->set_charset("utf8mb4"); #$DB->query("SET collation_connection = 'utf8mb4_bin'"); $workingDir = getcwd(); date_default_timezone_set('Europe/Berlin'); # get the tags as array per entrie $tags = array(); $queryStr = "SELECT * FROM serendipity_entrytags"; $query = $DB->query($queryStr); while($result = $query->fetch_assoc()) { $tags[$result['entryid']][] = $result['tag']; } $categories = array(); $queryStr = "SELECT ec.entryid, c.category_name FROM `serendipity_entrycat` AS ec LEFT JOIN serendipity_category as c ON ec.categoryid = c.categoryid"; $query = $DB->query($queryStr); while($result = $query->fetch_assoc()) { $categories[$result['entryid']][] = $result['category_name']; } # get the links and preformat them $links = array(); $queryStr = "SELECT * FROM serendipity_permalinks WHERE `type` = 'entry'"; $query = $DB->query($queryStr); while($result = $query->fetch_assoc()) { $_link = $result['permalink']; $_link = str_replace('archives/'.$result['entry_id'].'-','',$_link); $_link = str_replace('.html','',$_link); $_link = trim($_link, ' .,'); $links[$result['entry_id']] = $_link; } # get the entries $queryStr = "SELECT * FROM serendipity_entries WHERE `isdraft` = 'false'"; $query = $DB->query($queryStr); while($result = $query->fetch_assoc()) { $_tags = ''; if(isset($tags[$result['id']])) { $_tags = '"'.implode('","',$tags[$result['id']]).'"'; } $tagstring = $_tags; $_categories = ''; if(isset($categories[$result['id']])) { $_categories = '"'.implode('","',$categories[$result['id']]).'"'; } $category = '"Dev",'.$_categories; $category = trim($category, " ,"); $filename = $result['id']; if(isset($links[$result['id']])) { $filename = $links[$result['id']]; } $year = date("Y",$result['timestamp']); $month = date("m",$result['timestamp']); if(!file_exists('output/'.$year)) { mkdir('output/'.$year); } if(!file_exists('output/'.$year.'/'.$month)) { mkdir('output/'.$year.'/'.$month); } $targetfile = 'output/'.$year.'/'.$month.'/'.$filename.".md"; $date = date("Y-m-d",$result['timestamp']); $title = trim($result['title']); $title = str_replace('"','',$title); $filedata = <<close();