function handlePost($params)
 {
     session_write_close();
     header('Connection: close');
     $app = Dataface_Application::getInstance();
     try {
         require_once 'inc/PageImporter.php';
         require_once 'inc/SweteSite.class.php';
         if (!@$_POST['website_id']) {
             throw new Exception("No Site Specified");
         }
         $site = SweteSite::loadSiteById($_POST['website_id']);
         if (!$site) {
             throw new Exception("No site found by that ID.");
         }
         $importer = new PageImporter();
         $importer->site = $site;
         $importer->translate = true;
         $importer->logTranslationMisses = true;
         if (@$_POST['--depth'] and intval($_POST['--depth'])) {
             $importer->depth = intval($_POST['--depth']);
         }
         if (@$_POST['--startingPoint']) {
             $importer->startingPoint = trim($_POST['--startingPoint']);
         }
         $importer->loadContent = true;
         $importer->doImport();
         $addedIds = array();
         $updatedIds = array();
         foreach ($importer->pagesAdded as $p) {
             $addedIds[] = $p->val('webpage_id');
         }
         foreach ($importer->pagesUpdated as $p) {
             $updatedIds[] = $p->val("webpage_id");
         }
         $out = array('code' => 200, 'message' => 'Successfully imported ' . count($importer->pagesAdded) . ' pages updated ' . count($importer->pagesUpdated) . ' pages.', 'pagesUpdated' => count($importer->pagesUpdated), 'pagesAdded' => count($importer->pagesAdded), 'addedIds' => $addedIds, 'updatedIds' => $updatedIds);
     } catch (Exception $ex) {
         $out = array('code' => $ex->getCode(), 'message' => $ex->getMessage());
     }
     header('Content-type: text/json; charset="' . $app->_conf['oe'] . '"');
     echo json_encode($out);
     return;
 }