Покажи Публикации - tommy.bg
* Виж публикациите на потр. | Виж темите на потр. | Виж прикачените файлове на потр
Страници: [1] 2 3 ... 5
1  Хумор, сатира и забава / Живота, вселената и някакви други глупости / Re: Новата социална мрежа Google+ -: Aug 11, 2011, 18:30
мерси
2  Хумор, сатира и забава / Живота, вселената и някакви други глупости / Re: Новата социална мрежа Google+ -: Aug 11, 2011, 10:25
някой да прати и на мен:
tkacarski@gmail.com
3  Програмиране / Общ форум / Re: C++ задача - имена и егн -: Mar 12, 2011, 16:21
Мисля, че се получи. Благодаря на всички които помогнаха.
4  Програмиране / Общ форум / Re: C++ задача - имена и егн -: Mar 11, 2011, 23:42
Не включва. Не искам някой да ми пише задачата искам идея
5  Програмиране / Общ форум / Re: C++ задача - имена и егн -: Mar 11, 2011, 23:25
трябва да е само с материала от увод в програмирането с масиви цикли и т.н
6  Програмиране / Общ форум / Re: C++ задача - имена и егн -: Mar 11, 2011, 22:44
А как ще стане въвеждането на повече от един човек?
7  Програмиране / Общ форум / C++ задача - имена и егн -: Mar 11, 2011, 21:21
Здравейте. За домашно ни дадоха една задача. Задачата е следната: Да се въведе име и егн на n брой хора и след това да се изведът по следния начин:

1. Името | Егн-то
2. Името | Егн-то

Пробвах с двумерен масив обаче за въвеждането на егн не е удобно защото за всяко число от егн-то трябва да натискам ентер. Пробвах с цикъл (for) но така се препокриват.
Надявам се някой да ме насочи към това какво трябва да използвам.
Благодаря предварително на тези дето помогнат.
8  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 04, 2011, 18:02
Затворил съм го . Интервали  няма, както и нови редове. Ето как съм го затворил:
Код
GeSHi (PHP):
  1.  if (validateInput($request, $response, $config))
  2.  
  3.           uploadFile($request, $response, $config);
  4.  
  5.           describeFile($request, $response, $config);
  6.  
  7.  
  8.           getList($response, $config);
  9.  
  10.           view($response, $config);
  11. ?>
9  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 04, 2011, 17:49
Цитат
278.
       
 279.
      view($response, $config);


PS: PHP 5.3+

А версията която ползвам е 5.2.12
10  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 04, 2011, 17:31
backtolife, какво се нервиш? В началото бях споменал, че никога не съм се занимавал с php. За това, че човека ми е написал 500 реда код съм му наистина благодарен. До колкото виждам проблема идва от там, че версията която използват в суперхостинг е по-стара и за това не тръгва.
11  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 04, 2011, 17:09
Същата работа
12  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 04, 2011, 02:01
Версията на php e 5.2.12. Хоства се в superhosting.bg
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):
  1.      <?php
  2.  
  3.         function validateInput($request, &$response, $config)
  4.  
  5.      {
  6.  
  7.      if (!$request['submitted'])
  8.  
  9.      return false;
  10.  
  11.      $hasError = false;
  12.  
  13.  
  14.      if (empty($request['desc']))
  15.  
  16.      {
  17.  
  18.      $response['errors'][] = "Полето 'Description' е задължително.";
  19.  
  20.      $hasError = true;
  21.  
  22.      }
  23.  
  24.  
  25.  
  26.      if ($request['file']['error'] !== UPLOAD_ERR_OK)
  27.  
  28.      {
  29.  
  30.     $errorMap = array
  31.  
  32.      (
  33.  
  34.     UPLOAD_ERR_INI_SIZE => "The uploaded file exceeds the upload_max_filesize directive in php.ini.",
  35.  
  36.      UPLOAD_ERR_FORM_SIZE => "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.",
  37.  
  38.      UPLOAD_ERR_PARTIAL => "The uploaded file was only partially uploaded. ",
  39.       UPLOAD_ERR_NO_FILE => "No file was uploaded.",
  40.  
  41.      UPLOAD_ERR_NO_TMP_DIR => "Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3. ",
  42.  
  43.      UPLOAD_ERR_CANT_WRITE => "Failed to write file to disk. Introduced in PHP 5.1.0. ",
  44.  
  45.      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.",
  46.  
  47.      );
  48.  
  49.  
  50.  
  51.      $response['errors'][] = $errorMap[$request['file']['error']];
  52.  
  53.      return false;
  54.  
  55.      }
  56.  
  57.  
  58.  
  59.      if (file_exists($config['destinationDir'] . '/' . $request['file']['name']))
  60.  
  61.      {
  62.  
  63.      $response['errors'][] = $request['file']['name'] . " вече съществува. ";
  64.  
  65.      $hasError = true;
  66.  
  67.     }
  68.  
  69.  
  70.  
  71.      if ($request['file']['name'] > $config['maxFileSize'])
  72.  
  73.      {
  74.  
  75.      $response['errors'][] =  "Файлът има размер по-голям от разрешения. (" .
  76.  
  77.      $request['file']['size'] . " > " . $config['maxFileSize']. ")";
  78.  
  79.      $hasError = true;
  80.  
  81.      }
  82.  
  83.  
  84.  
  85.      if (!in_array(strtolower(pathinfo( $request['file']['name'], PATHINFO_EXTENSION)), $config['allowedExtensions']))
  86.  
  87.      {
  88.  
  89.      $response['errors'][] =  "Файлове с такова разшорение не са разрешени за качване.";
  90.  
  91.      $response['errors'][] =  "Разрешените разширения са " . implode(', ', $config['allowedExtensions']);
  92.  
  93.      $hasError = true;
  94.  
  95.      }
  96.  
  97.  
  98.  
  99.      return !$hasError;
  100.  
  101.     }
  102.  
  103.  
  104.  
  105.      function uploadFile($request, &$response, $config)
  106.  
  107.      {
  108.  
  109.      move_uploaded_file($request['file']['tmp_name'], $config['destinationDir'] . '/' . $request['file']['name']);
  110.  
  111.      $response['messages'][] = "Качено в " . $config['destinationDir'] . '/' . $request['file']['name'];
  112.  
  113.      }
  114.  
  115.  
  116.  
  117.      function getList(&$response, $config)
  118.  
  119.      {
  120.  
  121.      $response['files'] = glob($config['destinationDir'].'/*.*');
  122.  
  123.      }
  124.  
  125.  
  126.  
  127.      function describeFile($request, &$response, $config)
  128.  
  129.      {
  130.  
  131.      libxml_use_internal_errors(true);
  132.  
  133.      $xml = simplexml_load_file($config['destinationFile']);
  134.  
  135.      if (!$xml)
  136.  
  137.      {
  138.  
  139.      $response['errors'][] = "Failed loading XML\n";
  140.  
  141.      foreach(libxml_get_errors() as $error)
  142.  
  143.      {
  144.  
  145.             $response['errors'][] = $error->message;
  146.  
  147.         }
  148.  
  149.      return false;
  150.  
  151.      }
  152.  
  153.  
  154.  
  155.      $file = $xml->addChild('file');
  156.  
  157.      $file->addChild('name', $request['file']['name']);
  158.  
  159.      $file->addChild('description', $request['desc']);
  160.  
  161.      file_put_contents($config['destinationFile'], $xml->asXML());
  162.  
  163.      }
  164.  
  165.  
  166.  
  167.      function view($response, $config)
  168.  
  169.      {
  170.  
  171.      $pageTemplate = <<<EOT
  172.  
  173.      <html>
  174.  
  175.      <head>
  176.  
  177.      <style type="text/css">
  178.  
  179.      .error
  180.  
  181.      {
  182.  
  183.      border : 1px solid red;
  184.  
  185.      background-color: #ffa0a0;
  186.  
  187.      color: #220000;
  188.  
  189.      text-align : center;
  190.  
  191.      padding : 20 20;
  192.  
  193.      margin : 10;
  194.  
  195.      }
  196.  
  197.      .message
  198.  
  199.      {
  200.  
  201.      border : 1px solid green;
  202.  
  203.      background-color: #a0ffa0;
  204.  
  205.      color : #220000;
  206.  
  207.      text-align : center;
  208.  
  209.      padding : 20 20;
  210.  
  211.      margin : 10;
  212.  
  213.      }
  214.  
  215.  
  216.  
  217.      .files
  218.  
  219.      {
  220.  
  221.      border : 1px solid black;
  222.  
  223.      padding : 20;
  224.  
  225.      margin : 10;
  226.  
  227.      }
  228.  
  229.  
  230.  
  231.      .form
  232.  
  233.      {
  234.  
  235.      border : 1px solid black;
  236.  
  237.      padding : 20;
  238.  
  239.      margin : 10;
  240.  
  241.      }
  242.  
  243.      </style>
  244.  
  245.      </head>
  246.  
  247.      <body>
  248.  
  249.      %s
  250.  
  251.      %s
  252.  
  253.      %s
  254.  
  255.      %s
  256.  
  257.      </body>
  258.  
  259.      </html>
  260.  
  261.      EOT;
  262.  
  263.  
  264.  
  265.      $listItemTemplate = <<<EOT
  266.  
  267.         <li>%s</li>
  268.  
  269.      EOT;
  270.  
  271.  
  272.  
  273.      $listTemplate = <<<EOT
  274.  
  275.      <div class="files">
  276.  
  277.      <ol>
  278.  
  279.      %s
  280.  
  281.      </ol>
  282.  
  283.      </div>
  284.  
  285.      EOT;
  286.  
  287.  
  288.  
  289.      $errorTemplate = <<<EOT
  290.  
  291.      <div class="error">%s</div>
  292.  
  293.      EOT;
  294.  
  295.  
  296.  
  297.      $messageTemplate = <<<EOT
  298.  
  299.      <div class="message">%s</div>
  300.  
  301.      EOT;
  302.  
  303.  
  304.  
  305.      $formTemplate = <<<EOT
  306.  
  307.      <form action="" method="post" enctype="multipart/form-data" class="form">
  308.  
  309.      <input type="hidden" name="submitted" value="1" />
  310.  
  311.      <input type="hidden" name="MAX_FILE_SIZE" value="%d" />
  312.  
  313.      <label for="file">Filename:</label><input type="file" name="file" id="file" />
  314.  
  315.      <br />
  316.  
  317.      <label for="file">Description:</label><textarea cols="20" rows="5"  name="desc" id="desc"></textarea>
  318.  
  319.      <br />
  320.  
  321.      <input type="submit" name="submit" value="Submit" />
  322.  
  323.      </form>
  324.  
  325.      EOT;
  326.  
  327.  
  328.      $errorView = '';
  329.  
  330.      $messageView = '';
  331.  
  332.      $fileListView = 'No files uploaded.';
  333.  
  334.  
  335.      if (!empty($response[errors]))
  336.  
  337.      {
  338.  
  339.      $errorView = sprintf($errorTemplate, implode('<br />', $response[errors]));
  340.  
  341.      }
  342.  
  343.  
  344.  
  345.      if (!empty($response[messages]))
  346.  
  347.      {
  348.  
  349.      $messageView = sprintf($messageTemplate, implode('<br />', $response[messages]));
  350.  
  351.      }
  352.  
  353.      if (!empty($response[files]))
  354.  
  355.      {
  356.  
  357.      $listItemRenderer = function ($fileName) use ($listItemTemplate)
  358.  
  359.      {
  360.  
  361.      return sprintf($listItemTemplate, htmlentities(pathinfo($fileName, PATHINFO_BASENAME), ENT_QUOTES));
  362.  
  363.      };
  364.  
  365.  
  366.  
  367.      $fileListView = sprintf($listTemplate, implode("\n", array_map)
  368.  
  369.      (
  370.  
  371.      $listItemRenderer,
  372.  
  373.      $response[files]))
  374.  
  375.      );
  376.  
  377.      }
  378.  
  379.      $formView = sprintf($formTemplate, $config[maxFileSize]);
  380.  
  381.      printf($pageTemplate, $errorView, $messageView, $formView, $fileListView);
  382.  
  383.      }
  384.  
  385.  
  386.      //-----------------------------------------------------------------------------------------//
  387.  
  388.      $config = array
  389.  
  390.      (
  391.  
  392.      'maxFileSize' => 900000,
  393.  
  394.      'allowedExtensions' => array
  395.  
  396.      (
  397.  
  398.      'jpeg',
  399.  
  400.      'jpg',
  401.  
  402.      'gif',
  403.  
  404.      'bmp',
  405.  
  406.      ),
  407.  
  408.      'allowOverwrite' => false,
  409.  
  410.  
  411.  
  412.      'destinationDir' => 'uploads',
  413.  
  414.      'destinationFile' => 'db.xml',
  415.  
  416.      );
  417.  
  418.      $request = array
  419.  
  420.      (
  421.  
  422.      'submitted' => isset($_POST[submitted]),
  423.  
  424.      'file' => isset($_FILES[file]) ? $_FILES[file] : false,
  425.  
  426.      'desc' => isset($_POST[desc]) ? $_POST[desc] : false,
  427.  
  428.      );
  429.  
  430.      $response = array
  431.  
  432.      (
  433.  
  434.      'errors' => array(),
  435.  
  436.      'messages' => array(),
  437.  
  438.      'files' => array(),
  439.  
  440.      );
  441.  
  442.      if (validateInput($request, $response, $config))
  443.  
  444.      {
  445.  
  446.      uploadFile($request, $response, $config);
  447.  
  448.      describeFile($request, $response, $config);
  449.  
  450.      }
  451.  
  452.  
  453.      getList($response, $config);
  454.  
  455.      view($response, $config);
  456.  
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):
  1. $errorView = '';
  2.  
  3.      $messageView = '';
  4.  
  5.      $fileListView = 'No files uploaded.';
  6.  
  7.  
  8.  
  9.      if (!empty($response['errors']))
  10.  
  11.      {
  12.  
  13.      $errorView = sprintf($errorTemplate, implode('<br />', $response['errors']));
  14.  
  15.      }
  16.  
  17.  
  18.  
  19.      if (!empty($response['messages']))
  20.  
15  Програмиране / Web development / Re: Php файл да качва видео клип и да пише в xml файл -: Mar 02, 2011, 03:55
Това е upload формата

Код
GeSHi (PHP):
  1. <?php
  2. $site_name = $_SERVER['HTTP_HOST'];
  3. $url_dir = " http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF' ]);
  4. $url_this = " http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF' ];
  5.  
  6. // Къде да се записват качените файлове?
  7.  
  8. $upload_dir = "files/";
  9. $upload_url = $url_dir."/files/";
  10. $message ="log.txt";
  11. /************************************************************
  12. Създава директория за качените файлове
  13. ************************************************************/
  14. if (!is_dir("files")) {
  15. if (!mkdir($upload_dir))
  16. die ("няма папка за качените файлове и не можах да създам такава");
  17. if (!chmod($upload_dir,0755))
  18. die ("не можах да сменя правата на 755");
  19. }
  20. /************************************************************
  21. Обслужва заявката на потребителя
  22. ************************************************************/
  23. if ($_REQUEST[del]) {
  24. print "<script>window.location.href='$url_this?message=deleted successfully'</script>";
  25. }
  26. else if ($_FILES['userfile']) {
  27. $message = do_upload($upload_dir, $upload_url);
  28. print "<script>window.location.href='$url_this?message=$message'</script>";
  29. }
  30. else if (!$_FILES['userfile']);
  31. else
  32. $message = "Invalid File Specified.";
  33.  
  34. /************************************************************
  35. Списък с файлове
  36. ************************************************************/
  37. $handle=opendir($upload_dir);
  38. $filelist = "";
  39. while ($file = readdir($handle)) {
  40. if(!is_dir($file) && !is_link($file)) {
  41. $filelist .= "<br><a href='$upload_dir$file'>".$file."</a>";
  42. }
  43. }
  44. function do_upload($upload_dir, $upload_url) {
  45. $temp_name = $_FILES['userfile']['tmp_name'];
  46. $file_name = $_FILES['userfile']['name'];
  47. $file_type = $_FILES['']['exe'];
  48. $file_type = $_FILES['']['mp3'];
  49. $file_type = $_FILES['']['avi'];
  50. $file_type = $_FILES['']['mp3u'];
  51. $file_type = $_FILES['']['php'];
  52. $file_type = $_FILES['']['html'];
  53. $file_type = $_FILES['']['*.*'];
  54. $file_size = $_FILES['userfile']['size'];
  55. $result = $_FILES['userfile']['error'];
  56. $file_url = $upload_url.$file_name;
  57. $file_path = $upload_dir.$file_name;
  58.  
  59. //File Name Check
  60. if ( $file_name =="") {
  61. $message = "Невалиден тип файл";
  62. return $message;
  63. }
  64. //File Size Check
  65. else if ( $file_size > 999999999999999999999) {
  66. print $file_size;
  67. $message = "Размера на файла е много голям.";
  68. return $message;
  69. }
  70. //File Type Check
  71. else if ( $file_type == "text/plain"
  72. || $file_type == "application/force-download"
  73. || $file_type == "application/octet-stream") {
  74. $message = "Не може да качвате скриптови файлове";
  75. return $message;
  76. }
  77. $result = move_uploaded_file($temp_name, $file_path);
  78. if (!chmod($file_path,0755))
  79. $message = "не можах да сменя правата на 755";
  80. else
  81. $message = ($result)?"$file_name($file_type) файла качен успешно." :
  82. "Каченият файл е повреден.";
  83. return $message;
  84. }
  85. ?>
  86. <table style="width: 40%" align="center" valign="top">
  87. <tr>
  88. <td>
  89. <div align="center" style="font-size: 19px; font-weight: bold">
  90. </table>
  91. <body bgcolor="#667987"><center>
  92. <font color=red><?=$_REQUEST[message]?></font>
  93. <form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
  94. Качи фаил: <input type="file" id="userfile" name="userfile" size="20">
  95. <input type="submit" name="upload" value="Upload">
  96. </form>
  97. <b>До сега потребителите ни са качили следните файлове:</b>
  98. <hr style="color:yellow; background-color:black; height:1px;
  99. margin-right:0; text-align:right; border:0px">
  100. <?=$filelist?>
  101. </center>
  102. <?
  103. if ($_REQUEST[debug]==1) print "------------------Debugging Info----------------<br>";
  104. if ($_REQUEST[debug]==1) print "site=$site_name<br>dir=$url_dir<br>url=$url_this<br>";
  105. if ($_REQUEST[debug]==1) print "upload dir=$upload_dir<br>upload url=$upload_url<br>";
  106. ?>
  107.  
Страници: [1] 2 3 ... 5