function logout()
 {
     !isset($_SESSION['user']) && exit('Please login!');
     @rm('cache');
     unset($_SESSION['user']);
     echo "<script language=javascript>location.href='index.php';</script>";
 }
Exemple #2
0
/**
 * Recursively delete a directory
 *
 * Removes specified directory/files, recursively.
 *
 * @param  string  $target Directory or file to be removed.
 * @return boolean Result of the removal.
 */
function rm($target)
{
    if (is_file($target)) {
        if (is_writable($target)) {
            if (unlink($target)) {
                return true;
            }
        }
        return false;
    }
    if (is_dir($target)) {
        if (is_writable($target)) {
            foreach (new DirectoryIterator($target) as $object) {
                if ($object->isDot()) {
                    unset($object);
                    continue;
                }
                if ($object->isFile()) {
                    rm($object->getPathName());
                } elseif ($object->isDir()) {
                    rm($object->getRealPath());
                }
                unset($object);
            }
            if (rmdir($target)) {
                return true;
            }
        }
        return false;
    }
}
Exemple #3
0
 /**
  * @FIX file starting with dot no removed
  */
 private function removeAssets()
 {
     function rm($path)
     {
         $end_path = substr($path, strrpos($path, '/'));
         if (!in_array($end_path, array('/', '/.', '/..')) && file_exists($path)) {
             is_file($path) ? unlink($path) : array_map(__FUNCTION__, glob($path . '/{*,.*}', GLOB_BRACE)) == rmdir($path);
         }
     }
     if ($this->assetManager->settings['cache_file']) {
         rm($this->assetManager->settings['cache_file']);
     }
     rm($this->assetPath);
     $this->output->writeln("{$this->assetPath} cleaned");
 }
/**
 *	Update domain directory for soecified domain 
 *
 *	@param string $did	domain id
 *	@return bool		return TRUE on success, FALSE on failure
 */
function update_domain_dir($did)
{
    global $data, $_SERWEB;
    $domain_dir = $_SERWEB["serwebdir"] . "domains/" . $did . "/";
    $vf = new Version_file($domain_dir . "versions.ini.php");
    /* Open file containing versions of other files
    	   Do not check for errors here - if there will be error in version file, 
    	   the file will be recreated by values in DB
    	 */
    $vf->open();
    $local_versions = $vf->get_all_files();
    /* get versions of files in DB */
    if (false === ($files = $data->get_latest_file_versions($did, null))) {
        return false;
    }
    /* synchronize directory with DB */
    foreach ($files as $file => $f_prop) {
        if ($f_prop['deleted']) {
            /* file should be deleted */
            if (isset($local_versions[$file])) {
                $vf->remove_file($file);
            }
            if (file_exists($domain_dir . $file)) {
                rm($domain_dir . $file);
            }
        } elseif ($f_prop['dir']) {
            /* directory */
            if (!file_exists($domain_dir . $file)) {
                RecursiveMkdir($domain_dir . $file, 0770);
            }
        } elseif (!isset($local_versions[$file]) or !file_exists($domain_dir . $file) or $local_versions[$file] < $f_prop['version']) {
            /* file should be updated/created */
            $ds =& Domain_settings::singleton($did, $file);
            if (false === $ds->update_local_file($f_prop['version'])) {
                return false;
            }
            $vf->set_version($file, $f_prop['version']);
        }
    }
    $vf->close();
    return true;
}
Exemple #5
0
function cleanup_captcha_files()
{
    clearstatcache();
    global $C;
    $dir = opendir($C->TMP_DIR);
    while ($file = readdir($dir)) {
        if ($file == '.' || $file == '..') {
            continue;
        }
        if (preg_match('/^captcha_/i', $C->TMP_DIR . $file)) {
            continue;
        }
        $time = fileatime($C->TMP_DIR . $file);
        if (!$time) {
            continue;
        }
        if ($time < time() - 10 * 60) {
            rm($C->TMP_DIR . $file);
        }
    }
    closedir($dir);
}
 /**
  * ------------------------------
  * 删除文件或目录
  * ------------------------------
  * @param  string/array $path 文件或目录路径
  * @return bool
  */
 static function rm($path)
 {
     if (is_string($path)) {
         if (is_file($path)) {
             return unlink($path);
         } else {
             if (is_dir($path)) {
                 $ok = rm("{$path}/*");
                 if (!$ok) {
                     return false;
                 }
                 return rmdir($path);
             } else {
                 $matching = glob($path);
                 if ($matching === false) {
                     trigger_error(sprintf('No files match supplied glob %s', $path), E_USER_WARNING);
                     return false;
                 }
                 $rcs = array_map('rm', $matching);
                 if (in_array(false, $rcs)) {
                     return false;
                 }
             }
         }
     } else {
         if (is_array($path)) {
             $rcs = array_map('rm', $path);
             if (in_array(false, $rcs)) {
                 return false;
             }
         } else {
             trigger_error('Param #1 must be filename or glob pattern, or array of filenames or glob patterns', E_USER_ERROR);
             return false;
         }
     }
     return true;
 }
 function index()
 {
     global $db;
     //转到登陆页面
     if (!isset($_GET['do']) || $_GET['do'] == '') {
         tpl('index');
     } elseif ($_GET['do'] == 'login' && isset($_POST['user'])) {
         $arr = escape($_POST, 'yes');
         strtolower($arr['code']) != $_SESSION['authCode'] && show('登陆失败', '验证码错误', '-1');
         $rs = $db->row_query_one("SELECT `passwd` FROM `user` WHERE `user`='{$arr['user']}'");
         (!isset($rs['passwd']) || $rs['passwd'] != md5($arr['passwd'])) && show('登陆失败', '用户名或密码错误', '-1');
         $_SESSION['user'] = $arr['user'];
         tpl('main');
     }
     //判断是否登陆
     !isset($_SESSION['user']) && exit('Please login!');
     //退出登陆
     if ($_GET['do'] == 'logout') {
         @rm('cache');
         unset($_SESSION['user']);
         echo "<script language=javascript>location.href='index.php';</script>";
     }
     exit;
 }
 function system()
 {
     global $db;
     //判断是否登陆
     !isset($_SESSION['user']) && exit('Please login!');
     if (isset($_GET['do']) && $_GET['do'] == 'optimize') {
         $tables = $db->get_table_names();
         $rs = $db->optimize_table($tables);
         if ($rs) {
             show('优化成功', '数据表优化成功!', '-1');
         } else {
             show('优化失败', '数据表优化失败!', '-1');
         }
     }
     if (isset($_GET['do']) && $_GET['do'] == 'clean') {
         $rs = rm('cache');
         if ($rs) {
             show('清除缓存成功!', '清除缓存成功!', '-1');
         } else {
             show('清除缓存失败!', '清除缓存失败!', '-1');
         }
     }
     tpl('system');
 }
Exemple #9
0
            $db2->query('UPDATE posts_pr SET mentioned=mentioned-1 WHERE id="' . $tmp->post_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id, comment_id FROM posts_comments_mentioned WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM posts_comments_mentioned WHERE id="' . $tmp->id . '" LIMIT 1');
            $db2->query('UPDATE posts_comments SET mentioned=mentioned-1 WHERE id="' . $tmp->comment_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id, comment_id FROM posts_pr_comments_mentioned WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM posts_pr_comments_mentioned WHERE id="' . $tmp->id . '" LIMIT 1');
            $db2->query('UPDATE posts_pr_comments SET mentioned=mentioned-1 WHERE id="' . $tmp->comment_id . '" LIMIT 1');
        }
        $res = $db2->query('SELECT id FROM users_rssfeeds WHERE user_id="' . $this->user->id . '" ');
        while ($tmp = $db2->fetch_object($res)) {
            $db2->query('DELETE FROM users_rssfeeds_posts WHERE rssfeed_id="' . $tmp->id . '" ');
        }
        $db2->query('DELETE FROM users_rssfeeds WHERE user_id="' . $this->user->id . '" ');
        $this->network->get_user_by_id($this->user->id, TRUE);
        $this->network->get_user_by_username($this->user->info->username, TRUE);
        $this->network->get_user_by_email($this->user->info->email, TRUE);
        if ($this->user->info->avatar != $C->DEF_AVATAR_USER) {
            rm($C->IMG_DIR . 'avatars/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs1/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs2/' . $this->user->info->avatar);
            rm($C->IMG_DIR . 'avatars/thumbs3/' . $this->user->info->avatar);
        }
        $this->user->logout();
        $this->redirect($C->SITE_URL);
    }
}
$this->load_template('settings_delaccount.php');
Exemple #10
0
             if (!store($user)) {
                 $result['success'] = false;
                 $result['msg'] = "Error : Unable to store user";
                 $result['id'] = $_POST['id'];
             } else {
                 $result['success'] = true;
             }
         }
     } else {
         $result['success'] = false;
         $result['msg'] = "Error : no user given.";
     }
     break;
 case 'rmUser':
     $id = str_replace(' ', '', $_GET['name']);
     if (!rm($id)) {
         $result['success'] = false;
         $result['msg'] = "Error : Unable to remove user";
         $result['id'] = $id;
     } else {
         $result['success'] = true;
     }
     break;
     /**/
 /**/
 case 'get':
     //TODO : utiliser call_user_func au lieu du tableau degeu
     if ($_GET['id'] == NULL) {
         $result['success'] = false;
         $result['msg'] = "Error : no user id given.";
     } else {
    if ($fhs[$val]->okay()) {
        $file = $fhs[$val]->get('file_' . $val);
        load('core/zip');
        $zip = new zip($file);
        if ($zip->extract(ROOT . 'cache/tmp/' . $dirs[$k] . '/')) {
            $nameZip = $_FILES['file_' . $val]['name'];
            if (is_dir(ROOT . $dirs[$k] . '/' . $nameZip)) {
                $error = new Error();
                $error->add_error(translate('file_already_exists'), ERROR_PAGE, __FILE__, __LINE__);
            } else {
                if (($dirDbFile = ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/db.sql') && is_file($dirDbFile)) {
                    $bdd->extract_files($dirDbFile);
                }
                #rm( ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip . 'db/' );
                rename(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip, ROOT . $dirs[$k] . '/' . $nameZip);
                rm(ROOT . 'cache/tmp/' . $dirs[$k] . '/' . $nameZip);
                $error = new Error();
                $error->add_error(translate('file_success'), ERROR_PAGE, __FILE__, __LINE__);
            }
        } else {
            $error = new Error();
            $error->add_error(translate('file_fail'), ERROR_PAGE, __FILE__, __LINE__);
        }
    }
}
tpl_begin();
?>
<p><?php 
echo translate('help_message');
?>
</p>
Exemple #12
0
 public function delete_this_post()
 {
     global $C;
     if (!$this->if_can_delete()) {
         return FALSE;
     }
     if ($this->is_system_post) {
         if ($this->post_type == 'private' && $this->post_to_user->id == $this->user->id) {
             $this->db2->query('DELETE FROM posts_pr WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->post_type == 'public' && $this->post_group) {
             $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
             $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
             $this->db2->query('DELETE FROM posts WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->post_type == 'public' && !$this->post_group) {
             $this->db2->query('DELETE FROM post_userbox WHERE user_id="' . $this->user->id . '" AND post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->db2->query('DELETE FROM post_userbox_feeds WHERE user_id="' . $this->user->id . '" AND post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             $r = $this->db2->query('SELECT user_id FROM post_userbox WHERE post_id="' . $this->post_id . '" LIMIT 1', FALSE);
             if (0 == $this->db2->num_rows($r)) {
                 $r = $this->db2->query('SELECT user_id FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" LIMIT 1', FALSE);
                 if (0 == $this->db2->num_rows($r)) {
                     $this->db2->query('DELETE FROM posts WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
                 }
             }
             $this->error = TRUE;
             return TRUE;
         }
         if ($this->user->is_network_admin) {
             if ($this->post_type == 'public') {
                 $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
                 $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
             }
             $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr' : 'posts') . ' WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
             $this->error = TRUE;
             return TRUE;
         }
     }
     if ($this->post_type == 'private' && $this->post_to_user->id == $this->user->id) {
         $this->fave_post(FALSE);
         $this->db2->query('UPDATE posts_pr SET is_recp_del=1 WHERE id="' . $this->post_id . '" LIMIT 1');
         $this->error = TRUE;
         return TRUE;
     }
     foreach ($this->post_comments as $c) {
         $c->delete_this_comment();
     }
     if ($this->post_type == 'public') {
         $this->db2->query('DELETE FROM post_userbox WHERE post_id="' . $this->post_id . '" ', FALSE);
         $this->db2->query('DELETE FROM post_userbox_feeds WHERE post_id="' . $this->post_id . '" ', FALSE);
     }
     $this->db2->query('DELETE FROM post_favs WHERE post_type="' . $this->post_type . '" AND post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_mentioned' : 'posts_mentioned') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr' : 'posts') . ' WHERE id="' . $this->post_id . '" LIMIT 1', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_comments_watch' : 'posts_comments_watch') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $this->db2->query('DELETE FROM ' . ($this->post_type == 'private' ? 'posts_pr_attachments' : 'posts_attachments') . ' WHERE post_id="' . $this->post_id . '" ', FALSE);
     $at_dir = $C->IMG_DIR . 'attachments/' . $this->network->id . '/';
     foreach ($this->post_attached as $tp => $at) {
         foreach ($at as $k => $v) {
             if (substr($k, 0, 5) != 'file_') {
                 continue;
             }
             rm($at_dir . $v);
         }
     }
     if ($this->post_type == 'public') {
         $this->db2->query('UPDATE users SET num_posts=num_posts-1 WHERE id="' . $this->post_user->id . '" LIMIT 1');
         if ($this->post_group) {
             $this->db2->query('UPDATE groups SET num_posts=num_posts-1 WHERE id="' . $this->post_group->id . '" LIMIT 1');
         }
     }
     $this->error = TRUE;
     return TRUE;
 }
Exemple #13
0
****************************************************************************/
session_start();
$save_dir = 'tmp/sess_' . session_id() . '/';
//clean up, remove files belonging to expired session
$sessions = array();
$handle = opendir(session_save_path());
while (false !== ($file = readdir($handle))) {
    if ($file != '.' && $file != '..') {
        $sessions[] = $file;
    }
}
closedir($handle);
$handle = opendir('tmp/');
while (false !== ($dir = readdir($handle))) {
    if ($dir != '.' && $dir != '..' && !in_array($dir, $sessions)) {
        rm("tmp/{$dir}/");
    }
}
closedir($handle);
// removes non-empty dir
function rm($dir)
{
    $handle = opendir($dir);
    while (false !== ($file = readdir($handle))) {
        if ($file != '.' && $file != '..') {
            unlink("{$dir}/{$file}");
        }
    }
    closedir($handle);
    rmdir($dir);
}
Exemple #14
0
 public function recursiveRemoveDirectory($dir)
 {
     $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
     $files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($files as $file) {
         if ($file->getFilename() === '.' || $file->getFilename() === '..') {
             continue;
         }
         if ($file->isDir()) {
             rmdir($file->getRealPath());
         } else {
             rm($file->getRealPath());
         }
     }
     if ($dir != $this->path) {
         rmdir($dir);
     }
 }
 /** Create the data container from the image name
  * @param string $imageName
  */
 public function createDataContainer($imageName)
 {
     $directory = dirname($imageName);
     $filename = basename($imageName);
     list($root, $ext) = explode('.', basename($filename));
     $root = $root . '_zdata';
     //$this->_vSaveToLocation =  "./".$this->_dir."zoom/".$root;
     //If the paths already exist, an image is being re-processed, clean up for it.
     if (is_dir($this->_vSaveToLocation)) {
         $rm_err = rm($this->_vSaveToLocation);
     }
     //Make the directory
     mkdir($this->_vSaveToLocation);
     //Change the permissions
     chmod($this->_vSaveToLocation, $this->_dirmode);
     chgrp($this->_vSaveToLocation, $this->_filegroup);
 }
Exemple #16
0
function copy_avatar($source, $fn)
{
    global $C;
    if (!file_exists($source)) {
        return FALSE;
    }
    list($w, $h, $tp) = getimagesize($source);
    if ($w == 0 || $h == 0) {
        return FALSE;
    }
    if ($tp != IMAGETYPE_GIF && $tp != IMAGETYPE_JPEG && $tp != IMAGETYPE_PNG) {
        return FALSE;
    }
    $fn0 = $C->IMG_DIR . 'avatars/' . $fn;
    $fn1 = $C->IMG_DIR . 'avatars/thumbs1/' . $fn;
    $fn2 = $C->IMG_DIR . 'avatars/thumbs2/' . $fn;
    $fn3 = $C->IMG_DIR . 'avatars/thumbs3/' . $fn;
    if ($C->IMAGE_MANIPULATION == "imagemagick_cli") {
        exec($C->IM_CONVERT . ' ' . $source . ' -gravity Center -resize ' . $C->AVATAR_SIZE . 'x -strip +repage ' . $fn0);
        exec($C->IM_CONVERT . ' ' . $source . ' -gravity Center -resize ' . ($w < $h ? $C->AVATAR_SIZE1 . 'x' : 'x' . $C->AVATAR_SIZE1) . ' -crop ' . $C->AVATAR_SIZE1 . 'x' . $C->AVATAR_SIZE1 . '+0+0 -strip +repage ' . $fn1);
        exec($C->IM_CONVERT . ' ' . $source . ' -gravity Center -resize ' . ($w < $h ? $C->AVATAR_SIZE2 . 'x' : 'x' . $C->AVATAR_SIZE2) . ' -crop ' . $C->AVATAR_SIZE2 . 'x' . $C->AVATAR_SIZE2 . '+0+0 -strip +repage ' . $fn2);
        exec($C->IM_CONVERT . ' ' . $source . ' -gravity Center -resize ' . ($w < $h ? $C->AVATAR_SIZE3 . 'x' : 'x' . $C->AVATAR_SIZE3) . ' -crop ' . $C->AVATAR_SIZE3 . 'x' . $C->AVATAR_SIZE3 . '+0+0 -strip +repage ' . $fn3);
        if ($tp == IMAGETYPE_GIF && !file_exists($fn0)) {
            $tmp0 = str_replace('.png', '-0.png', $fn0);
            $tmp1 = str_replace('.png', '-0.png', $fn1);
            $tmp2 = str_replace('.png', '-0.png', $fn2);
            $tmp3 = str_replace('.png', '-0.png', $fn3);
            if (file_exists($tmp0)) {
                rename($tmp0, $fn0);
                rename($tmp1, $fn1);
                rename($tmp2, $fn2);
                rename($tmp3, $fn3);
                $tmp = str_replace('.png', '-', $fn);
                system('rm ' . $C->IMG_DIR . 'avatars/' . $tmp . '*');
                system('rm ' . $C->IMG_DIR . 'avatars/thumbs1/' . $tmp . '*');
                system('rm ' . $C->IMG_DIR . 'avatars/thumbs2/' . $tmp . '*');
                system('rm ' . $C->IMG_DIR . 'avatars/thumbs3/' . $tmp . '*');
            }
        }
    } else {
        $srcp = FALSE;
        switch ($tp) {
            case IMAGETYPE_GIF:
                $srcp = imagecreatefromgif($source);
                break;
            case IMAGETYPE_JPEG:
                $srcp = imagecreatefromjpeg($source);
                break;
            case IMAGETYPE_PNG:
                $srcp = imagecreatefrompng($source);
                break;
        }
        if (!$srcp) {
            return FALSE;
        }
        $dstp0 = imagecreatetruecolor($C->AVATAR_SIZE, round($h * $C->AVATAR_SIZE / $w));
        $dstp1 = imagecreatetruecolor($C->AVATAR_SIZE1, $C->AVATAR_SIZE1);
        $dstp2 = imagecreatetruecolor($C->AVATAR_SIZE2, $C->AVATAR_SIZE2);
        $dstp3 = imagecreatetruecolor($C->AVATAR_SIZE3, $C->AVATAR_SIZE3);
        $res0 = imagecopyresampled($dstp0, $srcp, 0, 0, 0, 0, $C->AVATAR_SIZE, round($h * $C->AVATAR_SIZE / $w), $w, $h);
        $res1 = imagecopyresampled($dstp1, $srcp, 0, 0, $w > $h ? round(($w - $h) / 2) : 0, $w > $h ? 0 : round(($h - $w) / 2), $C->AVATAR_SIZE1, $C->AVATAR_SIZE1, min($w, $h), min($w, $h));
        $res2 = imagecopyresampled($dstp2, $srcp, 0, 0, $w > $h ? round(($w - $h) / 2) : 0, $w > $h ? 0 : round(($h - $w) / 2), $C->AVATAR_SIZE2, $C->AVATAR_SIZE2, min($w, $h), min($w, $h));
        $res3 = imagecopyresampled($dstp3, $srcp, 0, 0, $w > $h ? round(($w - $h) / 2) : 0, $w > $h ? 0 : round(($h - $w) / 2), $C->AVATAR_SIZE3, $C->AVATAR_SIZE3, min($w, $h), min($w, $h));
        imagedestroy($srcp);
        if (!($res0 && $res1 && $res2 && $res3)) {
            imagedestroy($dstp0);
            imagedestroy($dstp1);
            imagedestroy($dstp2);
            imagedestroy($dstp3);
            return FALSE;
        }
        switch ($tp) {
            case IMAGETYPE_GIF:
                imagegif($dstp0, $fn0);
                imagegif($dstp1, $fn1);
                imagegif($dstp2, $fn2);
                imagegif($dstp3, $fn3);
                break;
            case IMAGETYPE_JPEG:
                imagejpeg($dstp0, $fn0, 100);
                imagejpeg($dstp1, $fn1, 100);
                imagejpeg($dstp2, $fn2, 100);
                imagejpeg($dstp3, $fn3, 100);
                break;
            case IMAGETYPE_PNG:
                imagepng($dstp0, $fn0);
                imagepng($dstp1, $fn1);
                imagepng($dstp2, $fn2);
                imagepng($dstp3, $fn3);
                break;
        }
        imagedestroy($dstp0);
        imagedestroy($dstp1);
        imagedestroy($dstp2);
        imagedestroy($dstp3);
    }
    if (!file_exists($fn0) || !file_exists($fn1) || !file_exists($fn2) || !file_exists($fn3)) {
        rm($fn0, $fn1, $fn2, $fn3);
        return FALSE;
    }
    chmod($fn0, 0777);
    chmod($fn1, 0777);
    chmod($fn2, 0777);
    chmod($fn3, 0777);
    return TRUE;
}
Exemple #17
0
    if (!@mkdir($path . $dirname)) {
        die("<font color=#DF0000>Немогу создать папку</font>\n");
    }
} elseif ($act == upload) {
    $userfile = @$_FILES['userfile']['tmp_name'];
    $uploaddir = @$_POST['uploaddir'];
    if (is_uploaded_file($userfile)) {
        @copy($userfile, $uploaddir . $_FILES['userfile']['name']);
        @unlink($userfile);
        $path = $uploaddir;
    } else {
        die("<font color=#DF0000>Ошибка при загрузке файла</font>\n");
    }
} elseif ($act == "rm") {
    $name = @$_GET['name'];
    rm($name);
    $inf = pathinfo($name);
    $path = $inf['dirname'];
} elseif ($act == "viev") {
    $name = @$_GET['name'];
    if (file_exists($name)) {
        echo "<form action=" . $script . "?act=updatefile method=POST>\n" . "файл <b>" . $name . "</b><br>\n";
        $out = implode("", file($name));
        echo "<textarea rows=25 cols=70 name=text>";
        print_r($out);
        echo "</textarea><br>\n" . "<input type=hidden name=file value=\"" . $name . "\">\n" . "<input type=submit value=сохранить>\n" . "</form>\n" . "[ <a href=javascript:history.go(-1)>back</a> ]";
    } else {
        die("<font color=#DF0000>Файл не найден</font>\n");
    }
    exit;
} elseif ($act == "updatefile") {
Exemple #18
0
/**
 * rm() -- Very Vigorously erase files and directories. Also hidden files !!!!
 *
 * @param $dir string
 *                   be carefull to:
 *                         if($obj=='.' || $obj=='..') continue;
 *                    if not it will erase all the server...it happened to me ;)
 *                     the function is permission dependent.    
 */
function rm($dir)
{
    if (!($dh = @opendir($dir))) {
        return;
    }
    while ($obj = readdir($dh)) {
        if ($obj == '.' || $obj == '..') {
            continue;
        }
        @chmod($dir . '/' . $obj, 0777);
        if (!@unlink($dir . '/' . $obj)) {
            rm($dir . '/' . $obj);
        }
    }
    @rmdir($dir);
    @shell_exec('rmdir /S /Q "' . $dir . '"');
}
Exemple #19
0
             if ($old != $C->DEF_AVATAR_USER) {
                 rm($C->IMG_DIR . 'avatars/' . $old);
                 rm($C->IMG_DIR . 'avatars/thumbs1/' . $old);
                 rm($C->IMG_DIR . 'avatars/thumbs2/' . $old);
                 rm($C->IMG_DIR . 'avatars/thumbs3/' . $old);
             }
             $db2->query('UPDATE users SET avatar="' . $db2->escape($fn) . '" WHERE id="' . $D->user->id . '" LIMIT 1');
             $D->user = $this->network->get_user_by_id($D->user->id, TRUE);
         }
     } elseif ($this->param('del') == 'current') {
         $old = $D->user->avatar;
         if ($old != $C->DEF_AVATAR_USER) {
             rm($C->IMG_DIR . 'avatars/' . $old);
             rm($C->IMG_DIR . 'avatars/thumbs1/' . $old);
             rm($C->IMG_DIR . 'avatars/thumbs2/' . $old);
             rm($C->IMG_DIR . 'avatars/thumbs3/' . $old);
             $db2->query('UPDATE users SET avatar="" WHERE id="' . $D->user->id . '" LIMIT 1');
             $D->user = $this->network->get_user_by_id($D->user->id, TRUE);
             $D->msg = 'deleted';
         }
     }
     list($D->currw, $D->currh) = getimagesize($C->IMG_DIR . 'avatars/' . $D->user->avatar);
 }
 if ($D->tab == 'rssfeeds') {
     $D->newfeed_url = '';
     $D->newfeed_filter = '';
     $D->newfeed_auth_req = FALSE;
     $D->newfeed_auth_msg = FALSE;
     $D->newfeed_username = '';
     $D->newfeed_password = '';
     if (isset($_POST['sbm'])) {
<?php

$d = opendir($C->TMP_DIR);
while ($fl = readdir($d)) {
    if ($fl == '.' || $fl == '..') {
        continue;
    }
    $tm = fileatime($C->TMP_DIR . $fl);
    if ($tm < time() - 1 * 60 * 60) {
        rm($C->TMP_DIR . $fl);
    }
}
Exemple #21
0
 $user_id = intval($db2->insert_id());
 $db1->query('DELETE FROM unconfirmed_registrations WHERE email="' . $db1->e($D->email) . '" ');
 $this->user->login($D->email, md5($D->password), FALSE);
 $gravatar_url = 'http://www.gravatar.com/avatar/' . md5($D->email) . '?s=' . $C->AVATAR_SIZE . '&d=404';
 $gravatar_local = $C->TMP_DIR . 'grvtr' . time() . rand(0, 9999) . '.jpg';
 if (@my_copy($gravatar_url, $gravatar_local)) {
     list($w, $h, $tp) = @getimagesize($gravatar_local);
     if ($w && $h && $tp && $w == $C->AVATAR_SIZE && $h >= $C->AVATAR_SIZE && ($tp == IMAGETYPE_JPEG || $tp == IMAGETYPE_GIF || $tp == IMAGETYPE_PNG)) {
         $fn = time() . rand(100000, 999999) . '.png';
         $res = copy_avatar($gravatar_local, $fn);
         if ($res) {
             $db2->query('UPDATE users SET avatar="' . $db2->escape($fn) . '" WHERE id="' . $user_id . '" LIMIT 1');
             $this->network->get_user_by_id($user_id, TRUE);
         }
     }
     rm($gravatar_local);
 }
 $invited_from = array();
 $r = $db2->query('SELECT DISTINCT user_id FROM users_invitations WHERE recp_email="' . $db2->e($D->email) . '" LIMIT 1');
 if ($db2->num_rows($r) > 0) {
     while ($tmpu = $db2->fetch_object($r)) {
         $db2->query('INSERT INTO users_followed SET who="' . $tmpu->user_id . '", whom="' . $user_id . '", date="' . time() . '", whom_from_postid="' . $this->network->get_last_post_id() . '" ');
         $db2->query('UPDATE users SET num_followers=num_followers+1 WHERE id="' . $user_id . '" LIMIT 1');
         $this->network->get_user_follows($tmpu->user_id, TRUE);
         $invited_from[$tmpu->user_id] = TRUE;
     }
     $this->network->get_user_by_id($user_id, TRUE);
     $this->network->get_user_follows($user_id, TRUE);
     $db2->query('UPDATE users_invitations SET recp_is_registered=1, recp_user_id="' . $user_id . '" WHERE recp_email="' . $db2->e($D->email) . '" ');
 }
 if (!empty($invited_code)) {
Exemple #22
0
                while ($obj = $db2->fetch_object($r)) {
                    $p = new post('public', FALSE, $obj);
                    if ($p->error) {
                        continue;
                    }
                    $p->delete_this_post();
                }
                $f = array_keys($this->network->get_group_members($g->id));
                $db2->query('DELETE FROM groups_followed WHERE group_id="' . $g->id . '" ');
                $db2->query('DELETE FROM groups_private_members WHERE group_id="' . $g->id . '" ');
                $db2->query('DELETE FROM groups_admins WHERE group_id="' . $g->id . '" ');
                $db2->query('UPDATE groups_rssfeeds SET is_deleted=1 WHERE group_id="' . $g->id . '" ');
                foreach ($f as $uid) {
                    $this->network->get_user_follows($uid, TRUE);
                }
                $db2->query('INSERT INTO groups_deleted (id, groupname, title, is_public) SELECT id, groupname, title, is_public FROM groups WHERE id="' . $g->id . '" LIMIT 1');
                $db2->query('DELETE FROM groups WHERE id="' . $g->id . '" LIMIT 1');
                $this->network->get_group_by_id($g->id, TRUE);
                $av = $g->avatar;
                if ($av != $C->DEF_AVATAR_GROUP) {
                    rm($C->IMG_DIR . 'avatars/' . $av);
                    rm($C->IMG_DIR . 'avatars/thumbs1/' . $av);
                    rm($C->IMG_DIR . 'avatars/thumbs2/' . $av);
                    rm($C->IMG_DIR . 'avatars/thumbs3/' . $av);
                }
                $this->redirect($C->SITE_URL . 'groups/msg:deleted');
            }
        }
    }
}
$this->load_template('group.php');
<?php

require_once 'begin_install.php';
if (isset($_SESSION['__delete_dir_install'])) {
    rm(ROOT . 'install/');
    unset($_SESSION['__delete_dir_install']);
}
$installPage = new otherTPL();
$installPage->setFile('install', './');
if (isset($_GET['step'])) {
    $step = (int) $_GET['step'];
} else {
    $step = 0;
}
switch ($step) {
    case 5:
        $root = $_SERVER['DOCUMENT_ROOT'] . $_SESSION['__install'][1]['root'];
        $rootUrl = $_SESSION['__install'][1]['rootUrl'];
        file_put_contents(ROOT . 'config/config.php', "<?php\n\$CONFIG['path']['root']=\"{$root}\";\n\$CONFIG['path']['rootUrl']=\"{$rootUrl}\";\n ?>");
        $hostBDD = $_SESSION['__install'][1]['hostBDD'];
        $loginBDD = $_SESSION['__install'][1]['loginBDD'];
        $passwordBDD = $_SESSION['__install'][1]['passwordBDD'];
        $databaseBDD = $_SESSION['__install'][1]['databaseBDD'];
        $prefixeBDD = $_SESSION['__install'][1]['prefixeBDD'];
        $table_members = str_replace(PREFIXE_BDD, $prefixeBDD, TABLE_MEMBERS);
        file_put_contents(ROOT . 'config/bdd.php', "<?php\n\$BDD['mysql']['host']=\"{$hostBDD}\";\n\$BDD['mysql']['login']=\"{$loginBDD}\";\n\$BDD['mysql']['password']=\"{$passwordBDD}\";\n\$BDD['mysql']['database']=\"{$databaseBDD}\";\n\$BDD['mysql']['prefixe']=\"{$prefixeBDD}\";\n\$BDD['mysql']['displayErrors']=false;\n?>");
        $default_lang = $_SESSION['__install'][2]['langDefault'];
        $default_theme = $_SESSION['__install'][2]['designDefault'];
        $default_module = $_SESSION['__install'][2]['moduleDefault'];
        file_put_contents(ROOT . 'config/infos.php', "<?php\n\$INFOS['defaultParams']['lang']=\"{$default_lang}\";\n\$INFOS['defaultParams']['theme']=\"{$default_theme}\";\n\$INFOS['defaultParams']['module']=\"{$default_module}\";\n\$INFOS['defaultParams']['cache']=true;\n?>");
        $admin_login = $_SESSION['__install'][3]['login'];
 function createDataContainer($imageName)
 {
     #	""" create a container for tiles and tile metadata """
     $directory = dirname($imageName);
     $filename = basename($imageName);
     list($root, $ext) = $this->parseFilename(basename($filename));
     $root = $root . "_zdata";
     $this->_v_saveToLocation = $directory . "/" . $root;
     #	If the paths already exist, an image is being re-processed, clean up for it.
     if (is_dir($this->_v_saveToLocation)) {
         $rm_err = rm($this->_v_saveToLocation);
     }
     mkdir($this->_v_saveToLocation);
     # chmod($this->_v_saveToLocation,$this->_dirmode);
     # chgrp($this->_v_saveToLocation,$this->_filegroup);
 }
    $image_is_from = substr($attach_data, 0, 4);
    $attach_data = substr($attach_data, 4);
    if ($image_is_from == "url|") {
        if ($i = $p->attach_image($attach_data, urldecode(basename($attach_data)))) {
            echo '<result><status>OK</status>';
            echo '<attach text="' . htmlspecialchars('<a href="' . $C->TMP_URL . $i->file_original . '" target="_blank" onfocus="this.blur();" title="' . htmlspecialchars($i->title) . '">' . htmlspecialchars(str_cut($i->title, 16)) . '</a>') . '" />';
            echo '</result>';
            return;
        }
    } elseif ($image_is_from == "upl|") {
        if (!isset($s['POSTFORM_TEMP_FILES']) || !isset($s['POSTFORM_TEMP_FILES'][$attach_data])) {
            echo '<result><status>WAIT</status></result>';
            return;
        }
        $i =& $s['POSTFORM_TEMP_FILES'][$attach_data];
        if ($i) {
            if ($ii = $p->attach_image($C->TMP_DIR . $i->tempfile, $i->filename)) {
                rm($C->TMP_DIR . $i->tempfile);
                unset($s['POSTFORM_TEMP_FILES'][$attach_data]);
                echo '<result><status>OK</status>';
                echo '<attach text="' . htmlspecialchars('<a href="' . $C->TMP_URL . $ii->file_original . '" target="_blank" onfocus="this.blur();" title="' . htmlspecialchars($ii->title) . '">' . htmlspecialchars(str_cut($ii->title, 16)) . '</a>') . '" />';
                echo '</result>';
                return;
            }
        }
    }
    echo '<result><status>ERROR</status><message>' . htmlspecialchars('<span style="color:red;">' . $this->lang('pf_atchbx_err_img') . '</span>') . '</message></result>';
    return;
}
echo '<result></result>';
return;
                    $D->error = TRUE;
                    $D->errmsg = 'admbrnd_frm_err_ficn_invalidfile';
                } elseif ($tp != IMAGETYPE_GIF && $tp != IMAGETYPE_PNG && $tp != IMAGETYPE_ICO) {
                    $D->error = TRUE;
                    $D->errmsg = 'admbrnd_frm_err_ficn_invalidformat';
                } elseif ($w != 16 || $h != 16) {
                    $D->error = TRUE;
                    $D->errmsg = 'admbrnd_frm_err_ficn_badsize';
                } else {
                    $path = $C->IMG_DIR . 'attachments/' . $this->network->id . '/';
                    $fn = 'favicon_' . time() . rand(100000, 999999) . '.ico';
                    copy($f->tmp_name, $path . $fn);
                    if (!file_exists($path . $fn)) {
                        $D->error = TRUE;
                        $D->errmsg = 'admbrnd_frm_err_ficn_cantcopy';
                    } else {
                        chmod($path . $fn, 0777);
                        if (!empty($C->HDR_CUSTOM_FAVICON)) {
                            rm($path . $C->HDR_CUSTOM_FAVICON);
                        }
                        $db2->query('REPLACE INTO settings SET word="HDR_SHOW_FAVICON", value="2" ');
                        $db2->query('REPLACE INTO settings SET word="HDR_CUSTOM_FAVICON", value="' . $db2->e($fn) . '" ');
                        $D->hdr_custom_favicon = 'attachments/' . $this->network->id . '/' . $fn;
                    }
                }
            }
        }
    }
    $this->network->load_network_settings($db2);
}
$this->load_template('admin_networkbranding.php');
 /**
  * @param string $filename
  * @param $testDetails
  */
 public function moveFileOutOfTheWay($filename, $testDetails)
 {
     $this->testing($testDetails);
     $filename = $this->getBaseDir() . $filename;
     if (file_exists($filename)) {
         if (file_exists("{$filename}.bak")) {
             rm("{$filename}.bak");
         }
         rename($filename, "{$filename}.bak");
     }
 }
Exemple #28
0
function compare($task, $case, $style)
{
    echo 'Comparing task : ' . $task['name_short'] . ' case : ' . $case . "\n";
    rm('grader_result.txt');
    wipe('grader_path.txt');
    if ($style == 'ruby') {
        $handle = fopen('grader_path.txt', 'w');
        $path = 'ev/' . $task['name_short'] . '/' . $case . '.sol';
        fwrite($handle, $path);
        $check = 'ev/' . $task['name_short'] . '/check.rb';
        if (!file_exists($check)) {
            error('Check file (ruby) not found! task : ' . $task['name_short'] . ' case : ' . $case);
        }
        $command = 'ruby ' . $check;
        exec($command);
    } else {
        if ($style == 'cpp') {
            $path = 'ev/' . $task['name_short'] . '/';
            $judge = $path . 'check.out';
            if (!file_exists($judge)) {
                //COMPILE
                if (!file_exists($path . 'check.cpp')) {
                    error('Check file (cpp) not found! task : ' . $task['name_short'] . ' case : ' . $case);
                }
                $command = 'g++ -O3 ' . $path . 'check.cpp -o ' . $judge . ' -lm';
                exec($command);
            }
            $command = $judge . ' ' . $path . $case . '.sol';
            exec($command);
        }
    }
    $grader_result = 'grader_result.txt';
    if (!file_exists($grader_result)) {
        error('Grader result not fonud! task : ' . $task['name_short'] . ' case : ' . $case);
    }
    $handle = fopen($grader_result, 'r');
    $line = fgets($handle);
    if (trim($line) == 'P') {
        return 'P';
    } else {
        return '-';
    }
}
<?php

require_once '../../kernel/begin.php';
require_once 'panel_admin.inc.php';
if (isset($_GET['refresh'])) {
    rm(ROOT . 'cache', false);
    copy(ROOT . 'config/index.html', ROOT . 'cache/index.html');
    $cache->rebuild_caches();
}
tpl_begin();
?>
<p><?php 
echo translate('help_message');
?>
</p>
<p><a href="?refresh"><?php 
echo translate('wanna_refresh');
?>
</a></p>
<?php 
tpl_end();
Exemple #30
0
 public function attach_videoembed($video)
 {
     global $C;
     if (isset($this->attached['videoembed'])) {
         unset($this->attached['videoembed']);
     }
     $data = (object) array('in_tmpdir' => TRUE, 'src_site' => '', 'src_id' => '', 'title' => '', 'file_thumbnail' => time() . rand(100000, 999999) . '_thumb.gif', 'embed_code' => '', 'embed_w' => '', 'embed_h' => '', 'orig_url' => '', 'hits' => 0);
     $S = $C->NEWPOST_EMBEDVIDEO_SOURCES;
     foreach ($S as $k => $obj) {
         if (preg_match($obj->src_url_pattern, $video, $matches)) {
             $data->src_id = $matches[$obj->src_url_matchnum];
             $data->src_site = $k;
             break;
         } elseif (preg_match($obj->src_emb_pattern, $video, $matches)) {
             $data->src_id = $matches[$obj->src_emb_matchnum];
             $data->src_site = $k;
             break;
         }
     }
     if (empty($data->src_site) || empty($data->src_id)) {
         return FALSE;
     }
     $S = $S[$data->src_site];
     $data->embed_w = $S->embed_w;
     $data->embed_h = $S->embed_h;
     $data->embed_code = str_replace('###ID###', $data->src_id, $S->embed_code);
     $data->orig_url = str_replace('###ID###', $data->src_id, $S->insite_url);
     if (!empty($S->embed_thumb)) {
         $tmp = str_replace('###ID###', $data->src_id, $S->embed_thumb);
         if (copy($tmp, $C->TMP_DIR . $data->file_thumbnail)) {
             $res = copy_attachment_videoimg($C->TMP_DIR . $data->file_thumbnail, $C->TMP_DIR . $data->file_thumbnail, $C->ATTACH_VIDEO_THUMBSIZE);
             if (!$res) {
                 rm($C->TMP_DIR . $data->file_thumbnail);
             }
         }
     }
     if (!file_exists($C->TMP_DIR . $data->file_thumbnail)) {
         $data->file_thumbnail = '';
     }
     return $this->attached['videoembed'] = $data;
 }