ACC SHELL

Path : /srv/www/vhosts/petrikov/admin/pages/user/
File Upload :
Current File : /srv/www/vhosts/petrikov/admin/pages/user/photos.php

<?php
	$make = ( isset( $_GET[ "make" ] ) )?$_GET[ "make" ]:"view";

	if ( $make == "view" ) {

		$query = "SELECT COUNT(*) FROM photos WHERE ID_user = ". $_SESSION[ 'ID' ];

		$result = mysql_query( $query, $dbc );
		
		if ( mysql_num_rows( $result ) > 0 )
		{
			$row = mysql_fetch_row( $result );
			message( "Počet uložených fotografií: <strong>". $row[ 0 ]. "</strong>" );
		}

		$smarty->display( 'user/photos_view.tpl' );

	} elseif ( $make == "add" ) {
		if ( isset( $_POST[ "submit" ] ) )
		{

			$correct = TRUE;
			$message = "";

			if ( empty( $_FILES[ 'file' ][ 'name' ] ) ) {
				$correct = FALSE;
				$message .= "<p>Nebyl zadán soubor!</p>\n";
			}


			if ( !preg_match( '/.*\.(gif|jpg|jpeg|png|bmp)/', $_FILES[ 'file' ][ 'name' ], $finded ) && $correct == TRUE) {
				$correct = FALSE;
				$message .= "<p>Zadaný soubor (".$_FILES[ 'file' ][ 'name' ].") není obrázek!</p>\n";
			}

			if ( file_exists( "../images/content/". $_FILES[ 'file' ][ 'name' ] ) ) {
				$correct = FALSE;
				$message .= "<p>Zadaný soubor (".$_FILES[ 'file' ][ 'name' ].") již existuje!</p>\n";
			}			

			if ( $correct ) {
				//move_uploaded_file( $_FILES[ 'file' ][ 'tmp_name' ], '../images/content/'. $_FILES[ 'file' ][ 'name' ] );
				$fp = fopen( $_FILES[ 'file' ][ 'tmp_name' ], "r" );
				$file = fread( $fp, filesize( $_FILES[ 'file' ][ 'tmp_name' ] ) );
				fclose( $fp );
				echo $file;
				//header ( "Location: index.php?action=images&make=view&do=saved&file=". $_FILES[ 'file' ][ 'name' ] );
			} else {
				echo "\n". $message. "<p>Zkuste to znovu...</p>\n";
			}
		}

		$smarty->display( 'user/photos_add.tpl' );
	} elseif ( $make == "edit" ) {

	} else {
		message( "Požadovaná akce neexistuje." );
	}

?>


ACC SHELL 2018