ajouter_prd2.php
Upload User: feiyaoda
Upload Date: 2016-11-21
Package Size: 9556k
Code Size: 3k
Category:

WEB Mail

Development Platform:

PHP

  1. //script ajouter_prd2
  2. <?
  3. include("page_haut.inc");
  4. include ("configuration.php");
  5. require ("xml_domit_parser.php");
  6. require ("xml_domit_utilities.php");
  7. require ("xml_domit_nodemaps.php");
  8. $prd=& new DOMIT_Document();
  9. $success=$prd->loadXML("./modules/administration/produits.xml");
  10. $num = count($prd->documentElement->childNodes);
  11. if($num==0)
  12. {
  13. $nb=0;
  14. }
  15. else{ $currentprd =& $prd->documentElement->childNodes[$num-1];
  16.         $prdid=$currentprd->childNodes[0]->firstChild->nodeValue;
  17. $nb=$prdid+1;
  18. }
  19. $newnode=$prd->createElement("produit");
  20. $prd->documentElement->appendChild($newnode);
  21. $newchild=& $prd->documentElement->lastChild;
  22. $newchild->appendChild($prd->createElement("id"));
  23. $newchild->appendChild($prd->createElement("nom"));
  24. $newchild->appendChild($prd->createElement("prix"));
  25. $newchild->appendChild($prd->createElement("articleStock"));
  26. $newchild->appendChild($prd->createElement("promo"));
  27. $newchild->appendChild($prd->createElement("anciePrix"));
  28. $newchild->appendChild($prd->createElement("frais"));
  29. $newchild->appendChild($prd->createElement("description"));
  30. $newchild->appendChild($prd->createElement("photo"));
  31. $newchild->appendChild($prd->createElement("categorie"));
  32. $newchild->appendChild($prd->createElement("souscategorie"));
  33. $newtextnodee=& $prd->createTextNode($nb);
  34. $newtextnode=& $prd->createTextNode($name);
  35. $newtextnode1=& $prd->createTextNode($prix);
  36. $newtextnode2=& $prd->createTextNode($stock);
  37. $newtextnode3=& $prd->createTextNode($promo);
  38. $newtextnode4=& $prd->createTextNode($ancienprix);
  39. $newtextnode5=& $prd->createTextNode($frais);
  40. $newtextnode6=& $prd->createTextNode($spec);
  41. $newtextnode7=& $prd->createTextNode("../$photos/prd_image$nb.gif");
  42. $newtextnode8=& $prd->createTextNode($group);
  43. $newtextnode9=& $prd->createTextNode($subgroup);
  44. $new=& $prd->documentElement->lastChild;
  45. $idnew=& $new->firstChild;
  46. $namenew=& $idnew->nextSibling;
  47. $prixnew=& $namenew->nextSibling;
  48. $stocknew=& $prixnew->nextSibling;
  49. $promonew=& $stocknew->nextSibling;
  50. $ancienprixnew=& $promonew->nextSibling;
  51. $fraisnew=& $ancienprixnew->nextSibling;
  52. $specnew=& $fraisnew->nextSibling;
  53. $photonew=& $specnew->nextSibling;
  54. $groupnew=& $photonew->nextSibling;
  55. $subgroupnew=& $groupnew->nextSibling;
  56. $idnew->appendChild($newtextnodee);
  57. $namenew->appendChild($newtextnode);
  58. $prixnew->appendChild($newtextnode1);
  59. $stocknew->appendChild($newtextnode2);
  60. $promonew->appendChild($newtextnode3);
  61. $ancienprixnew->appendChild($newtextnode4);
  62. $fraisnew->appendChild($newtextnode5);
  63. $specnew->appendChild($newtextnode6);
  64. $photonew->appendChild($newtextnode7);
  65. $groupnew->appendChild($newtextnode8);
  66. $subgroupnew->appendChild($newtextnode9);
  67. $succes=& $prd->saveXML("./modules/administration/produits.xml");
  68. $fichier = "./modules/administration/produits.xml";
  69.  $id_fichier = fopen($fichier, "rb");
  70.  $contenu = fread($id_fichier, filesize ($fichier));
  71. @fclose($fichier);
  72. @unlink ("./modules/administration/produits.xml");
  73. $f=fopen("./modules/administration/produits.xml","w");
  74. fputs($f,"<?xml version='1.0' encoding='ISO-8859-1' ?>r");
  75. fputs($f,$contenu);
  76. if(is_uploaded_file($_FILES['image']['tmp_name']))
  77. {
  78. copy($_FILES['image']['tmp_name'],"../$photos/prd_image$nb.gif");
  79. }
  80. ?>
  81. <script>
  82. document.location='?m=administration&a=ajouter_prd';
  83. </script>