Ejemplo n.º 1
0
 public function test1()
 {
     $ini_file = '/tmp/test.ini';
     $x = new ini($ini_file);
     $x->set('Category', 'spex', 17);
     $val = $x->get('Category', 'spex');
     unlink($ini_file);
     $this->assertEquals($val, 17);
 }
Ejemplo n.º 2
0
function sendMail()
{
    $cfg = new ini();
    $cfg->setFileName('./include/config/account.ini');
    $cfg->load();
    $user_mail = $cfg->getElementByValue('user', 'email');
    $mail = new PHPMailer();
    $mail->IsSMTP();
    //$mail->SMTPDebug= 2;
    //konfiguracja serwera
    $mail->PluginDir = "phpmailer/";
    $mail->Mailer = "smtp";
    $mail->Host = $cfg->getElementByValue('server-config', 'Host');
    $mail->SMTPSecure = $cfg->getElementByValue('server-config', 'SMTPSecure');
    $mail->Port = $cfg->getElementByValue('server-config', 'Port');
    //
    $mail->SMTPKeepAlive = true;
    $mail->SMTPAuth = true;
    $mail->Username = $cfg->getElementByValue('server-config', 'Login');
    $mail->Password = $cfg->getElementByValue('server-config', 'Passwort');
    //koniec połączenia
    //baza danych
    $mydb = new DB();
    $qwery = "SELECT `id`, `email` FROM mail_data Where sended=" . $checkbox_value;
    $request = mysql_query($qwery);
    if ($request === false) {
        die('Nie można było odebrać danych do bazy' . ' z powodu blendu:' . mysql_error());
    }
    if (mysql_num_rows() == 0) {
        echo 'Brak danych w bazie';
        exit(1);
    }
    while ($row = mysql_fetch_assoc($request)) {
        $id = $row['id'];
        $address = $row['email'];
        $mail->SetLanguage("pl", "phpmailer/language/");
        $mail->CharSet = "UTF-8";
        $mail->ContentType = "text/html";
        $mail->isHTML(true);
        $mail->From = user_mail;
        $mail->FromName = "Kamil z webbooster";
        $mail->Subject = "Tytuł wiadomości";
        $mail->Body = '
To jest nowa testowa treść, z prawidłowo interpretowanymi polskimi znaczkami, a to jest <b>pogrubione</b>, a to jest <a href="http://www.example.com">link</a><br/>
<div>trolololo</div>
';
        $mail->AddAddress($address);
        if ($mail->Send()) {
            return true;
        } else {
            throw new Exception('"E-mail nie mógł zostać wysłany, przyczyna :".$mail->ErrorInfo', 5);
        }
    }
    //
    $mail->SmtpClose();
    //zamykamy połączeie
}
Ejemplo n.º 3
0
 private function openDatabase($channel)
 {
     $channel = strtolower($channel);
     if (isset($this->quotesCache[$channel])) {
         return $this->quotesCache[$channel];
     } else {
         $cqDB = new ini("modules/quotes_ini/quotes_database/" . $channel . ".txt");
         if ($cqDB->getError()) {
             return false;
         }
         $this->quotesCache[$channel] = $cqDB;
         return $cqDB;
     }
 }
Ejemplo n.º 4
0
	function _get_recursive($key, $filename, $locale_id)
	{
		$path = $this->_get_path($filename, $locale_id);
		$md5_path = md5($path);		
		if(isset($this->_cache[$md5_path][$key]))
			return $this->_cache[$md5_path][$key];
		
		if(isset($this->_ini_objects[$md5_path]))
			$ini =& $this->_ini_objects[$md5_path];
		else
		{	  	
			$ini =& ini :: instance($path);			
			$this->_ini_objects[$md5_path] =& $ini;					
		}
		
		if(!($value = $ini->get_option($key, 'constants')))
	  {
		  if($ini->has_option('filename', 'extends'))
		  {
		  	$extend_filename = $ini->get_option('filename', 'extends');
		  	$value = $this->_get_recursive($key, $extend_filename, $locale_id);
		  }
		}
		
		if($value)
			$this->_cache[$md5_path][$key] = $value;

		return $value;
	}
Ejemplo n.º 5
0
 /**
  * Запись/обновление кеша
  * 
  * @access private
  * @param string $name уникальное имя сервера
  * @param array $params
  * @return boolean
  */
 public function set_cache($name, $params)
 {
     $cache = new ini($this->sysf . 'cache.ini');
     if (empty($cache->file)) {
         return false;
     }
     $cache->content[$name] = $params;
     $cache->write();
 }
Ejemplo n.º 6
0
 static function add($script)
 {
     if (!in_array($script, self::$includes)) {
         if (self::isLink($script)) {
         } else {
             ini::append('replace', 'css', $script);
         }
         self::$includes[] = $script;
     }
 }
Ejemplo n.º 7
0
 function rollApps()
 {
     $tmp = $apps = array();
     $file = SYS_ROOT . 'conf/global/apps.ini';
     $tmp = ini::parse($file);
     foreach ($tmp as $k => $v) {
         $v['app'] = $k;
         s::roll('apps', $v);
     }
 }
Ejemplo n.º 8
0
 function test_group()
 {
     $ini =& ini::instance('test.ini', TEST_CASES_DIR, false);
     debug_mock::expect_write_notice('unknown block', array('ini' => $ini->file_name(), 'block_name' => 'no_group'));
     $this->assertNull($ini->group('no_group'));
     $this->assertNotNull($ini->group('default'));
     $group = $ini->group('test2');
     $this->assertTrue(is_array($group) && sizeof($group) == 3);
     $this->assertEqual($group['test1'], 2);
     $this->assertEqual($group['test2'], 3);
     $this->assertEqual($group['test3'], "  #It's just a \"test\"!#  ");
 }
Ejemplo n.º 9
0
 function load($app)
 {
     $file = APPS . $app . '/settings.ini';
     if (defined('ADMIN_SITE_ID')) {
         $site_id = ADMIN_SITE_ID;
     } else {
         $site_id = SITE_ID;
     }
     self::$settings[$app] = ini::parse($file, $site_id);
     if (!self::$settings[$app]) {
         self::$settings[$app] = ini::parse($file, 1);
     }
 }
Ejemplo n.º 10
0
function &get_ini($file_name, $use_cache = null)
{
    if (!($path = get_ini_real_path($file_name))) {
        error('ini file not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $file_name));
    }
    if (isset($GLOBALS['testing_ini'][$file_name])) {
        $use_cache = false;
    }
    if (!($ini =& ini::instance($path, $use_cache))) {
        error('couldnt retrieve ini instance', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $path));
    }
    return $ini;
}
Ejemplo n.º 11
0
/**
 * @return unknown
 * @param $filename unknown
 * @param $use_cache unknown
 * @desc Enter description here...
 */
function &get_ini($filename, $use_cache = null)
{
    if (file_exists(PROJECT_DIR . 'core/settings/' . $filename)) {
        $root_dir = PROJECT_DIR . 'core/settings/';
    } elseif (file_exists(LIMB_DIR . 'core/settings/' . $filename)) {
        $root_dir = LIMB_DIR . 'core/settings/';
    } else {
        error('ini file not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $filename));
    }
    if (!($ini =& ini::instance($filename, $root_dir, $use_cache))) {
        error('couldnt retrieve ini instance', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $filename));
    }
    return $ini;
}
Ejemplo n.º 12
0
 public function getSlaps()
 {
      $slaps = new ini( "./modules/slap/slaps.ini" );
      
      if( $slaps->getError( ) )
      {
           $this->ircClass->notice( $nick, "Error while getting slaps." );
           return;
      }
      
      $sections = $slaps->getSections( );
      
      foreach( $sections as $slap )
      {
           $msg = $slaps->getIniVal( $slap, "msg" );
           $status = $slaps->getIniVal( $slap, "status" );
           
           $argArray = array('msg'	=> $msg,
                     'status' => $status);
      }
      
      $this->slaps = $slaps;
 }
Ejemplo n.º 13
0
 public function handle_onjoin($line, $args)
 {
     $nick = $line['fromNick'];
     $hostmask = $line['fromIdent'] . "@" . $line['fromHost'];
     $channel = $line['text'];
     if ($channel == $this->ircClass->getNick()) {
         return;
     }
     if ($nick == $this->ircClass->getNick()) {
         return;
     }
     $ini = new ini("modules/chopper_ini/hosts.ini");
     $_ops = $ini->getVars($channel);
     foreach ($_ops as $_hm => $_mode) {
         $_mode = trim($_mode);
         //$this->ircClass->privMsg($channel,"Does {$hostmask} match {$_hm}?");
         if ($this->ircClass->hostMasksMatch($hostmask, $_hm)) {
             //$this->ircClass->privMsg($channel,"Yep. Granting +{$_mode} to {$nick} in {$channel}.");
             $this->ircClass->changeMode($channel, "+", $_mode, $nick);
             break;
         }
     }
 }
Ejemplo n.º 14
0
 static function add($script, $where = 'head')
 {
     // if not already added..
     if (!in_array($script, self::$isAdded)) {
         // force adding it to the html head
         if ($where != 'head') {
             ini::append('replace', $where, self::draw($script));
         } else {
             self::$toGlom[] = $script;
         }
         // add it to "already added" list
         self::$isAdded[] = $script;
     }
 }
Ejemplo n.º 15
0
 public function init()
 {
     unset($this->badWords);
     $this->badWords = array();
     $badWords = new ini("modules/bad_words/bad_words.ini");
     if ($badWords->getError()) {
         return;
     }
     $channels = $badWords->getSections();
     if ($channels === false) {
         return;
     }
     foreach ($channels as $channel) {
         $channel = irc::myStrToLower($channel);
         $bw = $badWords->getSection($channel);
         if ($bw == false || !is_array($bw)) {
             continue;
         }
         foreach ($bw as $badword => $blah) {
             $this->badWords[$channel][$badword] = true;
         }
     }
 }
Ejemplo n.º 16
0
 public function __construct($keyStr)
 {
     $iniParams = ini::read(os::path('lib', 'modules', 'captcha', 'config.ini'));
     foreach ($iniParams as $k => $v) {
         $this->{$k} = $v;
     }
     // CAPTCHA image colors (RGB, 0-255)
     // $this->foreground_color = array(0, 0, 0);
     // $this->background_color = array(220, 230, 255);
     $this->foreground_color = array(mt_rand(0, 100), mt_rand(0, 100), mt_rand(0, 100));
     $this->background_color = array(mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
     // Что надо нарисовать
     $this->keyString = $keyStr;
 }
Ejemplo n.º 17
0
 function installApp()
 {
     if ($_FILES['app']['name']) {
         if ($_FILES['app']['type'] != 'application/zip') {
             s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>');
         } else {
             $arr = explode('.', $_FILES['app']['name']);
             if (count($arr) < 5) {
                 s::set('ERRORS', '<ul><li>Неверный формат архива приложения.</li></ul>');
             } else {
                 define('INSTALL_APP', $arr[0]);
                 define('INSTALL_APP_VERSION', $arr[1] . '.' . $arr[2] . '.' . $arr[3]);
                 files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/');
                 $path = SYS_ROOT . 'var/tmp/apps/';
                 zipfile::read($_FILES['app']['tmp_name']);
                 zipfile::extract($path);
                 $install_file = $path . 'install.php';
                 if (!file_exists($install_file)) {
                     s::set('ERRORS', '<ul><li>Не найден инсталляционый файл приложения.</li></ul>');
                 } else {
                     include $install_file;
                     // copy lang files
                     $tmp_lang_dir = SYS_ROOT . 'var/tmp/apps/langs/';
                     $lang_dir = SYS_ROOT . 'langs/admin/';
                     if (file_exists($lang_dir)) {
                         $array = files::getFiles($tmp_lang_dir);
                         foreach ($array as $v) {
                             if (!file_exists($lang_dir . $v)) {
                                 copy($tmp_lang_dir . $v, $lang_dir . $v);
                             } else {
                                 $lang = ini::parse($tmp_lang_dir . $v);
                                 ini::parse($lang_dir . $v);
                                 ini::add($lang);
                                 ini::write();
                             }
                         }
                     }
                     // copy app files
                     $dir = SYS_ROOT . 'var/tmp/apps/' . INSTALL_APP . '/';
                     $new_dir = SYS_ROOT . 'apps/' . INSTALL_APP . '/';
                     files::copyDir($dir, $new_dir);
                     // clear tmp
                     files::fullRemoveDir(SYS_ROOT . 'var/tmp/apps/');
                     headers::app('manage');
                 }
             }
         }
     }
 }
Ejemplo n.º 18
0
Archivo: lang.php Proyecto: rigidus/ea
 function load($lang, $site_id = false)
 {
     if ($site_id) {
         $file = SYS_ROOT . 'langs/web/' . $site_id . '/' . $lang . '.ini';
     } else {
         $file = SYS_ROOT . 'langs/admin/' . $lang . '.ini';
     }
     $array = ini::parse($file);
     if ($array) {
         foreach ($array as $v) {
             self::$lang = $v;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 19
0
function &get_ini($file_name, $use_cache = null)
{
    if (isset($GLOBALS['testing_ini'][$file_name])) {
        $dir = VAR_DIR;
        $use_cache = false;
    } elseif (file_exists(PROJECT_DIR . 'core/settings/' . $file_name)) {
        $dir = PROJECT_DIR . 'core/settings/';
    } elseif (file_exists(LIMB_DIR . 'core/settings/' . $file_name)) {
        $dir = LIMB_DIR . 'core/settings/';
    } else {
        error('ini file not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $file_name));
    }
    if (!($ini =& ini::instance($dir . $file_name, $use_cache))) {
        error('couldnt retrieve ini instance', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('file' => $dir . $file_name));
    }
    return $ini;
}
Ejemplo n.º 20
0
 function _do_get($key, $filename, $locale_id)
 {
     $path = $this->_get_path($filename, $locale_id);
     if (isset($this->_cache[$path][$key])) {
         return $this->_cache[$path][$key];
     }
     if (isset($this->_ini_objects[$path])) {
         $ini =& $this->_ini_objects[$path];
     } else {
         $ini =& ini::instance($path);
         $this->_ini_objects[$path] =& $ini;
     }
     if ($value = $ini->get_option($key, 'constants')) {
         $this->_cache[$path][$key] = $value;
     }
     return $value;
 }
Ejemplo n.º 21
0
 function loadEngine()
 {
     if (self::$sections[0] == string::clearBoth(SYS_DIR)) {
         self::$engine = 'admin';
     } elseif (SYS_DIR == '/') {
         self::$engine = 'admin';
     }
     if (!self::$engine) {
         // load boot.ini
         $ini = ini::parse(SYS_ROOT . 'conf/global/boot.ini');
         if ($ini) {
             self::$engine = arrays::returnValue($ini, self::$sections[0]);
         }
     }
     if (!self::$engine) {
         self::$engine = 'web';
     }
     define('ENGINE', self::$engine);
 }
Ejemplo n.º 22
0
 static function getHeader($includes, $masterFname, $hashFname)
 {
     // check hash
     $hash = self::getHash($includes);
     $previousHash = trim(file_get_contents(realpath($hashFname)));
     if (self::DEBUG) {
         funx::debug("Exists {$masterFname}? " . intval(file_exists($masterFname)) . " New Hash: {$hash}, Old Hash: {$previousHash}");
     }
     if (!file_exists($masterFname) or $hash != $previousHash) {
         self::saveHeader($hash, $includes, $masterFname, $hashFname);
     }
     // return header information
     if (strstr($masterFname, 'js')) {
         ini::append('replace', 'head', '<script type="text/javascript" src="/' . $masterFname . '"></script>' . "\n");
     } elseif (strstr($masterFname, 'css')) {
         ini::append('replace', 'head', '<link rel="stylesheet" href="/' . $masterFname . '" type="text/css">' . "\n");
     }
     //'<link rel="stylesheet" href="/'.$masterFname.'" type="text/css" media="Screen">'."\n");
     return $ret;
 }
Ejemplo n.º 23
0
 private function loadAds()
 {
     $ads = new ini("./modules/default/ads.ini");
     if ($ads->getError()) {
         return;
     }
     $sections = $ads->getSections();
     foreach ($sections as $ad) {
         $int = $ads->getIniVal($ad, "int");
         $channel = $ads->getIniVal($ad, "chan");
         $msg = $ads->getIniVal($ad, "msg");
         $argArray = array('msg' => $msg, 'channel' => $channel);
         $this->timerClass->addTimer($ad, $this, "misc_adTimer", $argArray, $int);
     }
     $this->ads = $ads;
 }
Ejemplo n.º 24
0
 function get($name, $value = false, $lang = false)
 {
     if (!self::$biblio) {
         if (!$lang) {
             $lang = LANG_INDEX;
         }
         self::$biblio = ini::parse(SYS_ROOT . 'data/' . $lang . '/biblio.ini');
     }
     if ($value !== false) {
         if (isset(self::$biblio[$name][$value])) {
             return self::$biblio[$name][$value];
         } else {
             return false;
         }
     } else {
         if (isset(self::$biblio[$name])) {
             return self::$biblio[$name];
         } else {
             return false;
         }
     }
 }
Ejemplo n.º 25
0
 function _get_recursive($key, $filename, $language_id)
 {
     $path = $this->_get_path($filename, $language_id);
     if (isset($this->_cache[$path][$key])) {
         return $this->_cache[$path][$key];
     }
     if (isset($this->_ini_objects[$path])) {
         $ini =& $this->_ini_objects[$path];
     } else {
         $ini =& ini::instance($path);
         $this->_ini_objects[$path] =& $ini;
     }
     if (!($value = $ini->variable('constants', $key))) {
         if ($ini->has_variable('extends', 'filename')) {
             $extend_filename = $ini->variable('extends', 'filename');
             $value = $this->_get_recursive($key, $extend_filename, $language_id);
         }
     }
     if ($value) {
         $this->_cache[$path][$key] = $value;
     }
     return $value;
 }
Ejemplo n.º 26
0
 /**
  * Вытаскивает таблицу маршрутизации из .ini файла, если не находит — возвращает пустой массив.
  */
 private function load_ini(Context $ctx)
 {
     $raw = array();
     foreach ($ctx->config->get('routes', array()) as $k => $v) {
         $raw['GET/' . $k] = $v;
     }
     foreach (os::find('lib', 'modules', '*', 'route.ini') as $iniFile) {
         foreach (ini::read($iniFile) as $k => $v) {
             if (is_array($v)) {
                 $raw[$k] = $v;
                 $raw[$k]['static'] = true;
             } elseif ('dynamic' == $k and false !== strpos($v, '::')) {
                 list($class, $method) = explode('::', $v);
                 if (method_exists($class, $method)) {
                     try {
                         if (is_array($tmp = call_user_func(array($class, $method), $ctx))) {
                             foreach ($tmp as $k => $v) {
                                 $raw[$k] = $v;
                             }
                         }
                     } catch (Exception $e) {
                         Logger::log(get_class($e) . ' in ' . $v . '()');
                     }
                 }
             }
         }
     }
     // Опрос динамических маршрутов.
     foreach ((array) $ctx->registry->poll('ru.molinos.cms.route.poll') as $tmp) {
         if (!empty($tmp['result'])) {
             foreach ($tmp['result'] as $k => $v) {
                 $raw[$k] = $v;
             }
         }
     }
     return $raw;
 }
Ejemplo n.º 27
0
 function &_get_ini($with_variation = false, $directory = '')
 {
     $type = $with_variation ? 'variation' : 'default';
     $country = $this->get_country_code();
     $country_variation = $this->get_country_variation();
     $language = $this->get_language_code();
     $locale = $language;
     if ($country !== '') {
         $locale .= '-' . $country;
     }
     if ($with_variation) {
         if ($country_variation !== '') {
             $locale .= '@' . $country_variation;
         }
     }
     $file_name = $locale . '.ini';
     if (file_exists($directory . '/' . $file_name)) {
         return ini::instance($directory . '/' . $file_name);
     } else {
         return null;
     }
 }
Ejemplo n.º 28
0
 static function trim($ra, $allowedKeys)
 {
     $ret = array();
     if (is_array($ra)) {
         // copy over allowed keys
         foreach ($allowedKeys as $k) {
             $ret[$k] = $ra[$k];
         }
         // track missing keys
         $missing = '';
         $ak = array_flip($allowedKeys);
         foreach ($ra as $k => $i) {
             if (!isset($ak[$k])) {
                 $missing .= (strlen($missing) ? ', ' : '') . "{$k}";
             }
         }
         if (strlen($missing)) {
             $missing = "DB Warning: These fields aren't allowed in one of the tables: {$missing}\n";
             funx::debug($missing);
             email::send(ini::get('email-address'), 'DB Squeak', $missing);
         }
     }
     return $ret;
 }
Ejemplo n.º 29
0
<?php

ini_set('memory_limit', '256M');
if (!defined('DIR_KIT')) {
    define('DIR_KIT', dirname(__FILE__) . '/');
}
append_include_path(DIR_KIT);
append_include_path(DIR_KIT . 'ext/');
umask(07);
ini_set('display_errors', '0');
error_reporting(E_ERROR | E_PARSE);
ini::set('debug', false);
ini::set('dir-sessions', '/tmp/');
function __autoload($class)
{
    $dirs = array(DIR_KIT, DIR_KIT . 'obj/', 'php/obj/');
    foreach ($dirs as $dir) {
        $f = $dir . $class . '.php';
        if (is_file($f)) {
            require_once $f;
            break;
        }
    }
}
function append_include_path($dir)
{
    $t = 'include_path';
    $d = ini_get($t);
    if (!strstr($d, $dir)) {
        ini_set($t, $d . ':' . $dir);
    }
Ejemplo n.º 30
0
<?php

error_reporting(E_ALL);
foreach (glob("cgi-bin/*.php") as $filename) {
    include_once $filename;
}
$config = ini::SettingArray('default.ini');
if (isset($_GET['ajax']) || isset($_POST['ajax'])) {
    if (isset($config['language'])) {
        include_once 'language/' . $config['language'] . '.php';
    }
    if (file_exists('site/ajax/' . $_GET['ajax'] . '.php')) {
        include_once 'site/ajax/' . $_GET['ajax'] . '.php';
    } else {
        echo json_encode(array('error' => 'Ajax not Found.'));
    }
} elseif (isset($_GET['html']) || isset($_POST['html'])) {
    if (file_exists('site/html/' . $_GET['html'] . '.html')) {
        include_once 'site/html/' . $_GET['html'] . '.html';
    } else {
        echo '<div id="exception">' . _SITE_NONE_MODULE . '</div>';
    }
} elseif (isset($_GET['doc']) || isset($_POST['doc'])) {
    include_once 'config.php';
    if (isset($config['language'])) {
        include_once 'language/' . $config['language'] . '.php';
    }
    ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>