function ucm_change($id, $newid, $title, $data, $align = 'left', $mode = 'html') { $id = basename($id); $newid = basename($newid); if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $id) != '' || empty($id)) { return false; } if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $newid) != '' || empty($newid)) { return false; } if (!is_file(DF_PATH . $id . '.ucm')) { return false; } if ($id != $newid && is_file(DF_PATH . $newid . '.ucm')) { return false; } if (!file_write_contents(DF_PATH . $id . '.ucm', $title . "\n" . $align . "\n" . $data)) { return false; } rcms_rename_file(DF_PATH . $id . '.ucm', DF_PATH . $newid . '.ucm'); if ($id != $newid) { $config = file_get_contents(CONFIG_PATH . 'menus.ini'); $config = str_replace('"ucm:' . $id . '"', '"ucm:' . $newid . '"', $config); } return true; }
function articles_move($catid, $artid, $newcatid, $dir = ARTICLES_PATH) { $newartid = @file_get_contents($dir . $newcatid . '/last') + 1; $oldartprefix = $dir . $catid . '/' . $artid . '/'; $newartprefix = $dir . $newcatid . '/' . $newartid . '/'; rcms_rename_file($oldartprefix, $newartprefix); file_write_contents($dir . $newcatid . '/last', $newartid); articles_move_at_last($catid, $artid, $newcatid, $newartid, $dir); return $newartid; }
function ucm_change($curid, $newid, $title, $data, $align = 'left', $dir = MENU_MODULES_PATH) { $curid = basename($curid); $newid = basename($newid); if (is_file($dir . 'ucm.' . $curid . '/index.php')) { if (preg_replace("/[a-z0-9]*/i", '', $newid) != '' || empty($newid)) { return 5; } rcms_rename_file($dir . 'ucm.' . $curid, $dir . 'ucm.' . $newid); if (file_write_contents($dir . 'ucm.' . $newid . '/index.php', "<?php show_window('" . $title . "', file_get_contents(\$module_dir . '/data.txt'), '{$align}'); ?>") && file_write_contents($dir . 'ucm.' . $newid . '/data.txt', $data)) { $config = file_get_contents(CONFIG_PATH . 'menus.ini'); $config = str_replace('"ucm.' . $curid . '"', '"ucm.' . $newid . '"', $config); if (!file_write_contents(CONFIG_PATH . 'menus.ini', $config)) { return 6; } return 0; } else { return 6; } } else { return 6; } }
function page_change($id, $newid, $title, $text, $description, $keywords, $mode = 'html', $date) { global $system; $id = basename($id); $newid = basename($newid); if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $id) != '' || empty($id)) { return false; } if (preg_replace("/[a-z0-9\\-\\_]*/i", '', $newid) != '' || empty($newid)) { return false; } if (!is_file(PAGES_PATH . $id)) { return false; } if ($id != $newid && is_file(PAGES_PATH . $newid)) { return false; } $page = array('title' => $title, 'text' => $text, 'description' => $description, 'keywords' => $keywords, 'mode' => $mode, 'author_nick' => $system->user['nickname'], 'author_name' => $system->user['username'], 'date' => sql_to_unix_time($date)); if (!file_write_contents(PAGES_PATH . $id, serialize($page))) { return false; } rcms_rename_file(PAGES_PATH . $id, PAGES_PATH . $newid); return true; }
function scanForNewImages() { $return = array(); $new_images = $this->getImages(GALLERY_UPLOAD_DIR); foreach ($new_images as $image) { $image_newname = strtolower($image); $image_newname = translitCP1251toUTF8($image_newname); $temp_i = 0; $ext = array_reverse(explode('.', $image)); $ext = $ext[0]; while (in_array($image_newname, $this->indexes['filename']) || is_file(GALLERY_IMAGES_DIR . $image_newname)) { $temp_i++; $image_newname = substr($image, 0, -strlen($ext) - 1) . '_' . $temp_i . '.' . $ext; } if (substr($ext, 0, 2) == 'jp') { $type = 'jpeg'; } else { $type = $ext; } list($width, $height, $x, $x) = getimagesize(GALLERY_UPLOAD_DIR . $image); $size = $width . 'x' . $height; rcms_rename_file(GALLERY_UPLOAD_DIR . $image, GALLERY_IMAGES_DIR . $image_newname); $this->registerInIndex($image_newname, $image_newname, $size, $type); $return[$image] = $image_newname; } return $return; }
function moveArticleToContainer($src_container, $cat_id, $art_id, $new_container, $new_cat_id = 0) { $cat_id = (int) $cat_id; $art_id = (int) $art_id; if (!$this->setWorkContainer($src_container)) { return false; } if (!$this->setWorkContainer($new_container)) { return false; } if (!$this->setWorkContainer($src_container)) { return false; } if ($src_container == '#root' || $src_container == '#hidden') { $cat_prefix = ARTICLES_PATH . $src_container . '/'; $art_prefix = ARTICLES_PATH . $src_container . '/' . $art_id . '/'; } else { $cat_prefix = ARTICLES_PATH . $src_container . '/' . $cat_id . '/'; $art_prefix = ARTICLES_PATH . $src_container . '/' . $cat_id . '/' . $art_id . '/'; } if ($new_container == '#root' || $new_container == '#hidden') { $ncat_prefix = ARTICLES_PATH . $new_container . '/'; } else { $ncat_prefix = ARTICLES_PATH . $new_container . '/' . $new_cat_id . '/'; } if (!is_dir($art_prefix)) { $this->last_error = __('Invalid article'); return false; } if (!is_dir($ncat_prefix)) { $this->last_error = __('Invalid target category'); return false; } if ($src_container == '#root' || $src_container == '#hidden') { $data = $this->index[$art_id]; rcms_remove_index($art_id, $this->index, true); } else { $data = $this->index[$cat_id][$art_id]; rcms_remove_index($art_id, $this->index[$cat_id], true); } $this->saveIndex(); $new_art_id = @file_get_contents($ncat_prefix . 'lst') + 1; $nart_prefix = $ncat_prefix . $new_art_id . '/'; rcms_rename_file($art_prefix, $nart_prefix); file_write_contents($ncat_prefix . 'lst', file_get_contents($ncat_prefix . 'lst') + 1); if (!$this->setWorkContainer($new_container)) { return false; } if ($new_container == '#root' || $new_container == '#hidden') { $this->index[$new_art_id] = $data; } else { $this->index[$new_cat_id][$new_art_id] = $data; } return $this->saveIndex(); }
$topic_id = empty($_GET['id']) ? 0 : (int) $_GET['id']; $topics[$topic_id]['sticky'] = !$topics[$topic_id]['sticky']; if (file_write_contents(FORUM_PATH . 'topic_index.dat', serialize($topics))) { rcms_redirect('?module=' . $module . '&action=topic&id=' . $topic_id, true); $action = ''; } } elseif ($action == 'arch_topic') { $topic_id = empty($_GET['t']) ? 0 : (int) $_GET['t']; if (!empty($topics[$topic_id])) { if ($system->checkForRight('FORUM') || $system->user['username'] != 'guest' && $system->user['username'] == $topics[$topic_id]['author_name']) { $archive = @unserialize(@file_get_contents(FORUM_PATH . 'archive/topic_index.dat')); $archive[$topic_id] = $topics[$topic_id]; if (file_write_contents(FORUM_PATH . 'archive/topic_index.dat', serialize($archive))) { rcms_remove_index($topic_id, $topics, true); if (is_file(FORUM_PATH . 'topic.' . $topic_id . '.dat')) { rcms_rename_file(FORUM_PATH . 'topic.' . $topic_id . '.dat', FORUM_PATH . 'archive/topic.' . $topic_id . '.dat'); } //Не удаляем, ложим в архив! if (file_write_contents(FORUM_PATH . 'topic_index.dat', serialize($topics))) { rcms_redirect('?module=' . $module, true); $action = ''; } } } else { show_error(__('You cannot archive this topic')); } } else { show_error(__('There is no topic with this id')); } } elseif ($action == 'del_topic') { $topic_id = empty($_GET['t']) ? 0 : (int) $_GET['t'];
<br/> <?php } ?> <input type="submit" name="save" value="<?php echo __('Submit'); ?> "> </form> </td> </tr> </table> <?php } elseif (!empty($_REQUEST['rename']) && $_REQUEST['rename'] != '.') { if (!empty($_REQUEST['save'])) { rcms_rename_file($_REQUEST['path'] . $_REQUEST['rename'], $_REQUEST['path'] . $_REQUEST['newname']); rcms_showAdminMessage(__('File updated')); $_REQUEST['rename'] = $_REQUEST['newname']; } clearstatcache(); $link = $url_inc . '&rename=' . $_REQUEST['rename'] . '&path=' . $_REQUEST['path']; $backlink = $url_inc . '&path=' . $_REQUEST['path']; ?> <table border='0' cellspacing='0' cellpadding='1' width="100%"> <tr> <th><?php echo __('File manager') . ' - ' . __('Rename') . ' - ' . $_REQUEST['rename']; ?> </th> </tr> <tr>
function tpl_change($id, $newid, $title, $comment, $sender_name, $sender_email, $subject, $letter, $important, $important_text) { global $system; $id = basename($id); $newid = basename($newid); if (preg_replace("/[a-z0-9]*/i", '', $id) != '' || empty($id)) { return false; } if (preg_replace("/[a-z0-9]*/i", '', $newid) != '' || empty($newid)) { return false; } if (!is_file(SENDMAIL_PATH . $id)) { return false; } if ($id != $newid && is_file(SENDMAIL_PATH . $newid)) { return false; } $page = array('title' => $title, 'comment' => $comment, 'sender_name' => $sender_name, 'sender_email' => $sender_email, 'subject' => $subject, 'letter' => $letter, 'important' => $important, 'important_text' => $important_text); if (!file_write_contents(SENDMAIL_PATH . $id, serialize($page))) { return false; } rcms_rename_file(SENDMAIL_PATH . $id, SENDMAIL_PATH . $newid); return true; }
function page_change($curname, $curlang, $newname, $newlang, $title, $text, $dir = PAGES_PATH) { $curname = basename($curname); $curlang = basename($curlang); $newname = basename($newname); $newlang = basename($newlang); if (empty($title)) { return 3; } if (empty($text)) { return 3; } if (file_exists($dir . $curlang . '.' . $curname . '.html')) { if (preg_replace("/[a-z0-9]*/i", '', $newname) != '' || empty($newname)) { return 11; } if (preg_replace("/[a-z0-9]*/i", '', $newlang) != '' || empty($newlang)) { return 11; } rcms_rename_file($dir . $curlang . '.' . $curname . '.html', $dir . $newlang . '.' . $newname . '.html'); rcms_rename_file($dir . $curlang . '.' . $curname . '.txt', $dir . $newlang . '.' . $newname . '.txt'); $title = strip_tags($title); if (!file_write_contents($dir . $newlang . '.' . $newname . '.txt', $title)) { return 7; } if (!file_write_contents($dir . $newlang . '.' . $newname . '.html', $text)) { return 7; } return 0; } else { return 7; } }