PHP Installation file issue


/ Published in: PHP
Save to your folder(s)

I created myself an install file using PHP. What this file does is creates folders and puts in each folder the corresponding file from the zip. Afterwards these files are moved to other folders which are already created or will be created by the install file. (I know this might sound as a stupid procces instead of just moving the files to the folders the first place but theres a reason for this).

The problem is that when I install the zip it creates the folders with the files and creates the newer folders where the files are supposed to be move but I have to install the zip two or three times for all of the proccess to be done properly.

Why could this be?

Here is the file I have and hopefully I have explained myself :).


Copy this code and paste it in your HTML
  1. <?php
  2. defined('_JEXEC') or die('Restricted access');
  3.  
  4. $this->path = JInstaller::getInstance()->getPath('extension_administrator');
  5.  
  6. $path = $this->path;
  7.  
  8. $path2 = JInstaller::getInstance()->getPath('extension_site');
  9. //Fichero controlador Back
  10.  
  11. if(JFolder::create(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'media')){}
  12. if(JFolder::create(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'media'.DS.'css')){}
  13. if(JFolder::create(JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'models')){}
  14. if(JFolder::create(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views'.DS.'kiala')){}
  15. if(JFolder::create(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views'.DS.'kiala'.DS.'tmpl')) {}
  16. if(JFolder::create(JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views'.DS.'kiala')){}
  17. if(JFolder::create(JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views'.DS.'kiala'.DS.'tmpl')) {}
  18.  
  19. if(JFile::exists($path .DS. 'controllers' .DS. 'kiala.php')){
  20.  
  21.  
  22. JFile::copy($path .DS.'controllers'.DS.'kiala.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'controllers'.DS.'kiala.php');
  23.  
  24. }
  25.  
  26. //Fichero modelo Back
  27.  
  28. if(JFile::exists($path .DS. 'models' .DS. 'kiala.php')){
  29.  
  30.  
  31. JFile::copy($path .DS.'models'.DS.'kiala.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'models'.DS.'kiala.php');
  32.  
  33. }
  34.  
  35. //Fichero controlador Front
  36.  
  37. if(JFile::exists($path2 .DS. 'controllersfront' .DS. 'kiala.php')){
  38.  
  39.  
  40. JFile::copy($path2 .DS.'controllersfront'.DS.'kiala.php', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'controllers'.DS.'kiala.php');
  41.  
  42. }
  43.  
  44.  
  45.  
  46. //Fichero modelo Front
  47.  
  48.  
  49.  
  50. if(JFile::exists($path2 .DS. 'modelsfront' .DS. 'kiala.php')){
  51.  
  52.  
  53. JFile::copy($path2 .DS.'modelsfront'.DS.'kiala.php', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'models'.DS.'kiala.php');
  54.  
  55. }
  56.  
  57. if(JFile::exists($path .DS. 'models' .DS. 'kiala_ws.php')){
  58.  
  59.  
  60. JFile::copy($path .DS.'models'.DS.'kiala_ws.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'models'.DS.'kiala_ws.php');
  61.  
  62. }
  63.  
  64. //Carpeta Vistas Back
  65.  
  66. if(JFile::exists($path .DS. 'media' .DS.'css'.DS. 'kiala.css')){
  67.  
  68.  
  69. JFile::copy($path .DS.'media'.DS.'css'.DS.'kiala.css', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'media' .DS.'css'.DS.'kiala.css');
  70.  
  71. }
  72.  
  73.  
  74.  
  75. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'view.html.php')){
  76.  
  77.  
  78. JFile::copy($path .DS.'views'.DS.'kiala'.DS.'view.html.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala'.DS.'view.html.php');
  79.  
  80. }
  81.  
  82. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'index.html')){
  83.  
  84.  
  85. JFile::copy($path .DS.'views'.DS.'kiala'.DS.'index.html', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala'.DS.'index.html');
  86.  
  87. }
  88.  
  89.  
  90.  
  91.  
  92. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'index.html')){
  93.  
  94.  
  95. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'index.html', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'index.html');
  96.  
  97. }
  98.  
  99. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'kialacp.php')){
  100.  
  101.  
  102. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'kialacp.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'kialacp.php');
  103.  
  104. }
  105.  
  106. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'order.php')){
  107.  
  108.  
  109. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'order.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'order.php');
  110.  
  111. }
  112.  
  113. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'order_editstatus.php')){
  114.  
  115.  
  116. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'order_editstatus.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'order_editstatus.php');
  117.  
  118. }
  119.  
  120. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'order_print.php')){
  121.  
  122.  
  123. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'order_print.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'order_print.php');
  124.  
  125. }
  126.  
  127. if(JFile::exists($path .DS. 'views' .DS.'kiala'.DS. 'tmpl'.DS. 'orders.php')){
  128.  
  129.  
  130. JFile::copy($path .DS.'views'.DS.'kiala'.DS. 'tmpl'.DS. 'orders.php', JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'orders.php');
  131.  
  132. }
  133.  
  134. //View Front
  135.  
  136. if(JFile::exists($path2 .DS. 'viewsfront' .DS.'kiala'.DS. 'view.html.php')){
  137.  
  138.  
  139. JFile::copy($path2 .DS.'viewsfront'.DS.'kiala'.DS.'view.html.php', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala'.DS.'view.html.php');
  140.  
  141. }
  142.  
  143. if(JFile::exists($path2 .DS. 'viewsfront' .DS.'kiala'.DS. 'tmpl'.DS. 'index.html')){
  144.  
  145.  
  146. JFile::copy($path2 .DS.'viewsfront'.DS.'kiala'.DS. 'tmpl'.DS. 'index.html', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'index.html');
  147.  
  148. }
  149.  
  150. if(JFile::exists($path2 .DS. 'viewsfront' .DS.'kiala'.DS. 'tmpl'.DS. 'kiala.php')){
  151.  
  152.  
  153. JFile::copy($path2 .DS.'viewsfront'.DS.'kiala'.DS. 'tmpl'.DS. 'kiala.php', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'kiala.php');
  154.  
  155. }
  156.  
  157. if(JFile::exists($path2 .DS. 'viewsfront' .DS.'kiala'.DS. 'tmpl'.DS. 'details_kiala.php')){
  158.  
  159.  
  160. JFile::copy($path2 .DS.'viewsfront'.DS.'kiala'.DS. 'tmpl'.DS. 'details_kiala.php', JPATH_ROOT.DS.'components'.DS.'com_virtuemart'.DS.'views' .DS.'kiala' .DS.'tmpl'.DS.'details_kiala.php');
  161.  
  162. }
  163.  
  164. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.