Esempio n. 1
0
 /**
  * Добавление нового блока в буфер
  *
  * @param string $path
  * @param int|null $position
  * @return boolean
  */
 public function add($path, $position = null)
 {
     if (array_key_exists($path, $this->blocks)) {
         return false;
     }
     $parse_path = explode(".", $path);
     $diff = array_diff($parse_path, array(''));
     if (count($parse_path) - count($diff) != 0) {
         return false;
     }
     foreach ($parse_path as $value) {
         if (mb_substr($value, 0, 1) == '_') {
             return false;
         }
     }
     $file_path = ROOT_PATH . '/app/blocks/' . implode("/", $parse_path) . '.php';
     if (is_file($file_path)) {
         require_once $file_path;
         $class = mb_ucwords(implode("_", $parse_path)) . "_Block";
         if (!is_null($position)) {
             $this->positions[$path] = $position;
         }
         $this->blocks[$path] = new $class();
         return true;
     } else {
         return false;
     }
 }
 function test_mb_ucwords()
 {
     $this->assertEquals('Åäö', mb_ucwords('åäö'));
     $this->assertEquals('Åäö Öäå', mb_ucwords('åäö öäå'));
     $this->assertEquals(ucwords('H.G. Wells'), mb_ucwords('H.G. Wells'));
     $this->assertEquals(ucwords('h.g. wells'), mb_ucwords('h.g. wells'));
     $this->assertEquals(ucwords('H.G. WELLS'), mb_ucwords('H.G. WELLS'));
 }
Esempio n. 3
0
 protected function modify_element($element)
 {
     if ($this->mb) {
         return mb_ucwords($element);
     } else {
         return ucwords($element);
     }
 }
Esempio n. 4
0
 protected function modify_paramvalue($from_value)
 {
     if ($this->mb) {
         return mb_ucwords($from_value);
     } else {
         return ucwords($from_value);
     }
 }
Esempio n. 5
0
 function wikify_album()
 {
     global $wgRequest, $wgOut;
     $this->artist = trim(mb_ucwords($wgRequest->getVal('artist')));
     $this->album = trim($wgRequest->getVal('album'));
     $this->year = trim($wgRequest->getVal('year'));
     $discog = trim($wgRequest->getVal('discog'));
     $method = $wgRequest->getVal('method', null);
     if ($method) {
         if (in_array($method, $this->getMethods())) {
             if ($wgRequest->getVal('cover')) {
                 $wikiText = wfMsgNoTrans("wft-album-header", $this->artist, mb_ucwords($this->album), $this->album, $this->year) . "\n";
             } else {
                 $wikiText = wfMsgNoTrans("wft-album-header-nocover", $this->artist, mb_ucwords($this->album), $this->album, $this->year) . "\n";
             }
             $wikiText .= $this->{"format_" . $method}($discog);
             $wikiText .= wfMsgNoTrans("wft-album-footer", $this->artist, $this->album, $this->year) . "\n\n";
             $wgOut->addHTML("<textarea rows='15' cols='100'>{$wikiText}</textarea>");
         } else {
             $this->displayError(wfMsg("wft-error-unknownmethod", $method));
         }
     }
 }
Esempio n. 6
0
function neworder($core, $data, $file = false)
{
    $sid = (int) $data['site'];
    $spc = (int) $data['from'];
    $fid = (int) $data['flow'];
    $oid = (int) $data['offer'];
    $tgt = (int) $data['target'];
    $iptext = $data['ip'];
    $ip = ip2int($iptext);
    $name = $data['name'] ? $core->text->line($data['name']) : 'Без Воображения';
    $ind = (int) $data['index'];
    $area = $core->text->line($data['area']);
    $city = $core->text->line($data['city']);
    $street = $core->text->line($data['street']);
    $addr = $core->text->line($data['addr']);
    if ($addr == 'Уточнить по телефону') {
        $addr = '';
    }
    if ($addr == 'Адрес узнать по телефону') {
        $addr = '';
    }
    $comm = $core->text->line($data['comm']);
    $phone = (string) trim(preg_replace('#[^0-9]+#i', '', $data['phone']));
    $pres = $data['present'] > 0 ? (int) $data['present'] : 0;
    $cnt = $data['count'] > 0 ? (int) $data['count'] : 1;
    $more = $data['more'] > 0 ? (int) $data['more'] : 0;
    $dsc = $data['discount'] > 0 && $data['discount'] < 100 ? (int) $data['discount'] : 0;
    $cntr = $data['country'] ? strtolower(substr($core->text->link($data['country']), 0, 2)) : false;
    $dlvr = $data['delivery'] > 0 ? (int) $data['delivery'] : 1;
    $exti = (int) $data['exti'];
    $extu = $exti ? preg_replace('#[^0-9A-Za-z\\_\\-\\.]+#i', '', $data['extu']) : 0;
    $exts = $exti ? preg_replace('#[^0-9A-Za-z\\_\\-\\.]+#i', '', $data['exts']) : 0;
    $utmi = (int) $data['utmi'];
    $utmc = (int) $data['utmc'];
    $utms = (int) $data['utms'];
    $items = is_array($data['items']) ? serialize($data['items']) : '';
    $meta = $data['meta'] ? addslashes(serialize(unserialize(stripslashes($data['meta'])))) : '';
    $addr1 = $core->text->line($data['addr1']);
    $addr2 = $core->text->line($data['addr2']);
    $addr3 = $core->text->line($data['addr3']);
    if ($addr1) {
        $addr .= ', ' . $addr1;
    }
    if ($addr2) {
        $addr .= ', ' . $addr2;
    }
    if ($addr3) {
        $addr .= ', ' . $addr3;
    }
    if (!($oid && ($offer = $core->wmsale->get('offer', $oid)))) {
        return 'offer';
    }
    $site = $sid ? $core->wmsale->get('site', $sid) : false;
    $flow = $fid ? $core->wmsale->get('flow', $fid) : false;
    $ext = $exti ? $core->wmsale->get('ext', $exti) : false;
    $status = $data['status'] ? (int) $data['status'] : 1;
    if ($status == 1) {
        $status = $offer['offer_payment'] == 1 ? 0 : 1;
    }
    $userid = $flow ? $flow['user_id'] : ($ext ? $ext['user_id'] : false);
    if ($userid && $core->user->get($userid, 'user_ban')) {
        return 'security';
    }
    if ($phone) {
        // Name and address
        $name = mb_ucwords($name);
        if (!$ind) {
            if (preg_match('#^([0-9]+)#i', $addr, $ind)) {
                $ind = $ind[1];
                $ad = preg_split('#[\\s,\\.]+#i', $addr, 2);
                $addr = trim($ad[1], ' ,');
            } else {
                $ind = '';
            }
        }
        // Price, presents and discounts
        if ($data['items']) {
            $price = $cnt = 0;
            $vars = $core->wmsale->get('vars', $offer['offer_id']);
            foreach ($vars as &$v) {
                if ($data['items'][$v['var_id']]) {
                    $cnt += $data['items'][$v['var_id']];
                    $price += $data['items'][$v['var_id']] * $v['var_price'];
                }
            }
            unset($v, $vars);
        } else {
            $price = $cnt * $offer['offer_price'];
        }
        if ($dsc) {
            $price = ceil($price * ((100 - $dsc) / 100));
        }
        if ($pres) {
            $price += $core->lang['presentp'][$pres];
        }
        if ($more) {
            $price += $more;
        }
        if ($offer['offer_delivery']) {
            $price += $core->lang['deliverp'][$dlvr];
        } else {
            $dlvr = 0;
        }
        // GeoIP data
        $geoipdata = geoip($core, $iptext);
        if ($geoipdata) {
            $geoip = array('geoip_country' => $geoipdata['country'], 'geoip_city' => $geoipdata['city'], 'geoip_region' => $geoipdata['region'], 'geoip_district' => $geoipdata['district'], 'geoip_lat' => $geoipdata['lat'], 'geoip_lng' => $geoipdata['lng']);
            if (!$cntr) {
                $cntr = $geoip['geoip_country'];
            }
            if (!$addr && !$city) {
                $city = $geoip['geoip_city'];
            }
            if (!$addr && !$area) {
                $area = $geoip['geoip_region'];
            }
        } else {
            $geoip = false;
        }
        // Check IP and phone
        if ($phone[0] == '9' && strlen($phone) == 10) {
            $phone = '7' . $phone;
        }
        if (substr($phone, 0, 2) == '89') {
            $phone = '79' . substr($phone, 2);
        }
        if (substr($phone, 0, 2) == '99') {
            $phone = '79' . substr($phone, 2);
        }
        $pok = substr($phone, 0, 2) == '79' ? 1 : 0;
        // Check for bans
        $phs = $core->db->field("SELECT `status` FROM " . DB_BAN_PH . " WHERE `phone` = '{$phone}' LIMIT 1");
        $ips = $core->db->field("SELECT `status` FROM " . DB_BAN_IP . " WHERE `ip` = '{$ip}' LIMIT 1");
        if ($phs || $ips) {
            return 'ban';
        }
        // Guess gender automatically
        $nc = new NCLNameCaseRu();
        $gender = $nc->genderDetect($name) != NCL::$MAN ? 2 : 1;
        unset($nc);
        // Script based company guess
        $comp = 0;
        if ($offer['offer_script']) {
            $scr = explode("\n", $offer['offer_script']);
            foreach ($scr as $sc) {
                // Prepare script line to process
                $sc = trim($sc);
                if (!$sc) {
                    continue;
                }
                // Get company for the script line
                if (preg_match('/#([0-9]+)/si', $sc, $ms)) {
                    $cms = $ms[1];
                } else {
                    continue;
                }
                // Get type and ID to match
                if (preg_match('#([a-z]+)\\:([0-9]+)#si', $sc, $ms)) {
                    $iid = $ms[2];
                    $iit = $ms[1];
                    if (!($iid && $iit)) {
                        continue;
                    }
                } else {
                    continue;
                }
                // Match if it matches
                switch ($iit) {
                    case 'user':
                        if ($flow['user_id'] == $iid) {
                            $comp = $cms;
                        }
                        break;
                    case 'flow':
                        if ($fid == $iid) {
                            $comp = $cms;
                        }
                        break;
                    case 'site':
                        if ($sid == $iid) {
                            $comp = $cms;
                        }
                        break;
                    case 'space':
                        if ($spc == $iid) {
                            $comp = $cms;
                        }
                        break;
                    case 'ext':
                        if ($exti == $iid) {
                            $comp = $cms;
                        }
                        break;
                    case 'country':
                        if ($cntr == $iid) {
                            $comp = $cms;
                        }
                        break;
                }
                if ($comp) {
                    break;
                }
                // If script worked OK
            }
            unset($sc, $scr);
        }
        if (!$comp) {
            if ($offer['offer_mr'] && !$site['site_comp']) {
                $ct = $core->db->field("SELECT comp_id FROM " . DB_ORDER . " WHERE order_time > '" . (time() - 604800) . "' AND ( order_phone = '{$phone}' OR order_ip = '{$ip}' ) ORDER BY order_id DESC LIMIT 1");
                $mrt = unserialize($offer['offer_mrt']);
                if (!($ct && in_array($ct, $mrt))) {
                    if ($mrt && ($ct = wrand($mrt))) {
                        $comp = $ct;
                    } else {
                        $comp = $site['comp_id'];
                    }
                } else {
                    $comp = $ct;
                }
            } else {
                $comp = $site['comp_id'];
            }
        }
        $data = array('offer_id' => $oid, 'comp_id' => $comp, 'wm_id' => $userid, 'flow_id' => $fid, 'site_id' => $sid, 'space_id' => $spc, 'target_id' => $tgt, 'utm_id' => $utmi, 'utm_src' => $utms, 'utm_cn' => $utmc, 'ext_id' => $exti, 'ext_uid' => $extu, 'ext_src' => $exts, 'order_time' => time(), 'order_ip' => $ip, 'order_country' => $cntr, 'order_name' => $name, 'order_gender' => $gender, 'order_phone' => $phone, 'order_phone_ok' => $pok, 'order_index' => $ind, 'order_area' => $area, 'order_city' => $city, 'order_street' => $street, 'order_addr' => $addr, 'order_items' => $items, 'order_meta' => $meta, 'order_count' => $cnt, 'order_present' => $pres, 'order_discount' => $dsc, 'order_delivery' => $dlvr, 'order_more' => $more, 'order_price' => $price, 'order_comment' => $comm, 'order_status' => $status, 'order_webstat' => $status);
        if ($geoip) {
            $data += $geoip;
        }
        if ($core->db->add(DB_ORDER, $data)) {
            $id = $core->db->lastid();
            if ($file) {
                if (is_uploaded_file($file['tmp_name'])) {
                    $dot = strrpos($file['name'], '.');
                    $ext = strtolower(substr($file['name'], $dot + 1));
                    $name = $id . '-' . substr($core->text->link(substr($file['name'], 0, $dot)), 0, 90) . '.' . $ext;
                    $goodext = array('jpg', 'jpeg', 'gif', 'png', 'zip', 'rar', 'rar5', '7z', 'cdr', 'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx');
                    if (in_array($ext, $goodext)) {
                        move_uploaded_file($file['tmp_name'], sprintf(FILENAME, $name));
                        $core->db->edit(DB_ORDER, array('order_file' => $name), "order_id = '{$id}'");
                    }
                }
            }
            if ($exti && ($url = $core->wmsale->get('ext', $exti, 'url_new'))) {
                if (preg_match_all('#\\{eval:\\[(.*?)\\]\\}#si', $url, $ems)) {
                    foreach ($ems[0] as $k => $v) {
                        $url = str_replace($v, eval($ems[1][$k]), $url);
                    }
                }
                $url = str_replace('{id}', $id, $url);
                $url = str_replace('{uid}', $extu, $url);
                $url = str_replace('{src}', $exts, $url);
                $url = str_replace('{time}', time(), $url);
                $url = str_replace('{price}', $price, $url);
                $url = str_replace('{count}', $cnt, $url);
                foreach ($offer as $k => $v) {
                    $url = str_replace("{offer:{$k}}", $v, $url);
                }
                $odata = $offer['offer_pars'] ? unserialize($offer['offer_pars']) : false;
                if ($odata) {
                    foreach ($odata as $k => $v) {
                        $url = str_replace("{data:{$k}}", $v, $url);
                    }
                }
                curl($url);
            }
            // PostBack processing
            if ($userid && ($pbu = $core->wmsale->get('flow', $flw, 'flow_pbu'))) {
                $pbd = array('id' => $id, 'offer' => $oid, 'flow' => $flw, 'target' => $tgt, 'site' => $sid, 'space' => $spc, 'count' => $cnt, 'price' => $price, 'status' => ${$status});
                foreach ($pbd as $pbk => $pbv) {
                    $pbu = str_replace('{' . $pbk . '}', $pbv, $pbu);
                }
                curl($pbu, $pbd);
            }
            return (int) $id;
        } else {
            return 'db';
        }
    } else {
        return 'data';
    }
}
Esempio n. 7
0
<?php

function mb_ucwords($str)
{
    $str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
    return $str;
}
if (isset($_POST['search'])) {
    $search1 = mb_ucwords($_POST['search']);
    $search2 = $_POST['search'];
    echo $search;
} else {
    $search2 = '';
}
$link = mysqli_connect('localhost', 'admin', 'admin', 'test');
$config[] = '0';
$record = mysqli_query($link, "SELECT * FROM `drivers_config`");
while ($record1 = mysqli_fetch_assoc($record)) {
    $config[$record1['name']] = $record1;
}
function forsort($a, $b)
{
    if ($a['position'] > $b['position']) {
        return 1;
    } else {
        return -1;
    }
}
uasort($config, 'forsort');
echo '<div>';
echo '<table class="table fixed">';
Esempio n. 8
0
 /**
  * Capitalize the chain
  *
  * @param String $string Chain to be capitalize
  *
  * @return string
  */
 static function capitalize($string)
 {
     return mb_ucwords($string);
 }
Esempio n. 9
0
 function capitalizeWords($text)
 {
     /*$result = '';
       $space = true;
       for ( $i = 0; $i < strlen ( $text); $i++ ) {
       $car = strtolower ( $text[$i] );
       if ( strpos( "abcdefghijklmnopqrstuvwxyz1234567890", $car ) !== false ) {
       if ($space ) $car = strtoupper ( $car );
       $result .= $car;
       $space  = false;
       }
       else
       $space = true;
       }
       return $result;*/
     if (function_exists('mb_detect_encoding')) {
         if (strtoupper(mb_detect_encoding($text)) == 'UTF-8') {
             $text = utf8_encode($text);
         }
     }
     if (function_exists('mb_ucwords')) {
         return mb_ucwords($text);
     } else {
         return mb_convert_case($text, MB_CASE_TITLE, "UTF-8");
     }
 }
Esempio n. 10
0
        }
        $filter = $filter . ")";
    }
} else {
    $filter = '';
}
//print_r($all);
if (isset($_POST["dolg"])) {
    $dolg = "(`dolg1` <> 0 OR `dolg2` <> 0)";
} else {
    $dolg = '';
}
$link = mysqli_connect('localhost', 'admin', 'admin', 'test');
$search = "";
if (isset($_POST["search"])) {
    $search = $search . "WHERE (`" . $_POST["idcol"] . "` LIKE '%" . $_POST["search"] . "%' OR `" . $_POST["idcol"] . "` LIKE '%" . mb_ucwords($_POST["search"]) . "%')";
}
//echo substr_count($search, 'WHERE');
if (isset($_POST["filterC"])) {
    if (!in_array($_POST["idcol"], $_POST["filterC"])) {
        if ($filter != '') {
            if (!substr_count($search, 'WHERE')) {
                $search = $search . "WHERE " . $filter;
            } else {
                $search = $search . "AND " . $filter;
            }
        }
        if ($dolg != '') {
            if (!substr_count($search, 'WHERE')) {
                $search = $search . "WHERE " . $dolg;
            } else {
Esempio n. 11
0
 /**
  * Return the string with all the words in upper case.
  *
  * Delimiters are used to determine what is a word.
  *
  * @param string $delimiters
  *
  * @return Rope
  */
 public function upperWords($delimiters = " \t\r\n\f\v")
 {
     return static::of(mb_ucwords($this->contents, $delimiters, $this->encoding), $this->encoding);
 }
Esempio n. 12
0
 /**
  * Парсит путь к вызываемому классу и методу
  */
 protected static function parse($call)
 {
     if (mb_strpos($call, ':') !== false) {
         $parse_call = explode(':', $call);
         if (count($parse_call) > 2) {
             return false;
         }
         $diff = array_diff($parse_call, array(''));
         if (count($parse_call) - count($diff) != 0) {
             return false;
         }
         list($path, $method) = $parse_call;
     } else {
         list($path, $method) = array($call, null);
     }
     $parse_path = explode(".", $path);
     $diff = array_diff($parse_path, array(''));
     if (count($parse_path) - count($diff) != 0) {
         return false;
     }
     foreach ($parse_path as $value) {
         if (mb_substr($value, 0, 1) == '_') {
             return false;
         }
     }
     $class = mb_ucwords(implode("_", $parse_path)) . "_Cli";
     $path = ROOT_PATH . '/app/clis/' . implode("/", $parse_path) . '.php';
     return array($path, $class, $method);
 }
Esempio n. 13
0
<?php

function mb_ucwords($str)
{
    $str = mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
    return $str;
}
$link = mysqli_connect('localhost', 'admin', 'admin', 'test');
if (isset($_POST['name'])) {
    $POST = $_POST;
    $POST['name'] = mb_ucwords($POST['name']);
    $query1 = '';
    $query2 = '';
    $query3 = '';
    foreach ($POST as $key => $value) {
        if ($key == 'information') {
            $b = '';
        } else {
            $b = ', ';
        }
        $query1 = $query1 . "`" . $key . "`" . $b;
        $query2 = $query2 . "'" . $value . "'" . $b;
        $query3 = $query3 . "`" . $key . "`='" . $value . "'" . $b;
    }
    if ($POST['index'] != '') {
        $query = "UPDATE `drivers` SET " . $query3 . " WHERE `index`='" . $POST['index'] . "'";
    } else {
        $query = "INSERT INTO `drivers` (" . $query1 . ") VALUES (" . $query2 . ")";
    }
    echo '<br>' . $query;
    $res = mysqli_query($link, $query);
Esempio n. 14
0
 /**
  * Получение модели события
  *
  * @param string $path
  * @return object
  */
 public static function get($path)
 {
     if (array_key_exists($path, static::$models)) {
         return static::$models[$path];
     }
     $parse_path = explode(".", $path);
     $diff = array_diff($parse_path, array(''));
     if (count($parse_path) - count($diff) != 0) {
         return false;
     }
     foreach ($parse_path as $value) {
         if (mb_substr($value, 0, 1) == '_') {
             return false;
         }
     }
     $file_path = ROOT_PATH . '/app/events/' . implode("/", $parse_path) . '.php';
     if (is_file($file_path)) {
         require_once $file_path;
         $class = mb_ucwords(implode("_", $parse_path)) . "_Event";
         return static::$models[$path] = new $class();
     } else {
         return false;
     }
 }
Esempio n. 15
0
<?php

/**
 * Created by PhpStorm.
 * User: just
 * Date: 21.11.15
 * Time: 10:19
 */
/*
    * Задача 6:
    * Да се състави програма, чрез която се въвежда изречение с отделни думи.
    * Като резултат на екрана да се извежда същия текст, но всяка отделна
    * дума да започва с главна буква, а следващите я букви да са малки.
    * Пример: супер яката задача
    * Изход: Супер Яката Задача
*/
//Enter values
$text = readline('Enter your text');
//Body
if (!function_exists('mb_ucwords')) {
    function mb_ucwords($str)
    {
        return mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
    }
}
$text = mb_ucwords($text);
//Print
echo $text;