Example #1
0
 /**
  * {@inheritdoc}
  */
 public function close()
 {
     if ($this->dbHandle) {
         $this->dbHandle->close();
         $this->dbHandle = null;
     }
 }
Example #2
0
 /**
  * 析构函数
  */
 public function __destruct()
 {
     if ($this->isConnected) {
         $this->mem->close();
     }
     $this->mem = NULL;
 }
Example #3
0
 /**
  * Delete all values from the cache
  *
  * @param boolean $check Optional - only delete expired cache items
  * @return boolean True if the cache was succesfully cleared, false otherwise
  * @access public
  */
 function clear($check)
 {
     if (!$this->__init) {
         return false;
     }
     $dir = dir($this->settings['path']);
     if ($check) {
         $now = time();
         $threshold = $now - $this->settings['duration'];
     }
     while (($entry = $dir->read()) !== false) {
         if ($this->__setKey($entry) === false) {
             continue;
         }
         if ($check) {
             $mtime = $this->__File->lastChange();
             if ($mtime === false || $mtime > $threshold) {
                 continue;
             }
             $expires = $this->__File->read(11);
             $this->__File->close();
             if ($expires > $now) {
                 continue;
             }
         }
         $this->__File->delete();
     }
     $dir->close();
     return true;
 }
Example #4
0
 /**
  * Close the zip archive
  *
  * @return  bool
  * @throws  \Comodojo\Exception\ZipException
  */
 public function close()
 {
     if ($this->zip_archive->close() === false) {
         throw new ZipException(self::getStatus($this->zip_archive->status));
     }
     return true;
 }
Example #5
0
 /**
  * Close connection if it exists
  *
  * @author KnowledgeTree Team
  * @access private
  * @params mysql connection object $con
  * @return void
  */
 private function closeMysql($con)
 {
     try {
         $this->_dbhandler->close();
     } catch (Exeption $e) {
         $this->error['con'] = "Could not close: " . $e;
     }
 }
 /**
  * Class destructor
  *
  * Closes the connection to Memcache(d) if present.
  *
  * @return	void
  */
 public function __destruct()
 {
     if ($this->_memcached instanceof Memcache) {
         $this->_memcached->close();
     } elseif ($this->_memcached instanceof Memcached && method_exists($this->_memcached, 'quit')) {
         $this->_memcached->quit();
     }
 }
 /**
  * Class destructor
  *
  * Closes the connection to Memcache(d) if present.
  *
  * @return    void
  */
 public function __destruct()
 {
     if ($this->_memcached instanceof Memcache) {
         $this->_memcached->close();
     } elseif ($this->_memcached instanceof Memcached) {
         $this->_memcached->quit();
     }
 }
Example #8
0
 /**
  * Closes a previously opened database connection
  */
 public function closeConnection()
 {
     if ($this->debug) {
         $this->debug->log(__METHOD__);
     }
     $this->isConnected() && $this->DB->close();
     $this->DB = null;
 }
Example #9
0
 /**
  * 关闭数据库连接
  *
  * @return void
  */
 public function close()
 {
     $this->_driver->close($this->_writeConnection);
     $this->_writeConnection = null;
     if (!empty($this->_readConnection)) {
         $this->_driver->close($this->_readConnection);
         $this->_readConnection = null;
     }
 }
Example #10
0
	/**
	 * Disconnect from the Mongo server.
	 *
	 * @return boolean True on successful disconnect, false otherwise.
	 */
	public function disconnect() {
		if ($this->server && $this->server->connected) {
			try {
				$this->_isConnected = !$this->server->close();
			} catch (Exception $e) {}
			unset($this->connection, $this->server);
			return !$this->_isConnected;
		}
		return true;
	}
Example #11
0
 /**
  * Deconstructor
  *
  * Close connections to the database
  * @since Version 3.7
  */
 protected function __deconstruct()
 {
     if ($this->destroy) {
         if ($this->db instanceof \sql_db) {
             $this->db->close();
         } else {
             #$this->closeConnection();
         }
     }
 }
Example #12
0
 /**
  * 析构函数
  *
  * 程序执行完毕,打扫战场
  *
  * @access public
  *
  * @return void
  */
 public function __destruct()
 {
     if ($this->_dbLink) {
         $this->_dbLink = null;
     }
     if ($this->_mongo) {
         $this->_mongo->close();
     }
     return true;
 }
 /**
  * 析构函数
  * 执行session存储器实例,将模拟的session内容写入保存
  */
 function __destruct()
 {
     if (!is_object($this->_storageHandler)) {
         return '';
     }
     if (!empty($this->_sess_data) && !empty($this->_session_id)) {
         $sess_data = serialize($this->_sess_data);
         $this->_storageHandler->write($this->_session_id, $sess_data);
     }
     $this->_storageHandler->close();
 }
Example #14
0
 /**
  * Compress data into the archive
  *
  * @param string $sFile Name of the ZIP file
  * @param string $sFolder Name of the folder we are going to compress. Must be located within the "file/cache/" folder.
  * @return mixed Returns the full path to the newly created ZIP file.
  */
 public function compress($sFile, $sFolder)
 {
     // Create random ZIP
     $sArchive = PHPFOX_DIR_CACHE . md5((is_array($sFile) ? serialize($sFile) : $sFile) . Phpfox::getParam('core.salt') . PHPFOX_TIME) . '.zip';
     chdir(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS);
     if (is_object($this->_oZip)) {
         if ($this->_oZip->open($sArchive, ZipArchive::CREATE)) {
             $aFiles = Phpfox::getLib('file')->getAllFiles(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS);
             foreach ($aFiles as $sNewFile) {
                 $sNewFile = str_replace(PHPFOX_DIR_CACHE . $sFolder . PHPFOX_DS, '', $sNewFile);
                 $this->_oZip->addFile($sNewFile);
             }
             $this->_oZip->close();
         }
     } else {
         shell_exec(Phpfox::getParam('core.zip_path') . ' -r ' . escapeshellarg($sArchive) . ' ./');
     }
     chdir(PHPFOX_DIR);
     return $sArchive;
 }
 /**
  * onMessage($clientId, $message) get messages from server (request / response)
  * @param int $clientId connect identifier
  * @param varchar $message costom message throught socket
  * @access public
  */
 public function onMessage($clientId, $message)
 {
     // get client ip
     $ip = long2ip($this->_server->clients[$clientId][6]);
     // check if message length is 0
     if (strlen($message) == 0) {
         // send nothing
         $this->_server->close($clientId);
         return;
     }
     // the speaker is the only person in the room. Don't let them feel lonely.
     if (sizeof($this->_server->clients) == 1) {
         $this->_server->send($clientId, "There isn't anyone else in the room, but I'll still listen to you. Some one in the dark :))");
     } else {
         // send the message to everyone but the person who said it
         foreach ($this->_server->clients as $id => $client) {
             if ($id != $clientId) {
                 $this->_server->send($id, "User {$clientId} ({$ip}) said \"{$message}\"");
             }
         }
     }
 }
 /**
  * @throws Exception
  * Download files from remote server
  * Unzip to TMP folder
  */
 private function download()
 {
     if (empty($this->servers)) {
         return;
     }
     $client = new \CAnalytics\Module\IdctSftpClient\SftpClient();
     foreach ($this->servers as $key => $server) {
         if (empty($server->name) || empty($server->host) || empty($server->username) || empty($server->password) || empty($server->directory)) {
             continue;
         }
         $serverStatus = true;
         $credentials = \CAnalytics\Module\IdctSftpClient\Credentials::withPassword($server->username, $server->password);
         $client->setCredentials($credentials);
         try {
             $client->connect($server->host);
         } catch (Exception $e) {
             $serverStatus = false;
         }
         $this->trafficServerModel->updateServerStatus($server->id, $serverStatus);
         if (!$serverStatus) {
             continue;
         }
         $this->cleanTmpDir($server->id);
         $filesList = $client->getFileList($server->directory);
         $filesList = $this->filterList($server->id, $filesList, true);
         if (empty($filesList)) {
             continue;
         }
         $this->checkDir($this->uploadDir . $server->id);
         //  Download Files Form Remote server
         foreach ($filesList as $key => $fileName) {
             if (!file_exists($this->getLocalDir($server->id) . $fileName)) {
                 $client->download($this->getRemoteDir($server->directory) . $fileName, $this->getLocalDir($server->id) . $fileName);
             }
             $fileList[$key] = null;
         }
         //  UnzipFiles
         $filesList = $this->getFileListing($this->getLocalDir($server->id));
         $filesList = $this->filterList($server->id, $filesList, true);
         foreach ($filesList as $key => $fileName) {
             $res = $this->zip->open($this->getLocalDir($server->id) . $fileName);
             if ($res === TRUE) {
                 $this->zip->extractTo($this->getLocalDir($server->id, true));
                 $this->zip->close();
             }
             $fileList[$key] = null;
         }
         $servers[$key] = null;
         $client->close();
     }
 }
 /**
  * The execute method
  *
  * @param InputInterface  $input  The Input class
  * @param OutputInterface $output The output class
  *
  * @access protected
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $start_date = time();
     $this->em = $this->getContainer()->get('doctrine')->getManager('default');
     $root_dir = $this->getContainer()->getParameter("kernel.root_dir") . "/config/gatling/data";
     PiFileManager::mkdirr($root_dir, 0777);
     $path = $root_dir . "/connexion_sfynx.csv";
     file_put_contents($path, 'username,password' . "\n", LOCK_EX);
     //
     $firstId = (int) $input->getOption('firstId');
     $lastId = (int) $input->getOption('lastId');
     $output->writeln('First id user : ' . $firstId);
     $output->writeln('last id user : ' . $lastId);
     //
     $output->writeln(" - début de chargement de donnée");
     $sqluser = "INSERT INTO `fos_user` (`id`, `lang_code`,  `username`, `username_canonical`, `email`, `email_canonical`, `enabled`, `salt`, " . "`password`, `last_login`, `locked`, `expired`, `expires_at`, `confirmation_token`, `password_requested_at`, " . "`roles`, `permissions`, `credentials_expired`, `credentials_expire_at`, `name`, `nickname`, " . "`created_at`) VALUES " . "(:id, 'fr_FR', :user, :user, :user, :user, 1, '73rwkq08i3wo0ow840c0g48k800o0ok', " . "'xREF5HHqHbZmlmoO3+s5BXtVtYa3TIf8Wv+IVXJsQwx+0FG1WnqxjJ46toQ1u/+v1lfKOwo90FqEbqiPDzDo+g==', '2014-11-13 00:00:00', " . "0, 0, NULL, NULL, NULL, 'a:1:{i:0;s:9:\"ROLE_USER\";}', 'a:4:{i:0;s:4:\"VIEW\";i:1;s:4:\"EDIT\";i:2;s:6:\"CREATE\";i:3;s:6:\"DELETE\";}', 0, NULL, :user, :user, '2014-11-12 17:55:21' " . ");";
     $this->em->getConnection()->beginTransaction();
     $stmtuser = $this->em->getConnection()->prepare($sqluser);
     try {
         $psw = "user";
         $start_date_user = time();
         for ($j = $firstId; $j <= $lastId; $j++) {
             $user_value = 'user' . $j;
             $params = array('id' => $j, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value, 'user' => $user_value);
             $stmtuser->execute($params);
             //
             file_put_contents($path, "{$user_value},{$psw}\n", FILE_APPEND);
         }
         $end_date_user = time();
         $duration_user = $end_date_user - $start_date_user;
         $output->writeln(" - fin de chargement de données des users en " . $duration_user . "s");
         $this->em->flush();
         // Try and commit the transaction
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $output->writeln($e->getMessage());
         // Rollback the failed transaction attempt
         $this->em->getConnection()->rollback();
         $this->em->close();
     }
     $end_date = time();
     $duration = $end_date - $start_date;
     $output->writeln(" - fin de chargement de donnée en " . $duration . "s");
 }
 /**
  * get files info by item_id and file_type_name
  *
  * @access public
  * @param int $item_id item id
  * @param string $file_type_name file type name
  * @return array files info
  */
 function getFilesInfo($item_id, $file_type_name = false)
 {
     $join = new XooNIpsJoinCriteria('xoonips_file_type', 'file_type_id', 'file_type_id', 'INNER', 'ft');
     $criteria = new CriteriaCompo(new Criteria('item_id', $item_id));
     $criteria->add(new Criteria('is_deleted', 0));
     if ($file_type_name !== false) {
         $criteria->add(new Criteria('name', $file_type_name, '=', 'ft'));
     }
     $files_info = array();
     $res =& $this->xf_handler->open($criteria, '', false, $join);
     while ($xf_obj =& $this->xf_handler->getNext($res)) {
         $info = $xf_obj->getArray();
         $info['file_path'] = $this->getFilePath($info['file_id']);
         $info['file_url'] = XOONIPS_URL . '/download.php?file_id=' . $info['file_id'];
         $info['image_url'] = XOONIPS_URL . '/image.php?file_id=' . $info['file_id'];
         $files_info[] = $info;
     }
     $this->xf_handler->close($res);
     return $files_info;
 }
Example #19
0
 /**
  * 关闭连接
  *
  * @return void
  */
 public function close()
 {
     if (null != $this->oCache) {
         return $this->oCache->close();
     }
 }
Example #20
0
 /**
  * Closes the database connection
  */
 public function __destruct()
 {
     $this->link->close();
 }
Example #21
0
 /**
  * Releases the cursor. Should always be call after having fetched rows from
  * a query execution.
  *
  * @return void
  * @api
  */
 public function free()
 {
     $this->statement->close();
 }
Example #22
0
 /**
  * 关闭连接
  * 
  * @return void
  */
 public function close()
 {
     $this->db->close();
 }
Example #23
0
 public function __destroy()
 {
     $this->mysqli->close();
 }
Example #24
0
 /**
  * Close the SessionHandler backend.
  *
  * @return  boolean  True on success, false otherwise.
  */
 public function close()
 {
     return $this->engine->close();
 }
/**
 * Closes an opened connection.
 *
 * @param object $obj The object returned by cassandra_connect().
 *
 * @return int 1
 */
function cassandra_close($obj)
{
    return $obj->close();
}
Example #26
0
 /**
  * Closes a table
  *
  * @access  public
  * @return  object PEAR_Error on failure
  */
 function close()
 {
     if ($this->_dba->isWritable()) {
         // pack up the field structure and store it back in the table
         if (isset($this->_schema)) {
             $schema = $this->_packSchema($this->_schema);
             if (DBA::isError($schema)) {
                 return $schema;
             }
             $this->_dba->replace(DBA_SCHEMA_KEY, $schema);
         } else {
             echo "No schema, what's the point :P\n";
         }
     }
     $this->_maxKey = null;
     return $this->_dba->close();
 }
Example #27
0
 /**
  * Run the view's close method
  *
  * @access public
  * @return void
  */
 public function close()
 {
     return $this->_view->close();
 }
Example #28
0
 /**
  * Close the Moodle Workbook
  */
 function close() {
     $this->pear_excel_workbook->close();
 }
 /**
  * Destructor.
  */
 public function __destruct()
 {
     $this->connection->close();
 }
Example #30
0
 /**
  * Return result of task execution for $task_id
  * @param object $connection AMQPConnection object
  * @param string $task_id Celery task identifier
  * @param int $expire expire time result queue, milliseconds
  * @param boolean $removeMessageFromQueue whether to remove message from queue
  * @return array array('body' => JSON-encoded message body, 'complete_result' => AMQPMessage object)
  * 			or false if result not ready yet
  */
 function GetMessageBody($connection, $task_id, $expire = 0, $removeMessageFromQueue = true)
 {
     if (!$this->receiving_channel) {
         $ch = $connection->channel();
         $expire_args = null;
         if (!empty($expire)) {
             $expire_args = array("x-expires" => array("I", $expire));
         }
         $ch->queue_declare($task_id, false, true, false, true, false, $expire_args);
         $ch->queue_bind($task_id, 'celeryresults');
         $ch->basic_consume($task_id, '', false, false, false, false, array($this, 'Consume'));
         $this->receiving_channel = $ch;
     }
     try {
         $this->receiving_channel->wait(null, false, $this->wait_timeout);
     } catch (PhpAmqpLib\Exception\AMQPTimeoutException $e) {
         return false;
     }
     /* Check if the callback function saved something */
     if ($this->message) {
         if ($removeMessageFromQueue) {
             $this->receiving_channel->queue_delete($task_id);
         }
         $this->receiving_channel->close();
         $connection->close();
         return array('complete_result' => $this->message, 'body' => $this->message->body);
     }
     return false;
 }