diff --git a/composer.json b/composer.json index 113feaa..87e47f8 100644 --- a/composer.json +++ b/composer.json @@ -1,11 +1,4 @@ { - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/Youpie/simple-html-dom" - } - ], - "config": { "vendor-dir": "system/vendor/", "optimize-autoloader": true, @@ -18,8 +11,7 @@ "michelf/php-markdown": "1.*", "suin/php-rss-writer": "1.*", "kanti/hub-updater": "0.*", - "jbroadway/urlify": "^1.0", - "simple-html-dom/simple-html-dom": "*" + "jbroadway/urlify": "^1.0" }, "autoload": { "files": [ diff --git a/lang/ir_FA.ini b/lang/fa_IR.ini similarity index 100% rename from lang/ir_FA.ini rename to lang/fa_IR.ini diff --git a/system/admin/admin.php b/system/admin/admin.php index d7c3ea3..951332b 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -85,7 +85,7 @@ function remove_accent($str) } // Add content -function add_content($title, $tag, $url, $content, $user, $description = null, $media = null, $draft, $category, $type) +function add_content($title, $tag, $url, $content, $user, $draft, $category, $type, $description = null, $media = null) { $tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ','))); @@ -218,7 +218,7 @@ function add_content($title, $tag, $url, $content, $user, $description = null, $ } // Edit content -function edit_content($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $media = null, $revertPost, $publishDraft, $category, $type) +function edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, $type, $destination = null, $description = null, $date = null, $media = null) { $tag = explode(',', preg_replace("/\s*,\s*/", ",", rtrim($tag, ','))); @@ -775,7 +775,6 @@ function migrate($title, $time, $tags, $content, $url, $user, $source) } else { $post_content = '' . "\n" . '' . "\n\n" . $content; } - if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { $post_content = stripslashes($post_content); @@ -789,31 +788,8 @@ function migrate($title, $time, $tags, $content, $url, $user, $source) file_put_contents($dir . $filename, print_r($post_content, true)); } save_tag_i18n($post_tag, $post_tagmd); - // import images - if(count($images) > 0) { - foreach ($images as $image_url) { - $imagefile = basename($image_url); - if(!@copy($image_url,'content/images/'.$imagefile)) - { - $errors= error_get_last(); - echo "COPY ERROR: ".$errors['type']; - echo "
\n".$errors['message']; - } else { - echo "$imagefile copied from remote!
\n"; - // $images_imported++; - } - } - } - $redirect = site_url() . 'admin/clear-cache'; header("Location: $redirect"); - } else { - echo "

Found empty Fields:

\r\n"; - echo "post title: $post_title
\n"; - echo "post tag: $post_tag
\n"; - echo "post url: $post_url
\n"; - echo "post content: ".substr($post_content, 0, 50)."
\n"; - echo "

I WILL NOT IMPORT THIS !!!

\r\n
\r\n"; } } @@ -846,44 +822,7 @@ function get_feed($feed_url, $credit) } else { $source = null; } - - $images = array(); - // identify the host-name of the rss feed we are parsing - $source_host = parse_url($feed_url); - if(empty($source_host['host'])) { - $source_host['host'] = $_SERVER['SERVER_NAME']; // seems like we are parsing a local feed - } - - $cnt_images = 0; - $html = new \SimpleHtmlDom\simple_html_dom($content); - foreach ($html->find('img') as $img) { - $src = $img->src; - // identify host of img url - $img_host = parse_url($src, PHP_URL_HOST); - $img_path = parse_url($src, PHP_URL_PATH); - if(empty($img_host)) { - $img_host = $source_host['host']; - } - // we only import images if they match the host of the rss feed, - // otherwise legal consequences (copyright breach) may occur - if($img_host == $source_host['host']) { - $cnt_images ++; - $images[] = $source_host['scheme'].'://'.$img_host.$img_path; - // alter the path of the image, point to local src after import - $img->src = '/content/images/'.basename($src); - } - } - - // debug - /** - if($cnt_images > 0) { - echo "

IMAGES and bent content

"; - echo var_export($images, true); - echo "
" . htmlspecialchars($html) . "
"; - } - */ - - migrate($title, $time, $tags, $html, $url, $user, $images, $source); + migrate($title, $time, $tags, $content, $url, $user, $source); } } else { return $str = '
  • Unsupported feed.
  • '; diff --git a/system/admin/views/config.html.php b/system/admin/views/config.html.php index cfbce47..67da930 100644 --- a/system/admin/views/config.html.php +++ b/system/admin/views/config.html.php @@ -66,45 +66,45 @@
    - checked> + checked>
    - checked> + checked>
    - checked> + checked>
    - checked> + checked>
    - checked> + checked>
    - checked> + checked>
    - checked> + checked>
    diff --git a/system/htmly.php b/system/htmly.php index 93c75a5..bcb4d8f 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -474,45 +474,45 @@ post('/add/content', function () { if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, null, $draft, $category, 'post'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, null, $draft, $category, 'post'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'post', $description, null); } } elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($image)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, $image, $draft, $category, 'image'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, $image, $draft, $category, 'image'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'image', $description, $image); } } elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, $video, $draft, $category, 'video'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, $video, $draft, $category, 'video'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'video', $description, $video); } } elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, $audio, $draft, $category, 'audio'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, $audio, $draft, $category, 'audio'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'audio', $description, $audio); } } elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, $quote, $draft, $category, 'quote'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, $quote, $draft, $category, 'quote'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'quote', $description, $quote); } } elseif ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { if (!empty($url)) { - add_content($title, $tag, $url, $content, $user, $description, $link, $draft, $category, 'link'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link); } else { $url = $title; - add_content($title, $tag, $url, $content, $user, $description, $link, $draft, $category, 'link'); + add_content($title, $tag, $url, $content, $user, $draft, $category, 'link', $description, $link); } } else { $message['error'] = ''; @@ -2070,9 +2070,9 @@ get('/archive/:req', function ($req) { $date = strtotime($req); if (isset($time[0]) && isset($time[1]) && isset($time[2])) { - $timestamp = strftime('%d %B %Y', $date); + $timestamp = format_date($date, 'dd MMMM yyyy'); } elseif (isset($time[0]) && isset($time[1])) { - $timestamp = strftime('%B %Y', $date); + $timestamp = format_date($date, 'MMMM yyyy'); } else { $timestamp = $req; } @@ -2442,37 +2442,37 @@ post('/post/:name/edit', function () { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $image, $revertPost, $publishDraft, $category, 'image'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category, 'video'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $link, $revertPost, $publishDraft, $category, 'link'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $quote, $revertPost, $publishDraft, $category, 'quote'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $audio, $revertPost, $publishDraft, $category, 'audio'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, null, $revertPost, $publishDraft, $category, 'post'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null); } else { $message['error'] = ''; @@ -3435,37 +3435,37 @@ post('/:year/:month/:name/edit', function () { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $image, $revertPost, $publishDraft, $category, 'image'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'image', $destination, $description, $dateTime, $image); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($video)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $video, $revertPost, $publishDraft, $category, 'video'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'video', $destination, $description, $dateTime, $video); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($link)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $link, $revertPost, $publishDraft, $category, 'link'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'link', $destination, $description, $dateTime, $link); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($quote)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $quote, $revertPost, $publishDraft, $category, 'quote'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'quote', $destination, $description, $dateTime, $quote); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($audio)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $audio, $revertPost, $publishDraft, $category, 'audio'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'audio', $destination, $description, $dateTime, $audio); } else if ($proper && !empty($title) && !empty($tag) && !empty($content) && !empty($is_post)) { if (empty($url)) { $url = $title; } - edit_content($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, null, $revertPost, $publishDraft, $category, 'post'); + edit_content($title, $tag, $url, $content, $oldfile, $revertPost, $publishDraft, $category, 'post', $destination, $description, $dateTime, null); } else { $message['error'] = ''; diff --git a/system/includes/functions.php b/system/includes/functions.php index af08faf..e9a5af9 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -570,7 +570,7 @@ function get_category_info($category) } } - if (strtolower($category) == 'uncategorized') { + if (strtolower($category ?? '') == 'uncategorized') { return default_category(); } @@ -1432,7 +1432,7 @@ EOF; echo '