Guest User

loop_for

a guest
Sep 28th, 2011
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.46 KB | None | 0 0
  1. <?php
  2. require_once('../includes/config.php');
  3. require_once('../includes/functions/func.global.php');
  4. require_once('../includes/functions/func.admin.php');
  5. require_once('../includes/functions/func.images.php');
  6. require_once('../includes/functions/class.nestedset.php');
  7.  
  8. require_once('class.menu.php');
  9.  
  10.  
  11. // Connect to database
  12. $db = db_connect($config);
  13.  
  14.  
  15. $params = array (   'db'        => $db,
  16.                     'debug'     => false,
  17.                     'lang'      => 'lang_russian_nestedsets',
  18.                     'path'      => '../includes/lang/',
  19.                     'db_table'  => array (
  20.                        
  21.                    
  22.                         'tbl'   => $config['db']['pre'].'cat_gallery',
  23.                                             'nid'   => 'node_id',
  24.                                             'l'     => 'lft',
  25.                                             'r'     => 'rgt',
  26.                                             'mov'   => 'moved',
  27.                                             'pay'   => 'payload'));
  28.  
  29.  
  30.  
  31.                                            
  32.                                            
  33.                                            
  34.                                            
  35.  
  36. if(isset($_POST['Submit']))
  37. {
  38.  
  39.     //Сабмит уже с формы добавления
  40. $query="INSERT INTO `".$config['db']['pre']."projects` ( `project_id` ,
  41. `project_description`,`project_name`,
  42.  
  43. `project_avatar`,
  44. `project_in_work`
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. ) VALUES ('',
  52. '".validate_input($_POST['description'])."',
  53. '".htmlspecialchars($_POST['name'],ENT_QUOTES)."',
  54.  
  55. 'nofoto',
  56. '".validate_input($_POST['in_work'])."'
  57.  
  58.  
  59.  
  60. );";
  61. mysql_query($query) or die(mysql_error());
  62. $project_id=mysql_insert_id();
  63.         /*****************************************************************************************/
  64.                 /**************************    ATTACHMENTS    ********************************************/
  65.                 /*****************************************************************************************/
  66.  
  67.     foreach ($_FILES as $file) {
  68.         if ($file['name'] != "") {
  69.  
  70.  
  71.             if (!in_array($file['type'], $config['accepted_images'])) {
  72.                 //do nothing
  73.             } else {
  74.                
  75. $attach_num = mysql_num_rows(mysql_query("SELECT 1 FROM `" . $config['db']['pre'] .
  76.                     "images_projects`"));
  77.  
  78.                 $dir = floor($attach_num / 500) + 1;
  79.  
  80.  
  81.                 $fname = upload_image($config, $file['tmp_name'], "../" . $config['folder_projects'] .
  82.                     "/" . $dir . "/", "little|large|middle|middle3|micro");
  83.  
  84.                 mysql_query("INSERT INTO  `" . $config['db']['pre'] .
  85.                     "images_projects` (`file_id`, `object_id`, `file_name`)  VALUES ('','" .
  86.                     validate_input($project_id) . "','" . $dir . "/" . validate_input($fname) . "')") or
  87.                     error(mysql_error());
  88.                  
  89.            
  90.  
  91.          
  92.  
  93.          
  94.  
  95.                 mysql_query("UPDATE `" . $config['db']['pre'] .
  96.                     "projects` SET `project_avatar`='" . $dir . "/" . validate_input($fname) .
  97.                     "' WHERE `project_id`=" . validate_input($project_id)) or error(mysql_error());
  98.  
  99.              
  100.             }
  101.  
  102.         }
  103.     }
  104.  
  105.  
  106.         foreach ($_POST['title']  as $val => $value  ) {
  107.  
  108.                
  109.                 if(!empty($value)) {
  110.                    
  111.    
  112.                $peremennaya .= $post. "->" . $value.'<br>';
  113.                  mysql_query("UPDATE  `" . $config['db']['pre'] .
  114.                     "images_projects` SET `image_description`= '" . $value . "' WHERE object_id = " . validate_input($project_id)) or
  115.                     error(mysql_error());
  116.  }
  117. }
  118.  
  119.  
  120.  
  121.  
  122.     mysql_query("UPDATE `" . $config['db']['pre'] .
  123.         "images_projects` SET `file_avatar`='1' WHERE `object_id`=" . validate_input($project_id) .
  124.         " LIMIT 1;") or error(mysql_error());
  125.    
  126.  
  127.  
  128.        
  129.  
  130.  
  131.        
  132.  
  133.                      //////////////////////////////////////////////////////////////////////////////
  134.                 /*****************************************************************************************/
  135.                 /**************************    ATTACHMENTS  END  *****************************************/
  136.                 /*****************************************************************************************/
  137. /* CUSTOM FIELDS */
  138.     header('Refresh: 5; URL:project_view.php');
  139.         var_dump($_POST['title']);
  140.         print "<hr>";
  141.         print $nd;
  142.         print $nd2;
  143.         print "<hr>";
  144.           var_dump($_FILES);
  145.         print "<hr>";
  146.      
  147.         echo explode("? ", $_POST['title']);
  148.     exit;
  149. }
  150. $TITLE="Добавить проект";
  151. require_once('overall_header.php');
  152.  
  153.  
  154.  
  155.  
  156. ?>
  157. <!--Start form-->
  158. <br>
  159. <table width="850" cellpadding="0" cellspacing="0" border="0" style="border:1px solid #CCCCCC;" align="center">
  160. <tr>
  161. <td align="center" bgcolor="#F6F6F6" style="padding:15px;">  
  162. <form action="" method="post" enctype="multipart/form-data" name="createForm" id="createForm" >
  163.   <table width="70%" cellpadding="0" cellspacing="2" border="0">
  164.  
  165.  
  166.    
  167.    
  168.     <tr>
  169.       <td><strong>Название:</strong></td>
  170.       <td><input name="name" type="text" class="textbox" id="name" value="" style="width:60%"></td>
  171.     </tr>
  172.  
  173.    
  174.  
  175.    
  176.    
  177.    
  178.    
  179.    
  180.         <tr>
  181.     <td width="20%"><strong>В процессе выполнения</strong></td>
  182.     <td>:
  183. <select name="in_work">
  184. <option value="1">Да</option>
  185. <option value="0">Нет</option>
  186. </select>
  187.   </tr>
  188.  
  189.  
  190.  
  191.  
  192.  
  193.     <tr>
  194.       <td valign="top"><strong>Описание:</strong></td>
  195.       <td valign="top"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
  196.           <tr>
  197.             <td width="7" valign="top"></td>
  198.             <td><textarea name="description" id="content" style="width:316px;height:200px;"></textarea>
  199.     </td>
  200.           </tr>
  201.       </table></td>
  202.     </tr>
  203.  
  204.  
  205.    
  206.    
  207.    
  208.  
  209.  
  210.  
  211.  
  212.     <tr>
  213.       <td><strong>Изображения:</strong></td>
  214.       <td>
  215.  <?php  for($i=1; $i< 11;$i++){ ?>
  216.  
  217.  <strong>Описание:</strong><input type="text" name="title[<?php echo $i ?>]"><input name="uploadedfile<?php echo $i ?>" type="file" /><br>
  218.  
  219.  
  220.  
  221.  
  222.  <?php } ?>  
  223.      
  224.       <div>
  225.  
  226.  
  227.     </div>
  228.  
  229.  
  230.  
  231.  
  232.            
  233.       </td>
  234.     </tr>
  235.  
  236.  
  237.  
  238.     <tr>
  239.       <td>&nbsp;</td>
  240.       <td>&nbsp;</td>
  241.     </tr>
  242.  
  243.  
  244.  
  245.     <tr>
  246.       <td>&nbsp;</td>
  247.       <td>&nbsp;</td>
  248.     </tr>
  249.     <tr>
  250.       <td></td>
  251.       <td height="30" style="padding-left:6px;">
  252.         <input name="Submit" type="submit" class="button" value="Добавить">
  253. &nbsp;
  254.       <input name="Reset" type="reset" class="button" value="Сбросить">
  255.       </td>
  256.     </tr>
  257.   </table>
  258. </form></td>
  259. </tr>
  260. </table>
  261. <!--End form-->
  262. <?php require_once('overall_footer.php'); ?>
  263.  
Advertisement
Add Comment
Please, Sign In to add comment