示例#1
0
 /**
  * Writes the container data to the session store
  *
  * @return boolean
  */
 public function write()
 {
     // do we need to rotate?
     if ($this->rotationInterval and $this->rotationTimer < time()) {
         $this->rotate();
     }
     return $this->driver->write();
 }
 function run()
 {
     set_time_limit(0);
     try {
         DB::query("UPDATE Driver SET Active = 0");
         DB::query("UPDATE DriverRelease SET Active = 0");
         $url = 'http://stackalytics.com/driverlog/api/1.0/drivers';
         $jsonResponse = @file_get_contents($url);
         $driverArray = json_decode($jsonResponse, true);
         $array = $driverArray['drivers'];
         foreach ($array as $contents) {
             if (!isset($contents['project_name']) || !isset($contents['name'])) {
                 continue;
             }
             $driver = Driver::get()->filter(array("Name" => trim($contents['name']), "Project" => trim($contents['project_name'])))->first();
             if (!$driver) {
                 $driver = new Driver();
             }
             $driver->Name = trim($contents['name']);
             $driver->Description = isset($contents['description']) ? $contents['description'] : null;
             $driver->Project = $contents['project_name'];
             $driver->Vendor = isset($contents['vendor']) ? $contents['vendor'] : null;
             $driver->Url = isset($contents['wiki']) ? $contents['wiki'] : null;
             $driver->Active = 1;
             if (isset($contents['releases_info'])) {
                 $releases = $contents['releases_info'];
                 foreach ($releases as $release) {
                     $driver_release = DriverRelease::get()->filter("Name", trim($release['name']))->first();
                     if (!$driver_release) {
                         $driver_release = new DriverRelease();
                     }
                     $driver_release->Name = trim($release['name']);
                     $driver_release->Url = $release['wiki'];
                     $driver_release->Active = 1;
                     $driver_release->write();
                     $driver->Releases()->add($driver_release);
                 }
             }
             $driver->write();
         }
         return 'OK';
     } catch (Exception $ex) {
         SS_Log::log($ex, SS_Log::ERR);
         echo $ex->getMessage();
     }
 }
示例#3
0
 function superPostAdd()
 {
     global $gbl, $sgbl, $login, $ghtml;
     if (!$sgbl->isHyperVm()) {
         return;
     }
     if ($this->vpstype_f === 'xen') {
         $driver = new Driver(null, $this->nname, $this->nname);
         $driver->get();
         $driver->driver_b->pg_vps = 'xen';
         $driver->setUpdateSubaction();
         $driver->write();
         if ($this->xenlocation) {
             $dirlocation = new Dirlocation(null, $this->nname, $this->nname);
             $dirlocation->dbaction = 'add';
             foreach ($this->xenlocation as $k) {
                 $name = "lvm:{$k['nname']}";
                 $xenloc[$name] = new xen_location_a(null, $this->nname, $name);
             }
             $dirlocation->parent_clname = $this->getClName();
             $dirlocation->xen_location_a = $xenloc;
             $this->addToList('dirlocation', $dirlocation);
         }
     }
 }