function prepare_file($request)
{
    //Data holder
    global $post_data;
    //Check if the request has been sent and store the data
    //in the global $post_array
    if ($_POST['publish'] || $_POST['draft']) {
        foreach ($_POST as $tag => $data) {
            switch ($tag) {
                case 'author-id':
                    $post_data['author']['id'] = $data;
                    break;
                case 'author-name':
                    $post_data['author']['name'] = $data;
                    break;
                default:
                    $post_data['tag'] = $data;
                    break;
            }
        }
    }
    //Full content of the article is saved separately
    $article_content = $post_data['content'];
    //unset the $post_data['content'] and store the content file name;
    unset($post_data['content']);
    $post_data['content'] = $post_data['url'] . 'content';
    //Set the file names
    $json_file = $post_data['id'] . '-' . $post_data['url'] . 'json';
    $content_file = $post_data['content'];
    //Writing and creating all the needed files
    if (!write_article($json_file, $post_data) && !write_content($content_file, $article_content)) {
        // Log error and die if any of the files fail to be written
    }
    //If files written successfully continue with .htaccess and rss-fee
    //Create or update rss-feed file
    if (!write_rss()) {
        //Log the error if writing of rss fails
    }
    //Create or update .htaccess
    if (!write_htaccess()) {
        //Log the error if writing of .htaccess fails
    }
}
示例#2
0
                 $db_error = 6;
             } else {
                 $content .= "<br />\n<i class='entypo check'></i> " . $locale['setup_1300'] . "<br /><br />\n<i class='entypo check'></i> ";
                 $content .= $locale['setup_1301'] . "<br /><br />\n<i class='entypo icancel'></i> ";
                 $content .= "<strong>" . $locale['setup_1303'] . "</strong> " . $locale['setup_1308'] . "<br /><br />\n";
                 $success = FALSE;
                 $db_error = 0;
             }
         } else {
             $content .= "<br />\n" . $locale['setup_1300'] . "<br /><br />\n";
             $content .= "<strong>" . $locale['setup_1303'] . "</strong> " . $locale['setup_1306'] . "<br />\n";
             $content .= "<span class='small'>" . $locale['setup_1307'] . "</span><br /><br />\n";
             $success = FALSE;
             $db_error = 5;
         }
         write_htaccess(fusion_get_settings('site_path'));
     } else {
         $content .= "<div class='alert alert-danger'>\n";
         $content .= $locale['setup_1300'] . "<br /><br />\n";
         $content .= "<strong>" . $locale['setup_1303'] . "</strong> " . $locale['setup_1314'] . "<br />\n";
         $content .= "<span class='small'>" . $locale['setup_1315'] . "</span><br /><br />\n";
         $content .= "</div>\n";
         $success = FALSE;
         $db_error = 4;
     }
 } else {
     // has tables -- should direct to next step instead.
     $content .= "<div class='alert alert-warning'>\n";
     $content .= "<strong>" . $locale['setup_1312'] . "</strong><br />\n";
     $content .= "<span class='small'>" . $locale['setup_1313'] . "</span><br /><br />\n";
     $content .= "</div>\n";