function guestbook_add_post($file, $text, $gst_nick, $config = 'minichat.ini') { global $system; $text = trim($text); if (empty($text)) { return false; } $config = parse_ini_file(CONFIG_PATH . $config); if ($data = @file_get_contents($file)) { $data = unserialize($data); } if (empty($config['max_db_size'])) { $config['max_db_size'] = $config['messages_to_show']; } $tmp = count($data) - $config['max_db_size']; if ($tmp >= 0) { $chunk = array_chunk(array_reverse($data, true), $config['max_db_size'] - 1, true); $data = array_reverse($chunk[0], true); } $newmesg['author_username'] = $system->user["username"]; if (!LOGGED_IN && (!$config['allow_guests_enter_name'] || empty($gst_nick))) { $gst_nick = strlen($gst_nick) > $config["max_word_len"] ? '<abbr title="' . htmlspecialchars($gst_nick) . '">' . substr($gst_nick, 0, $config["max_word_len"]) . '</a>' : htmlspecialchars($gst_nick); } $newmesg['author_nickname'] = LOGGED_IN ? $system->user["nickname"] : $gst_nick; $newmesg['time'] = rcms_get_time(); $newmesg['text'] = strlen($text) > $config["max_message_len"] ? substr($text, 0, $config["max_message_len"]) : $text; $data[] = $newmesg; file_write_contents($file, serialize($data)); return true; }
function writeLine($room, $text) { //$time = gmdate("H:i:s",rcms_get_time()); $time = gmdate("Y-m-d H:i:s", rcms_get_time()); $fp = fopen(CHANNEL_PATH . $room, 'a'); fwrite($fp, '<span class="time">' . $time . '</span> | ' . $text . "\n"); fclose($fp); }
function createFile($cid, $name, $desc, $link, $size, $author) { if (empty($name)) { return false; } if (empty($this->data[$cid])) { return false; } $this->data[$cid]['files'][] = array('name' => $name, 'desc' => $desc, 'link' => $link, 'size' => $size, 'date' => rcms_get_time(), 'author' => $author, 'count' => 0); return true; }
function gallery_post_comment($id, $text) { global $system; $images = rcms_scandir(GALLERY_PATH); if ($data = @file_get_contents(GALLERY_PATH . $images[$id] . '.cm')) { $data = unserialize($data); } else { $data = array(); } $newmesg['author_user'] = $system->user["username"]; $newmesg['author_nick'] = $system->user["nickname"]; $newmesg['time'] = rcms_get_time(); $newmesg['text'] = substr($text, 0, 2048); $data[] = $newmesg; file_write_contents(GALLERY_PATH . $images[$id] . '.cm', serialize($data)); return true; }
function pm_post_msg($username, $nickname, $text, $to) { global $_CACHE, $system; $text = trim($text); if (empty($text)) { return false; } if (!getUserData($to)) { return false; } $file = DATA_PATH . '/pm/' . $to . '.dat'; make_pm_file($file); $data =& $_CACHE['gbook'][$file]; if (!isset($data)) { if (!is_readable($file) || !($data = unserialize(file_get_contents($file)))) { $data = array(); } } $newmesg['username'] = $username; $newmesg['nickname'] = htmlspecialchars($nickname); $newmesg['time'] = rcms_get_time(); $newmesg['text'] = $text; $newmesg['new'] = '1'; $data[] = $newmesg; return file_write_contents($file, serialize($data)); }
/** * * Return Year select Web From element * * @param $name name of element * @param $label text label for input * @param $br append new line - bool * @return string * */ function wf_YearSelector($name, $label = '', $br = false) { $curyear = gmdate("Y", rcms_get_time()); $inputid = wf_InputId(); $count = 5; if ($br) { $newline = '<br>'; } else { $newline = ''; } $selector = '<select name="' . $name . '">'; for ($i = 0; $i < $count; $i++) { $selector .= '<option value="' . ($curyear - $i) . '">' . ($curyear - $i) . '</option>'; } $selector .= '</select>'; if ($label != '') { $selector .= '<label for="' . $inputid . '">' . __($label) . '</label>'; } $selector .= $newline; return $selector; }
echo $style; ?> " nowrap="nowrap" align="center"> <?php echo user_create_link($topic['author_name'], $topic['author_nick']); ?> </td> <td class="<?php echo $style; ?> " nowrap="nowrap" align="center"> <?php if ($topic['last_reply'] != 0 && @$topic['last_reply_id'] != 0) { ?> <?php if (rcms_format_time('d', $topic['last_reply']) == rcms_format_time('d', rcms_get_time())) { ?> <?php echo __('Today at') . ' ' . rcms_format_time('H:i:s', $topic['last_reply']); ?> <?php } else { ?> <?php echo rcms_format_time('H:i:s d.m.Y', $topic['last_reply']); ?> <?php } ?> <?php if (!empty($topic['last_reply_author'])) {
function addComment($cat_id, $art_id, $text) { $cat_id = (int) $cat_id; $art_id = (int) $art_id; if (empty($this->container)) { $this->last_error = __('No section selected!'); return false; } global $system; 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; } $art_prefix = ARTICLES_PATH . $this->container . '/' . $cat_id . '/' . $art_id . '/'; } else { $art_prefix = ARTICLES_PATH . $this->container . '/' . $art_id . '/'; } if (is_file($art_prefix . 'define')) { if ($data = @file_get_contents($art_prefix . 'comments')) { $data = unserialize($data); } else { $data = array(); } $article_data = rcms_parse_ini_file($art_prefix . 'define'); // Forming new message $newmesg['author_user'] = $system->user['username']; $newmesg['author_nick'] = $system->user['nickname']; $newmesg['time'] = rcms_get_time(); $newmesg['text'] = substr($text, 0, 2048); $newmesg['author_ip'] = $_SERVER['REMOTE_ADDR']; // Matrix haz you neo ;) // Including new message $data[] = $newmesg; $save = serialize($data); if (!file_write_contents($art_prefix . 'comments', serialize($data))) { $this->last_error = __('Cannot write to file'); return false; } $article_data['comcount']++; if (!write_ini_file($article_data, $art_prefix . 'define')) { $this->last_error = __('Cannot write to file'); return false; } if ($this->container !== '#root' && $this->container !== '#hidden') { $this->index[$cat_id][$art_id]['ccnt']++; $this->index[$cat_id][$art_id]['lcnt'] = $newmesg['time']; } else { $this->index[$art_id]['ccnt']++; $this->index[$art_id]['lcnt'] = $newmesg['time']; } $res = $this->saveIndex(); return $res; } else { $this->last_error = __('There are no article with this ID'); return false; } }
/** * Sends e-mail. * * @param string $to * @param string $from * @param string $sender * @param string $encoding * @param string $subj * @param string $text * @return boolean */ function rcms_send_mail($to, $from, $sender, $encoding, $subj, $text, $type = 'text/plain') { if (!function_exists('mail')) { show_window(__('Error'), __('Function mail() disabled in PHP')); return false; } $headers = 'From: =?' . $encoding . '?B?' . base64_encode($sender) . '?= <' . $from . ">\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= 'Message-ID: <' . md5(uniqid(rcms_get_time())) . "@" . $sender . ">\n"; $headers .= 'Date: ' . gmdate('D, d M Y H:i:s T', rcms_get_time()) . "\n"; $headers .= "Content-type: {$type}; charset={$encoding}\n"; $headers .= "Content-transfer-encoding: 8bit\n"; $headers .= "X-Mailer: ReloadCMS\n"; $headers .= "X-MimeOLE: ReloadCMS\n"; return mail($to, '=?' . $encoding . '?B?' . base64_encode($subj) . '?=', $text, $headers); }
function statistic_register() { global $system; if (is_file(DATA_PATH . 'stats.dat')) { $stats = @file(DATA_PATH . 'stats.dat'); $stats = @unserialize($stats[0]); } $userip = $_SERVER['REMOTE_ADDR']; $referer = $_SERVER['HTTP_REFERER']; $page = $_SERVER['REQUEST_URI']; // Add popularity to referer if (!empty($referer) && ($referer = parse_url($referer))) { if (!empty($stats['ref'][$referer['host']])) { $stats['ref'][$referer['host']]++; } else { $stats['ref'][$referer['host']] = 1; } } //Add popularity to page if (!empty($stats['popular'][$page])) { $stats['popular'][$page]++; } else { $stats['popular'][$page] = 1; } // Register last user's visit time $stats['ips'][$userip] = time(); // Register user in total hits count if (!empty($stats['totalhits'])) { $stats['totalhits']++; } else { $stats['totalhits'] = 1; } // Check the last update time if (!empty($stats['update']) && $stats['update'] < mktime(0, 0, 0, date('n'), date('j'), date('Y'))) { if (!empty($stats['ref'])) { unset($stats['ref']); // Remove yestarday's referers } unset($stats['todayhits']); // Remove yestarday's hits unset($stats['todayhosts']); // Remove yestarday's hosts } if (!empty($stats['todayhits'])) { $stats['todayhits']++; } else { $stats['todayhits'] = 1; } // Today hosts counter if (!empty($stats['todayhosts'][$userip])) { $stats['todayhosts'][$userip]++; } else { $stats['todayhosts'][$userip] = 1; } // Online users $stats['online'][$userip]['name'] = $system->user['username']; $stats['online'][$userip]['nick'] = $system->user['nickname']; $stats['online'][$userip]['time'] = rcms_get_time(); $online = array(); $registered_already = array(); if (!empty($stats['online'])) { foreach ($stats['online'] as $ip => $data) { if ($data['time'] > rcms_get_time() - 5 * 60 && !in_array($data['name'], $registered_already)) { $online[$ip] = $data; $registered_already[] = $data['name']; } } } $stats['online'] = $online; // Update time's update $stats['update'] = rcms_get_time(); @file_write_contents(DATA_PATH . 'stats.dat', serialize($stats)); return true; }
theme_advanced_toolbar_location : \'top\', theme_advanced_toolbar_align : \'left\', theme_advanced_statusbar_location : \'bottom\', theme_advanced_resizing : true, paste_auto_cleanup_on_paste : true, content_css: \'/css/tinymce.css\', extended_valid_elements : \'script[type|language|src]\', forced_root_block : \'\', force_br_newlines : true, force_p_newlines : false }); $(\'table.bb_editor\').hide();} else { tinyMCE.get(\'text\').hide(); $(\'table.bb_editor\').show(); }"'), 'top'); $frm->addrow(__('Date') . ' (yyyy-mm-dd hh:mm:ss)', $frm->text_box('date', gmdate("Y-m-d H:i:s", rcms_get_time())), 'top'); $frm->show(); } elseif ($edited = post('edit', get('page'))) { if ($page = page_get($edited)) { $frm = new InputForm('', 'post', __('Submit'), '', '', '', 'edit'); $frm->addbreak(__('Edit article')); $frm->hidden('edit', $edited); $frm->hidden('save', '1'); $frm->addrow('<abbr title="' . __('Use only small Latin letters and digits') . '">' . __('MenuID') . '</abbr>', $frm->text_box('id', $edited)); $frm->addrow(__('Title'), $frm->text_box('title', $page['title'])); if (empty($page['description'])) { $page['description'] = $page['title']; } $frm->addrow(__('Description for search engines'), $frm->text_box('description', $page['description'])); if (empty($page['keywords'])) { $page['keywords'] = '';
} else { show_error(__('Message text or title are empty')); } } } if (!empty($_POST['new_post_perform'])) { $new_post_text = empty($_POST['new_post_text']) ? '' : $_POST['new_post_text']; $topic_id = empty($_POST['new_post_topic']) ? 0 : (int) $_POST['new_post_topic']; if (isset($sysconfig['forum-guest']) and !LOGGED_IN) { show_error(__('You are not logined!')); } else { if (!empty($new_post_text)) { if (!empty($topics[$topic_id])) { if (mb_strlen($new_post_text) <= $max_message_len) { if (!$topics[$topic_id]['closed']) { $time = rcms_get_time(); $topics[$topic_id]['replies']++; $topics[$topic_id]['last_reply'] = $time; $topics[$topic_id]['last_reply_author'] = $system->user['nickname']; $posts = @unserialize(@file_get_contents(FORUM_PATH . 'topic.' . $topic_id . '.dat')); if (!is_array($posts)) { $posts = array(); } $keys = array_keys($posts); rsort($keys, SORT_NUMERIC); if (empty($keys[0])) { $keys[0] = 0; } $post_id = $keys[0] + 1; $posts[$post_id] = array('author_nick' => $system->user['nickname'], 'author_name' => $system->user['username'], 'date' => $time, 'author_ip' => $_SERVER['REMOTE_ADDR'], 'text' => $new_post_text); $topics[$topic_id]['last_reply_id'] = $post_id;
function statistic_register() { global $system; if (is_file(DATA_PATH . 'stats.dat')) { $stats = @file(DATA_PATH . 'stats.dat'); $stats = @unserialize($stats[0]); } $useragent = $_SERVER['HTTP_USER_AGENT']; $userip = $_SERVER['REMOTE_ADDR']; //$referer = $_SERVER['HTTP_REFERER']; $page = $_SERVER['REQUEST_URI']; // Add popularity to browser if (!empty($stats['ua'][$useragent])) { $stats['ua'][$useragent]++; } else { $stats['ua'][$useragent] = 1; } // Add popularity to page if (!empty($stats['popular'][$page])) { $stats['popular'][$page]++; } else { $stats['popular'][$page] = 1; } // Register last user's visit time $stats['ips'][$userip] = time(); // Register user in total hits count if (!empty($stats['totalhits'])) { $stats['totalhits']++; } else { $stats['totalhits'] = 1; } // Check the last update time if (!empty($stats['update']) && $stats['update'] < mktime(0, 0, 0, date('n'), date('j'), date('Y'))) { unset($stats['todayhits']); // Remove yestarday's hits unset($stats['todayhosts']); // Remove yestarday's hosts } if (!empty($stats['todayhits'])) { $stats['todayhits']++; } else { $stats['todayhits'] = 1; } if (empty($stats['todayhosts'][$userip])) { $stats['todayhosts'][$userip] = true; } // Online users if ($system->user['username'] != 'guest') { $stats['online'][$system->user['username']]['nick'] = $system->user['nickname']; $stats['online'][$system->user['username']]['time'] = rcms_get_time(); } $online = array(); if (!empty($stats['online'])) { foreach ($stats['online'] as $name => $data) { if ($data['time'] > rcms_get_time() - 15 * 60) { $online[$name] = $data; } } $stats['online'] = $online; } // Update time's update $stats['update'] = time(); @file_write_contents(DATA_PATH . 'stats.dat', serialize($stats)); return true; }
function articles_post_comment($catid, $artid, $text, $dir = ARTICLES_PATH) { global $system; if (!is_file($dir . $catid . '/access')) { $minlevel = 0; } else { $minlevel = (int) file_get_contents($dir . $catid . '/access'); } if ($minlevel > @$system->user['accesslevel'] && !$system->checkForRight('-any-')) { return false; } if ($data = @file_get_contents($dir . $catid . '/' . $artid . '/comments')) { $data = unserialize($data); } else { $data = array(); } $article_data = parse_ini_file($dir . $catid . '/' . $artid . '/define'); $newmesg['author_user'] = $system->user["username"]; $newmesg['author_nick'] = $system->user["nickname"]; $newmesg['time'] = rcms_get_time(); $newmesg['text'] = substr($text, 0, 2048); $data[] = $newmesg; $save = serialize($data); file_write_contents($dir . $catid . '/' . $artid . '/comments', $save); $article_data['comcount']++; write_ini_file($article_data, $dir . $catid . '/' . $artid . '/define'); return true; }
} switch ($lightbox_config['folders']) { case 'user': $folder .= $user . '/'; break; case 'user_year': $folder .= $user . '/' . rcms_format_time('Y', rcms_get_time()) . '/'; 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'])) {
<?php //////////////////////////////////////////////////////////////////////////////// // Copyright (C) ReloadCMS Development Team // // http://reloadcms.com // // This product released under GNU General Public License v2 // //////////////////////////////////////////////////////////////////////////////// global $lang; $articles = new articles(); $current_year = rcms_format_time('Y', rcms_get_time()); $current_month = rcms_format_time('n', rcms_get_time()); if (!empty($_POST['cal-year']) && $_POST['cal-year'] >= $current_year - 6 && $_POST['cal-year'] <= $current_year) { $selected_year = $_POST['cal-year']; } else { $selected_year = $current_year; } if (!empty($_POST['cal-month']) && $_POST['cal-month'] >= 1 && $_POST['cal-month'] <= 12) { $selected_month = $_POST['cal-month']; } else { $selected_month = $current_month; } $calendar = new calendar($selected_month, $selected_year); foreach ($articles->getContainers(0) as $container => $null) { $articles->setWorkContainer($container); if ($list = $articles->getStat('time')) { foreach ($list as $id => $time) { $id = explode('.', $id); if (rcms_format_time('n', $time) == $selected_month && rcms_format_time('Y', $time) == $selected_year) { $calendar->assignEvent(rcms_format_time('d', $time), '?module=articles&from=' . mktime(0, 0, 0, $selected_month, rcms_format_time('d', $time), $selected_year) . '&until=' . mktime(23, 59, 59, $selected_month, rcms_format_time('d', $time), $selected_year)); } }
function post_message($username, $nickname, $text, $file = RCMS_GB_DEFAULT_FILE, $config = 'comments.ini') { global $_CACHE, $comment_config; $text = trim($text); if (empty($text)) { return false; } $comment_config = parse_ini_file(CONFIG_PATH . $config); $data =& $_CACHE['gbook'][$file]; if (!isset($data)) { if (!is_readable($file) || !($data = unserialize(file_get_contents($file)))) { $data = array(); } } if (!empty($comment_config['max_db_size'])) { $data = array_slice($data, -$comment_config['max_db_size'] + 1); } $newmesg['username'] = $username; $newmesg['nickname'] = !empty($comment_config['max_word_len']) && mb_strlen($nickname) > $comment_config['max_word_len'] ? '<abbr title="' . htmlspecialchars($nickname) . '">' . mb_substr($nickname, 0, $comment_config['max_word_len']) . '</abbr>' : htmlspecialchars($nickname); $newmesg['time'] = rcms_get_time(); $newmesg['text'] = mb_strlen($text) > $comment_config['max_message_len'] ? mb_substr($text, 0, $comment_config['max_message_len']) : $text; $data[] = $newmesg; return file_write_contents($file, serialize($data)); }
function downloads_create_file($cid, $name, $desc, $link, $size, $author, $file) { if (empty($name)) { return false; } if (($data = download_get_data_file($file)) === false) { return false; } if (empty($data[$cid])) { return false; } $data[$cid]['files'][] = array('name' => $name, 'desc' => $desc, 'link' => $link, 'size' => $size, 'date' => rcms_get_time(), 'author' => $author); if (!download_save_data_file($file, $data)) { return false; } return true; }