7
|
Програмиране / Общ форум / C++ задача - имена и егн
|
-: Mar 11, 2011, 21:21
|
Здравейте. За домашно ни дадоха една задача. Задачата е следната: Да се въведе име и егн на n брой хора и след това да се изведът по следния начин:
1. Името | Егн-то 2. Името | Егн-то
Пробвах с двумерен масив обаче за въвеждането на егн не е удобно защото за всяко число от егн-то трябва да натискам ентер. Пробвах с цикъл (for) но така се препокриват. Надявам се някой да ме насочи към това какво трябва да използвам. Благодаря предварително на тези дето помогнат.
|
|
|
8
|
Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл
|
-: Mar 04, 2011, 18:02
|
Затворил съм го . Интервали няма, както и нови редове. Ето как съм го затворил: GeSHi (PHP): if (validateInput($request, $response, $config)) uploadFile($request, $response, $config); describeFile($request, $response, $config); getList($response, $config); view($response, $config); ?>
|
|
|
13
|
Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл
|
-: Mar 03, 2011, 22:08
|
Значи махнах кавичките и на останалите и сега ми дава грешка "Parse error: syntax error, unexpected $end in /home/evraziab/public_html/upload.php on line 456" GeSHi (PHP): <?php function validateInput($request, &$response, $config) { if (!$request['submitted']) return false; $hasError = false; if (empty($request['desc'])) { $response['errors'][] = "Полето 'Description' е задължително."; $hasError = true; } if ($request['file']['error'] !== UPLOAD_ERR_OK) { ( UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini.", UPLOAD_ERR_FORM_SIZE => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.", UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded. ", UPLOAD_ERR_NO_FILE => "No file was uploaded.", UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. ", UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk. Introduced in PHP 5.1.0. ", UPLOAD_ERR_EXTENSION => "A PHP extension stopped the file upload. PHP does not provide a way to ascertain which extension caused the file upload to stop; examining the list of loaded extensions with phpinfo() may help. Introduced in PHP 5.2.0.", ); $response['errors'][] = $errorMap[$request['file']['error']]; return false; } if (file_exists($config['destinationDir'] . '/' . $request['file']['name'])) { $response['errors'][] = $request['file']['name'] . " вече съществува. "; $hasError = true; } if ($request['file']['name'] > $config['maxFileSize']) { $response['errors'][] = "Файлът има размер по-голям от разрешения. (" . $request['file']['size'] . " > " . $config['maxFileSize']. ")"; $hasError = true; } { $response['errors'][] = "Файлове с такова разшорение не са разрешени за качване."; $response['errors'][] = "Разрешените разширения са " . implode(', ', $config['allowedExtensions']); $hasError = true; } return !$hasError; } function uploadFile($request, &$response, $config) { move_uploaded_file($request['file']['tmp_name'], $config['destinationDir'] . '/' . $request['file']['name']); $response['messages'][] = "Качено в " . $config['destinationDir'] . '/' . $request['file']['name']; } function getList(&$response, $config) { $response['files'] = glob($config['destinationDir'].'/*.*'); } function describeFile($request, &$response, $config) { libxml_use_internal_errors(true); $xml = simplexml_load_file($config['destinationFile']); if (!$xml) { $response['errors'][] = "Failed loading XML\n"; foreach(libxml_get_errors() as $error) { $response['errors'][] = $error->message; } return false; } $file = $xml->addChild('file'); $file->addChild('name', $request['file']['name']); $file->addChild('description', $request['desc']); file_put_contents($config['destinationFile'], $xml->asXML()); } function view($response, $config) { $pageTemplate = <<<EOT <html> <head> <style type="text/css"> .error { border : 1px solid red; background-color: #ffa0a0; color: #220000; text-align : center; padding : 20 20; margin : 10; } .message { border : 1px solid green; background-color: #a0ffa0; color : #220000; text-align : center; padding : 20 20; margin : 10; } .files { border : 1px solid black; padding : 20; margin : 10; } .form { border : 1px solid black; padding : 20; margin : 10; } </style> </head> <body> %s %s %s %s </body> </html> EOT; $listItemTemplate = <<<EOT <li>%s</li> EOT; $listTemplate = <<<EOT <div class="files"> <ol> %s </ol> </div> EOT; $errorTemplate = <<<EOT <div class="error">%s</div> EOT; $messageTemplate = <<<EOT <div class="message">%s</div> EOT; $formTemplate = <<<EOT <form action="" method="post" enctype="multipart/form-data" class="form"> <input type="hidden" name="submitted" value="1" /> <input type="hidden" name="MAX_FILE_SIZE" value="%d" /> <label for="file">Filename:</label><input type="file" name="file" id="file" /> <br /> <label for="file">Description:</label><textarea cols="20" rows="5" name="desc" id="desc"></textarea> <br /> <input type="submit" name="submit" value="Submit" /> </form> EOT; $errorView = ''; $messageView = ''; $fileListView = 'No files uploaded.'; if (!empty($response[errors ])) { $errorView = sprintf($errorTemplate, implode('<br />', $response[errors ])); } if (!empty($response[messages ])) { $messageView = sprintf($messageTemplate, implode('<br />', $response[messages ])); } if (!empty($response[files ])) { $listItemRenderer = function ($fileName) use ($listItemTemplate) { }; ( $listItemRenderer, $response[files])) ); } $formView = sprintf($formTemplate, $config[maxFileSize ]); printf($pageTemplate, $errorView, $messageView, $formView, $fileListView); } //-----------------------------------------------------------------------------------------// ( 'maxFileSize' => 900000, 'allowedExtensions' => array ( 'jpeg', 'jpg', 'gif', 'bmp', ), 'allowOverwrite' => false, 'destinationDir' => 'uploads', 'destinationFile' => 'db.xml', ); ( 'submitted' => isset($_POST[submitted ]), 'desc' => isset($_POST[desc ]) ? $_POST[desc ] : false, ); ( ); if (validateInput($request, $response, $config)) { uploadFile($request, $response, $config); describeFile($request, $response, $config); } getList($response, $config); view($response, $config);
|
|
|
14
|
Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл
|
-: Mar 03, 2011, 21:29
|
Дава ми тази грешка "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/evraziab/public_html/upload.php on line 336" А 336 ред е това "if (!empty($response['errors']))" и колко него редовете изглеждат така GeSHi (PHP): $errorView = ''; $messageView = ''; $fileListView = 'No files uploaded.'; if (!empty($response['errors'])) { $errorView = sprintf($errorTemplate, implode('<br />', $response['errors'])); } if (!empty($response['messages']))
|
|
|
15
|
Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл
|
-: Mar 02, 2011, 03:55
|
Това е upload формата GeSHi (PHP): <?php $site_name = $_SERVER['HTTP_HOST']; $url_dir = " http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF' ]); $url_this = " http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF' ]; // Къде да се записват качените файлове? $upload_dir = "files/"; $upload_url = $url_dir."/files/"; $message ="log.txt"; /************************************************************ Създава директория за качените файлове ************************************************************/ die ("няма папка за качените файлове и не можах да създам такава"); if (!chmod($upload_dir,0755)) die ("не можах да сменя правата на 755"); } /************************************************************ Обслужва заявката на потребителя ************************************************************/ if ($_REQUEST[del]) { print "<script>window.location.href='$url_this?message=deleted successfully'</script>"; } else if ($_FILES['userfile']) { $message = do_upload($upload_dir, $upload_url); print "<script>window.location.href='$url_this?message=$message'</script>"; } else if (!$_FILES['userfile']); else $message = "Invalid File Specified."; /************************************************************ Списък с файлове ************************************************************/ $filelist = ""; $filelist .= "<br><a href='$upload_dir$file'>".$file."</a>"; } } function do_upload($upload_dir, $upload_url) { $temp_name = $_FILES['userfile']['tmp_name']; $file_name = $_FILES['userfile']['name']; $file_type = $_FILES['']['exe']; $file_type = $_FILES['']['mp3']; $file_type = $_FILES['']['avi']; $file_type = $_FILES['']['mp3u']; $file_type = $_FILES['']['php']; $file_type = $_FILES['']['html']; $file_type = $_FILES['']['*.*']; $file_size = $_FILES['userfile']['size']; $result = $_FILES['userfile']['error']; $file_url = $upload_url.$file_name; $file_path = $upload_dir.$file_name; //File Name Check if ( $file_name =="") { $message = "Невалиден тип файл"; return $message; } //File Size Check else if ( $file_size > 999999999999999999999) { $message = "Размера на файла е много голям."; return $message; } //File Type Check else if ( $file_type == "text/plain" || $file_type == "application/force-download" || $file_type == "application/octet-stream") { $message = "Не може да качвате скриптови файлове"; return $message; } if (!chmod($file_path,0755)) $message = "не можах да сменя правата на 755"; else $message = ($result)?"$file_name($file_type) файла качен успешно." : "Каченият файл е повреден."; return $message; } ?> <table style="width: 40%" align="center" valign="top"> <tr> <td> <div align="center" style="font-size: 19px; font-weight: bold"> </table> <body bgcolor="#667987"><center> <font color=red><?=$_REQUEST[message]?></font> <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post"> Качи фаил: <input type="file" id="userfile" name="userfile" size="20"> <input type="submit" name="upload" value="Upload"> </form> <b>До сега потребителите ни са качили следните файлове:</b> <hr style="color:yellow; background-color:black; height:1px; margin-right:0; text-align:right; border:0px"> <?=$filelist?> </center> <? if ($_REQUEST[debug ]==1) print "------------------Debugging Info----------------<br>"; if ($_REQUEST[debug ]==1) print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>"; if ($_REQUEST[debug ]==1) print "upload dir=$upload_dir<br>upload url=$upload_url<br>"; ?>
|
|
|
|