Exemplo n.º 1
0
function util_requireOtherFiles()
{
    $root = util_getRootPath();
    require_once "{$root}/phplib/idiorm/idiorm.php";
    require_once "{$root}/phplib/idiorm/paris.php";
    require_once "{$root}/phplib/serverPreferences.php";
    require_once "{$root}/phplib/db.php";
    require_once "{$root}/phplib/logging.php";
    require_once "{$root}/phplib/session.php";
    require_once "{$root}/phplib/smarty.php";
    require_once "{$root}/phplib/memcache.php";
}
Exemplo n.º 2
0
 public static function runAllModules($lexems, $definitions)
 {
     $adsModules = Config::get('global.adsModulesH');
     if ($adsModules) {
         foreach ($adsModules as $adsModule) {
             require_once util_getRootPath() . "phplib/ads/{$adsModule}/{$adsModule}AdsModule.php";
             $className = ucfirst($adsModule) . 'AdsModule';
             $module = new $className();
             $result = $module->run(empty($lexems) ? null : $lexems, empty($definitions) ? null : $definitions);
             if ($result) {
                 SmartyWrap::assign('adsProvider', $adsModule);
                 SmartyWrap::assign('adsProviderParams', $result);
                 break;
             }
         }
     }
 }
Exemplo n.º 3
0
 static function init()
 {
     self::$theSmarty = new Smarty();
     self::$theSmarty->template_dir = util_getRootPath() . 'templates';
     self::$theSmarty->compile_dir = util_getRootPath() . 'templates_c';
     self::$theSmarty->inheritance_merge_compiled_includes = false;
     // This allows variable names in {include} tags
     self::assign('wwwRoot', util_getWwwRoot());
     self::assign('imgRoot', util_getImgRoot());
     self::assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many());
     self::assign('sUser', session_getUser());
     self::assign('nick', session_getUserNick());
     self::assign('currentYear', date("Y"));
     self::assign('isMobile', util_isMobile());
     self::assign('suggestNoBanner', util_suggestNoBanner());
     self::assign('cfg', Config::getAll());
     self::assign('GLOBALS', $GLOBALS);
     self::$theSmarty->registerPlugin('function', 'getDebugInfo', array('SmartyWrap', 'getDebugInfo'));
 }
Exemplo n.º 4
0
 static function getByDate($displayDate, $wotm = false)
 {
     $creditsFile = $wotm ? self::CREDITS_FILE_WOTM : self::CREDITS_FILE_WOTD;
     $lines = @file(util_getRootPath() . $creditsFile);
     if (!$lines) {
         return null;
     }
     foreach ($lines as $line) {
         $commentStart = strpos($line, '#');
         if ($commentStart !== false) {
             $line = substr($line, 0, $commentStart);
         }
         $line = trim($line);
         if ($line) {
             $parts = explode('::', trim($line));
             if (preg_match("/{$parts[0]}/", $displayDate)) {
                 return WotdArtist::get_by_label($parts[1]);
             }
         }
     }
     return null;
 }
Exemplo n.º 5
0
function smarty_init()
{
    $smarty = new Smarty();
    $smarty->template_dir = util_getRootPath() . 'templates';
    $smarty->compile_dir = util_getRootPath() . 'templates_c';
    $smarty->assign('wwwRoot', util_getWwwRoot());
    $smarty->assign('cssRoot', util_getCssRoot());
    $smarty->assign('imgRoot', util_getImgRoot());
    $smarty->assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many());
    $smarty->assign('sUser', session_getUser());
    $smarty->assign('is_mirror', pref_isMirror());
    $smarty->assign('nick', session_getUserNick());
    $smarty->assign('contact_email', pref_getContactEmail());
    $smarty->assign('hostedBy', pref_getHostedBy());
    $smarty->assign('currentYear', date("Y"));
    $smarty->assign('bannerType', pref_getServerPreference('bannerType'));
    $smarty->assign('developmentMode', pref_getServerPreference('developmentMode'));
    $smarty->assign('isMobile', util_isMobile());
    smarty_registerFunction($smarty, 'getDebugInfo', 'smarty_function_getDebugInfo');
    $smarty->assign('GLOBALS', $GLOBALS);
    $GLOBALS['smarty_theSmarty'] = $smarty;
}
Exemplo n.º 6
0
 static function init()
 {
     self::$theSmarty = new Smarty();
     self::$theSmarty->template_dir = util_getRootPath() . 'templates';
     self::$theSmarty->compile_dir = util_getRootPath() . 'templates_c';
     self::assign('wwwRoot', util_getWwwRoot());
     self::assign('imgRoot', util_getImgRoot());
     self::assign('staticServer', Config::get('static.url'));
     self::assign('sources', Model::factory('Source')->order_by_desc('isOfficial')->order_by_asc('displayOrder')->find_many());
     self::assign('sUser', session_getUser());
     self::assign('is_mirror', Config::get('global.mirror'));
     self::assign('nick', session_getUserNick());
     self::assign('contact_email', Config::get('global.contact'));
     self::assign('hostedBy', Config::get('global.hostedBy'));
     self::assign('currentYear', date("Y"));
     self::assign('bannerType', Config::get('banner.type'));
     self::assign('developmentMode', Config::get('global.developmentMode'));
     self::assign('isMobile', util_isMobile());
     self::assign('suggestNoBanner', util_suggestNoBanner());
     self::assign('acEnable', Config::get('search.acEnable'));
     self::assign('acMinChars', Config::get('search.acMinChars'));
     self::assign('GLOBALS', $GLOBALS);
     self::$theSmarty->registerPlugin('function', 'getDebugInfo', array('SmartyWrap', 'getDebugInfo'));
 }
Exemplo n.º 7
0
$provider = util_getRequestParameter('provider');
// Display a banner for this provider
$go = util_getRequestParameter('go');
// Track a click and redirect to this provider
$clickurl = util_getRequestParameter('clickurl');
// Sent to us by OpenX; when displaying a banner, we have to link to this URL
if ($go) {
    $provider = $go;
    $go = true;
}
require_once "../phplib/ads/{$provider}/{$provider}AdsModule.php";
if ($provider == 'diverta') {
    $bookId = util_getRequestParameter('bookId');
    $book = DivertaBook::get_by_id($bookId);
    if (!$book) {
        exit;
    }
    if ($go) {
        $book->clicks++;
        $book->save();
        util_redirect($book->url);
    }
    $book->impressions++;
    $book->save();
    smarty_assign('book', $book);
    smarty_assign('hasImage', file_exists(util_getRootPath() . "wwwbase/img/diverta/thumb/{$book->sku}.jpg"));
}
smarty_assign('clickurl', str_replace('__', '&', $clickurl));
$output = smarty_fetch("ads/{$provider}.ihtml");
$output = addslashes(str_replace("\n", ' ', $output));
print "document.write(\"{$output}\");";
Exemplo n.º 8
0
<?php

require_once __DIR__ . '/../phplib/util.php';
// TODO: Add user pages
// TODO: Add inflection models (from modele-flexiune.php)
define('FILE_SIZE_LIMIT', 9000000);
define('FILE_URL_LIMIT', 45000);
$g_numFiles = 0;
$g_curFileName = null;
$g_curFile = null;
$g_curFileSize = 0;
$g_curFileUrl = 0;
log_scriptLog('Running generateSitemap.php');
chdir(util_getRootPath());
openNewFile();
addOtherUrls();
$query = 'select id, formNoAccent from Lexem order by formNoAccent';
log_scriptLog("Running mysql query: [{$query}]");
$dbResult = db_execute($query);
$rowB = array(null, null);
$rowC = array(null, null);
foreach ($dbResult as $dbRow) {
    // Keep a moving window of 3 lexems that we can use to eliminate duplicates
    $rowA = $rowB;
    $rowB = $rowC;
    $rowC = $dbRow;
    if ($rowB[1] && $rowB[1] != $rowA[1]) {
        // If 2 or more lexems have identical forms, only add a definition URL for the first one
        addUrl('http://dexonline.ro/definitie/' . urlencode($rowB[1]));
    }
    if ($rowB[0] && ($rowB[1] == $rowA[1] || $rowB[1] == $rowC[1])) {
Exemplo n.º 9
0
function dumpAbbrevs($remoteFile)
{
    global $FTP;
    log_scriptLog("dumping abbreviations");
    $sources = AdminStringUtil::loadAbbreviationsIndex();
    $sectionNames = AdminStringUtil::getAbbrevSectionNames();
    $sections = array();
    foreach ($sectionNames as $name) {
        $raw_section = parse_ini_file(util_getRootPath() . "docs/abbrev/{$name}.conf", true);
        $section = array();
        foreach ($raw_section[$name] as $short => $long) {
            $abbrev_info = array('short' => $short, 'long' => $long, 'ambiguous' => false);
            if (substr($short, 0, 1) == "*") {
                $abbrev_info['short'] = substr($short, 1);
                $abbrev_info['ambiguous'] = true;
            }
            $section[] = $abbrev_info;
        }
        $sections[$name] = $section;
    }
    SmartyWrap::assign('sources', $sources);
    SmartyWrap::assign('sections', $sections);
    $xml = SmartyWrap::fetch('xml/xmldump/abbrev.tpl');
    $FTP->staticServerPutContents(gzencode($xml), $remoteFile);
}
Exemplo n.º 10
0
<?php

/*
 * Alin Ungureanu, 2013
 * alyn.cti@gmail.com
 */
require_once '../phplib/util.php';
require_once util_getRootPath() . 'phplib/AppLog.php';
require_once util_getRootPath() . 'phplib/MemoryManagement.php';
db_init();
$logFile = Config::get('app_log.diacritics_log');
/*
 * Builds examples and improves statistics for the diacritics mechanism
 */
class DiacriticsBuilder
{
    protected $currOffset;
    protected $file;
    protected $fileEndOffset;
    protected static $diacritics;
    protected static $nonDiacritics;
    protected static $paddingNumber;
    protected static $paddingChar;
    private $globalCount;
    private $localCount;
    private $currentFolder;
    private $folderCount;
    /*
     * initialises instance variables
     */
    function __construct()
Exemplo n.º 11
0
define('DATABASE_TMPFILE_GZIP', DATABASE_TMPFILE . '.gz');
$doDatabaseCopy = true;
$doCodeUpdate = true;
for ($i = 1; $i < count($argv); $i++) {
    $arg = $argv[$i];
    if ($arg == "-nc") {
        $doCodeUpdate = false;
    } else {
        if ($arg == '-nd') {
            $doDatabaseCopy = false;
        } else {
            OS::errorAndExit("Unknown flag: {$arg}");
        }
    }
}
log_scriptLog('Running updateMirror.php with databaseCopy:' . ($doDatabaseCopy ? 'yes' : 'no') . ' codeUpdate:' . ($doCodeUpdate ? 'yes' : 'no'));
if ($doDatabaseCopy) {
    $wget = sprintf("wget -q -O %s %s", DATABASE_TMPFILE_GZIP, DATABASE_URL);
    OS::executeAndAssert($wget);
    $gzip = sprintf("gunzip %s", DATABASE_TMPFILE_GZIP);
    OS::executeAndAssert($gzip);
    $parts = db_splitDsn();
    $mysql = sprintf("mysql -h %s -u %s --password='******' %s < %s", $parts['host'], $parts['user'], $parts['password'], $parts['database'], DATABASE_TMPFILE);
    OS::executeAndAssert($mysql);
    $rm = sprintf("rm -f %s", DATABASE_TMPFILE);
    OS::executeAndAssert($rm);
}
if ($doCodeUpdate) {
    OS::executeAndAssert('cd ' . util_getRootPath() . '; /usr/bin/git pull --quiet');
}
log_scriptLog('updateMirror.php completed successfully (against all odds)');
Exemplo n.º 12
0
function util_requireOtherFiles()
{
    $root = util_getRootPath();
    require_once StringUtil::portable("{$root}/phplib/smarty/Smarty.class.php");
    require_once StringUtil::portable("{$root}/phplib/idiorm/idiorm.php");
    require_once StringUtil::portable("{$root}/phplib/idiorm/paris.php");
    require_once StringUtil::portable("{$root}/phplib/db.php");
    require_once StringUtil::portable("{$root}/phplib/logging.php");
    require_once StringUtil::portable("{$root}/phplib/session.php");
    require_once StringUtil::portable("{$root}/phplib/memcache.php");
}
Exemplo n.º 13
0
<?php

require_once "../phplib/util.php";
$TODAY = date("Y-m-d");
$FOLDER = util_getRootPath() . '/wwwbase/download/xmldump';
$URL = 'http://dexonline.ro/download/xmldump';
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Update4Instructions");
}
$lastDump = getLastDumpDate($TODAY, $FOLDER);
smarty_assign('lastDump', $lastDump);
smarty_assign('url', $URL);
$lastClientUpdate = util_getRequestParameterWithDefault('last', '0');
if ($lastClientUpdate == '0') {
    // Dump the freshest full dump we have
    // TODO: return an error if there is no full dump
    smarty_assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
smarty_assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $FOLDER));
header('Content-type: text/xml');
print smarty_fetch('common/update4.ihtml');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    $files = scandir($folder, 1);
    // descending
    foreach ($files as $file) {
        $matches = array();
        if (preg_match('/^(\\d\\d\\d\\d-\\d\\d-\\d\\d)-abbrevs.xml.gz$/', $file, $matches)) {
Exemplo n.º 14
0
 public static function init()
 {
     self::$DEFAULT_IMAGE = "generic.jpg";
     self::$IMAGE_CREDITS_DIR = util_getRootPath() . 'docs/imageCredits';
 }
Exemplo n.º 15
0
<?php

require_once "../phplib/util.php";
$user = session_getUser();
if (!$user) {
    FlashMessage::add('Nu puteți alege o imagine de profil dacă nu sunteți autentificat.');
    util_redirect(util_getWwwRoot());
}
define('AVATAR_RESOLUTION', 48);
define('AVATAR_QUALITY', 100);
$AVATAR_REMOTE_FILE = "/img/user/{$user->id}.jpg";
$AVATAR_RAW_GLOB = util_getRootPath() . "wwwbase/img/generated/{$user->id}_raw.*";
$x0 = util_getRequestParameter('x0');
$y0 = util_getRequestParameter('y0');
$side = util_getRequestParameter('side');
$delete = util_getRequestParameter('delete');
if ($delete) {
    $f = new FtpUtil();
    $f->staticServerDelete($AVATAR_REMOTE_FILE);
    $user->hasAvatar = 0;
    $user->save();
    FlashMessage::add('Imaginea a fost ștearsă.', 'info');
    util_redirect('preferinte');
}
$rawFileList = glob($AVATAR_RAW_GLOB);
if (empty($rawFileList)) {
    FlashMessage::add('Imaginea dumneavoastră de profil nu mai există. Vă rugăm să o reîncărcați.');
    util_redirect(util_getWwwRoot());
}
$rawFileName = $rawFileList[0];
$canvas = imagecreatetruecolor(AVATAR_RESOLUTION, AVATAR_RESOLUTION);
Exemplo n.º 16
0
<?php

ini_set('include_path', util_getRootPath() . '/phplib' . PATH_SEPARATOR . ini_get('include_path'));
require_once 'Auth/OpenID/Consumer.php';
require_once 'Auth/OpenID/FileStore.php';
require_once 'Auth/OpenID/SReg.php';
require_once 'Auth/OpenID/AX.php';
if (!isset($_SESSION)) {
    session_start();
}
class OpenID
{
    private static function getStore()
    {
        $store_path = '/tmp/dex_openidStorePath';
        if (!file_exists($store_path) && !mkdir($store_path)) {
            print "Could not create the FileStore directory '{$store_path}'";
            exit(0);
        }
        return new Auth_OpenID_FileStore($store_path);
    }
    private static function getConsumer()
    {
        return new Auth_OpenID_Consumer(self::getStore());
    }
    private static function getReturnTo()
    {
        return util_getFullServerUrl() . "auth/revenireOpenid";
    }
    /**
     * Returns null and sets a flash message on all errors.
Exemplo n.º 17
0
<?php

WordOfTheMonth::$IMAGE_CREDITS_DIR = util_getRootPath() . 'docs/imageCredits';
class WordOfTheMonth extends BaseObject
{
    public static $_table = 'WordOfTheMonth';
    public static $DEFAULT_IMAGE = 'generic.jpg';
    public static $IMAGE_CREDITS_DIR;
    public static function getWotM($date)
    {
        return Model::factory('WordOfTheMonth')->where_lte('displayDate', $date)->order_by_desc('displayDate')->limit(1)->find_one();
    }
    public static function getCurrentWotM()
    {
        return Model::factory('WordOfTheMonth')->where_raw('displayDate <= curdate()')->order_by_desc('displayDate')->limit(1)->find_one();
    }
    public function getImageUrl()
    {
        if ($this->image) {
            return Config::get('static.url') . 'img/wotd/cuvantul-lunii/' . $this->image;
        }
        return null;
    }
    public function getThumbUrl()
    {
        $pic = $this->image ? $this->image : self::$DEFAULT_IMAGE;
        return Config::get('static.url') . 'img/wotd/cuvantul-lunii/thumb/' . $pic;
    }
    public function getArtist()
    {
        return $this->image ? WotdArtist::getByDate($this->displayDate, true) : null;
Exemplo n.º 18
0
 static function loadRawAbbreviations()
 {
     return parse_ini_file(util_getRootPath() . "docs/abbrev.conf", true);
 }
Exemplo n.º 19
0
<?php

WordOfTheMonth::$IMAGE_DESCRIPTION_DIR = util_getRootPath() . 'docs/imageCredits';
class WordOfTheMonth extends BaseObject
{
    public static $_table = 'WordOfTheMonth';
    public static $IMAGE_DESCRIPTION_DIR;
    public static function getWotM($date)
    {
        return Model::factory('WordOfTheMonth')->where_lte('displayDate', $date)->order_by_desc('displayDate')->limit(1)->find_one();
    }
    public static function getCurrentWotM()
    {
        return Model::factory('WordOfTheMonth')->where_raw('displayDate <= curdate()')->order_by_desc('displayDate')->limit(1)->find_one();
    }
    public function getImageUrl()
    {
        if ($this->image) {
            return Config::get('static.url') . 'img/wotd/cuvantul-lunii/' . $this->image;
        }
        return null;
    }
    public function getThumbUrl()
    {
        if ($this->image) {
            return Config::get('static.url') . 'img/wotd/cuvantul-lunii/thumb/' . $this->image;
        }
        return null;
    }
    public function getImageCredits()
    {
Exemplo n.º 20
0
<?php

WordOfTheDay::$IMAGE_DIR = util_getRootPath() . "wwwbase/img/wotd";
WordOfTheDay::$THUMB_DIR = util_getRootPath() . "wwwbase/img/wotd/thumb";
WordOfTheDay::$THUMB_SIZE = 48;
class WordOfTheDay extends BaseObject
{
    public static $_table = 'WordOfTheDay';
    public static $IMAGE_DIR;
    public static $THUMB_DIR;
    public static $THUMB_SIZE;
    public static function getRSSWotD()
    {
        return Model::factory('WordOfTheDay')->where_gt('displayDate', '2011-01-01')->where_raw('displayDate < NOW()')->order_by_desc('displayDate')->limit(25)->find_many();
    }
    public static function getArchiveWotD($year, $month)
    {
        $query = "SELECT displayDate, lexicon, replace(displayDate, '-', '/') linkDate, DAYOFWEEK(displayDate) dayOfWeek, DAYOFMONTH(displayDate) dayOfMonth \n        FROM WordOfTheDay W\n        JOIN WordOfTheDayRel R ON W.id=R.wotdId\n        JOIN Definition D ON R.refId=D.id AND D.status=0 AND R.refType='Definition'\n        WHERE MONTH(displayDate)={$month} AND YEAR(displayDate)={$year}\n        ORDER BY displayDate";
        //TODO
        $dbRes = db_execute($query);
        $results = array();
        foreach ($dbRes as $row) {
            $wotda = new WotDArchive();
            $wotda->set($row);
            $results[] = $wotda;
        }
        return $results;
    }
    public static function getTodaysWord()
    {
        return Model::factory('WordOfTheDay')->where_raw('displayDate = curdate()')->find_one();
<?php

// TODO: Convert to Idiorm if this is ever needed again
require_once 'phplib/util.php';
require_once 'phplib/ads/adsModule.php';
require_once 'phplib/ads/diverta/divertaAdsModule.php';
define('IMG_URL_PREFIX', 'http://www.dol.ro/wcsstore/DOL/');
define('ORIG_FILE_PREFIX', '/tmp/dol/big/');
define('THUMB_PREFIX', util_getRootPath() . 'wwwbase/img/diverta/thumb/');
define('IMG_NORMAL', 0);
define('IMG_NOT_JPEG', 1);
define('IMG_CORRUPT', 2);
$opts = getopt('f:h:d:s:t:a:p:u:i:o:');
if (count($opts) != 10) {
    usage();
}
define('CSV_DELIMITER', getDelimiter($opts['d']));
OS::executeAndAssert('mkdir -p ' . ORIG_FILE_PREFIX);
if (!file_exists($opts['f'])) {
    print "Input file does not exist.\n";
    exit;
}
$handle = fopen($opts['f'], "r");
$i = 0;
while (($fields = fgetcsv($handle, 10000, CSV_DELIMITER)) !== false) {
    $i++;
    if ($i <= $opts['h']) {
        continue;
    }
    $sku = $fields[$opts['s']];
    print "Line {$i}: [{$sku}]\n";
function pref_parsePreferenceFile()
{
    $raw = parse_ini_file(util_getRootPath() . "dex.conf", true);
    _pref_traverseRecursivePreferences($raw);
    $GLOBALS['serverPreferences'] = $raw;
}
Exemplo n.º 23
0
        return self::$config;
    }
    /* Returns an array containing all the variables in the given section, or the empty array if the section does not exist. */
    static function getSection($section)
    {
        return array_key_exists($section, self::$config) ? self::$config[$section] : array();
    }
    static function getLocVersions()
    {
        if (!self::$locVersions) {
            $result = array();
            $locParts = self::get('global.locVersions');
            foreach ($locParts as $part) {
                $part = trim($part);
                if ($part) {
                    $versionAndDate = preg_split('/ /', $part);
                    assert(count($versionAndDate == 2));
                    $lv = new LocVersion();
                    $lv->name = trim($versionAndDate[0]);
                    $date = trim($versionAndDate[1]);
                    $lv->freezeTimestamp = $date == 'current' ? null : strtotime($date);
                    $result[] = $lv;
                }
            }
            self::$locVersions = array_reverse($result);
        }
        return self::$locVersions;
    }
}
Config::load(util_getRootPath() . "dex.conf");
Exemplo n.º 24
0
                $error = 'A intervenit o eroare la încărcare.';
            }
        }
    }
}
if ($error) {
    FlashMessage::add($error);
    util_redirect(util_getWwwRoot() . 'preferinte');
}
$user = session_getUser();
if (!$user) {
    FlashMessage::add('Nu puteți alege o imagine de profil dacă nu sunteți autentificat.');
    util_redirect(util_getWwwRoot());
}
// Remove any old files (with different extensions)
$oldFiles = glob(util_getRootPath() . "wwwbase/img/user/{$user->id}_raw.*");
foreach ($oldFiles as $oldFile) {
    unlink($oldFile);
}
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
$destFileName = util_getRootPath() . "wwwbase/img/user/{$user->id}_raw.{$ext}";
if (!move_uploaded_file($file['tmp_name'], $destFileName)) {
    FlashMessage::add('A intervenit o eroare la copierea fișierului.');
    util_redirect(util_getWwwRoot() . 'preferinte');
}
chmod($destFileName, 0666);
SmartyWrap::addCss('jcrop');
SmartyWrap::addJs('jcrop');
SmartyWrap::assign('page_title', "Editarea pozei de profil");
SmartyWrap::assign('rawFileName', "{$user->id}_raw.{$ext}");
SmartyWrap::display('editare-avatar.ihtml');
Exemplo n.º 25
0
function _log_namedLog($name, $s)
{
    $f = fopen(util_getRootPath() . "log/{$name}", "a");
    fwrite($f, date("Y-m-d H:i:s", time()) . " {$s}\n");
    fclose($f);
}
Exemplo n.º 26
0
            $doFullDump = false;
        } else {
            OS::errorAndExit("Unknown flag: {$arg}");
        }
    }
}
log_scriptLog('Running dumpDatabase.php with argument ' . ($doFullDump ? 'full' : 'public'));
$dbName = $parts['database'];
$tablesToIgnore = '';
foreach ($schemaOnly as $table) {
    $tablesToIgnore .= "--ignore-table={$dbName}.{$table} ";
}
if ($doFullDump) {
    $targetDir = util_getRootPath() . '/wwwbase/download/mirrorAccess/';
} else {
    $targetDir = util_getRootPath() . '/wwwbase/download/';
    $tablesToIgnore .= "--ignore-table={$dbName}.User --ignore-table={$dbName}.Definition --ignore-table={$dbName}.diverta_Book --ignore-table={$dbName}.divertaIndex ";
}
OS::executeAndAssert("rm -f {$TMP_DIR}/{$FILENAME}");
OS::executeAndAssert("echo \"-- Copyright (C) 2004-{$currentYear} DEX online (http://dexonline.ro)\" > {$TMP_DIR}/{$FILENAME}");
OS::executeAndAssert("cat {$LICENSE} >> {$TMP_DIR}/{$FILENAME}");
$mysql = "{$COMMON_COMMAND} {$tablesToIgnore} >> {$TMP_DIR}/{$FILENAME}";
OS::executeAndAssert($mysql);
// Dump only the schema for some tables
$command = "{$COMMON_COMMAND} --no-data";
foreach ($schemaOnly as $table) {
    $command .= " {$table}";
}
$command .= " >> {$TMP_DIR}/{$FILENAME}";
OS::executeAndAssert($command);
if (!$doFullDump) {
Exemplo n.º 27
0
<?php

require_once __DIR__ . '/../phplib/util.php';
$SQL_FILE = Config::get('global.tempDir') . '/dex-database.sql';
$GZ_FILE = Config::get('global.tempDir') . '/dex-database.sql.gz';
$LICENSE = util_getRootPath() . '/tools/dumpDatabaseLicense.txt';
$parts = db_splitDsn();
$COMMON_COMMAND = sprintf("mysqldump -h %s -u %s --password='******' %s ", $parts['host'], $parts['user'], $parts['password'], $parts['database']);
$schemaOnly = array('RecentLink', 'Cookie', 'UserWordBookmark', 'DefinitionSimple', 'history_Comment', 'history_Definition');
$currentYear = date("Y");
// Full/Public dump: the public dump omits the user table, which contains emails and md5-ed passwords.
$doFullDump = false;
for ($i = 1; $i < count($argv); $i++) {
    $arg = $argv[$i];
    if ($arg == "--full") {
        $doFullDump = true;
    } else {
        if ($arg == '--public') {
            $doFullDump = false;
        } else {
            OS::errorAndExit("Unknown flag: {$arg}");
        }
    }
}
log_scriptLog('Running dumpDatabase.php with argument ' . ($doFullDump ? 'full' : 'public'));
$dbName = $parts['database'];
$tablesToIgnore = '';
foreach ($schemaOnly as $table) {
    $tablesToIgnore .= "--ignore-table={$dbName}.{$table} ";
}
if ($doFullDump) {
Exemplo n.º 28
0
 /**
  * Creates and caches a map($from, pair($to, $ambiguous)) for this sourceId.
  * That is, for each sourceId and abbreviated text, we store the expanded text and whether the abbreviation is ambiguous.
  * An ambiguous abbreviation such as "top" or "gen" also has a meaning as an inflected form.
  * Ambiguous abbreviations should be expanded carefully, or with human approval.
  */
 private static function loadAbbreviations($sourceId)
 {
     if (!array_key_exists($sourceId, self::$ABBREVS)) {
         self::loadAbbreviationsIndex();
         $result = array();
         if (array_key_exists($sourceId, self::$ABBREV_INDEX)) {
             $list = array();
             foreach (self::$ABBREV_INDEX[$sourceId] as $section) {
                 $raw = parse_ini_file(util_getRootPath() . "docs/abbrev/{$section}.conf", true);
                 // If an abbreviation is defined in several sections, use the one that's defined later
                 $list = array_merge($list, $raw[$section]);
             }
             foreach ($list as $from => $to) {
                 $ambiguous = $from[0] == '*';
                 if ($ambiguous) {
                     $from = substr($from, 1);
                 }
                 $numWords = 1 + substr_count($from, ' ');
                 $regexp = str_replace(array('.', ' '), array("\\.", ' *'), $from);
                 $pattern = "\\W({$regexp})(\\W|\$)";
                 $hasCaps = $from !== mb_strtolower($from);
                 $result[$from] = array('to' => $to, 'ambiguous' => $ambiguous, 'regexp' => $pattern, 'numWords' => $numWords, 'hasCaps' => $hasCaps);
             }
             // Sort the list by number of words, then by ambiguous
             uasort($result, 'self::abbrevCmp');
         }
         self::$ABBREVS[$sourceId] = $result;
     }
     return self::$ABBREVS[$sourceId];
 }