function write_file($filename, $text, $db_escape = false) { $text = General::input_clean($text); if (!is_file($filename) && USE_FTP) { $filename = str_replace(docroot(), '', $filename); $root_dir = FTP_ROOTDIR; $file = fopen('ftp://' . FTP_USER . ':' . FTP_PASS . '@' . FTP_SERVER . '/' . FTP_ROOTDIR . $filename, "wb"); $fwrite = fwrite($file, $text); fclose($file); RheinaufFile::chmod($filename, 777); return $fwrite; } else { if (!is_writable($filename)) { RheinaufFile::chmod($filename, 777); } $file = fopen($filename, "wb"); $fwrite = fwrite($file, $text); fclose($file); return $fwrite; } }
function maxscale($file) { $size = getimagesize($file); if ($size[0] > $this->max_scale['x'] || $size[1] > $this->max_scale['y']) { if (!class_exists('Bilder')) { include_once 'Bilder.php'; } if (!is_writeable($file)) { RheinaufFile::chmod($file, '777'); } $img = new Bilder($file, $file); if ($size[0] > $this->max_scale['x']) { $img->scaleMaxX($this->max_scale['x']); } else { $img->scaleMaxY($this->max_scale['y']); } $img->output(); } }
function xchmod($dir, $mode) { RheinaufFile::chmod($dir, $mode); $current_dir = opendir($dir); while ($entryname = readdir($current_dir)) { if (RheinaufFile::is_dir("{$dir}/{$entryname}") and ($entryname != "." and $entryname != "..")) { RheinaufFile::xchmod("{$dir}/{$entryname}", $mode); } elseif ($entryname != "." and $entryname != "..") { RheinaufFile::chmod("{$dir}/{$entryname}", $mode); } } closedir($current_dir); }
function db_insert() { $insert_sql = 'REPLACE INTO `' . $this->table . '` ('; $field_names = array(); foreach ($this->cols_array as $key => $col) { $field_name = $key; $field_names[] = '`' . $field_name . '`'; } $insert_sql .= implode(', ', $field_names); $insert_sql .= ") VALUES ("; $field_values = array(); foreach ($this->cols_array as $key => $col) { $field_value = $col['value'] ? $col['value'] : $_POST[rawurlencode($key)]; $field_value = !strstr($field_value, '--') ? $field_value : ''; $field_value = is_array($field_value) ? implode(', ', $field_value) : $field_value; if ($col['type'] == 'timestamp') { $t = Date::unify_timestamp($_POST[rawurlencode($key) . '_jahr'] . $_POST[rawurlencode($key) . '_monat'] . $_POST[rawurlencode($key) . '_tag'] . $_POST[rawurlencode($key) . '_stunde'] . $_POST[rawurlencode($key) . '_minute'] . '00'); $field_value = $t; } if ($col['type'] == 'email') { $field_value = $_POST[rawurlencode($key) . '_name']; if ($_POST[rawurlencode($key) . '_mail']) { $field_value .= ' <' . $_POST[rawurlencode($key) . '_mail'] . '>'; } } if ($col['type'] == 'upload') { if ($_FILES[rawurlencode($key) . '_upload']['name']) { if ($this->upload_folder) { if (!RheinaufFile::is_dir($folder = $this->upload_path . $_POST[$this->upload_folder])) { RheinaufFile::mkdir($folder); RheinaufFile::chmod($folder, '777'); } $upload_folder = $_POST[$this->upload_folder] . "/"; } $file = $this->upload_path . $upload_folder . $_FILES[rawurlencode($key) . '_upload']['name']; move_uploaded_file($_FILES[rawurlencode($key) . '_upload']['tmp_name'], $file); RheinaufFile::chmod($file, '777'); $field_value = $upload_folder . $_FILES[rawurlencode($key) . '_upload']['name']; } } if ($key == 'id') { $field_value = $_POST['edit_id'] ? $_POST['edit_id'] : ''; } $field_values[] = "'" . General::input_clean(rawurldecode($field_value), true) . "'"; } $insert_sql .= implode(', ', $field_values) . ')'; $this->connection->db_query($insert_sql); }
function new_db_insert() { $uniqid = md5(uniqid(rand(), true)); $schulname = General::input_clean($_POST['Schulname']); $plz = General::input_clean($_POST['PLZ']); $bilder_pfade = array(); if ($_FILES['bild']['name'][0] != '') { $output_path = DOCUMENT_ROOT . INSTALL_PATH . '/Images/BuddyListe/' . $plz . '_' . $schulname . '/'; if (!is_dir($output_path)) { RheinaufFile::mkdir($output_path); RheinaufFile::chmod($output_path, 777); } for ($i = 0; $i < count($_FILES['bild']); $i++) { if ($_FILES['bild']['error'][$i] == '0') { $bild = new Bilder($_FILES['bild']['tmp_name'][$i], $output_path . $_FILES['bild']['name'][$i]); $bild->scaleMaxX(200); $bild->output(); $bilder_pfade[] = 'Images/BuddyListe/' . $plz . '_' . $schulname . '/' . $_FILES['bild']['name'][$i]; } } } $insert_sql = 'INSERT INTO `RheinaufCMS>BuddyListe` ( `id` ,'; $field_names = array(); for ($i = 0; $i < count($this->fields); $i++) { $field_name = $this->fields[$i]['name']; $field_names[] = '`' . $field_name . '`'; } $insert_sql .= implode(', ', $field_names); $insert_sql .= ",`Bilder`,`angenommen`,`uniqid`) VALUES ('',"; $field_values = array(); for ($i = 0; $i < count($this->fields); $i++) { $field_value = $_POST[rawurlencode($this->fields[$i]['name'])]; $field_value = !strstr($field_value, '--') ? $field_value : ''; $field_value = is_array($field_value) ? implode(', ', $field_value) : $field_value; $field_values[] = "'" . General::input_clean(rawurldecode($field_value), true) . "'"; } $insert_sql .= implode(', ', $field_values) . ",'" . implode(';', $bilder_pfade) . "','0','{$uniqid}')"; $this->connection->db_query($insert_sql); }
function save_tmp() { $folder = $this->work_folder(); $contents = General::utf_8_decode($_POST['editor_text']); $contents = $this->strip_baseURL($contents); if (!RheinaufFile::is_dir($folder)) { RheinaufFile::mkdir($folder); RheinaufFile::chmod($folder, '0777'); } RheinaufFile::write_file($folder . "tmp.html", $contents); print 'Gespeichert'; }
function new_page_create() { $navi_id = $_GET['edit']; $rubrik_id = $this->navi[$navi_id]['id']; $rubrik_name = $this->navi[$navi_id]['Rubrik']; $new_name = General::input_clean($_POST['new_name'], true); $Show = isset($_POST['Show']) ? $_POST['Show'] : '0'; $new_id = count($this->navi[$navi_id]['Subnavi']); $new_subnavi = array(); $new_subnavi['ext_link'] = $this->path_adjust($_POST['ext_link']); $new_subnavi['Seite'] = $new_name; $new_subnavi['Show'] = $Show; $new_subnavi['Show_to'] = $this->input_group_array(); $this->navi[$navi_id]['Subnavi'][] = $new_subnavi; $this->make_the_new_navi(); $name_encoded = $this->path_encode($this->I18n_get_real($new_name)); $rubrik_name = $this->path_encode($this->I18n_get_real($rubrik_name)); if (!RheinaufFile::is_dir(DOCUMENT_ROOT . $install_path . '/Content/' . $rubrik_name . '/' . $name_encoded)) { RheinaufFile::mkdir(INSTALL_PATH . "/Content/{$rubrik_name}/{$name_encoded}"); RheinaufFile::chmod(INSTALL_PATH . "/Content/{$rubrik_name}/{$name_encoded}", 777); } $new_content_file = DOCUMENT_ROOT . $this->install_path . '/Content/' . $rubrik_name . '/' . $name_encoded . '/content.html'; if (!RheinaufFile::is_file($new_content_file)) { RheinaufFile::write_file($new_content_file, ' '); } $this->htaccess_update(); }