function rcms_mkdir($dir) { if (!is_dir($dir)) { if (!is_dir(dirname($dir))) { rcms_mkdir(dirname($dir)); } } return @mkdir($dir, 0777); }
function rcms_mkdir($dir) { if (defined('SAFEMODE_HACK') && SAFEMODE_HACK) { $url = parse_url(SAFEMODE_HACK_FTP); if ($url['scheme'] != 'ftp') { return false; } return rcms_ftp_mkdir($dir, $url['host'], $url['user'], $url['pass'], '.' . $url['path']); } if (!@is_dir($dir)) { if (!@is_dir(dirname($dir))) { rcms_mkdir(dirname($dir)); } } return @mkdir($dir, 0777); }
function ucm_create($id, $title, $data, $align = 'left', $dir = MENU_MODULES_PATH) { $id = basename(trim($id)); if (preg_replace("/[a-z0-9]*/i", '', $id) != '' || empty($id)) { return 5; } $workdir = $dir . 'ucm.' . $id . '/'; if (!rcms_mkdir($workdir)) { return 6; } if (file_write_contents($workdir . 'index.php', "<?php show_window('" . $title . "', file_get_contents(\$module_dir . '/data.txt'), '{$align}'); ?>") && file_write_contents($workdir . 'data.txt', $data)) { return 0; } else { return 6; } }
return true; } else { return false; } } if (!user_can_upload_images()) { return false; } $start_path = realpath(RCMS_ROOT_PATH . 'uploads/'); if (!empty($lightbox_config['distribute_enable'])) { if (!cfr('GENERAL')) { $start_path .= $system->user['username']; } if (!@is_dir($start_path)) { $msg = __('Nothing founded'); rcms_mkdir(RCMS_ROOT_PATH . 'uploads/' . $system->user['username']); //rcms_redirect(''); } } if (empty($_GET['path'])) { $user_path = $start_path; } else { $user_path = realpath($_GET['path']); if (strlen($start_path) > strlen($user_path)) { $user_path = $start_path; } } $user_path = str_replace('\\', '/', $user_path) . '/'; if (user_can_delete(get('delete'))) { if (!rcms_delete_files($user_path . $_GET['delete'], true)) { $msg .= __('Error occurred') . ' ' . $_GET['delete'];
break; case 'user_year_month': $folder .= $user . '/' . rcms_format_time('Y/m', rcms_get_time()) . '/'; break; case 'year': $folder .= rcms_format_time('Y', rcms_get_time()) . '/'; break; case 'year_month': $folder .= rcms_format_time('Y/m', rcms_get_time()) . '/'; break; default: break; } } if (!is_dir($folder)) { rcms_mkdir($folder); } } //Напоследок вырежем небезопасные символы и заменим русские буквы и пробелы в названии картинки на транслит $filename = $folder . $u . make_safe_filename($_FILES['uploadfile']['name']); //Включено управление контроля картинок? if (!empty($lightbox_config['change_enable'])) { //Размер правильный? if (!empty($lightbox_config['max_size'])) { if ($lightbox_config['max_size'] * 1000000 < filesize($_FILES['uploadfile']['tmp_name'])) { echo __('Error') . '! ' . __('Max size') . ': ' . $lightbox_config['max_size'] . ' Mb'; return false; } } //Ширина? if (!empty($lightbox_config['max_width']) && $lightbox_config['max_width'] < $size[0]) {
function saveArticle($cat_id, $art_id, $title, $src, $keywords, $sef_desc, $desc, $text, $mode = 'text', $comments = 'yes') { $cat_id = (int) $cat_id; $art_id = (int) $art_id; global $system; if (empty($this->container)) { $this->last_error = __('No section selected!'); return false; } $new_flag = $art_id == 0; if ($this->container !== '#root' && $this->container !== '#hidden') { if (!($category = $this->getCategory($cat_id))) { return false; } if ($category['accesslevel'] > (int) @$system->user['accesslevel'] && !$system->checkForRight('-any-')) { $this->last_error = __('Access denied'); return false; } $cat_prefix = ARTICLES_PATH . $this->container . '/' . $cat_id . '/'; if ($new_flag) { $art_id = @file_get_contents($cat_prefix . 'lst') + 1; } $art_prefix = ARTICLES_PATH . $this->container . '/' . $cat_id . '/' . $art_id . '/'; $art_data =& $this->articles[$this->container][$cat_id][$art_id]; } else { $cat_prefix = ARTICLES_PATH . $this->container . '/'; if ($new_flag) { $art_id = @file_get_contents($cat_prefix . 'lst') + 1; } $art_prefix = ARTICLES_PATH . $this->container . '/' . $art_id . '/'; $art_data =& $this->articles[$this->container][$art_id]; } // For security reasons all html will be striped off $title = str_replace('"', '"', trim(strip_tags($title))); $src = trim(strip_tags($src)); $text = trim($text); $desc = trim($desc); // Now check for empty fields if (empty($title)) { $this->last_error = __('Title is empty'); return false; } if (empty($src)) { $src = "-"; } if (empty($text) && empty($desc)) { $this->last_error = __('Text is empty'); return false; } if (empty($desc)) { $desc = substr($text, 0, 250) . (strlen($text) > 250 ? ' ...' : ''); } if (!$new_flag && ($old = $this->getArticle($cat_id, $art_id, false, false, false, false)) === false) { $this->last_error = __('There are no article with this ID'); return false; } if (!is_dir($art_prefix)) { rcms_mkdir($art_prefix); } // Writing files if ($new_flag) { $add_data = array('author_nick' => $system->user['nickname'], 'author_name' => $system->user['username'], 'time' => rcms_get_time()); } else { $add_data = array('author_nick' => $old['author_nick'], 'author_name' => $old['author_name'], 'time' => $old['time']); } if (!write_ini_file(array_merge(array('title' => $title, 'src' => $src, 'keywords' => strip_tags($keywords), 'sef_desc' => strip_tags($sef_desc), 'comments' => $comments, 'views' => !$new_flag ? $old['views'] : 0, 'mode' => $mode, 'comcount' => !$new_flag ? $old['comcount'] : 0), $add_data), $art_prefix . 'define') || !file_write_contents($art_prefix . 'short', $desc) || !file_write_contents($art_prefix . 'full', $text)) { $this->last_error = __('Error while saving article'); return false; } if ($new_flag && !file_write_contents($cat_prefix . 'lst', $art_id)) { $this->last_error = __('Cannot update last article flag'); return false; } if ($this->container !== '#root' && $this->container !== '#hidden') { $this->index[$cat_id][$art_id]['time'] = $add_data['time']; $this->index[$cat_id][$art_id]['ccnt'] = !$new_flag ? $old['comcount'] : 0; $this->index[$cat_id][$art_id]['view'] = !$new_flag ? $old['views'] : 0; if ($new_flag) { $this->index[$cat_id][$art_id]['lcnt'] = 0; } } else { $this->index[$art_id]['time'] = $add_data['time']; $this->index[$art_id]['ccnt'] = !$new_flag ? $old['comcount'] : 0; $this->index[$art_id]['view'] = !$new_flag ? $old['views'] : 0; if ($new_flag) { $this->index[$art_id]['lcnt'] = 0; } } $_SESSION['art_id'] = $art_id; return $this->saveIndex(); }
<?php /* Support chat All features in one file. */ //Preparations define('RCMS_ROOT_PATH', './'); define('AJAX', true); include RCMS_ROOT_PATH . 'common.php'; define('CHANNEL_PATH', RCMS_ROOT_PATH . 'content/support/'); if (!is_dir(CHANNEL_PATH)) { rcms_mkdir(CHANNEL_PATH); } $nickname = $system->user['nickname']; //Добавить возможность к каналу выбора его владельца. Посторонние не должны видеть канал. Админ видит все каналы. if (cfr('GENERAL')) { $channel = isset($_POST['channel']) ? preg_replace("/[^a-z0-9]/i", '', $_POST['channel']) : 'general'; } else { $channel = $nickname; } //Main logic if (isset($_POST['action'])) { switch ($_POST['action']) { //User case 'join': writeLine($channel, '<span><b>' . $nickname . '</b> has entered the chatroom</span>'); break; case 'send': $text = strip_tags($_POST['text']); writeLine($channel, $text);
function articles_creare_category($title, $desc = '', $icon = array(), $access = 0, $dir = ARTICLES_PATH) { // If title is empty we cannot create category if (empty($title)) { return 4; } // So let's get new category id and create directory for category $categories = rcms_scandir($dir, '', 'dir'); $catid = 1; while (is_dir($dir . $catid)) { $catid++; } $catprefix = $dir . $catid . '/'; rcms_mkdir($catprefix); // Now we can safely create category files file_write_contents($catprefix . 'title', $title); file_write_contents($catprefix . 'description', $desc); file_write_contents($catprefix . 'access', $access); file_write_contents($catprefix . 'last', '0'); // If there is an icon uploaded let's parse it if (!empty($icon) && empty($icon['error'])) { $icon['name'] = basename($icon['name']); $icon['tmp'] = explode('.', $icon['name']); if ($icon['type'] == 'image/gif' || $icon['type'] == 'image/jpeg' || $icon['type'] == 'image/png') { move_uploaded_file($icon['tmp_name'], $catprefix . 'icon.' . $icon['tmp'][count($icon['tmp']) - 1]); } else { return 6; } } return 0; }
// Copyright (C) ReloadCMS Development Team // // http://reloadcms.com // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// //Preparations $name_dir = DATA_PATH . 'emailing/names/'; if (is_dir($name_dir)) { $skins_name = rcms_scandir($name_dir); } else { rcms_mkdir($name_dir); } $mail_dir = DATA_PATH . 'emailing/emails/'; if (is_dir($mail_dir)) { $skins_email = rcms_scandir($mail_dir); } else { rcms_mkdir($mail_dir); } //Send emails by names if (!empty($_POST['name'])) { $_list = explode(',', $_POST['to']); $list = array(); foreach ($_list as $user_mask) { $user_mask = trim($user_mask); $users = user_get_list($user_mask); foreach ($users as $userdata) { $list[] = $userdata['email']; } } if (!empty($list) && !empty($_POST['subj']) && !empty($_POST['body'])) { $to = implode(';', $list); rcms_send_mail($to, $system->user['email'], $system->user['nickname'], $system->config['encoding'], $_POST['subj'], $_POST['body']);
$msg = ''; if (!empty($_FILES['upload'])) { if (!empty($_FILES['upload']['name'])) { $_FILES['upload']['name'] = str_replace('%', '', $_FILES['upload']['name']); if (!move_uploaded_file($_FILES['upload']['tmp_name'], $_REQUEST['path'] . $_FILES['upload']['name'])) { $msg = __('Error occurred'); } else { $msg = __('Files uploaded'); } } } elseif (!empty($_REQUEST['delete']) && $_REQUEST['delete'] != '.') { if (!rcms_delete_files($_REQUEST['path'] . $_REQUEST['delete'], true)) { $msg = __('Error occurred'); } } elseif (!empty($_REQUEST['mkdir'])) { if (!rcms_mkdir($_REQUEST['path'] . $_REQUEST['dirname'])) { $msg = __('Error occurred'); } } elseif (!empty($_REQUEST['mkfile'])) { if (!($fp = fopen($_REQUEST['path'] . $_REQUEST['filename'], "w"))) { $msg = __('Error occurred'); } else { fclose($fp); } } ?> <table border='0' cellspacing='0' cellpadding='1' width="100%"> <tr> <th colspan="2"><?php echo __('File manager'); echo !empty($_REQUEST['path']) ? ' - ' . $_REQUEST['path'] : '';