本文整理汇总了PHP中Updater类的典型用法代码示例。如果您正苦于以下问题:PHP Updater类的具体用法?PHP Updater怎么用?PHP Updater使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Updater类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: instance
/**
* This function returns an instance of the Updater
* class. It is the only way to create a new Updater, as
* it implements the Singleton interface
*
* @return Updater
*/
public static function instance()
{
if (!self::$_instance instanceof Updater) {
self::$_instance = new Updater();
}
return self::$_instance;
}
示例2: init
function init()
{
global $_version;
require_once CONF_PATH . 'autofill.inc.php';
$this->init_header();
Updater::init();
$this->init_final();
}
示例3: create
public function create($statsType)
{
// prepare things unique to this statsType
$ucStatsType = ucfirst($statsType);
if (!isset($this->updateIfOlderThan[$ucStatsType])) {
throw new Exception("unknown type of article stats type given: '{$statsType}'");
exit;
}
$viewName = $this->viewNameBase . strtolower($statsType);
$articleStatsClassName = $ucStatsType . "_ArticleStats";
// get search results for statsTypes that need them
$searchResults = $this->runSearch($ucStatsType);
// setup the objects we need
$db = new Db('https://' . AM_CRAWLER_USER . ':' . AM_CRAWLER_PW . '@' . AM_CRAWLER_DB_URL, AM_CRAWLER_DB_NAME);
$urls = new Urls();
$getter = new UrlGetter();
$articleStats = new $articleStatsClassName($getter, $urls);
$updater = new Updater($db, $this->log);
// setup update options
$updater->setViewName(array("crawl", $viewName));
$updater->setArticleStats($articleStats);
$updater->setSecondsBetweenUpdates($this->secondsBetweenDocUpdates[$ucStatsType]);
$updater->setUpdateIfOlderThan($this->updateIfOlderThan[$ucStatsType]);
$updater->setSearchResults($searchResults);
return $updater;
}
示例4: do_upgrade
public function do_upgrade()
{
$request = $this->getRequest();
if ($request->isPost()) {
$updater = new Updater();
if ($updater->updateAvailable()) {
$image_data = $updater->downloadLatest();
if (!$updater->validateSignature($image_data)) {
die('INVALID SIGNATURE');
}
if ($updater->performUpdate($image_data)) {
die('Upgrading, please wait for the device to reboot.');
} else {
die('FAILED');
}
}
}
}
示例5: ApplyUpdate
public static function ApplyUpdate($File, $Last, $Hash, $Date)
{
$Lines = file($File, FILE_IGNORE_NEW_LINES);
foreach ($Lines as $Line) {
$Statement = Updater::$DBConnection->prepare($Line);
$Statement->execute();
}
if ($Last == true) {
Updater::UpdateDatabaseVersion($Hash, $Date);
}
}
示例6: main
public function main($argv)
{
Pix_Table::$_save_memory = true;
list(, $type, $year, $month) = $argv;
if (!in_array($type, array('company', 'bussiness', 'company-continue', 'bussiness-continue'))) {
return $this->wrong_argv();
}
if (in_array($type, array('company', 'bussiness'))) {
$year = intval($year);
$month = intval($month);
if (!intval($year) or !intval($month)) {
return $this->wrong_argv();
}
}
if ('company' == $type) {
$ids = Crawler::crawlerMonth($year, $month);
$ids = array_unique($ids);
file_put_contents('ids', implode("\n", $ids));
foreach ($ids as $id) {
$u = Updater::update($id);
if ($u) {
$u->updateSearch();
}
}
} elseif ('company-continue' == $type) {
$ids = explode("\n", file_get_contents('ids'));
$pos = array_search($year, $ids);
var_dump($pos);
if (false === $pos) {
return $this->wrong_argv();
}
foreach (array_slice($ids, $pos - 1) as $id) {
$u = Updater::update($id);
if ($u) {
$u->updateSearch();
}
}
} else {
$ids = Crawler::crawlerBussiness($year, $month);
$ids = array_unique($ids);
file_put_contents('ids', implode("\n", $ids));
foreach ($ids as $id) {
$u = Updater::updateBussiness($id);
if ($u) {
$u->updateSearch();
}
}
}
}
示例7: init
function init()
{
global $_config;
if (!$_config) {
require_once SYSTEM_ROOT . './config.inc.php';
}
$this->init_header();
$this->init_useragent();
CACHE::pre_fetch('setting', 'plugin', 'plugins');
Updater::init();
$this->init_syskey();
$this->init_cookie();
cloud::init();
HOOK::INIT();
$this->init_final();
}
示例8: protect
/**
* Block a page if referer is found on list of blocked domains
*
* @param string $action If empty, send 403 response; if URL, redirect here; if non-empty string, print message
*/
public static function protect($action = '')
{
// Try to update the list
if (!defined('SEMALT_UNIT_TESTING')) {
Updater::update();
}
// Simply stop here if referer is not on the list
if (!self::isRefererOnBlocklist()) {
return;
}
self::doBlock($action);
// Stop execution altogether, bye bye bots
if (!defined('SEMALT_UNIT_TESTING')) {
exit;
}
}
示例9: ENUM
$sql = "ALTER TABLE `" . OW_DB_PREFIX . "googlelocation_data` ADD `entityType` ENUM( 'user', 'event' ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `entityId` ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
try {
$sql = "UPDATE `" . OW_DB_PREFIX . "googlelocation_data` SET `entityType` = 'user' ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
try {
$sql = "ALTER TABLE `" . OW_DB_PREFIX . "googlelocation_data` DROP INDEX `entityId` ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
try {
$sql = "ALTER IGNORE TABLE `" . OW_DB_PREFIX . "googlelocation_data` ADD INDEX `entityId` ( `entityId` , `entityType` ) ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
try {
$sql = " DELETE FROM g `" . OW_DB_PREFIX . "googlelocation_data` g\n LEFT JOIN `" . OW_DB_PREFIX . "base_user` u ON u.id = g.entityId\n WHERE g.entityType = 'user' AND u.id IS NULL ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
try {
$sql = " ALTER TABLE `" . OW_DB_PREFIX . "googlelocation_data` CHANGE `json` `json` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
}
Updater::getLanguageService()->importPrefixFromZip(dirname(__FILE__) . DS . 'langs.zip', 'googlelocation');
示例10: install
protected function install()
{
$updater = new Updater();
$updater->update();
}
示例11: copy
copy($source . $file, $dest . $file);
}
}
}
closedir($dir_handle);
} else {
copy($source, $dest);
}
}
$errors = array();
try {
$sql = "ALTER TABLE `" . OW_DB_PREFIX . "map` ADD `id_cat` INT( 10 ) NOT NULL DEFAULT '0' AFTER `id_owner` ,ADD INDEX ( `id_cat` ) ";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
$errors[] = $e;
}
try {
$sql = "CREATE TABLE IF NOT EXISTS `" . OW_DB_PREFIX . "map_category` (\n `id` int(10) NOT NULL auto_increment,\n `id2` int(10) NOT NULL default '0',\n `active` enum('0','1') collate utf8_bin NOT NULL default '1',\n `name` varchar(100) collate utf8_bin NOT NULL,\n `name_translate` varchar(100) collate utf8_bin NOT NULL,\n UNIQUE KEY `id` (`id`),\n KEY `name` (`name`),\n KEY `id2` (`id2`),\n KEY `active` (`active`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
$errors[] = $e;
}
try {
$sql = "INSERT INTO `" . OW_DB_PREFIX . "map_category` (\n`id` ,\n`id2` ,\n`active` ,\n`name` ,\n`name_translate`\n)\nVALUES (\n'0', '0', '1', 'Default', 'cat_default'\n);";
Updater::getDbo()->query($sql);
} catch (Exception $e) {
$errors[] = $e;
}
if (!empty($errors)) {
// print_r($errors);
}
示例12: testIsUpgradePossible
/**
* @dataProvider versionCompatibilityTestData
*/
public function testIsUpgradePossible($oldVersion, $newVersion, $result)
{
$updater = new Updater(\OC::$server->getHTTPHelper(), \OC::$server->getConfig());
$this->assertSame($result, $updater->isUpgradePossible($oldVersion, $newVersion));
}
示例13: VARCHAR
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
try {
$sql = "SHOW COLUMNS FROM `" . OW_DB_PREFIX . "video_clip` LIKE 'plugin';";
$cols = Updater::getDbo()->queryForList($sql);
if (!count($cols)) {
$sql = "ALTER TABLE `" . OW_DB_PREFIX . "video_clip` ADD `plugin` VARCHAR(255) NULL DEFAULT 'video' ; ";
Updater::getDbo()->update($sql);
}
} catch (Exception $e) {
}
// refresh static cache
$plugin = OW::getPluginManager()->getPlugin('spvideolite');
$staticDir = OW_DIR_STATIC_PLUGIN . $plugin->getModuleName() . DS;
$pluginStaticDir = OW_DIR_PLUGIN . $plugin->getModuleName() . DS . 'static' . DS;
if (file_exists($staticDir)) {
UTIL_File::removeDir($staticDir);
}
mkdir($staticDir);
chmod($staticDir, 0777);
UTIL_File::copyDir($pluginStaticDir, $staticDir);
示例14: Exception
if (!$rs) {
throw new Exception("upgrade::setTRStoFloat(): " . $this->conn->error);
}
$res = $rs->fetch_array(MYSQLI_ASSOC);
if (strpos($res['data_type'], 'int') === false) {
return 0;
}
// already done
// not done: change every TRS/TRM field to float
foreach ($cmds as $query) {
$this->conn->query($query);
}
return 0;
}
}
$upg = new Updater();
if ($upg->slaveMode() == true) {
return;
}
// restricted mode. do not try to update database anyway
try {
$upg->removeUpdateMark();
$upg->updateVersionHistory();
$upg->updatePerroGuiaClub();
$upg->addCountries();
$upg->addColumnUnlessExists("Mangas", "Orden_Equipos", "TEXT");
$upg->addColumnUnlessExists("Resultados", "TIntermedio", "double", "0.0");
$upg->addColumnUnlessExists("Resultados", "Games", "int(4)", 0);
$upg->addColumnUnlessExists("Perros", "NombreLargo", "varchar(255)");
$upg->addColumnUnlessExists("Perros", "Genero", "varchar(16)");
$upg->addColumnUnlessExists("Provincias", "Pais", "varchar(2)", "ES");
示例15: dirname
<?php
/**
* This software is intended for use with Oxwall Free Community Software http://www.oxwall.org/ and is
* licensed under The BSD license.
* ---
* Copyright (c) 2011, Oxwall Foundation
* All rights reserved.
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Oxwall Foundation nor the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
$updateDir = dirname(__FILE__) . DS;
Updater::getLanguageService()->importPrefixFromZip($updateDir . 'langs.zip', 'groups');
OW::getAuthorization()->addAction('groups', 'view', true);