Exemplo n.º 1
0
 /**
  * Down notify.
  * 
  * @access public
  * @return void
  */
 public function downNotify()
 {
     $notifyDir = $this->app->getBasePath() . 'www/data/notify/';
     $packageFile = $notifyDir . 'notify.zip';
     $loginFile = $notifyDir . 'config.json';
     /* write login info into tmp file. */
     $loginInfo = new stdclass();
     $userInfo = new stdclass();
     $userInfo->Account = $this->app->user->account;
     $userInfo->Url = common::getSysURL() . $this->config->webRoot;
     $userInfo->PassMd5 = '';
     $userInfo->Role = $this->app->user->role;
     $userInfo->AutoSignIn = true;
     $userInfo->Lang = $this->cookie->lang;
     $loginInfo->User = $userInfo;
     $loginInfo->LastLoginTime = time() / 86400 + 25569;
     $loginInfo = json_encode($loginInfo);
     file_put_contents($loginFile, $loginInfo);
     define('PCLZIP_TEMPORARY_DIR', $notifyDir);
     $this->app->loadClass('pclzip', true);
     /* remove the old config.json, add a new one. */
     $archive = new pclzip($packageFile);
     $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'config.json');
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     $result = $archive->add($loginFile, PCLZIP_OPT_REMOVE_ALL_PATH);
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     unlink($loginFile);
     $this->fetch('file', 'sendDownHeader', array('fileName' => 'notify.zip', 'zip', file_get_contents($packageFile)));
     $result = $archive->delete(PCLZIP_OPT_BY_NAME, 'config.json');
     if ($result == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
 }
Exemplo n.º 2
0
         $filename = tempnam("", "jh_");
         setcookie(DTX_COOKIE_NAME, $filename);
         $file = fopen($filename, "w");
         foreach ($unitIDs as $unitID) {
             fwrite($file, trim($unitID) . "\n");
         }
         fclose($file);
         $tpl->show();
     }
 } elseif (array_key_exists(DTX_COOKIE_NAME . "_project", $_COOKIE)) {
     // Step 3: The last cookie is the project Id cookie, so we know
     // that we can create the zip file from the dtx files.
     // create zip
     $zipname = tempnam("", "jh_");
     $zip = new pclzip($zipname);
     $addResult = $zip->add($outDirName . "/", PCLZIP_OPT_REMOVE_ALL_PATH);
     if ($addResult == 0) {
         $msg = "Error creating zip file:" . $zip->errorInfo(true);
         $tpl->SetVariable("MESSAGE", $msg);
         $tpl->Show();
     } else {
         $projectInfos = GetProjectInfos($_COOKIE[DTX_COOKIE_NAME . "_project"]);
         $filename = $projectInfos["Name"] . ".zip";
         // we have the zip, send it
         header("Content-Type: archive/zip");
         // replace by text/plain for debug
         header('Content-Disposition: attachment; filename="' . $filename . '"');
         // don't use file_get_contents, it might be too recent
         //        echo file_get_contents($zipname);
         $file = fopen($zipname, "rb");
         while (!feof($file)) {