pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Advertising: Credit Card Consolidation - Cheap Car Insurance - Loans - Loans
PHP paste-bin - collaborative debugging tool View Help

Posted by alvan on Wed 9th Apr 12:50 (modification of post by Anonymous view diff)
diff | download | new post

  1. <?php
  2. include("include/config.php");
  3.  
  4. // check
  5. if(isset($_GET['id'])) {
  6.         $id = intval($_GET['id']);
  7.         $row = $db->fetch($db->query("select * from stiri where id='$id'"));
  8. } else
  9.         $id = false;
  10.  
  11. // config
  12. $t->set_file('tpl_main','adauga.stiri.tpl');
  13. $t->set_var(array(
  14.         'NUME_BUTON' => ($id)?'Modifica':'Adauga',
  15.         'MSG' => '',
  16.         'TITLU' => ($id)?stripslashes($row['titlu']):'',
  17.         'CONTINUT' => ($id)?stripslashes($row['text']):''
  18. ));
  19.  
  20. // categorii
  21. $t->set_block('tpl_main','cat','var_cat');
  22. $cat = $db->queryAll("select * from cat where activ='1' order by `order` asc");
  23. if (count($cat)>0) {
  24.  
  25.         foreach ($cat as $c) {
  26.                
  27.                 $selected = ($id and $row['cat']==$c['id'])?'selected="selected"':'';
  28.                
  29.                 $t->set_var(array(
  30.                         'CAT_ID' => $c['id'],
  31.                         'CAT_NUME' => stripslashes($c['nume']),
  32.                         'CAT_SELECTED' => $selected
  33.                 ));
  34.                 $t->parse('var_cat','cat',true);
  35.                
  36.         }
  37.  
  38. } else {
  39.         $t->set_var('var_cat','Nici o categorie activa.');
  40. }
  41.  
  42. // oameni
  43. $t->set_block('tpl_main','oameni','var_oameni');
  44. $oameni = $db->queryAll("select * from oameni_politici where activ='1' order by nume asc");
  45. if (count($oameni)>0) {
  46.  
  47.         if ($id)$op_array = explode(",",$row['oameniPolitici']);
  48.        
  49.         foreach ($oameni as $o) {
  50.                
  51.                 $selected = ($id and in_array($o['id'],$op_array))?'selected="selected"':'';
  52.                
  53.                 $t->set_var(array(
  54.                         'O_ID' => $o['id'],
  55.                         'O_NUME' => stripslashes($o['nume']),
  56.                         'O_SELECTED' => $selected
  57.                 ));
  58.                 $t->parse('var_oameni','oameni',true);
  59.                
  60.         }
  61.  
  62. } else {
  63.         $t->set_var('var_oameni','Nici un om politic activ.');
  64. }
  65.  
  66. // adaugare/modificare
  67. if(isset($_POST['submit'])) {
  68.  
  69.         $error = '';
  70.        
  71.         if (empty($_POST['titlu']))
  72.                 $error .= 'Va rugam introduceti un titlu.<br />';
  73.        
  74.         if (!$id) {
  75.                
  76.                 $ident = ident($db->escape($_POST['titlu']));
  77.                 $ident_check = $db->queryAll("select id from stiri where ident='$ident'");
  78.                 if (count($ident_check)>0)
  79.                         $error .= 'Va rugam introduceti un alt titlu, acesta este deja activ in baza de date.<br />';
  80.                
  81.                 if ($error=='') {
  82.                        
  83.                         $movie = 0;
  84.                         $titlu = $db->escape($_POST['titlu']);
  85.                         $ident = ident($titlu);
  86.                         $cat = $db->escape($_POST['cat']);
  87.                         $continut = $db->escape($_POST['continut']);
  88.                         $ora = date("h:i a");
  89.                        
  90.                         $imagine = $_FILES['imagine']['name'];
  91.                         $film = $_FILES['film']['name'];
  92.                        
  93.                         if ($imagine!='') {
  94.                                 $upl = new Upload('foto');
  95.                                 $imagine = $upl->uploadFile($_FILES['imagine'],'../upload/imagini/',200,100);
  96.                         }
  97.                        
  98.                         if (isset($_POST['oameni'])) {
  99.                                 $oameni = $_POST['oameni'];
  100.                                 $oameni = implode(",",$_POST['oameni']);
  101.                         } else
  102.                                 $oameni = '';
  103.                        
  104.                         if ($film!='') {
  105.                                 mkdir("../upload/filme/".$cat."/".$ident);
  106.                                 exec("chmod -R 777 ../upload/filme/".$cat."/".$ident);
  107.                        
  108.                                 exec("/usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -qscale 7 -ar 22050 -ab 32 -f flv -s 480x360 ../upload/filme/".$cat."/".$ident."/movie.flv ; /usr/bin/flvtool2 -U stdin ../upload/filme/".$cat."/".$ident."/movie.flv ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -vframes 1 -ss 00:00:15 -an -vcodec png -f rawvideo -s 480x360 ../upload/filme/".$cat."/".$ident."/image.png ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -vframes 1 -ss 00:00:15 -an -vcodec png -f rawvideo -s 480x360 ../upload/filme/".$cat."/".$ident."/thumb.png ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' &> ../upload/filme/".$cat."/".$ident."/movie.info");
  109.                                
  110.                                 $upl = new Upload;
  111.                                 $imagine = $upl->resize("../upload/filme/".$cat."/".$ident."/image.png","../upload/filme/".$cat."/".$ident."/thumb.png",100);
  112.                                
  113.                                 $movie = 1;
  114.                         }
  115.                        
  116.                         $db->query("insert into stiri set cat='$cat', titlu='$titlu', movie='$movie', text='$continut', imagine='$imagine', oameniPolitici='$oameni', ora='$ora', date=NOW(), ident='$ident'");
  117.                        
  118.                         redirect('vizualizare.stiri.php');
  119.                
  120.                 } else {
  121.                         $t->set_var(array(
  122.                                 'MSG' => $error,
  123.                                 'TITLU' => $_POST['titlu'],
  124.                                 'CONTINUT' => $_POST['continut']
  125.                         ));
  126.                 }
  127.                
  128.         } else {
  129.        
  130.                 $ident = ident($db->escape($_POST['titlu']));
  131.                 $ident_check = $db->queryAll("select id from stiri where ident='$ident' and id!='$id'");
  132.                 if (count($ident_check)>0)
  133.                         $error .= 'Va rugam introduceti un alt titlu, acesta este deja activ in baza de date.<br />';
  134.        
  135.                 if ($error=='') {
  136.                        
  137.                         $movie = '';
  138.                         $image = '';
  139.                        
  140.                         $titlu = $db->escape($_POST['titlu']);
  141.                         $ident = ident($titlu);
  142.                         $cat = $db->escape($_POST['cat']);
  143.                         $continut = $db->escape($_POST['continut']);
  144.                        
  145.                         $imagine = $_FILES['imagine']['name'];
  146.                         $film = $_FILES['film']['name'];
  147.                        
  148.                         $old = $db->fetch("select cat,ident from stiri where id='$id'");
  149.                        
  150.                         if ($imagine!='') {
  151.                                 if ($row['imagine']!='') {
  152.                                         unlink("../upload/imagini/".$row['imagine']);
  153.                                         unlink("../upload/imagini/thumb/".$row['imagine']);
  154.                                 }
  155.                        
  156.                                 $upl = new Upload('foto');
  157.                                 $imagine = $upl->uploadFile($_FILES['imagine'],'../upload/imagini/',200,100);
  158.                                 $image = ", imagine='$imagine'";
  159.                         }
  160.                        
  161.                         if (isset($_POST['oameni'])) {
  162.  
  163.                                 $oameni = $_POST['oameni'];
  164.                                 $oameni = implode(",",$_POST['oameni']);
  165.                         } else
  166.                                 $oameni = '';
  167.                        
  168.                         if ($film!='') {
  169.                                 if ($row['movie']==1) {
  170.                                         full_rmdir("../upload/filme/".$cat."/".$ident);
  171.                                         mkdir("../upload/filme/".$cat."/".$ident);
  172.                                         exec("chmod -R 777 ../upload/filme/".$cat."/".$ident);
  173.                                 } else {
  174.                                         mkdir("../upload/filme/".$cat."/".$ident);
  175.                                         exec("chmod -R 777 ../upload/filme/".$cat."/".$ident);
  176.                                 }
  177.                        
  178.                                 exec("/usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -qscale 7 -ar 22050 -ab 32 -f flv -s 480x360 ../upload/filme/".$cat."/".$ident."/movie.flv ; /usr/bin/flvtool2 -U stdin ../upload/filme/".$cat."/".$ident."/movie.flv ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -vframes 1 -ss 00:00:15 -an -vcodec png -f rawvideo -s 480x360 ../upload/filme/".$cat."/".$ident."/image.png ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' -vframes 1 -ss 00:00:15 -an -vcodec png -f rawvideo -s 100x100 ../upload/filme/".$cat."/".$ident."/thumb.png ; /usr/bin/ffmpeg -y -i '".$_FILES['film']['tmp_name']."' &> ../upload/filme/".$cat."/".$ident."/movie.info");
  179.                                
  180.                                 $upl = new Upload;
  181.                                 $imagine = $upl->resize("../upload/filme/".$cat."/".$ident."/image.png","../upload/filme/".$cat."/".$ident."/thumb.png",100);
  182.                                
  183.                                 $movie = ", movie='1'";
  184.  
  185.                         } elseif ($row['movie']==1 and ($old['ident']!=$ident or $old['cat']!=$cat)) {
  186.                                
  187.                                 rename("../upload/filme/".$old['cat']."/".$old['ident'],"../upload/filme/".$cat."/".$ident);
  188.                        
  189.                         }
  190.                        
  191.                         $db->query("update stiri set cat='$cat', titlu='$titlu' $movie , text='$continut' $image , oameniPolitici='$oameni', ident='$ident' where id='$id'");
  192.                        
  193.                         redirect('vizualizare.stiri.php');
  194.                
  195.                 } else {
  196.                         $t->set_var(array(
  197.                                 'MSG' => $error,
  198.                                 'TITLU' => $_POST['titlu'],
  199.                                 'CONTINUT' => $_POST['continut']
  200.                         ));
  201.                 }
  202.        
  203.         }
  204.        
  205. }
  206.  
  207. // html
  208. getMenu();
  209. getHeader(1);
  210. $t->pparse('','tpl_main');
  211. getFooter();
  212. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me
: