예제 #1
0
$app->group('/project', function () use($app) {
    $app->get('/:id', function ($id) use($app) {
        $project = getProjectOr404($id);
        if (!empty($_SESSION['user']) && $project['dct:creator'] == $_SESSION['user']['username']) {
            $is_my_project = true;
        } else {
            $is_my_project = false;
        }
        $app->render('project_single.php', compact('project', 'is_my_project'));
    })->conditions(array('id' => '[a-f0-9]{24}'));
    $app->post('/', function () use($app) {
        $post = $app->request->post();
        if ($_SESSION['action'] !== 'express') {
            authenticateUser();
            checkToken($post, $app);
            saveProject($post);
        }
        if (isset($post['format'])) {
            $_SESSION['format'] = $post['format'];
        } else {
            $_SESSION['format'] = null;
        }
        if ($_SESSION['action'] == 'edit') {
            $app->flash('info', 'プロジェクトの編集を完了しました');
            $app->redirect($app->config('static_path'));
        } else {
            $app->redirect($app->config('static_path') . 'complete');
        }
    });
    $app->get('/excerpt/:id', function ($id) use($app) {
        $project = getProjectOr404($id);
function saveProjectAction()
{
    $errors = NULL;
    if (isset($_POST['project_data']) && isset($_COOKIE['form'])) {
        setcookie('form', 1, time() - 3600);
        $data = $_POST['project_data'];
        $proj_id = getProjectFromSession()['id'];
        if (!saveProject($proj_id, $data)) {
            $errors[] = 'Произошла ошибка доступа к базе данных';
        }
    }
    indexAction($errors);
}
 /**
  * Saves designer project to current theme
  */
 public function save($info)
 {
     $chunk = new Chunk();
     if (!$chunk->save($info)) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request', true, 400);
         return array();
     }
     if ($chunk->last()) {
         ProviderLog::start('save');
         ProviderLog::start('save:json decode');
         // merge and decode content
         $result = json_decode($chunk->complete(), true);
         ProviderLog::end('save:json decode');
         $thumbnails = array_key_exists('thumbnails', $result) > 0 ? $result['thumbnails'] : '';
         $cssJsSources = array_key_exists('cssJsSources', $result) > 0 ? $result['cssJsSources'] : '';
         $md5Hashes = array_key_exists('md5Hashes', $result) > 0 ? $result['md5Hashes'] : '';
         $projectData = array_key_exists('projectData', $result) > 0 ? $result['projectData'] : '';
         $images = empty($result['images']) ? null : $result['images'];
         $helper = new PreviewHelper($this->_themeDir);
         $changed_files = getPreviewChangedFiles($this->_themeDir);
         FilesHelper::deleteFile($this->_themeDir . '/css/global.min.css');
         FilesHelper::deleteFile($this->_themeDir . '/css/bootstrap.min.css');
         ProviderLog::start('Save files');
         foreach ($changed_files as $file) {
             if (has_version_in_path($file)) {
                 continue;
             }
             $path = $this->_previewThemeDir . $file;
             $themeFileDir = dirname($path);
             if (file_exists($path)) {
                 if (strpos($file, 'designer/') || strpos($file, 'designerpreview/') || strpos($file, 'blocktopmenu_mod/')) {
                     FilesHelper::copyRecursive($path, $this->_modulesDir . $file);
                 } else {
                     if (preg_match('#[\\\\/]img$#', $themeFileDir)) {
                         // file inside 'img' directory
                         FilesHelper::renameFile($path, $this->_themeDir . $file);
                     } else {
                         FilesHelper::copyRecursive($path, $this->_themeDir . $file, array($helper, "removeDataId"));
                     }
                 }
             } else {
                 $helper->removeKey($file);
                 FilesHelper::deleteFile($this->_themeDir . $file);
             }
         }
         ProviderLog::end('Save files');
         ProviderLog::start('Save images');
         $this->_processImages($this->_themeDir, $images, $changed_files);
         ProviderLog::end('Save images');
         ProviderLog::start('_fixPreviewImagePaths');
         $this->_fixPreviewImagePaths();
         ProviderLog::end('_fixPreviewImagePaths');
         ProviderLog::start('Update module files');
         // backward fix with module override files
         FilesHelper::copyRecursive($this->_modulesDir . '/designerpreview/override', FilesHelper::normalizePath(_PS_OVERRIDE_DIR_));
         FilesHelper::copyRecursive($this->_modulesDir . '/designer/override', FilesHelper::normalizePath(_PS_OVERRIDE_DIR_));
         ProviderLog::end('Update module files');
         setPreviewChangedFiles($this->_themeDir, $this->_previewThemeDir, array());
         $helper->save();
         $this->_saveThumbnails($thumbnails);
         if (!empty($projectData)) {
             saveProject($this->_themeName, $projectData);
         }
         if (!empty($cssJsSources)) {
             setThemeCache($this->_themeDir, $cssJsSources);
         }
         if (!empty($md5Hashes)) {
             setThemeHashes($this->_themeDir, $md5Hashes);
         }
         ProviderLog::start('updateTranslations');
         updateTranslations($this->_themeDir);
         ProviderLog::end('updateTranslations');
         ProviderLog::end('save');
         return array('result' => 'done', 'log' => ProviderLog::getLog());
     }
     return array('result' => 'processed');
 }
예제 #4
0
        listProject();
        break;
    case "create":
        $path = '../' . $DIR_projectsData . $projectName . '/RENDER_DATA/';
        clear($path);
        $path = '../' . $DIR_projectsData . $projectName . '/';
        clear($path);
        echo json_encode(array("code" => 0));
        break;
    case "save":
        $pathToFile = $backPath . $DIR_projectsData . $projectName . '.vejs';
        if (is_file($pathToFile)) {
            if ($_POST['forceSave'] == 'true') {
                saveProject($pathToFile, $fileContent);
                echo json_encode(array("code" => 0));
            } else {
                echo json_encode(array("code" => 1, "info" => "The file already exist"));
            }
        } else {
            saveProject($pathToFile, $fileContent);
            echo json_encode(array("code" => 0));
        }
        break;
    case "delete":
        $path = '../' . $DIR_projectsData . $projectName . '/';
        $pathToFile = $backPath . $DIR_projectsData . $projectName . '.vejs';
        echo deleteProject($path, $pathToFile);
        break;
    default:
        echo json_encode(array('code' => -1, "info" => "There are missing args"));
}
예제 #5
0
<?php

include "../universal/config.php";
//---saveProject---//
if (isset($_POST["saveProject"])) {
    include "saveProject.php";
    $result = saveProject($_POST["q"], $_POST["projectName"], $_POST["shoot"], $_POST["video"], $_POST["photo"], $_POST["copy"], $_POST["shootDate"], $_POST["dueDate"], $_POST["notes"]);
    echo $result;
}
//---deleteProject---//
if (isset($_POST["deleteProject"])) {
    include "deleteProject.php";
    $result = deleteProject($_POST["projectName"]);
    echo $result;
}