/** * todo: * make it so that running this on an existing directory won't do anything * without a -f flag in which case it will overwrite everything */ public function handleApp($p) { Zinc::loadLib('build'); $appDir = $p[3]; self::gen_r($appDir, 'basic', array()); // set up the tmp dir mkdir($appDir . '/tmp/Smarty3', 0770, true); _chmod($appDir . '/tmp', 0770, true); _chgrp($appDir . '/tmp', GetWebUser(), true); }
public function save($var, &$data) { global $config; if (!$this->use) { return; } $filename = ROOT . 'cache/' . $var . '.php'; $fp = @fopen($filename, 'w'); if ($fp) { $file_buffer = '<?php $' . 'this->cache[\'' . $var . '\'] = ' . ((is_array($data)) ? $this->format($data) : "'" . str_replace("'", "\\'", str_replace('\\', '\\\\', $data)) . "'") . '; ?>'; @flock($fp, LOCK_EX); fputs($fp, $file_buffer); @flock($fp, LOCK_UN); fclose($fp); _chmod($filename, $config['mask']); } return $data; }
exit; } if (isset($_GET["process-ttl"])) { process_timeexec(); exit; } if (isset($_GET["myisamchk"])) { myisamchk(); exit; } if (isset($_GET["filesize"])) { _filesize(); exit; } if (isset($_GET["chmod"])) { _chmod(); exit; } if (isset($_GET["readfile"])) { _readfile(); exit; } if (isset($_GET["TCP_NICS_STATUS_ARRAY"])) { TCP_NICS_STATUS_ARRAY(); exit; } if (isset($_GET["LaunchRemoteInstall"])) { LaunchRemoteInstall(); exit; } if (isset($_GET["restart-web-server"])) {
function schmod($path, $oct, $rec = 0, $dmode = 0) { @_chmod($path, $oct); if (empty($rec)) { return true; } if (empty($dmode)) { $dmode = $oct; } // Is the folder a directory if (is_dir($path)) { @_chmod($path, $dmode); } //We can chown the whole server if (empty($path) || $path == '/') { return false; } // We need to add a slash for the filelist() function $path = substr($path, -1) == '/' || substr($path, -1) == '\\' ? $path : $path . '/'; $files = filelist($path, 1, 0, 'all'); $files = !is_array($files) ? array() : $files; //Start CHOWNING! foreach ($files as $k => $v) { // Its a file if (empty($v['dir'])) { @_chmod($k, $oct); // Its a Direcrtory } else { @_chmod($k, $dmode); } } @clearstatcache(); return true; }
public function resize(&$row, $folder_a, $folder_b, $filename, $measure, $do_scale = true, $watermark = true, $remove = false, $watermark_file = false) { global $config; $t = (object) array( 'filename' => $filename . '.' . $row->extension, 'source' => $folder_a . $row->filename ); if (!@is_readable($t->source)) { $row->error = 'not_readable'; return false; } $t->destination = $folder_b . $t->filename; foreach ($t as $tk => $tv) { $row->$tk = $tv; } // Get source image data $dim = @getimagesize($t->source); if ($dim[0] < 1 && $dim[1] < 1) { $row->error = 'bad_size'; return false; } if ($dim[0] < $measure[0] && $dim[1] < $measure[1]) { $measure[0] = $dim[0]; $measure[1] = $dim[1]; } $row->width = $dim[0]; $row->height = $dim[1]; $row->mwidth = $measure[0]; $row->mheight = $measure[1]; $mode = ($do_scale === true) ? 'c' : 'v'; $scale = $this->scale($mode, $row); $row->width = $scale->width; $row->height = $scale->height; switch ($dim[2]) { case IMG_JPG: $image_f = 'imagecreatefromjpeg'; $image_g = 'imagejpeg'; $image_t = 'jpg'; break; case IMG_GIF: $image_f = 'imagecreatefromgif'; $image_g = 'imagegif'; $image_t = 'gif'; break; case IMG_PNG: $image_f = 'imagecreatefrompng'; $image_g = 'imagepng'; $image_t = 'png'; break; } if (!$generated = $image_f($t->source)) { return false; } imagealphablending($generated, true); $thumb = imagecreatetruecolor($row->width, $row->height); imagecopyresampled($thumb, $generated, 0, 0, 0, 0, $row->width, $row->height, $dim[0], $dim[1]); // Watermark if ($watermark) { if ($watermark_file === false) { $watermark_file = $config['watermark']; } if (!empty($watermark_file)) { $wm = imagecreatefrompng($watermark_file); $wm_w = imagesx($wm); $wm_h = imagesy($wm); if ($watermark_file == 'w') { $dest_x = $row->width - $wm_w - 5; $dest_y = $row->height - $wm_h - 5; imagecopymerge($thumb, $wm, $dest_x, $dest_y, 0, 0, $wm_w, $wm_h, 100); imagedestroy($wm); } else { $dest_x = round(($row->width / 2) - ($wm_w / 2)); $dest_y = round(($row->height / 2) - ($wm_h / 2)); $thumb = $this->alpha_overlay($thumb, $wm, $wm_w, $wm_h, $dest_x, $dest_y, 100); } } } if ($type == IMG_JPG) { $created = @$image_g($thumb, $t->destination, 85); } else { $created = @$image_g($thumb, $t->destination); } if (!$created || !file_exists($t->destination)) { $row->error = 'not_created'; return false; } _chmod($t->destination, $config['mask']); imagedestroy($thumb); imagedestroy($image); if ($remove && file_exists($t->source)) { _rm($t->source); } return $row; }
function artist_check($ary) { global $config; $fullpath = $config['artists_path']; if (!is_array($ary)) $ary = w($ary); foreach ($ary as $row) { $fullpath .= $row . '/'; if (!@file_exists($fullpath)) { if (!_md($fullpath)) { return false; } _chmod($fullpath, $config['mask']); } } return true; }
/** * Write cache to disk */ public function write_cache($filename, $code) { global $config; // check if cache is writable if (!$this->cache_writable) { return false; } // check if filename is valid if(substr($filename, 0, strlen($this->cachedir)) !== $this->cachedir) { return false; } // try to open file $file = @fopen($filename, 'w'); if(!$file) { // try to create directories $dir = substr($filename, strlen($this->cachedir), strlen($filename)); $dirs = explode('/', $dir); $path = $this->cachedir; @umask(0); if (!@is_dir($path)) { if (!@mkdir($path)) { $this->cache_writable = 0; return false; } else { _chmod($path, $config['mask']); } } $count = count($dirs); if ($count > 0) { for ($i = 0; $i < $count-1; $i++) { if ($i>0) { $path .= '/'; } $path .= $dirs[$i]; if(!@is_dir($path)) { if(!@mkdir($path)) { $this->cache_writable = 0; return false; } else { _chmod($path, $config['mask']); } } } } // try to open file again after directories were created $file = @fopen($filename, 'w'); } if (!$file) { $this->cache_writable = 0; return false; } fputs($file, "<?php\n\n// Generated on " . date('r') . " (time=" . time() . ")\n\n?>"); fputs($file, $code); fclose($file); _chmod($filename, $config['mask']); return true; }
public static function unlock($path) { return !@_chmod($path, 777); }
public function _home() { global $config, $user, $cache; $ftp = new ftp(); if (!$ftp->ftp_connect($config['broadcast_host'])) { _pre('Can not connect', true); } if (!$ftp->ftp_login($config['broadcast_username'], $config['broadcast_password'])) { $ftp->ftp_quit(); _pre('Can not login', true); } $cds_file = ROOT . 'interfase/cds/schedule_playlist.txt'; // Submit if (_button()) { $hours = request_var('hours', array('' => '')); $build = ''; foreach ($hours as $hour => $play) { $build .= ((!empty($build)) ? nr(1) : '') . trim($hour) . ':' . trim($play); } if ($fp = @fopen($cds_file, 'w')) { @flock($fp, LOCK_EX); fputs($fp, $build); @flock($fp, LOCK_UN); fclose($fp); _chmod($cds_file, $config['mask']); if ($ftp->ftp_put('/Schedule/schedule_playlist.txt', $cds_file)) { echo '<h1>El archivo fue procesado correctamente.</h1>'; } else { echo '<h1>Error al procesar, intenta nuevamente.</h1>'; } } else { echo 'Error de escritura en archivo local.'; } echo '<br />'; } if (!@file_exists($cds_file)) { fatal_error(); } $cds = @file($cds_file); $filelist = $ftp->ftp_nlist('/Schedule'); echo '<pre>'; print_r($filelist); echo '</pre>'; foreach ($cds as $item) { $e_item = array_map('trim', explode(':', $item)); if (!empty($e_item[0])) { echo sumhour($e_item[0]) . ' <input type="text" name="hours[' . $e_item[0] . ']" value="' . $e_item[1] . '" size="100"' . ((oclock($e_item[0])) ? 'class="highlight"' : '') . ' /><br />' . nr(); } } $ftp->ftp_quit(); return true; }
function _unlock($file) { return _chmod($file, 777); }