За последние 24 часа нас посетили 19328 программистов и 1615 роботов. Сейчас ищут 944 программиста ...

процесс бар и переадресация

Тема в разделе "PHP для новичков", создана пользователем wolf777, 18 июн 2015.

  1. wolf777

    wolf777 Новичок

    С нами с:
    26 авг 2014
    Сообщения:
    207
    Симпатии:
    0
    ребят помогите пожалуйста, есть процесс бар и пошаговая установка cms, как сделать чтоб процесс бар закрывал информацию об установки cms и по окончании загрузки процесс бара, чтоб переадресовывалось на окончание установки и выводилась информация о том что cms установлена?

    вот сам процесс бар

    Код (PHP):
    1. <script
    2.  src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"
    3.  type="text/javascript"></script>
    4. <style>
    5. .timer {
    6.  position: relative;
    7.  font-size: 200px;
    8.  width: 1em;
    9.  height: 1em;
    10.  float: left;
    11. }
    12.  
    13. .timer>.percent {
    14.  position: absolute;
    15.  top: 1.05em;
    16.  left: 0;
    17.  width: 3.33em;
    18.  font-size: 0.3em;
    19.  text-align: center;
    20. }
    21.  
    22. .timer>#slice {
    23.  position: absolute;
    24.  width: 1em;
    25.  height: 1em;
    26.  clip: rect(0px, 1em, 1em, 0.5em);
    27. }
    28.  
    29. .timer>#slice.gt50 {
    30.  clip: rect(auto, auto, auto, auto);
    31. }
    32.  
    33. .timer>#slice>.pie {
    34.  border: 0.1em solid #c0c0c0;
    35.  position: absolute;
    36.  width: 0.8em; /* 1 - (2 * border width) */
    37.  height: 0.8em; /* 1 - (2 * border width) */
    38.  clip: rect(0em, 0.5em, 1em, 0em);
    39.  -moz-border-radius: 0.5em;
    40.  -webkit-border-radius: 0.5em;
    41.  border-radius: 0.5em;
    42. }
    43.  
    44. .timer>#slice>.pie.fill {
    45.  -moz-transform: rotate(180deg) !important;
    46.  -webkit-transform: rotate(180deg) !important;
    47.  -o-transform: rotate(180deg) !important;
    48.  transform: rotate(180deg) !important;
    49. }
    50.  
    51. .timer.fill>.percent {
    52.  display: none;
    53. }
    54.  
    55. .timer.fill>#slice>.pie {
    56.  border: transparent;
    57.  background-color: #c0c0c0;
    58.  width: 1em;
    59.  height: 1em;
    60. }
    61. </style>
    62. <script type="text/javascript">
    63.  var timer;
    64.  var timerCurrent;
    65.  var timerFinish;
    66.  var timerSeconds;
    67.  function drawTimer(percent){
    68.   $('div.timer').html(
    69.           '<div class="percent"></div><div id="slice"'+
    70.    (percent > 50?' class="gt50"':'')+
    71.    '><div class="pie"></div>'+
    72.    (percent > 50?'<div class="pie fill"></div>':'')+'</div>');
    73.   var deg = 360/100*percent;
    74.   $('#slice .pie').css({
    75.    '-moz-transform':'rotate('+deg+'deg)',
    76.    '-webkit-transform':'rotate('+deg+'deg)',
    77.    '-o-transform':'rotate('+deg+'deg)',
    78.    'transform':'rotate('+deg+'deg)'
    79.   });
    80.   $('.percent').html(Math.round(percent)+'%');
    81.  }
    82.  function stopWatch(){
    83.   var seconds = (timerFinish-(new Date().getTime()))/1000;
    84.   if(seconds <= 0){
    85.    drawTimer(100);
    86.    clearInterval(timer);
    87.   }else{
    88.    var percent = 100-((seconds/timerSeconds)*100);
    89.    drawTimer(percent);
    90.   }
    91.  }
    92.     $(document).ready(function(){    
    93.   timerSeconds = 42;
    94.   timerCurrent = 0;
    95.   timerFinish = new Date().getTime()+(timerSeconds*1000);
    96.   timer = setInterval('stopWatch()',50);  
    97.  });
    98. </script>
    99. ________________________
    100.  <div class="timer"></div>
    а вот сами шаги установки cms

    Код (PHP):
    1. switch ($step) {
    2.     case 0:
    3.         $next_step = $step + 1;
    4.         $next = $steps[$step]['next'];
    5.         $extra = '';
    6.         if (file_exists(dirname(__FILE__).'/../wa-sources/')) {
    7.             $extra = <<<HTML
    8. <input type="checkbox" value="1" name="check_latest" id="check_latest">
    9. <label for="check_latest">{$t->_('Check available updates')}</label>
    10. <br>
    11. HTML;
    12.             $extra = <<<HTML
    13. <input type="hidden" value="0" name="check_latest">
    14. HTML;
    15.         } else {
    16.             $extra = <<<HTML
    17. <input type="hidden" value="1" name="check_latest">
    18. HTML;
    19.         }
    20.         $locales = waInstallerLocale::listAvailable();
    21.         $select_locale = '';
    22.         if ($locales) {
    23.             $select_locale .= '<br><select name="lang" id="wa-installer-locale-select">';
    24.             foreach ($locales as $locale) {
    25.                 $t_item = new waInstallerLocale($locale);
    26.                 $selected = ($locale == $lang) ? ' selected="selected"' : '';
    27.                 $select_locale .= <<<HTML
    28. <option value="{$locale}"{$selected}>{$t_item->_($locale)}</option>
    29. HTML;
    30.             }
    31.             $select_locale .= '</select>';
    32.         } else {
    33.             $select_locale = <<<HTML
    34. <input type="hidden" value="{$lang}" name="lang">
    35. HTML;
    36.         }
    37.  
    38.         $content = <<<HTML
    39. <center><img src="/img/install-logo.jpg"></center>
    40.  
    41. <div class="i-welcome">
    42.     <h1 class="i-url"><span>http://</span>{$host}</h1>
    43.         <p>{$t->_('Webasyst Installer will deploy archive with Webasyst system files and apps in this folder.')}<br >
    44.         </p>
    45.  
    46.         {$extra}
    47.         <input type="submit" value="{$t->_('Install Webasyst')}" class="button green large" id="wa-installer-submit">
    48.         <br>
    49.         <br>
    50.         {$select_locale}
    51. </div>
    52. HTML;
    53.         break;
    54.     case 1:
    55.         try {
    56.             if (!file_exists($init_path)) {
    57.                 throw new Exception("File <b>wa-installer/lib/init.php</b> not found");
    58.             }
    59.  
    60.             require_once($init_path);
    61.             if (!class_exists('waInstallerApps')) {
    62.                 throw new Exception('Class <b>waInstallerApps</b> not found');
    63.             }
    64.             if (!class_exists('waInstaller')) {
    65.                 throw new Exception('Class <b>waInstaller</b> not found');
    66.             }
    67.  
    68.             $urls = array();
    69.             $local_path = dirname(__FILE__).'/../wa-sources/';
    70.             $apps = array();
    71.             $plugins = array();
    72.             if (!isset($_POST['complete']) || !$_POST['complete']) {
    73.                 if (file_exists($local_path) && is_dir($local_path)) {
    74.                     $cwd = getcwd();
    75.                     chdir($local_path);
    76.                     $pattern = '{*.tar.gz,wa-apps/*.tar.gz,wa-apps/*/plugins/*.tar.gz,wa-apps/*/themes/*.tar.gz}';
    77.                     foreach (glob($pattern, GLOB_BRACE) as $path) {
    78.                         if (preg_match('@^([\\w%0-9\\-!]+)\\.tar\\.gz$@', basename($path), $matches)) {
    79.                             $decoded = dirname($path).'/';
    80.                             if ($decoded == './') {
    81.                                 $decoded = '';
    82.                             }
    83.  
    84.                             $decoded .= urldecode($matches[1]);
    85.                             $urls[] = array(
    86.                                 'source' => $local_path.$path,
    87.                                 'target' => $decoded,
    88.                                 'slug'   => $decoded,
    89.                             );
    90.                             if (preg_match('@wa-apps/([\\w\\d\\-]+)$@', $decoded, $matches)) {
    91.                                 $apps[] = $matches[1];
    92.                             } elseif (preg_match('@wa-apps/([\\w\\d\\-]+)/plugins/([\\w\\d\\-]+)$@', $decoded, $matches)) {
    93.                                 if (!isset($plugins[$matches[1]])) {
    94.                                     $plugins[$matches[1]] = array();
    95.                                 }
    96.                                 $plugins[$matches[1]][] = $matches[2];
    97.                             }
    98.                         }
    99.                     }
    100.                     chdir($cwd);
    101.                 }
    102.  
    103.                 if (!count($urls)) {
    104.                     //not supported since 2.0
    105.                     $list = array();
    106.                     $urls = array();
    107.                     foreach ($list as $target => $item) {
    108.                         if (isset($item['target'])) {
    109.                             $target = $item['target'];
    110.                         }
    111.                         $urls[] = array(
    112.                             'source' => $item['download_url'],
    113.                             'target' => $target,
    114.                             'slug'   => $item['slug'],
    115.                         );
    116.  
    117.                         if (preg_match('@wa-apps/([\\w\\d\\-]+)$@', $target, $matches)) {
    118.                             $apps[] = $matches[1];
    119.                         }
    120.                     }
    121.                 }
    122.             }
    123.  
    124.             $installer_apps = new waInstallerApps();
    125.             waInstallerApps::setLocale($t->getLocale());
    126.             $installer = new waInstaller(waInstaller::LOG_DEBUG);
    127.             if ($urls && $installer->update($urls)) {
    128.                 foreach ($apps as $app) {
    129.                     $installer_apps->installWebAsystApp($app);
    130.                     if (!empty($plugins[$app])) {
    131.                         foreach ($plugins[$app] as $plugin) {
    132.                             $installer_apps->updateAppPluginsConfig($app, $plugin);
    133.                         }
    134.                     }
    135.                 }
    136.             } else {
    137.                 $state = $installer->getState();
    138.                 if (isset($state['stage_status']) && ($state['stage_status'] == waInstaller::STATE_ERROR)) {
    139.                     throw new Exception($state['error']);
    140.                 }
    141.             }
    142.             $log = parseLog($installer->getFullState('raw'), $t);
    143.             $next_step = $step + 1;
    144.             $next = $steps[$step]['next'];
    145.             $content = <<<HTML
    146. <h1>{$t->_('Files')} <i class="icon16 yes"></i></h1>
    147. <div class="i-log">{$log}</div>
    148. <p class="i-success">{$t->_('All files successfully extracted. Click "Continue" button below.')} <i class="icon16 yes"></i></p>
    149. HTML;
    150.  
    151.         } catch (Exception $e) {
    152.             $content = <<<HTML
    153. <h1>{$t->_('Files')} <i class="icon16 no"></i></h1>
    154. <p class="i-error">{$t->_('An error occurred during the installation')}</p>
    155. <p>{$e->getMessage()}</p>
    156. HTML;
    157.         }
    158.         break;
    159.