/**
  * Index site
  */
 public function index($task = false, $id = false)
 {
     if (($task == 'done' || $task == 'undone') && isint($id)) {
         $this->development_model->change_status($id, $task == 'done' ? true : false);
     } elseif ($task == 'delete' && isint($id)) {
         $this->development_model->delete_task($id);
     }
     $user = $this->auth->user();
     $data = array("user" => $user, "developer" => false, "devusers" => array(), "form" => array());
     if ($user) {
         $this->permissions->set_user($user->id);
     }
     $data['edit'] = $this->permissions->has_user_permission("developer_edit");
     $data['error'] = false;
     $this->_get_add_form($data['form']);
     if (isset($_POST['submit']) && $data['edit'] == true && in_array($_POST['type'], $this->_allowed_types)) {
         $postlen = strlen($_POST['add_entry']);
         if ($postlen > 512) {
             $data['form']['input']['value'] = $_POST['add_entry'];
             $data['error'] = 'The text may not have more than 512 characters.';
         } elseif ($postlen < 1) {
             $data['error'] = 'The text has to have at least 1 character.';
         } else {
             $this->development_model->add_task($user->id, $_POST['add_entry'], $_POST['type']);
         }
     }
     $data['developer'] = $this->development_model->get();
     foreach ($data['developer'] as $d) {
         foreach ($d as $u => $dd) {
             $data["devusers"][$u] = $this->auth->user($u);
         }
     }
     $this->load->view('team/index', $data);
 }
 /**
  * 检查字段type相关的value、length约束
  * @param  array $field
  * @return array
  */
 public function checkTypeConstraint(&$field)
 {
     switch ($field['type']) {
         case 'CHAR':
         case 'VARCHAR':
             $field['length'] = $field['length']['intchar'];
             if (!isset($field['length']) || empty($field['length'])) {
                 return $this->errorResultReturn('字符串类型长度不能为空!');
             }
             if (!isint($field['length'])) {
                 return $this->errorResultReturn('字符串类型长度只能为整数!');
             }
             break;
         case 'TINYINT':
         case 'SMALLINT':
         case 'INT':
         case 'BIGINT':
             $field['length'] = $field['length']['intchar'];
             if (!isint($field['length'])) {
                 return $this->errorResultReturn('整数类型长度只能为整数!');
             }
             // 默认值只能为整数
             if (!empty($field['value']) && !isint($field['value'])) {
                 return $this->errorResultReturn('整数型默认值只能为有效的整数!');
             }
             break;
         case 'FLOAT':
         case 'DOUBLE':
             $realLen = array();
             // 长度
             if (!empty($field['length']['real'])) {
                 if (!isint($field['length']['real'])) {
                     return $this->errorResultReturn('浮点型长度只能为整数!');
                 }
                 $realLen[] = $field['length']['real'];
                 // 精度
                 if (!empty($field['precision'])) {
                     if (!isint($field['precision'])) {
                         return $this->errorResultReturn('浮点型精度只能为整数!');
                     }
                     $realLen[] = $field['precision'];
                     unset($field['precision']);
                 }
             }
             // 数据库浮点数形式
             $field['length'] = implode(',', $realLen);
             // 默认值只能为real
             if (!empty($field['value']) && !is_numeric($field['value'])) {
                 return $this->errorResultReturn('浮点型默认值只能为有效的数字!');
             }
             break;
         default:
             // mysql支持TEXT长度和默认值
             unset($field['length']);
             unset($field['value']);
             $field['is_index'] = 0;
             $field['is_unique'] = 0;
     }
     unset($field['precision']);
     return $this->resultReturn(true);
 }
 function DetectBrowser()
 {
     $BROWSERS = array("msie%" => "Internet Explorer %", "firefox%" => "FireFox %", "opera%" => "Opera %", "chrome%" => "Chrome %", "safari%" => "Safari %", "applewebkit%" => "Safari %", "netscape%" => "Netscape %", "seamonkey%" => "SeaMonkey %", "konqueror%" => "Konqueror %", "iceweasel%" => "Iceweasel %", "nokia" => "Nokia Mini Map", "granparadiso" => "Mozilla Gran Paradiso", "bolt%" => "Bolt %", "lynx%" => "Lynx %", "netfront%" => "Netfront %", "ucbrowser%" => "UC Browser %", "isilox%" => "iSilo %", "amaya" => "Amaya", "flock" => "Flock", "novarravision%" => "Novarra-Vision %", "galeon" => "Galeon", "aol" => "AOL Explorer", "omniweb" => "OmniWeb", "icab" => "iCab", "avant" => "Avant", "kmeleon" => "K-Meleon", "camino" => "Camino", "maxthon" => "Maxthon", "ucweb" => "UCWEB Mobile", "polaris%" => "Polaris %", "netpositive" => "NetPositive", "lynx" => "Lynx", "elinks" => "eLinks", "dillo" => "Dillo", "ibrowse" => "iBrowse", "klondike" => "Klondike WAP", "crazybrowser" => "Crazy Browser", "mauiwapbrowser" => "Maui WAP", "operamini" => "Opera Mini", "thunderbrowse" => "ThunderBrowse", "thunderbird" => "Thunderbird", "shiretoko" => "FireFox 3", "namoroka" => "FireFox 3", "minefield" => "FireFox 4 (Minefield)", "bonecho" => "FireFox 2 (BonEcho)", "blackberry" => "BlackBerry Mobile", "jasmine%" => "Jasmine Mobile V%", "waterfox%" => "Waterfox %", "upbrowser%" => "UP.Browser %", "teleca" => "Teleca", "dolfin%" => "Dolfin %", "obigo" => "Obigo", "midori" => "Midori", "playstation%" => "playstation%", "trident7" => "Internet Explorer 11");
     $BOTS = array("googlebot" => "Google", "amazonaws" => "Amazon AWS", "mediapartners-google" => "Google adsense", "yahoo-verticalcrawler" => "Yahoo", "yahoo!slurp" => "Yahoo", "yahoo-mm" => "Yahoo-MMCrawler / Yahoo-MMAudVid", "inktomi" => "inktomi", "tfbnw" => "Facebook", "facebook" => "Facebook", "slurp" => "inktomi", "fast-webcrawler" => "Fast AllTheWeb", "msnbot" => "MSN / Bing", "askjeeves" => "Ask Jeeves", "teoma" => "Ask Jeeves", "scooter" => "Altavista", "openbot" => "Openbot", "iaarchiver" => "Alexa Crawler", "zyborg" => "Looksmart", "almaden" => "IBM", "baiduspider" => "Baidu", "psbot" => "PSBot", "gigabot" => "Gigabot", "naverbot" => "Naverbot", "surveybot" => "Surveybot", "boithocom-dc" => "Boitho", "answerbus" => "answerbus.com", "sohu-search" => "Sohu", "postrank" => "Postrank", "mailru" => "Mail.ru", "yandex" => "Yandex", "alexacom" => "Alexa.com", "twiceler" => "Twiceler", "jakartacommons" => "Jakarta Commons HttpClient Component", "youdaobot" => "YoudaoBot", "comodo" => "Comodo", "sogouwebspider" => "Sogou", "sosospider" => "Soso", "tineye" => "Tineye", "jobsde" => "Jobs.de", "kscrawler" => "Kindsight", "twengabot" => "Twenga", "zschobot" => "Zscho", "sheenbot" => "SheenBot", "speedyspider" => "Entireweb", "spinn3r" => "spinn3r News Crawler", "exabot" => "Exalead", "nigmaru" => "Nigma.ru", "isrccrawler" => "Microsoft Research (MSR)", "heritrix" => "Archive.org", "www80legscom" => "80legs.com Web Crawler", "mj12bot" => "Majestic-12", "thumbshotsbot" => "ThumbShots", "jobkereso" => "JobKereso", "ayna" => "Ayna.com", "jobroboterspider" => "Job Roboter");
     $MISC = array("w3ccssvalidator" => "W3C CSS Validator", "w3cvalidator" => "W3C (X)HTML Validator", "wdgvalidator" => "WDG Validator", "libwwwperl" => "libwww-perl", "pythonurllib" => "python-urllib", "pycurl" => "Python PycURL", "nessus" => "Nessus Client", "xenulinksleuth" => "Xenu Link Sleuth", "livezilla" => "LiveZilla", "httrack" => "HTTrack", "webcopier" => "WebCopier", "wget" => "WGet", "teleportpro" => "Teleport Pro");
     $browser = !empty($_SERVER["HTTP_USER_AGENT"]) ? str_replace(array(' ', '/', '_', '-', '['), array('', '', '', '', ''), strtolower($_SERVER["HTTP_USER_AGENT"])) : "";
     $lists = array($BOTS, $BROWSERS, $MISC);
     foreach ($lists as $index => $list) {
         foreach ($list as $brkey => $brname) {
             $fixkey = str_replace("%", "", $brkey);
             if (strpos($browser, $fixkey) !== false) {
                 $this->BrowserName = trim(str_replace("%", "", $brname));
                 if ($index == 1) {
                     $this->BrowserVersion = @substr($browser, strpos($browser, $fixkey) + strlen($fixkey), 2);
                     if (!isint($this->BrowserVersion) || isint(@substr($browser, strpos($browser, $fixkey) + strlen($fixkey), 3))) {
                         $this->BrowserVersion = @substr($browser, strpos($browser, $fixkey) + strlen($fixkey), 1);
                     }
                     if (isint($this->BrowserVersion) && $this->BrowserVersion > 0) {
                         $this->Browser = str_replace("%", $this->BrowserVersion, $brname);
                     } else {
                         $this->Browser = str_replace(" %", "", $brname);
                         $this->BrowserVersionUnknown = true;
                     }
                 } else {
                     $this->Browser = $brname;
                     $this->BrowserVersionUnknown = true;
                 }
                 $this->AgentType = $index;
                 return;
             }
         }
     }
 }
    /**
     * Creates a full blog-entry from a blog-array
     * @param array $array blog-array
     * @param string $entry_id the ID of the entry
     * @param bool $stop_on_pagebreak TRUE: Stops on first pagebreak
     * @param array $open_tags Open tags before the function is called (needed because of recursiveness)
     * @param int $id The id used for inside html-ids to prevent multiple same ID's in one DOM
     * @param bool $ireid FALSE: does not add a readmore-link on pagebreak 
     * @return string HTML-Markup of the post
     */
    function create_blog_post_from_array($array, $entry_id, $stop_on_pagebreak = false, $open_tags = array(), $id = false, $ireid = true)
    {
        if (!isint($entry_id)) {
            trigger_error('No $entry_id set.');
            $entry_id = rand(0, 9999);
            $ireid = false;
        }
        if (!is_array($array)) {
            if (is_string($array) || is_numeric($array)) {
                return $array;
            } else {
                return '';
            }
        }
        if (!is_int($id)) {
            $id = 0;
        }
        $singleton_tags = array("img", "base", "br", "col", "command", "embed", "hr", "input", "link", "meta", "param", "source");
        $return = '';
        foreach ($array as $k => $v) {
            if ($k == 'before') {
                if ($stop_on_pagebreak == true && strpos($v, '<!-- pagebreak -->') !== false) {
                    $return = explode('<!-- pagebreak -->', $v)[0];
                    if ($ireid) {
                        $return .= '<a href="' . site_url('blog/view/' . $entry_id) . '">Read more...</a>';
                    }
                    foreach ($array['closing_tag'] as $cv) {
                        unset($open_tags[count($open_tags) - 1]);
                        $return .= '</' . $cv . '>';
                    }
                    return $return;
                }
                $return .= $v;
                continue;
            }
            if ($k == 'tag') {
                $aatot = false;
                // aatot = Add Attributes To Open Tags ;-)
                if (!in_array($v, $singleton_tags)) {
                    $open_tags[] = array('tag' => $v);
                    $aatot = true;
                }
                if (isset($array['attributes']['class']) && $v == 'img' && $array['attributes']['class'] != 'inline') {
                    for ($i = count($open_tags) - 1; $i > -1; $i--) {
                        if ($open_tags[$i]['tag'] != 'a') {
                            $return .= '</' . $open_tags[$i]['tag'] . '>';
                        }
                    }
                    $return .= '</div></div>
	<div class="blog-image ' . $array['attributes']['class'] . '" id="img-' . $entry_id . '-' . $id . '">';
                    if (strpos($array['attributes']['class'], 'collapse') !== false) {
                        $return .= '<a href="#img-' . $entry_id . '-' . $id . '" class="image-expand"></a><a href="#closer" class="image-closer"></a>';
                    }
                    $return .= '<svg class="image-showcase top" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100px" viewBox="0 0 100 101" enable-background="new 0 0 100 101" xml:space="preserve" preserveAspectRatio="none">
	<polygon fill="#CCCCCC" points="-1,0 100,0 100,101 "/>
	<polygon fill="#FFFFFF" points="0,0 100,0 100,100 "/>
	</svg>';
                }
                $return .= '<' . $v;
                if (isset($array['attributes'])) {
                    foreach ($array['attributes'] as $ak => $av) {
                        if ($aatot) {
                            $open_tags[count($open_tags) - 1]['attributes'][$ak] = $av;
                        }
                        $return .= ' ' . $ak . '=';
                        if (strpos($av, '"') === false) {
                            $return .= '"' . $av . '"';
                        } else {
                            $return .= "'" . $av . "'";
                        }
                    }
                }
                $return .= '>';
                if (isset($array['attributes']['class']) && $v == 'img' && $array['attributes']['class'] != 'inline') {
                    $return .= '<svg class="image-showcase bottom" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100px" viewBox="0 0 100 101" enable-background="new 0 0 100 101" xml:space="preserve" preserveAspectRatio="none">
	<polygon fill="#CCCCCC" points="101,101 0,101 0,0 "/>
	<polygon fill="#FFFFFF" points="100,101 0,101 0,1 "/>
	</svg>
	</div>
					<div class="wrapper"><div class="blog-centered">';
                    foreach ($open_tags as $o) {
                        if ($o['tag'] == 'a') {
                            continue;
                        }
                        $return .= '<' . $o['tag'];
                        if (isset($o['attributes'])) {
                            foreach ($o['attributes'] as $ak => $av) {
                                $return .= ' ' . $ak . '=';
                                if (strpos($av, '"') === false) {
                                    $return .= '"' . $av . '"';
                                } else {
                                    $return .= "'" . $av . "'";
                                }
                            }
                        }
                        $return .= '>';
                    }
                }
                continue;
            }
            if ($k == 'closing_tag') {
                foreach ($v as $cv) {
                    unset($open_tags[count($open_tags) - 1]);
                    $return .= '</' . $cv . '>';
                }
                continue;
            }
            if ($k == 'after') {
                $return .= call_user_func(__FUNCTION__, $v, $entry_id, $stop_on_pagebreak, $open_tags, $id++, $ireid);
                continue;
            }
        }
        return $return;
    }
Beispiel #5
0
 function __construct($arr = null)
 {
     if ($arr != null) {
         // Cost
         if (array_key_exists('cost', $arr)) {
             // Explode mana cost
             $this->manas = cost_explode($arr['cost']);
             // Compute color and converted cost
             $this->color = '';
             $this->converted_cost = 0;
             foreach ($this->manas as $mana) {
                 // mana symbols
                 if (isint($mana)) {
                     // Is a number
                     $this->converted_cost += intval($mana);
                 } else {
                     // Is a mana
                     if (!in_array($mana, array('X', 'Y', 'Z'))) {
                         // X is worth 0 and no color, Y and Z only are in the ultimate nightmare ...
                         $this->add_color($mana);
                         if (isint($mana[0])) {
                             // Hybrid colorless/colored
                             $this->converted_cost += intval($mana[0]);
                         } else {
                             $this->converted_cost++;
                         }
                     }
                 }
             }
             // No color found, consider as colorless
             if ($this->color == '') {
                 $this->color = 'X';
             }
             // Search if color is given in card text
             $colornames = array('X' => 'colorless', 'W' => 'white', 'U' => 'blue', 'B' => 'black', 'R' => 'red', 'G' => 'green', 'WUBRG' => 'all colors');
             if (preg_match('`' . $arr['name'] . ' is (' . implode('|', $colornames) . ')`', $arr['text'], $matches)) {
                 if ($i = array_search($matches[1], $colornames)) {
                     $this->color = $i;
                 }
             }
             // Sort colors
             global $allcolorscode;
             $this->color_index = -1;
             for ($i = 0; $i < count($allcolorscode); $i++) {
                 // Search right order in hardcoded list
                 if (count(array_diff(str_split($this->color), str_split($allcolorscode[$i]))) == 0) {
                     $this->color_index = $i;
                     $this->color = $allcolorscode[$this->color_index];
                     break;
                 }
             }
             //if ( $this->color_index < 0 )
             //die('Color index error for ['.$this->color.'] '.$arr['name']) ;
         } else {
             die('No cost in array : ' . $arr['name']);
         }
         // Types
         if (array_key_exists('types', $arr)) {
             manage_types($arr['types'], $this);
         } else {
             die('No type in array : ' . $arr['name']);
         }
         // Text
         if (array_key_exists('text', $arr)) {
             $arr['text'] = str_replace('  ', "\n", $arr['text']);
             // That was wanted by spoiler writter
             // Transform
             $pieces = explode("\n-----\n", $arr['text']);
             if (count($pieces) > 1) {
                 // Card is a transform
                 manage_all_text($arr['name'], $pieces[0], $this);
                 // Manage "day"
                 // Then manage "night", 3+ lines : name, color/types, text (all other lines, such as "pow/tou \n other effects" for creats)
                 $transform = new stdClass();
                 $matches = explode("\n", $pieces[1]);
                 if (count($matches) > 0) {
                     $transform->name = stripslashes(array_shift($matches));
                 }
                 if (count($matches) > 0) {
                     $t = array_shift($matches);
                     $reg = '/\\%(\\S+) (.*)/s';
                     $transform->color = 'X';
                     if (preg_match($reg, $t, $matches_t)) {
                         $transform->color = $matches_t[1];
                         $t = $matches_t[2];
                     }
                     manage_types($t, $transform);
                 } else {
                     echo 'No color/type for transformed ' . $arr['name'] . '(' . $transform->name . ')<br>';
                 }
                 if (count($matches) > 0) {
                     manage_all_text($transform->name, implode("\n", $matches), $transform);
                 } else {
                     echo 'No text for transformed ' . $arr['name'] . '(' . $transform->name . ')<br>';
                 }
                 $this->transformed_attrs = $transform;
             } else {
                 // Split / Flip
                 $pieces = explode("\n----\n", $arr['text']);
                 if (count($pieces) > 1) {
                     manage_all_text($arr['name'], $pieces[0], $this);
                     // Manage "main" part
                     $matches = explode("\n", $pieces[1]);
                     if (strpos($arr['name'], '/') === false) {
                         // No "/" in name, it's a flip
                         $flip = new stdClass();
                         $flip->name = array_shift($matches);
                         if (count($matches) > 0) {
                             manage_types(array_shift($matches), $flip);
                         }
                         $this->flip_attrs = $flip;
                         manage_all_text($arr['name'], implode("\n", $matches), $flip);
                     } else {
                         // "/" in name, it's a split
                         $split = new stdClass();
                         if (count($matches) > 0) {
                             $split->manas = cost_explode(array_shift($matches));
                         }
                         if (count($matches) > 0) {
                             manage_types(array_shift($matches), $split);
                         }
                         $this->split = $split;
                         manage_all_text($arr['name'], implode("\n", $matches), $this);
                         // Apply colors to initial card
                         foreach ($split->manas as $mana) {
                             // mana symbols
                             if (!isint($mana)) {
                                 // Is a mana
                                 if ($mana != 'X') {
                                     // X is worth 0 and no color
                                     $this->add_color($mana);
                                 }
                             }
                         }
                     }
                 } else {
                     manage_all_text($arr['name'], $arr['text'], $this);
                 }
             }
         } else {
             die('No text in array : ' . $arr['name']);
         }
     }
 }
 /**
  * Remapper
  * @param string $method Method to be called
  * @param array $params array of parameters
  */
 public function _remap($method, $params = array())
 {
     if (!$this->has_perm) {
         return $this->template->render_permission_error();
     }
     if ($method == 'groups' && (!isset($params[0]) || isint($params[0]))) {
         return call_user_func_array(array($this, 'list_groups'), $params);
     } elseif ($method == 'groups') {
         return call_user_func_array(array($this, 'search_groups'), $params);
     } elseif ($method == 'user') {
         if (isset($params[1])) {
             if ($params[1] == 'groups') {
                 unset($params[1]);
                 return call_user_func_array(array($this, 'user_groups'), $params);
             }
             if ($params[1] == 'permissions') {
                 unset($params[1]);
             }
         }
         return call_user_func_array(array($this, 'user_permissions'), $params);
     }
     if (method_exists($this, $method)) {
         return call_user_func_array(array($this, $method), $params);
     }
     show_404();
 }
Beispiel #7
0
 $db->query('SELECT following FROM socialhns WHERE user_id = ' . $_SESSION['user_id']);
 $following = array();
 for ($i = 1; $i < 201; $i++) {
     array_push($following, $i);
 }
 if (!empty($following)) {
     $ownerlist = $_SESSION['user_id'] . ',' . implode(',', $following);
 } else {
     $ownerlist = $_SESSION['user_id'];
 }
 if (!isset($_GET['sid'])) {
     $limit = ' LIMIT 20';
     if (isset($_GET['newest']) && isint($_GET['newest'])) {
         $newest = $_GET['newest'];
         $timestamp = 'AND s.timestamp > ' . $newest . ' ';
     } elseif (isset($_GET['oldest']) && isint($_GET['oldest'])) {
         $oldest = $_GET['oldest'];
         $timestamp = 'AND s.timestamp < ' . $oldest . ' ';
         $limit = ' LIMIT 30';
     }
     $db->query('SELECT s.sid,s.owner,s.timestamp,s.type,s.data,s.likes,s.comments,s.shares,s.block,s.ids,u.username,i.firstname,i.middlename,i.lastname,i.default_image FROM (stream s JOIN login u ON s.owner = u.user_id) JOIN info i ON s.owner = i.user_id WHERE s.owner IN (' . $ownerlist . ') ' . $timestamp . 'AND s.type = 1 AND s.block NOT LIKE "%,' . $_SESSION['user_id'] . ',%" ORDER BY s.sid DESC' . $limit);
 } else {
     $db->query('SELECT s.sid,s.owner,s.timestamp,s.type,s.data,s.likes,s.comments,s.shares,s.block,s.ids,u.username,i.firstname,i.middlename,i.lastname,i.default_image FROM (stream s JOIN login u ON s.owner = u.user_id) JOIN info i ON s.owner = i.user_id WHERE s.owner IN (' . $ownerlist . ') AND s.type = 1 AND s.block NOT LIKE "%,' . $_SESSION['user_id'] . ',%" AND s.sid = ' . $_GET['sid'] . ' LIMIT 1');
 }
 if ($db->numRows() > 0) {
     header('Content-Type: application/json; charset=utf8');
     $rows = $db->fetchAssocRows();
     for ($i = 0; $i < count($rows); $i++) {
         unset($rows[$i]["block"]);
         $comments = json_decode($rows[$i]["comments"]);
         if (is_array($comments)) {
 private function _post()
 {
     if (!$this->_validated) {
         if (!isset($_POST['action'])) {
             return false;
         }
         $_POST['action'] = strtolower($_POST['action']);
         if ($_POST['action'] != 'prev' && $_POST['action'] != 'previous' && $_POST['action'] != 'next') {
             return false;
         }
         if (!isset($_POST['reference']) || !isint($_POST['reference'])) {
             return false;
         }
         $this->_validated = true;
         $_POST['get_answers'] = isset($_POST['get_answers']) && $_POST['get_answers'] == "true";
     }
     return $_POST;
 }
 $dati = urldecode($dat);
 $dato = str_replace("\\'", "'", $dati);
 //$dato = $dat;
 if ($var != "rewrite" && $var != "petition") {
     if ($var == "ROOT") {
         $atomParam = array();
         $atomParam["paraname"] = "ROOT";
         $atomParam["paratype"] = "Cadena";
         $atomParam["value"] = $SYS["ROOT"];
         $P[] = $atomParam;
     } else {
         if ($var != "jasperreport") {
             $atomParam = array();
             $atomParam["paraname"] = $var;
             if (is_numeric($dato)) {
                 if (isint($dato)) {
                     $tipo = "Entero";
                 } else {
                     $tipo = "Decimal";
                 }
             } else {
                 if (is_date($dato)) {
                     $tipo = "Fecha";
                 } else {
                     $tipo = "Cadena";
                 }
             }
             $atomParam["paratype"] = $tipo;
             $atomParam["value"] = $dato;
             $P[] = $atomParam;
         } else {
 /**
  * 检查类型约束
  * @param  string $type  需要约束的类型
  * @param  string $value 需要约束的值
  * @return mixed
  */
 public function checkTypeContraint($type, $value)
 {
     switch ($type) {
         case 'TINYINT':
         case 'SMALLINT':
         case 'INT':
         case 'BIGINT':
             if (!isint($value)) {
                 return $this->resultReturn(false, 'int');
             }
             break;
         case 'FLOAT':
         case 'DOUBLE':
             if (!isdouble($value)) {
                 return $this->resultReturn(false, 'double');
             }
             break;
         case 'date':
             if (!is_valid_date($value)) {
                 return $this->resultReturn(false, 'date');
             }
             break;
     }
     return $this->resultReturn(true);
 }
 /**
  * Remaps the requests for this controller
  * @param mixed $method is used as pagination when integer, else normal url-mapping
  * @param type $params 
  * @return type
  */
 public function _remap($method, $params)
 {
     if ($method == isint($method)) {
         return $this->index($method);
     } elseif (method_exists($this, $method)) {
         return call_user_func_array(array($this, $method), $params);
     }
     show_404();
 }
    function display_comments($comments, $module, $user, $is_answer = false, $offset)
    {
        if (isset($_GET['answer']) && isint($_GET['answer'])) {
            $answer = $_GET['answer'];
        } else {
            $answer = 0;
        }
        foreach ($comments as $c) {
            ?>
		<div class="comment<?php 
            echo $is_answer ? ' answer' : '';
            ?>
" id="comment-<?php 
            echo $c->id;
            ?>
">
			<?php 
            echo $is_answer ? '<a href="#comment-' . $c->id . '" class="fa fa-caret-right expander"></a>' : '';
            ?>
			<div class="comment-text">
				<a href="<?php 
            echo site_url('user/' . $c->creator->id);
            ?>
"><?php 
            echo showname($c->creator);
            ?>
</a>
				<span class="text"><?php 
            echo htmlentities($c->comment);
            ?>
</span>
			</div>
			<div class="comment-actions">
				<?php 
            echo dt_tm($c->date);
            ?>
 
				<?php 
            if ($answer != $c->id) {
                ?>
					<a href="?answer=<?php 
                echo $c->id;
                ?>
#comment-<?php 
                echo $c->id;
                ?>
" data-comment-answer="<?php 
                echo $c->id;
                ?>
">Answer</a>
				<?php 
            }
            ?>
				<?php 
            if (!isset($c->answers) && $c->count_answers > 0) {
                ?>
					 <a href="?answers=<?php 
                echo $c->id;
                ?>
#comment-<?php 
                echo $c->id;
                ?>
" data-comment-answers="true" data-comment-reference="<?php 
                echo $c->id;
                ?>
" data-comment-action="next">Show answers (<?php 
                echo $c->count_answers;
                ?>
)</a>
				<?php 
            }
            ?>
				
				<?php 
            echo $c->ratings->display_small('comment-' . $c->id);
            ?>
			</div>
			<a class="user-image" href="<?php 
            echo site_url('user/' . $c->creator->id);
            ?>
"><img src="<?php 
            echo avatar_image($c->creator->id);
            ?>
" class="avatar" /></a>
			<?php 
            echo '';
            ?>
			<?php 
            if (isset($c->answers)) {
                $is_this_answer_post = isset($_GET['answers']) && $_GET['answers'] == $c->id;
                if ($is_this_answer_post && $offset > 0) {
                    ?>
					<a class="show-answers-button" data-comment-reference="<?php 
                    echo $c->id;
                    ?>
" data-comment-action="previous" href="?answers=<?php 
                    echo $c->id;
                    ?>
&end=<?php 
                    echo $_GET['end'] > 30 ? $_GET['end'] - 30 : 0;
                    ?>
">Show <?php 
                    echo $offset > 30 ? 30 : $offset;
                    ?>
 previous answers.</a>
					<?php 
                }
                display_comments($c->answers, $module, $user, true, $offset);
                $remaining_answers = $c->count_answers - count($c->answers);
                if ($is_this_answer_post) {
                    $remaining_answers -= $offset;
                }
                if ($remaining_answers > 0) {
                    $next_answers = isset($_GET['end']) && $is_this_answer_post && isint($_GET['end']) ? $_GET['end'] + 30 : 30;
                    ?>
					<a class="show-answers-button" data-comment-reference="<?php 
                    echo end($c->answers)->id;
                    ?>
" data-comment-action="next" href="?answers=<?php 
                    echo $c->id;
                    ?>
&end=<?php 
                    echo $next_answers;
                    ?>
">Show <?php 
                    echo $remaining_answers > 30 ? 30 : $remaining_answers;
                    ?>
 more answers.</a>
					<?php 
                }
            }
            ?>
			<?php 
            if ($answer == $c->id) {
                ?>
				<?php 
                echo form_open(uri_string() . '?answers=' . $c->id . '#comment-' . $c->id, array('class' => 'create-answer'));
                ?>
					<?php 
                echo form_hidden('duplicate-preventer', uniqid());
                ?>
					<?php 
                echo form_hidden('comment-answer-to', $c->id);
                ?>
					<div class="comments-wrapper">
						<textarea name="comment" placeholder="<?php 
                echo $user ? 'Your comment...' : 'You have to log in or create an account to comment.';
                ?>
"<?php 
                echo $user ? 'autofocus' : ' disabled="disabled"';
                ?>
></textarea>
					</div>
					<?php 
                $submit_data = array('type' => 'submit', 'name' => 'comments-submit', 'value' => 'Submit comment');
                if (!$user) {
                    $submit_data['disabled'] = 'disabled';
                }
                ?>
					<?php 
                echo form_input($submit_data);
                ?>
				<?php 
                echo form_close();
                ?>
			<?php 
            }
            ?>
		</div>
		<?php 
        }
    }
 /**
  * Remaps the site
  * @param string $method the method to be executed
  * @param array $params the params to pass to the function
  */
 function _remap($method, $params)
 {
     if (method_exists($this, $method)) {
         return call_user_func_array(array($this, $method), $params);
     } elseif (isint($method)) {
         $params['id'] = $method;
         return call_user_func_array(array($this, 'view'), $params);
     } else {
         $params['string'] = $method;
         return call_user_func_array(array($this, 'search'), $params);
     }
 }
Beispiel #14
0
function applyRDChange($f_szType, $f_iInitialValue, $f_iPlanetId = PLANET_ID)
{
    $arrTFuncs = array('travel_eta' => 'ceil', 'r_d_eta' => 'ceil', 'r_d_costs' => 'ceil', 'fuel_use' => 'ceil');
    if (isset($arrTFuncs[$f_szType])) {
        $szTFunc = $arrTFuncs[$f_szType];
    } else {
        if ('income_' === substr($f_szType, 0, 7) && isint(substr($f_szType, 7))) {
            $szTFunc = 'floor';
        } else {
            return $f_iInitialValue;
        }
    }
    $szSqlQuery = '
	SELECT
		*
	FROM
		d_r_d_results
	WHERE
		type = \'' . $f_szType . '\' AND
		done_r_d_id in (
			SELECT
				r_d_id
			FROM
				planet_r_d
			WHERE
				planet_id = ' . $f_iPlanetId . ' AND
				eta = 0
		) AND
		enabled = \'1\'
	ORDER BY
		o ASC;';
    $arrRDResults = db_fetch($szSqlQuery);
    foreach ($arrRDResults as $arrChange) {
        if ('pct' == $arrChange['unit']) {
            $f_iInitialValue *= abs($arrChange['change']);
        } else {
            $f_iInitialValue += $arrChange['change'];
        }
    }
    return call_user_func($szTFunc, $f_iInitialValue);
}