Beispiel #1
1
function multinet_rebuild_globalconf()
{
    global $ubillingConfig;
    $altCfg = $ubillingConfig->getAlter();
    $global_template = file_get_contents("config/dhcp/global.template");
    $subnets_template = file_get_contents("config/dhcp/subnets.template");
    $alldhcpsubnets_q = "SELECT `id`,`netid` from `dhcp` ORDER BY `id` ASC";
    $alldhcpsubnets = simple_queryall($alldhcpsubnets_q);
    $allMembers_q = "SELECT `ip` from `nethosts` WHERE `option` != 'NULL'";
    $allMembers = simple_queryall($allMembers_q);
    $membersMacroContent = '';
    $vlanMembersMacroContent = '';
    $onuMembersMacroContent = '';
    if (!empty($allMembers)) {
        foreach ($allMembers as $ix => $eachMember) {
            $memberClass = 'm' . str_replace('.', 'x', $eachMember['ip']);
            $membersMacroContent .= 'deny members of "' . $memberClass . '";' . "\n";
        }
    }
    if (isset($altCfg['VLANGEN_SUPPORT'])) {
        if ($altCfg['VLANGEN_SUPPORT']) {
            $vlanMembers_q = "SELECT `ip` FROM `users` WHERE `login` IN(SELECT `login` FROM `vlanhosts`);";
            $allVlanMembers = simple_queryall($vlanMembers_q);
            if (!empty($allVlanMembers)) {
                foreach ($allVlanMembers as $ivl => $eachVlanMember) {
                    $memberVlanClass = 'm' . str_replace('.', 'x', $eachVlanMember['ip']);
                    $vlanMembersMacroContent .= 'deny members of "' . $memberVlanClass . '";' . "\n";
                }
            }
        }
    }
    $onuMembers_q = "SELECT `ip` FROM `nethosts` WHERE `netid` IN (SELECT `id` FROM `networks` WHERE `nettype` = 'dhcp82_bdcom' or `nettype` = 'dhcp82_zte');";
    $allOnuMembers = simple_queryall($onuMembers_q);
    if (!empty($allOnuMembers)) {
        foreach ($allOnuMembers as $index => $eachOnuMember) {
            $memberOnuClass = 'm' . str_replace('.', 'x', $eachOnuMember['ip']);
            $onuMembersMacroContent .= 'deny members of "' . $memberOnuClass . '";' . "\n";
        }
    }
    $subnets = '';
    if (!empty($alldhcpsubnets)) {
        foreach ($alldhcpsubnets as $io => $eachnet) {
            $netdata = multinet_get_network_params($eachnet['netid']);
            $templatedata['{STARTIP}'] = $netdata['startip'];
            $templatedata['{ENDIP}'] = $netdata['endip'];
            $templatedata['{CIDR}'] = explode('/', $netdata['desc']);
            $templatedata['{NETWORK}'] = $templatedata['{CIDR}'][0];
            $templatedata['{CIDR}'] = $templatedata['{CIDR}'][1];
            $templatedata['{ROUTERS}'] = int2ip(ip2int($templatedata['{STARTIP}']) + 1);
            $templatedata['{MASK}'] = multinet_cidr2mask($templatedata['{CIDR}']);
            $dhcpdata = dhcp_get_data_by_netid($eachnet['netid']);
            if (isset($dhcpdata['confname'])) {
                $templatedata['{HOSTS}'] = $dhcpdata['confname'];
                // check if override?
                if (!empty($dhcpdata['dhcpconfig'])) {
                    $currentsubtpl = $dhcpdata['dhcpconfig'];
                } else {
                    $currentsubtpl = $subnets_template;
                }
                $subnets .= multinet_ParseTemplate($currentsubtpl, $templatedata) . "\n";
            }
        }
    }
    $globdata['{SUBNETS}'] = $subnets;
    $globdata['{DENYMEMBERS}'] = $membersMacroContent;
    $globdata['{DENYVLANGENMEMBERS}'] = $vlanMembersMacroContent;
    $globdata['{DENYONUMEMBERS}'] = $onuMembersMacroContent;
    $globconf = multinet_ParseTemplate($global_template, $globdata);
    file_write_contents("multinet/dhcpd.conf", $globconf);
}
Beispiel #2
0
function output($title, $content, $disposition = 'browser')
{
    $_SERVER['PLANOWNER_DISPLAY_NAME'] = str_replace("'", "", $_SERVER['PLANOWNER_DISPLAY_NAME']);
    $_SERVER['STOPWATCH']['content_end'] = array_sum(explode(' ', microtime()));
    $_SERVER['STOPWATCH']['output_begin'] = array_sum(explode(' ', microtime()));
    // if there is no cookie, user is 'guest'
    if (!$_SERVER['USER']) {
        $_SERVER['USER'] = '******';
    }
    if ($_SERVER['OUTPUT_MODE'] == 'HTML') {
        Header("Content-type: text/html; charset=UTF-8");
        $page = output_html($title, $content);
    }
    if ($_SERVER['OUTPUT_MODE'] == 'IPHONE') {
        Header("Content-type: text/html; charset=UTF-8");
        $page = output_iphone($title, $content);
    }
    if ($_SERVER['OUTPUT_MODE'] == 'RSS' || strstr($_SERVER['OUTPUT_MODE'], 'ATOM')) {
        Header("Content-type: text/xml; charset=UTF-8");
        $page = output_feed($title, $content);
    }
    if ($_SERVER['OUTPUT_MODE'] == 'AJAX') {
        Header("Content-type: text/html; charset=UTF-8");
        $page = output_ajax($title, $content);
    }
    if ($disposition == 'return') {
        return $page;
    }
    if (strstr($disposition, $_SERVER['DOCUMENT_ROOT'])) {
        file_write_contents($disposition, $page);
        return $page;
    }
    echo $page;
    exit;
}
Beispiel #3
0
 function save_cache()
 {
     $this->CONTENT = ob_get_contents();
     //Записываем буфер в переменную
     rcms_delete_files($this->dir_cache . "/" . $this->hash_code);
     file_write_contents($this->dir_cache . "/" . $this->hash_code, $this->CONTENT);
 }
function guestbook_remove_post($file, $num, $config = false)
{
    if ($data = @file_get_contents($file)) {
        $data = unserialize($data);
    }
    unset($data[$num]);
    file_write_contents($file, serialize($data));
    return true;
}
Beispiel #5
0
function write_rate($for, $val, $ip)
{
    global $write;
    if (!$write) {
        $arr = array();
        if (file_exists(RATE_PATH . $for)) {
            $arr = unserialize(file_get_contents(RATE_PATH . $for));
        }
        $arr[$ip] = $val;
        file_write_contents(RATE_PATH . $for, serialize($arr));
    }
}
function gallery_delete_comment($id, $cid)
{
    $images = rcms_scandir(GALLERY_PATH);
    if ($data = @file_get_contents(GALLERY_PATH . $images[$id] . '.cm')) {
        $data = unserialize($data);
    } else {
        return false;
    }
    if (isset($data[$cid])) {
        unset($data[$cid]);
        file_write_contents(GALLERY_PATH . $images[$id] . '.cm', serialize($data));
    }
    return true;
}
Beispiel #7
0
function ucm_delete($id)
{
    $filename = basename($id) . '.ucm';
    if (!is_file(DF_PATH . $filename)) {
        return false;
    }
    if (rcms_delete_files(DF_PATH . $filename)) {
        $config = file_get_contents(CONFIG_PATH . 'menus.ini');
        $config = preg_replace('/[0-9]* = "ucm:' . $id . '"\\s/i', '', $config);
        file_write_contents(CONFIG_PATH . 'menus.ini', $config);
        return true;
    } else {
        return false;
    }
}
Beispiel #8
0
function ucm_delete($id, $dir = MENU_MODULES_PATH)
{
    $id = basename($id);
    $workdir = $dir . 'ucm.' . $id;
    if (is_dir($workdir)) {
        if (rcms_delete_files($workdir, true)) {
            $config = file_get_contents(CONFIG_PATH . 'menus.ini');
            $config = preg_replace('/[0-9]* = "ucm.' . $id . '"\\s/i', '', $config);
            if (!file_write_contents(CONFIG_PATH . 'menus.ini', $config)) {
                return 6;
            }
            return 0;
        } else {
            return 4;
        }
    } else {
        return 4;
    }
}
function download_save_data_file($file, $cont)
{
    if (!is_writeable($file) && is_file($file)) {
        return false;
    }
    $res = array();
    foreach ($cont as $key => $value) {
        if ($value !== false) {
            $res[$key] = $value;
        }
    }
    if (!($data = serialize($res))) {
        return false;
    }
    if (!file_write_contents($file, $data)) {
        return false;
    }
    return true;
}
Beispiel #10
0
 function close($uc = true, $uo = true)
 {
     if ($uc) {
         if (!$this->copened) {
             $this->openCurrentPolls();
         }
         $a = file_write_contents($this->polls_file, serialize($this->current));
     }
     if ($uo) {
         if (!$this->oopened) {
             $this->openArchivedPolls();
         }
         $b = file_write_contents($this->old_polls_file, serialize($this->old));
     }
     if ($uc && $uo) {
         return $a && $b;
     } elseif ($uo) {
         return $b;
     } elseif ($uc) {
         return $a;
     } else {
         return true;
     }
 }
Beispiel #11
0
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;
}
Beispiel #12
0
    $alter_conf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
    if ($alter_conf['EXPORT_ENABLED']) {
        $export_filepath = 'exports/';
        $export_fileext = '.export';
        if (wf_CheckGet(array('dlexf'))) {
            zb_DownloadFile($export_filepath . vf($_GET['dlexf'], 3) . $export_fileext, 'default');
        }
        show_window(__('Export payments data'), zb_ExportForm());
        if (isset($_POST['fromdate']) and isset($_POST['todate'])) {
            $from_date = $_POST['fromdate'];
            $to_date = $_POST['todate'];
            //export types
            //xml
            if ($alter_conf['EXPORT_FORMAT'] == 'xml') {
                $export_result = zb_ExportPayments($from_date, $to_date);
            }
            //dbf
            if ($alter_conf['EXPORT_FORMAT'] == 'dbf') {
                //need to be written
            }
            $export_filename = time();
            $exported_link = wf_Link('?module=payexport&dlexf=' . $export_filename, wf_img('skins/icon_download.png') . ' ' . __('Exported data download'), false, 'ubButton');
            file_write_contents($export_filepath . $export_filename . $export_fileext, $export_result);
            show_window('', $exported_link);
        }
    } else {
        show_error(__('Payments export not enabled'));
    }
} else {
    show_error(__('You cant control this module'));
}
Beispiel #13
0
         $prio = $_POST['priority'][$module];
         include_once 'sitemap/' . $module . '.php';
     }
 }
 $sitemap->sitemapFileName = $_POST['filename'];
 $result = $sitemap->sitemapFileName . '&nbsp;' . __('added successfully') . '<br/>';
 if (!empty($_POST['gz'])) {
     $sitemap->createGZipFile = true;
     $result .= $_POST['filename'] . '.gz&nbsp;' . __('added successfully') . '<br/>';
 }
 $sitemap->createSitemap();
 // create sitemap in memory
 $sitemap->writeSitemap();
 // write sitemap as file
 if (isset($_POST['robots_txt'])) {
     file_write_contents(RCMS_ROOT_PATH . 'robots.txt', $_POST['robots_txt']);
 }
 //save robots.txt
 if (!empty($_POST['robots'])) {
     //build new robots.txt
     rcms_delete_files(RCMS_ROOT_PATH . 'robots.txt');
     $sitemap->updateRobots();
     $result .= 'robots.txt&nbsp;' . __('added successfully') . '<br/>';
 }
 if (!empty($_POST['engines'])) {
     // submit sitemaps to search engines
     $result .= "<pre>";
     $result .= $sitemap->submitSitemap('');
     $result .= "</pre>";
 }
 $result .= __('Memory peak usage: ') . number_format(memory_get_peak_usage() / (1024 * 1024), 2) . "MB";
Beispiel #14
0
 function saveIndexFiles()
 {
     global $system;
     if ($system->checkForRight('GALLERY')) {
         file_write_contents(GALLERY_INDEXES_DIR . 'main.dat', serialize($this->indexes['main']));
         file_write_contents(GALLERY_INDEXES_DIR . 'filename.dat', serialize($this->indexes['filename']));
         file_write_contents(GALLERY_INDEXES_DIR . 'title.dat', serialize($this->indexes['title']));
         file_write_contents(GALLERY_INDEXES_DIR . 'size.dat', serialize($this->indexes['size']));
         file_write_contents(GALLERY_INDEXES_DIR . 'type.dat', serialize($this->indexes['type']));
         file_write_contents(GALLERY_INDEXES_DIR . 'keywords.dat', serialize($this->indexes['keywords']));
     }
     return true;
 }
Beispiel #15
0
 if (!is_dir(DATA_PATH . 'help/')) {
     mkdir(DATA_PATH . 'help/', 0777);
 }
 if (!is_dir($help_dir)) {
     mkdir($help_dir, 0777);
 }
 if (!empty($_GET['delete'])) {
     $dfile = $help_dir . '/' . get('delete');
     if (rcms_delete_files($dfile)) {
         show_window(__('Result'), __('File removed'));
     } else {
         show_window(__('Result'), __('Error occurred') . ':' . $dfile);
     }
 }
 if (!empty($_POST['save']) && !empty($module)) {
     file_write_contents($file, $_POST['help_edit']);
     show_window(__('Result'), __('File updated') . '. ' . __('Show') . ' — ' . show_help($module));
 }
 if (!empty($module)) {
     $result = file_exists($file) ? file_get_contents($file) : '';
     $frm = new InputForm('', 'post', __('Submit'));
     $frm->hidden('save', '1');
     $frm->addrow('', $frm->textarea('help_edit', $result, 55, 15) . tinymce_selector('help_edit'), 'top');
     $result = $frm->show(true);
     show_window(__('Help') . ' ' . __('for the module') . ' ' . get('edit') . ': ' . __('Edit'), $result, 'center');
 } else {
     $files = rcms_scandir($help_dir);
     if (!empty($files)) {
         $result = '<table width="100%">';
         foreach ($files as $helpfile) {
             $admin_link = '
    $frm = new InputForm(RCMS_ROOT_PATH, "post", $lang['users']['login'], '_top');
    $frm->addbreak($lang['admin_cp']['notlogged']);
    $frm->hidden('login_form', '1');
    $frm->addrow($lang['users']['username'], $frm->text_box("username", '', 20), 'top');
    $frm->addrow($lang['users']['password'], $frm->text_box("password", '', 20, 50, true), 'top');
    $frm->addrow($lang['users']['remember'], $frm->checkbox("remember", '1', ''), 'top');
    $frm->show();
} else {
    $rights =& $system->rights;
    if ($rights === array()) {
        $frm = new InputForm(RCMS_ROOT_PATH, "get", $lang['general']['return'], '_top');
        $frm->addbreak($lang['admin_cp']['loggedbutnotadmin']);
        $frm->show();
    } else {
        if (isset($_POST['remarks'])) {
            file_write_contents(DATA_PATH . 'admin_remarks.txt', $_POST['remarks']);
        }
        $frm = new InputForm('', "post", $lang['general']['submit']);
        $frm->addbreak($lang['admin_cp']['loggedok']);
        if ($rights !== 'ROOT') {
            foreach ($rights as $right => $right_desc) {
                $frm->addrow($right, $right_desc, 'top');
            }
        } else {
            $frm->addrow($lang['users']['youareroot']);
        }
        $frm->addbreak($lang['admin_cp']['remarks']);
        $frm->addrow($frm->textarea('remarks', file_get_contents(DATA_PATH . 'admin_remarks.txt'), 60, 10), '', 'middle', 'center');
        $frm->show();
    }
}
/**
 * Handle uploading a set of files.
 * @param array $files A list of valid $_FILES keys to process.
 */
function cpm_handle_file_uploads($files)
{
    global $cpm_config;
    $posts_created = array();
    $duplicate_posts = array();
    $files_uploaded = array();
    $thumbnails_written = array();
    $invalid_filenames = array();
    $thumbnails_not_written = array();
    $files_not_uploaded = array();
    $invalid_image_types = array();
    $gd_rename_file = array();
    $did_convert_cmyk_jpeg = array();
    $target_root = CPM_DOCUMENT_ROOT . '/' . $cpm_config->properties[$_POST['upload-destination'] . "_folder"];
    if (($subdir = cpm_get_subcomic_directory()) !== false) {
        $target_root .= '/' . $subdir;
    }
    $write_thumbnails = isset($_POST['thumbnails']) && $_POST['upload-destination'] == "comic";
    $new_post = isset($_POST['new_post']) && $_POST['upload-destination'] == "comic";
    $ok_to_keep_uploading = true;
    $files_created_in_operation = array();
    $filename_original_titles = array();
    foreach ($files as $key) {
        if (is_uploaded_file($_FILES[$key]['tmp_name'])) {
            if ($_FILES[$key]['error'] != 0) {
                switch ($_FILES[$key]['error']) {
                    case UPLOAD_ERR_INI_SIZE:
                    case UPLOAD_ERR_FORM_SIZE:
                        $cpm_config->warnings[] = sprintf(__("<strong>The file you uploaded was too large.</strong>  The max allowed filesize for uploads to your server is %s.", 'comicpress-manager'), ini_get('upload_max_filesize'));
                        break;
                    case UPLOAD_ERR_NO_FILE:
                        break;
                    default:
                        $cpm_config->warnings[] = sprintf(__("<strong>There was an error in uploading.</strong>  The <a href='http://php.net/manual/en/features.file-upload.errors.php'>PHP upload error code</a> was %s.", 'comicpress-manager'), $_FILES[$key]['error']);
                        break;
                }
            } else {
                if (strpos($_FILES[$key]['name'], ".zip") !== false) {
                    $invalid_files = array();
                    //harmonious zip_open zip_entry_name zip_read zip_entry_read zip_entry_open zip_entry_filesize zip_entry_close zip_close
                    if (extension_loaded("zip")) {
                        if (is_resource($zip = zip_open($_FILES[$key]['tmp_name']))) {
                            while ($zip_entry = zip_read($zip)) {
                                if (zip_entry_open($zip, $zip_entry, "r")) {
                                    $temp_path = $target_root . '/' . md5(rand());
                                    file_write_contents($temp_path, zip_entry_read($zip_entry, zip_entry_filesize($zip_entry)));
                                    $comic_file = zip_entry_name($zip_entry);
                                    $target_filename = pathinfo(zip_entry_name($zip_entry), PATHINFO_BASENAME);
                                    $result = cpm_breakdown_comic_filename($target_filename, true);
                                    if (file_exists($temp_path)) {
                                        extract(cpm_do_gd_file_check_on_upload($temp_path, $target_filename));
                                        if ($result !== false) {
                                            extract($result, EXTR_PREFIX_ALL, "filename");
                                            if ($file_ok) {
                                                if (($obfuscated_filename = cpm_obfuscate_filename($target_filename)) !== $target_filename) {
                                                    $cpm_config->messages[] = sprintf(__('Uploaded file %1$s renamed to %2$s.', 'comicpress-manager'), $target_filename, $obfuscated_filename);
                                                    $filename_original_titles[$obfuscated_filename] = $result['converted_title'];
                                                    $target_filename = $obfuscated_filename;
                                                }
                                                @rename($temp_path, $target_root . '/' . $target_filename);
                                                $files_created_in_operation[] = $target_root . '/' . $target_filename;
                                                $files_uploaded[] = $target_filename;
                                                if ($gd_did_rename) {
                                                    $gd_rename_file[] = $comic_file;
                                                }
                                                if ($did_filecheck) {
                                                    if ($is_cmyk) {
                                                        $did_convert_cmyk_jpeg[] = $comic_file;
                                                    }
                                                }
                                            } else {
                                                if ($did_filecheck) {
                                                    $invalid_image_types[] = $comic_file;
                                                } else {
                                                    $invalid_filenames[] = $comic_file;
                                                }
                                            }
                                        } else {
                                            $files_not_uploaded[] = $comic_file;
                                        }
                                    } else {
                                        $invalid_filenames[] = $comic_file;
                                    }
                                    @unlink($temp_path);
                                    zip_entry_close($zip_entry);
                                }
                                if (($result = cpm_breakdown_comic_filename($target_filename, true)) !== false) {
                                    extract($result, EXTR_PREFIX_ALL, 'filename');
                                    $target_path = $target_root . '/' . $target_filename;
                                    if (isset($_POST['upload-date-format']) && !empty($_POST['upload-date-format'])) {
                                        $target_filename = date(CPM_DATE_FORMAT, strtotime($result['date'])) . $result['title'] . '.' . pathinfo($_FILES[$key]['name'], PATHINFO_EXTENSION);
                                    }
                                } else {
                                    $invalid_filenames[] = $comic_file;
                                }
                            }
                            zip_close($zip);
                        }
                    } else {
                        $cpm_config->warnings[] = sprintf(__("The Zip extension is not installed. %s was not processed.", 'comicpress-manager'), $_FILES[$key]['name']);
                    }
                    //harmonious_end
                } else {
                    $target_filename = $_FILES[$key]['name'];
                    if (get_magic_quotes_gpc()) {
                        $target_filename = stripslashes($target_filename);
                    }
                    $tried_replace = false;
                    if (!empty($_POST['overwrite-existing-file-choice'])) {
                        $tried_replace = true;
                        $original_filename = $target_filename;
                        $target_filename = $_POST['overwrite-existing-file-choice'];
                        if (get_magic_quotes_gpc()) {
                            $target_filename = stripslashes($target_filename);
                        }
                        $new_post = false;
                        if (pathinfo($original_filename, PATHINFO_EXTENSION) != pathinfo($target_filename, PATHINFO_EXTENSION)) {
                            if (@unlink($target_root . '/' . $target_filename)) {
                                foreach (cpm_get_thumbnails_to_generate() as $type) {
                                    $path = CPM_DOCUMENT_ROOT . '/' . $cpm_config->properties[$type . "_comic_folder"];
                                    if (($subdir = cpm_get_thumbnails_to_generate()) !== false) {
                                        $path .= '/' . $subdir;
                                    }
                                    @unlink($path . '/' . $target_filename);
                                }
                            }
                            $target_filename = preg_replace('#\\.[^\\.]+$#', '', $target_filename) . '.' . pathinfo($original_filename, PATHINFO_EXTENSION);
                        }
                        $result = cpm_breakdown_comic_filename($target_filename);
                        $cpm_config->messages[] = sprintf(__('Uploaded file <strong>%1$s</strong> renamed to <strong>%2$s</strong>.', 'comicpress-manager'), $original_filename, $target_filename);
                    } else {
                        if (count($files) == 1) {
                            if (!empty($_POST['override-date'])) {
                                $date = strtotime($_POST['override-date']);
                                if ($date !== false && $date !== -1) {
                                    $new_date = date(CPM_DATE_FORMAT, $date);
                                    $old_filename = $target_filename;
                                    if (($target_result = cpm_breakdown_comic_filename($target_filename, true)) !== false) {
                                        $target_filename = $new_date . $target_result['title'] . '.' . pathinfo($target_filename, PATHINFO_EXTENSION);
                                    } else {
                                        $target_filename = $new_date . '-' . $target_filename;
                                    }
                                    if ($old_filename !== $target_filename) {
                                        $cpm_config->messages[] = sprintf(__('Uploaded file %1$s renamed to %2$s.', 'comicpress-manager'), $_FILES[$key]['name'], $target_filename);
                                    }
                                    $result = cpm_breakdown_comic_filename($target_filename);
                                } else {
                                    if (preg_match('/\\S/', $_POST['override-date']) > 0) {
                                        $cpm_config->warnings[] = sprintf(__("Provided override date %s is not parseable by strtotime().", 'comicpress-manager'), $_POST['override-date']);
                                    }
                                }
                            }
                        }
                        $result = cpm_breakdown_comic_filename($target_filename, true);
                        if ($result !== false) {
                            // bad file, can we get a date attached?
                            if (isset($_POST['upload-date-format']) && !empty($_POST['upload-date-format'])) {
                                $target_filename = date(CPM_DATE_FORMAT, strtotime($result['date'])) . $result['title'] . '.' . pathinfo($_FILES[$key]['name'], PATHINFO_EXTENSION);
                            }
                        }
                    }
                    $comic_file = $_FILES[$key]['name'];
                    extract(cpm_do_gd_file_check_on_upload($_FILES[$key]['tmp_name'], $target_filename));
                    $output_file = null;
                    if ($result !== false) {
                        extract($result, EXTR_PREFIX_ALL, "filename");
                        if ($file_ok) {
                            if (($obfuscated_filename = cpm_obfuscate_filename($target_filename)) !== $target_filename) {
                                $cpm_config->messages[] = sprintf(__('Uploaded file %1$s renamed to %2$s.', 'comicpress-manager'), $target_filename, $obfuscated_filename);
                                $filename_original_titles[$obfuscated_filename] = $result['converted_title'];
                                $target_filename = $obfuscated_filename;
                            }
                            $output_file = $target_root . '/' . $target_filename;
                            @move_uploaded_file($_FILES[$key]['tmp_name'], $output_file);
                            $files_created_in_operation[] = $output_file;
                            if (file_exists($output_file)) {
                                $files_uploaded[] = $target_filename;
                                if ($gd_did_rename) {
                                    $gd_rename_file[] = $comic_file;
                                }
                            } else {
                                $files_not_uploaded[] = $target_filename;
                            }
                            if ($did_filecheck) {
                                if ($is_cmyk) {
                                    $did_convert_cmyk_jpeg[] = $comic_file;
                                }
                            }
                        } else {
                            if ($did_filecheck) {
                                $invalid_image_types[] = $comic_file;
                            } else {
                                $invalid_filenames[] = $comic_file;
                            }
                        }
                    } else {
                        if (!$tried_replace) {
                            $invalid_filenames[] = $comic_file;
                        }
                    }
                    if ($cpm_config->scale_method_cache == CPM_SCALE_IMAGEMAGICK && cpm_option('cpm-strip-icc-profiles') == "1" && !empty($output_file)) {
                        $temp_output_file = $output_file . '.' . md5(rand());
                        $command = array("convert", "\"{$output_file}\"", "-strip", "\"{$temp_output_file}\"");
                        $strip_profiles = escapeshellcmd(implode(" ", $command));
                        exec($strip_profiles);
                        if (file_exists($temp_output_file)) {
                            @unlink($output_file);
                            @rename($temp_output_file, $output_file);
                        }
                    }
                }
            }
        }
        if ($wpmu_version) {
            if (cpm_wpmu_is_over_storage_limit()) {
                $ok_to_keep_uploading = false;
                break;
            }
        }
    }
    if ($ok_to_keep_uploading) {
        foreach ($files_uploaded as $target_filename) {
            $target_path = $target_root . '/' . $target_filename;
            @chmod($target_path, CPM_FILE_UPLOAD_CHMOD);
            if ($write_thumbnails) {
                $wrote_thumbnail = cpm_write_thumbnail($target_path, $target_filename);
            }
            if (!is_null($wrote_thumbnail)) {
                if (is_array($wrote_thumbnail)) {
                    $thumbnails_written[] = $target_filename;
                    $files_created_in_operation = array_merge($files_created_in_operation, $wrote_thumbnail);
                } else {
                    $thumbnails_not_written[] = $target_filename;
                }
            }
        }
        if ($wpmu_version) {
            if (cpm_wpmu_is_over_storage_limit()) {
                $ok_to_keep_uploading = false;
            }
        }
    }
    if ($ok_to_keep_uploading) {
        foreach ($files_uploaded as $target_filename) {
            if ($new_post) {
                extract(cpm_breakdown_comic_filename($target_filename), EXTR_PREFIX_ALL, "filename");
                if (isset($filename_original_titles[$target_filename])) {
                    $filename_converted_title = $filename_original_titles[$target_filename];
                }
                if (($post_hash = generate_post_hash($filename_date, $filename_converted_title)) !== false) {
                    extract($post_hash);
                    $ok_to_create_post = true;
                    if (isset($_POST['duplicate_check'])) {
                        $ok_to_create_post = ($post_id = post_exists($post_title, $post_content, $post_date)) == 0;
                    }
                    if ($ok_to_create_post) {
                        if (!is_null($post_id = wp_insert_post($post_hash))) {
                            $posts_created[] = get_post($post_id, ARRAY_A);
                            foreach (array('hovertext', 'transcript') as $field) {
                                if (!empty($_POST["{$field}-to-use"])) {
                                    update_post_meta($post_id, $field, $_POST["{$field}-to-use"]);
                                }
                            }
                        }
                    } else {
                        $duplicate_posts[] = array(get_post($post_id, ARRAY_A), $target_filename);
                    }
                } else {
                    $invalid_filenames[] = $target_filename;
                }
            }
        }
        cpm_display_operation_messages(compact('invalid_filenames', 'files_uploaded', 'files_not_uploaded', 'thumbnails_written', 'thumbnails_not_written', 'posts_created', 'duplicate_posts', 'invalid_image_types', 'gd_rename_file', 'did_convert_cmyk_jpeg'));
    } else {
        $cpm_config->messages = array();
        $cpm_config->warnings = array($cpm_config->wpmu_disk_space_message);
        foreach ($files_created_in_operation as $file) {
            @unlink($file);
        }
    }
    return array($posts_created, $duplicate_posts);
}
Beispiel #18
0
 function saveIndex()
 {
     if (empty($this->container)) {
         $this->last_error = __('No section selected!');
         return false;
     }
     if (($data = serialize($this->index)) === false) {
         $this->last_error = __('Error while converting index');
         return false;
     }
     if (!file_write_contents(ARTICLES_PATH . $this->container . '/index', $data)) {
         $this->last_error = __('Error while saving index');
         return false;
     }
     return true;
 }
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <link rel="stylesheet" href="./style.css" type="text/css">
</head>
<body>
<table cellspacing="1" cellpadding="3" border="0" width="100%">
<tr>
    <th colspan="3">ReloadCMS 1.0.X create users cache</th>
</tr>
<?php 
$users = user_get_list('*');
if (!is_file(DATA_PATH . 'users.cache.dat')) {
    $cache = array();
} else {
    $cache = @unserialize(@file(DATA_PATH . 'users.cache.dat'));
}
foreach ($users as $userdata) {
    $cache['nicks'][$userdata['username']] = $userdata['nickname'];
    $cache['mails'][$userdata['username']] = $userdata['email'];
    echo '
<tr>
    <td width="100%" class="row1" style="color: green">' . $userdata['nickname'] . '</td>
    <td class="row2" nowrap>' . $userdata['email'] . '</td>
</tr>';
}
file_write_contents(DATA_PATH . 'users.cache.dat', serialize($cache));
?>
</table>
</body>
</html>
Beispiel #20
0
function write_ini_file($data, $filename, $process_sections = false)
{
    $ini = '';
    if (!$process_sections) {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $ini .= $key . ' = "' . str_replace('"', '&quot;', $value) . "\"\n";
            }
        }
    } else {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $ini .= '[' . $key . ']' . "\n";
                foreach ($value as $ekey => $evalue) {
                    $ini .= $ekey . ' = "' . str_replace('"', '&quot;', $evalue) . "\"\n";
                }
            }
        }
    }
    return file_write_contents($filename, $ini);
}
Beispiel #21
0
    if (!empty($file)) {
        srand(microtime() * 1000000);
        $aforizm = file($file);
        $result = $aforizm[array_rand($aforizm, 1)];
        if ($system->checkForRight('GENERAL')) {
            $result = $result . '<br/>
	<a href = "?module=aforizm">
	<img src="' . IMAGES_PATH . 'skins/edit_small.gif" title="' . __('Edit') . '" alt="' . __('Edit') . '" border="0">
	</a>';
        }
        show_window('', $result);
    }
} elseif ($system->checkForRight('GENERAL')) {
    //Edit Aforizms
    if (!empty($_POST['save'])) {
        file_write_contents($file, $_POST['text']);
        show_window('', __('Module updated'));
    }
    if (!empty($file)) {
        $array_aforizm = file($file);
    } else {
        $array_aforizm = array();
    }
    $result = '';
    foreach ($array_aforizm as $aforizm) {
        $result .= $aforizm;
    }
    $frm = new InputForm('', 'post', __('Submit'));
    $frm->hidden('save', '1');
    $frm->addrow(__('Each value on a new line'));
    $frm->addrow(__('All HTML is allowed in this field and line breaks will not be transformed to &lt;br&gt; tags!'));
Beispiel #22
0
 function save_user($username, $userdata)
 {
     if (USERS_MYSQL) {
         if ($this->is_user($username)) {
             $query = "UPDATE `users` SET \r\n\t`userdata`='" . serialize($userdata) . "'\r\n\tWHERE `username` ='" . $username . "';";
         } else {
             $query = "INSERT INTO `users` (`username`,`userdata`) \r\n\tVALUES ('" . $username . "','" . serialize($userdata) . "');";
         }
         $result = nr_query($query);
         return !empty($result);
     } elseif (!file_write_contents(USERS_PATH . $username, serialize($userdata))) {
         return false;
     }
     return true;
 }
function user_remove_from_cache($username, &$cache)
{
    if (!isset($cache) || !is_array($cache)) {
        if (!is_file(DATA_PATH . 'users.cache.dat')) {
            $cache = array();
        } else {
            $cache = @unserialize(@file_get_contents(DATA_PATH . 'users.cache.dat'));
        }
    }
    if (!empty($cache['nicks'][$username])) {
        unset($cache['nicks'][$username]);
    }
    if (!empty($cache['mails'][$username])) {
        unset($cache['mails'][$username]);
    }
    file_write_contents(DATA_PATH . 'users.cache.dat', serialize($cache));
    return true;
}
//   but WITHOUT ANY WARRANTY, without even the implied warranty of           //
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                     //
//                                                                            //
//   This product released under GNU General Public License v2                //
////////////////////////////////////////////////////////////////////////////////
if (!empty($_POST['nconfig'])) {
    write_ini_file($_POST['nconfig'], CONFIG_PATH . 'config.ini');
}
if (isset($_POST['meta_tags'])) {
    file_write_contents(DATA_PATH . "meta_tags.html", $_POST['meta_tags']);
}
if (isset($_POST['top'])) {
    file_write_contents(DATA_PATH . "top.html", $_POST['top']);
}
if (isset($_POST["welcome_mesg"])) {
    file_write_contents(DATA_PATH . 'intro.html', $_POST["welcome_mesg"]);
}
$system->loadConfiguration();
$config =& $system->config;
// Interface generation
$frm = new InputForm("", "post", $lang['general']['submit']);
$frm->addbreak($lang['admincp']['general']['config']['full']);
$frm->addrow($lang['admincp']['general']['config']['sitename'], $frm->text_box("nconfig[title]", $config['title'], 40));
$frm->addrow($lang['admincp']['general']['config']['siteurl'], $frm->text_box("nconfig[site_url]", $config['site_url'], 40));
$frm->addrow($lang['admincp']['general']['config']['defskin'], user_skin_select(SKIN_PATH, 'nconfig[default_skin]', $config['default_skin']));
$frm->addrow($lang['admincp']['general']['config']['deflang'], user_lang_select(LANG_PATH, 'nconfig[default_lang]', $config['default_lang']));
$frm->addrow($lang['admincp']['general']['config']['latestnumber'], $frm->text_box('nconfig[num_of_latest]', @$config['num_of_latest']));
$frm->addrow($lang['general']['perpage'], $frm->text_box('nconfig[perpage]', @$config['perpage']));
$frm->addrow($lang['admincp']['general']['config']['allowchskin'], $frm->checkbox('nconfig[allowchskin]', '1', '', @$config['allowchskin']));
$frm->addrow($lang['admincp']['general']['config']['allowchlang'], $frm->checkbox('nconfig[allowchlang]', '1', '', @$config['allowchlang']));
$frm->addrow($lang['admincp']['general']['config']['regconfirmation'], $frm->checkbox('nconfig[regconf]', '1', '', @$config['regconf']));
Beispiel #25
0
function post_remove($id, $file = RCMS_GB_DEFAULT_FILE)
{
    global $_CACHE;
    $data =& $_CACHE['gbook'][$file];
    if (!isset($data)) {
        if (!is_readable($file) || !($data = unserialize(file_get_contents($file)))) {
            $data = array();
        }
    }
    rcms_remove_index($id, $data, true);
    if (file_write_contents($file, serialize($data))) {
        show_window('', __('Comment removed'));
    } else {
        show_window(__('Error'), __('Comment are not removed!'));
    }
}
Beispiel #26
0
<?php

if (cfr('PAYEXPORT')) {
    $alter_conf = rcms_parse_ini_file(CONFIG_PATH . "alter.ini");
    if ($alter_conf['EXPORT_ENABLED']) {
        show_window(__('Export payments data'), zb_ExportForm());
        if (isset($_POST['fromdate']) and isset($_POST['todate'])) {
            $from_date = $_POST['fromdate'];
            $to_date = $_POST['todate'];
            //export types
            //xml
            if ($alter_conf['EXPORT_FORMAT'] == 'xml') {
                $export_result = zb_ExportPayments($from_date, $to_date);
            }
            //dbf
            if ($alter_conf['EXPORT_FORMAT'] == 'dbf') {
                //need to be written
            }
            $export_file = 'exports/' . time() . '.export';
            $exported_link = '<a href="' . $export_file . '">' . __('Download') . '</a>';
            file_write_contents($export_file, $export_result);
            show_window(__('Exported data download'), $exported_link);
        }
    } else {
        show_error(__('Payments export not enabled'));
    }
} else {
    show_error(__('You cant control this module'));
}
Beispiel #27
0
rcms_loadAdminLib('ucm');
if (!empty($_POST['save'])) {
    $content = '';
    $i = -1;
    if (!empty($_POST['menus'])) {
        foreach ($_POST['menus'] as $element) {
            if (substr($element, 0, 1) == '/') {
                $content .= '[' . substr($element, 1) . "]\n";
                $i = 0;
            } elseif ($i !== -1) {
                $content .= $i . '=' . $element . "\n";
                $i++;
            }
        }
    }
    file_write_contents(CONFIG_PATH . 'menus.ini', $content);
}
/******************************************************************************
* Interface                                                                   *
******************************************************************************/
$menus = parse_ini_file(CONFIG_PATH . 'menus.ini', true);
include SKIN_PATH . $system->skin . '/skin.php';
$current = array();
$usused = array();
foreach ($menus as $column => $coldata) {
    if (!empty($skin['menu_point'][$column])) {
        $current['/' . $column] = __('Column') . ': ' . $skin['menu_point'][$column];
        foreach ($coldata as $menu) {
            if (substr($menu, 0, 4) == 'ucm:' && is_readable(DF_PATH . substr($menu, 4) . '.ucm')) {
                $current[$menu] = ' > ' . $menu;
            } elseif (!empty($system->modules['menu'][$menu])) {
Beispiel #28
0
function pm_post_remove($id, $file = RCMS_PM_DEFAULT_FILE)
{
    global $_CACHE;
    $data =& $_CACHE['gbook'][$file];
    if (!isset($data)) {
        if (!is_readable($file) || !($data = unserialize(file_get_contents($file)))) {
            $data = array();
        }
    }
    rcms_remove_index($id, $data, true);
    return file_write_contents($file, serialize($data));
}
Beispiel #29
0
 function logPut($type, $user, $message)
 {
     if (!empty($this->config['logging'])) {
         $entry = '---------------------------------' . "\n";
         $entry .= date('H:i:s d-m-Y', time()) . "\n";
         $entry .= $type . ' (' . $user . ' from ' . $_SERVER['REMOTE_ADDR'] . ')' . "\n";
         $entry .= $message . "\n";
         if ($this->logging_gz) {
             gzfile_write_contents($this->logging . date('Y-m-d', time()) . '.log.gz', $entry, 'a');
         } else {
             file_write_contents($this->logging . date('Y-m-d', time()) . '.log', $entry, 'a');
         }
     }
     return true;
 }
Beispiel #30
0
function guestbook_post_remove($id, $file = RCMS_GB_DEFAULT_FILE, $config = 'guestbook.ini')
{
    global $_CACHE;
    $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();
        }
    }
    rcms_remove_index($id, $data, true);
    return file_write_contents($file, serialize($data));
}