@unlink($dest); throw $e; } @unlink($dest); http::redirect('langs.php?added=' . $ret_code); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Upload a language pack if ($is_writable && !empty($_POST['upload_pkg'])) { try { if (empty($_POST['your_pwd']) || !$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) { throw new Exception(__('Password verification failed')); } files::uploadStatus($_FILES['pkg_file']); $dest = DC_L10N_ROOT . '/' . $_FILES['pkg_file']['name']; if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { throw new Exception(__('Unable to move uploaded file.')); } try { $ret_code = dc_lang_install($dest); } catch (Exception $e) { @unlink($dest); throw $e; } @unlink($dest); http::redirect('langs.php?added=' . $ret_code); } catch (Exception $e) { $core->error->add($e->getMessage()); }
public function process($do) { if ($do == 'single' || $do == 'full') { $this->status = $do; return; } $to_unlink = false; # Single blog import $files = $this->getPublicFiles(); $single_upl = null; if (!empty($_POST['public_single_file']) && in_array($_POST['public_single_file'], $files)) { $single_upl = false; } elseif (!empty($_FILES['up_single_file'])) { $single_upl = true; } if ($single_upl !== null) { if ($single_upl) { files::uploadStatus($_FILES['up_single_file']); $file = DC_TPL_CACHE . '/' . md5(uniqid()); if (!move_uploaded_file($_FILES['up_single_file']['tmp_name'], $file)) { throw new Exception(__('Unable to move uploaded file.')); } $to_unlink = true; } else { $file = $_POST['public_single_file']; } try { $bk = new dcImport($this->core, $file); $bk->importSingle(); } catch (Exception $e) { if ($to_unlink) { @unlink($file); } throw $e; } if ($to_unlink) { @unlink($file); } http::redirect($this->getURL() . '&do=single'); } # Full import $full_upl = null; if (!empty($_POST['public_full_file']) && in_array($_POST['public_full_file'], $files)) { $full_upl = false; } elseif (!empty($_FILES['up_full_file'])) { $full_upl = true; } if ($full_upl !== null && $this->core->auth->isSuperAdmin()) { if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) { throw new Exception(__('Password verification failed')); } if ($full_upl) { files::uploadStatus($_FILES['up_full_file']); $file = DC_TPL_CACHE . '/' . md5(uniqid()); if (!move_uploaded_file($_FILES['up_full_file']['tmp_name'], $file)) { throw new Exception(__('Unable to move uploaded file.')); } $to_unlink = true; } else { $file = $_POST['public_full_file']; } try { $bk = new dcImport($this->core, $file); $bk->importFull(); } catch (Exception $e) { if ($to_unlink) { @unlink($file); } throw $e; } if ($to_unlink) { @unlink($file); } http::redirect($this->getURL() . '&do=full'); } header('content-type:text/plain'); var_dump($_POST); exit; $this->status = true; }
$blowup_user['post_title_c'] = dcThemeConfig::adjustColor($_POST['post_title_c']); $blowup_user['post_comment_c'] = dcThemeConfig::adjustColor($_POST['post_comment_c']); $blowup_user['post_commentmy_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_c']); $blowup_user['footer_f'] = $_POST['footer_f']; $blowup_user['footer_s'] = dcThemeConfig::adjustFontSize($_POST['footer_s']); $blowup_user['footer_c'] = dcThemeConfig::adjustColor($_POST['footer_c']); $blowup_user['footer_l_c'] = dcThemeConfig::adjustColor($_POST['footer_l_c']); $blowup_user['footer_bg_c'] = dcThemeConfig::adjustColor($_POST['footer_bg_c']); $blowup_user['extra_css'] = dcThemeConfig::cleanCSS($_POST['extra_css']); if ($can_write_images) { $uploaded = null; if ($blowup_user['uploaded'] && is_file(blowupConfig::imagesPath() . '/' . $blowup_user['uploaded'])) { $uploaded = blowupConfig::imagesPath() . '/' . $blowup_user['uploaded']; } if (!empty($_FILES['upfile']) && !empty($_FILES['upfile']['name'])) { files::uploadStatus($_FILES['upfile']); $uploaded = blowupConfig::uploadImage($_FILES['upfile']); $blowup_user['uploaded'] = basename($uploaded); } $blowup_user['top_image'] = in_array($_POST['top_image'], $top_images) ? $_POST['top_image'] : 'default'; $blowup_user['body_bg_c'] = dcThemeConfig::adjustColor($_POST['body_bg_c']); $blowup_user['body_bg_g'] = in_array($_POST['body_bg_g'], $gradient_types) ? $_POST['body_bg_g'] : ''; $blowup_user['post_comment_bg_c'] = dcThemeConfig::adjustColor($_POST['post_comment_bg_c']); $blowup_user['post_commentmy_bg_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_bg_c']); $blowup_user['prelude_c'] = dcThemeConfig::adjustColor($_POST['prelude_c']); blowupConfig::createImages($blowup_user, $uploaded); } if ($can_write_css) { blowupConfig::createCss($blowup_user); } $core->blog->settings->addNamespace('themes');
if (!defined('DC_CONTEXT_ADMIN')) { return; } $blogroll = new dcBlogroll($core->blog); if (!empty($_REQUEST['edit']) && !empty($_REQUEST['id'])) { include dirname(__FILE__) . '/edit.php'; return; } $default_tab = ''; $link_title = $link_href = $link_desc = $link_lang = ''; $cat_title = ''; # Import links if (!empty($_POST['import_links']) && !empty($_FILES['links_file'])) { $default_tab = 'import-links'; try { files::uploadStatus($_FILES['links_file']); $ifile = DC_TPL_CACHE . '/' . md5(uniqid()); if (!move_uploaded_file($_FILES['links_file']['tmp_name'], $ifile)) { throw new Exception(__('Unable to move uploaded file.')); } require_once dirname(__FILE__) . '/class.dc.importblogroll.php'; try { $imported = dcImportBlogroll::loadFile($ifile); @unlink($ifile); } catch (Exception $e) { @unlink($ifile); throw $e; } if (empty($imported)) { unset($imported); throw new Exception(__('Nothing to import'));
$upfile = array('name' => $_FILES['upfile']['name'][0], 'type' => $_FILES['upfile']['type'][0], 'tmp_name' => $_FILES['upfile']['tmp_name'][0], 'error' => $_FILES['upfile']['error'][0], 'size' => $_FILES['upfile']['size'][0]); if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) { header('Content-type: application/json'); $message = array(); try { files::uploadStatus($upfile); $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']); $message['files'][] = array('name' => $upfile['name'], 'size' => $upfile['size'], 'html' => mediaItemLine($core->media->getFile($new_file_id), 1, $query)); } catch (Exception $e) { $message['files'][] = array('name' => $upfile['name'], 'size' => $upfile['size'], 'error' => $e->getMessage()); } echo json_encode($message); exit; } else { try { files::uploadStatus($upfile); $f_title = isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : ''; $f_private = isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false; $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private); dcPage::addSuccessNotice(__('Files have been successfully uploaded.')); $core->adminurl->redirect('admin.media', $page_url_params); } catch (Exception $e) { $core->error->add($e->getMessage()); } } } # Removing items if ($dir && !empty($_POST['medias']) && !empty($_POST['delete_medias'])) { try { foreach ($_POST['medias'] as $media) { $core->media->removeItem(rawurldecode($media));
public function doActions() { if (empty($_POST) || !empty($_REQUEST['conf']) || !$this->isWritablePath()) { return null; } $modules = !empty($_POST['modules']) && is_array($_POST['modules']) ? array_values($_POST['modules']) : array(); if (!empty($_POST['select'])) { # Can select only one theme at a time! if (is_array($_POST['select'])) { $modules = array_keys($_POST['select']); $id = $modules[0]; if (!$this->modules->moduleExists($id)) { throw new Exception(__('No such theme.')); } $this->core->blog->settings->addNamespace('system'); $this->core->blog->settings->system->put('theme', $id); $this->core->blog->triggerBlog(); dcPage::addSuccessNotice(__('Theme has been successfully selected.')); http::redirect($this->getURL() . '#themes'); } } elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['activate'])) { if (is_array($_POST['activate'])) { $modules = array_keys($_POST['activate']); } $list = $this->modules->getDisabledModules(); if (empty($list)) { throw new Exception(__('No such theme.')); } $count = 0; foreach ($list as $id => $module) { if (!in_array($id, $modules)) { continue; } # --BEHAVIOR-- themeBeforeActivate $this->core->callBehavior('themeBeforeActivate', $id); $this->modules->activateModule($id); # --BEHAVIOR-- themeAfterActivate $this->core->callBehavior('themeAfterActivate', $id); $count++; } dcPage::addSuccessNotice(__('Theme has been successfully activated.', 'Themes have been successuflly activated.', $count)); http::redirect($this->getURL()); } elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['deactivate'])) { if (is_array($_POST['deactivate'])) { $modules = array_keys($_POST['deactivate']); } $list = $this->modules->getModules(); if (empty($list)) { throw new Exception(__('No such theme.')); } $failed = false; $count = 0; foreach ($list as $id => $module) { if (!in_array($id, $modules)) { continue; } if (!$module['root_writable']) { $failed = true; continue; } $module[$id] = $id; # --BEHAVIOR-- themeBeforeDeactivate $this->core->callBehavior('themeBeforeDeactivate', $module); $this->modules->deactivateModule($id); # --BEHAVIOR-- themeAfterDeactivate $this->core->callBehavior('themeAfterDeactivate', $module); $count++; } if ($failed) { dcPage::addWarningNotice(__('Some themes have not been deactivated.')); } else { dcPage::addSuccessNotice(__('Theme has been successfully deactivated.', 'Themes have been successuflly deactivated.', $count)); } http::redirect($this->getURL()); } elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['delete'])) { if (is_array($_POST['delete'])) { $modules = array_keys($_POST['delete']); } $list = $this->modules->getDisabledModules(); $failed = false; $count = 0; foreach ($modules as $id) { if (!isset($list[$id])) { if (!$this->modules->moduleExists($id)) { throw new Exception(__('No such theme.')); } $module = $this->modules->getModules($id); $module['id'] = $id; if (!$this->isDeletablePath($module['root'])) { $failed = true; continue; } # --BEHAVIOR-- themeBeforeDelete $this->core->callBehavior('themeBeforeDelete', $module); $this->modules->deleteModule($id); # --BEHAVIOR-- themeAfterDelete $this->core->callBehavior('themeAfterDelete', $module); } else { $this->modules->deleteModule($id, true); } $count++; } if (!$count && $failed) { throw new Exception(__("You don't have permissions to delete this theme.")); } elseif ($failed) { dcPage::addWarningNotice(__('Some themes have not been delete.')); } else { dcPage::addSuccessNotice(__('Theme has been successfully deleted.', 'Themes have been successuflly deleted.', $count)); } http::redirect($this->getURL()); } elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['install'])) { if (is_array($_POST['install'])) { $modules = array_keys($_POST['install']); } $list = $this->store->get(); if (empty($list)) { throw new Exception(__('No such theme.')); } $count = 0; foreach ($list as $id => $module) { if (!in_array($id, $modules)) { continue; } $dest = $this->getPath() . '/' . basename($module['file']); # --BEHAVIOR-- themeBeforeAdd $this->core->callBehavior('themeBeforeAdd', $module); $this->store->process($module['file'], $dest); # --BEHAVIOR-- themeAfterAdd $this->core->callBehavior('themeAfterAdd', $module); $count++; } dcPage::addSuccessNotice(__('Theme has been successfully installed.', 'Themes have been successuflly installed.', $count)); http::redirect($this->getURL()); } elseif ($this->core->auth->isSuperAdmin() && !empty($_POST['update'])) { if (is_array($_POST['update'])) { $modules = array_keys($_POST['update']); } $list = $this->store->get(true); if (empty($list)) { throw new Exception(__('No such theme.')); } $count = 0; foreach ($list as $module) { if (!in_array($module['id'], $modules)) { continue; } $dest = $module['root'] . '/../' . basename($module['file']); # --BEHAVIOR-- themeBeforeUpdate $this->core->callBehavior('themeBeforeUpdate', $module); $this->store->process($module['file'], $dest); # --BEHAVIOR-- themeAfterUpdate $this->core->callBehavior('themeAfterUpdate', $module); $count++; } $tab = $count && $count == count($list) ? '#themes' : '#update'; dcPage::addSuccessNotice(__('Theme has been successfully updated.', 'Themes have been successuflly updated.', $count)); http::redirect($this->getURL() . $tab); } elseif (!empty($_POST['upload_pkg']) && !empty($_FILES['pkg_file']) || !empty($_POST['fetch_pkg']) && !empty($_POST['pkg_url'])) { if (empty($_POST['your_pwd']) || !$this->core->auth->checkPassword($this->core->auth->crypt($_POST['your_pwd']))) { throw new Exception(__('Password verification failed')); } if (!empty($_POST['upload_pkg'])) { files::uploadStatus($_FILES['pkg_file']); $dest = $this->getPath() . '/' . $_FILES['pkg_file']['name']; if (!move_uploaded_file($_FILES['pkg_file']['tmp_name'], $dest)) { throw new Exception(__('Unable to move uploaded file.')); } } else { $url = urldecode($_POST['pkg_url']); $dest = $this->getPath() . '/' . basename($url); $this->store->download($url, $dest); } # --BEHAVIOR-- themeBeforeAdd $this->core->callBehavior('themeBeforeAdd', null); $ret_code = $this->store->install($dest); # --BEHAVIOR-- themeAfterAdd $this->core->callBehavior('themeAfterAdd', null); dcPage::addSuccessNotice($ret_code == 2 ? __('Theme has been successfully updated.') : __('Theme has been successfully installed.')); http::redirect($this->getURL() . '#themes'); } else { # --BEHAVIOR-- adminModulesListDoActions $this->core->callBehavior('adminModulesListDoActions', $this, $modules, 'theme'); } return null; }