Exemplo n.º 1
2
function getLocation($str)
{
    $array_size = intval(substr($str, 0, 1));
    // 拆成的行数
    $code = substr($str, 1);
    // 加密后的串
    $len = strlen($code);
    $subline_size = $len % $array_size;
    // 满字符的行数
    $result = array();
    $deurl = "";
    for ($i = 0; $i < $array_size; $i += 1) {
        if ($i < $subline_size) {
            array_push($result, substr($code, 0, ceil($len / $array_size)));
            $code = substr($code, ceil($len / $array_size));
        } else {
            array_push($result, substr($code, 0, ceil($len / $array_size) - 1));
            $code = substr($code, ceil($len / $array_size) - 1);
        }
    }
    for ($i = 0; $i < ceil($len / $array_size); $i += 1) {
        for ($j = 0; $j < count($result); $j += 1) {
            $deurl = $deurl . "" . substr($result[$j], $i, 1);
        }
    }
    return str_replace("^", "0", urldecode($deurl));
}
Exemplo n.º 2
1
 function system_add_credentials()
 {
     if (!isset($_POST['AddCredentials'])) {
         $details = new stdClass();
         $details->system_id = intval($this->uri->segment(3, 0));
         if (!is_int($details->system_id) or $details->system_id == 0) {
             redirect('main/list_devices');
         }
         $this->load->model("m_system");
         $this->data['system_id'] = $details->system_id;
         $this->data['ip_address'] = ip_address_from_db($this->m_system->check_man_ip_address($details->system_id));
         $this->data['heading'] = 'Add Device SNMP Credentials';
         $this->data['include'] = 'v_add_system_c';
         $this->load->view('v_template', $this->data);
     } else {
         $system_id = $_POST['system_id'];
         $this->load->model("m_system");
         $this->load->library('encrypt');
         if ($_POST['snmp_community'] > '' and $_POST['snmp_version'] > '' and $_POST['ip_address'] > '') {
             $encode['ip_address'] = $_POST['ip_address'];
             $encode['snmp_version'] = $_POST['snmp_version'];
             $encode['snmp_community'] = $_POST['snmp_community'];
             $encoded = json_encode($encode);
             $encoded = $this->encrypt->encode($encoded);
             $this->m_system->update_system_man($system_id, 'access_details', $encoded);
             if ($_POST['snmp_scan'] == TRUE) {
                 redirect('admin_system/system_snmp/' . $system_id);
             } else {
                 redirect('main/system_display/' . $system_id);
             }
         } else {
             redirect('admin_system/system_add_credentials/' . $system_id);
         }
     }
 }
Exemplo n.º 3
1
function _rotate_step($step, $mode = 1)
{
    $step_h = intval($step / 256);
    $step_l = $step % 256;
    $data = array(255, AGB_ID, 6, 105, 1, $mode, 1, $step_h, $step_l);
    send_data(PORT_AGB, $data);
}
Exemplo n.º 4
1
 function hikashopSubscriptionType()
 {
     if (!HIKASHOP_PHP5) {
         $acl =& JFactory::getACL();
     } else {
         $acl = JFactory::getACL();
     }
     if (!HIKASHOP_J16) {
         $this->groups = $acl->get_group_children_tree(null, 'USERS', false);
     } else {
         $db = JFactory::getDBO();
         $db->setQuery('SELECT a.*, a.title as text, a.id as value  FROM #__usergroups AS a ORDER BY a.lft ASC');
         $this->groups = $db->loadObjectList('id');
         foreach ($this->groups as $id => $group) {
             if (isset($this->groups[$group->parent_id])) {
                 $this->groups[$id]->level = intval(@$this->groups[$group->parent_id]->level) + 1;
                 $this->groups[$id]->text = str_repeat('- - ', $this->groups[$id]->level) . $this->groups[$id]->text;
             }
         }
     }
     $this->choice = array();
     $this->choice[] = JHTML::_('select.option', 'none', JText::_('HIKA_NONE'));
     $this->choice[] = JHTML::_('select.option', 'special', JText::_('HIKA_CUSTOM'));
     $js = "function updateSubscription(map){\r\n\t\t\tchoice = document.adminForm['choice_'+map];\r\n\t\t\tchoiceValue = 'special';\r\n\t\t\tfor (var i=0; i < choice.length; i++){\r\n\t\t\t\tif (choice[i].checked){\r\n\t\t\t\t\tchoiceValue = choice[i].value;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\thiddenVar = document.getElementById('hidden_'+map);\r\n\t\t\tif(choiceValue != 'special'){\r\n\t\t\t\thiddenVar.value = choiceValue;\r\n\t\t\t\tif(hiddenVar.value == 'none') hiddenVar.value = '';\r\n\t\t\t\tdocument.getElementById('div_'+map).style.display = 'none';\r\n\t\t\t}else{\r\n\t\t\t\tdocument.getElementById('div_'+map).style.display = '';\r\n\t\t\t\tspecialVar = eval('document.adminForm.special_'+map);\r\n\t\t\t\tfinalValue = '';\r\n\t\t\t\tfor (var i=0; i < specialVar.length; i++){\r\n\t\t\t\t\tif (specialVar[i].checked){\r\n\t\t\t\t\t\tfinalValue += specialVar[i].value;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\thiddenVar.value = finalValue;\r\n\t\t\t}\r\n\t\t}";
     if (!HIKASHOP_PHP5) {
         $doc =& JFactory::getDocument();
     } else {
         $doc = JFactory::getDocument();
     }
     $doc->addScriptDeclaration($js);
 }
Exemplo n.º 5
1
 /**
  * PC标签中调用数据
  * @param array $data 配置数据
  */
 public function pc_tag($data)
 {
     $siteid = isset($data['siteid']) && intval($data['siteid']) ? intval($data['siteid']) : get_siteid();
     $r = $this->db->select(array('pos' => $data['pos'], 'siteid' => $siteid));
     $str = '';
     if (!empty($r) && is_array($r)) {
         foreach ($r as $v) {
             if (defined('IN_ADMIN') && !defined('HTML')) {
                 $str .= '<div id="block_id_' . $v['id'] . '" class="admin_block" blockid="' . $v['id'] . '">';
             }
             if ($v['type'] == '2') {
                 extract($v, EXTR_OVERWRITE);
                 $data = string2array($data);
                 if (!defined('HTML')) {
                     ob_start();
                     include $this->template_url($id);
                     $str .= ob_get_contents();
                     ob_clean();
                 } else {
                     include $this->template_url($id);
                 }
             } else {
                 $str .= $v['data'];
             }
             if (defined('IN_ADMIN') && !defined('HTML')) {
                 $str .= '</div>';
             }
         }
     }
     return $str;
 }
function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($GLOBALS["CACHEFILE"]));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    $md5file = trim(md5_file($GLOBALS["LOGSFILES"]));
    echo "// CACHE FILE: {$GLOBALS["CACHEFILE"]} {$prc}%\n";
    echo "// LOGS FILE: {$GLOBALS["LOGSFILES"]} - {$md5file} " . strlen($md5file) . "\n";
    if ($prc == 0) {
        if (strlen($md5file) < 32) {
            echo "\n\t// PRC = {$prc} ; md5file={$md5file}\n\tfunction Start{$time}(){\n\t\t\tif(!RTMMailOpen()){return;}\n\t\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
            return;
        }
    }
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\t\$('#SQUID_ARTICA_QUOTA_RULES').flexReload();\n\t\tRTMMailHide();\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
}
Exemplo n.º 7
1
/**
 * nv_getAllowed()
 *
 * @return
 */
function nv_getAllowed()
{
    global $module_data, $db, $admin_info;
    $sql = 'SELECT id,full_name,admins FROM ' . NV_PREFIXLANG . '_' . $module_data . '_department';
    $result = $db->query($sql);
    $contact_allowed = array('view' => array(), 'reply' => array(), 'obt' => array());
    while ($row = $result->fetch()) {
        $id = intval($row['id']);
        if (defined('NV_IS_SPADMIN')) {
            $contact_allowed['view'][$id] = $row['full_name'];
            $contact_allowed['reply'][$id] = $row['full_name'];
        }
        $admins = $row['admins'];
        $admins = array_map('trim', explode(';', $admins));
        foreach ($admins as $a) {
            if (preg_match('/^([0-9]+)\\/([0-1]{1})\\/([0-1]{1})\\/([0-1]{1})$/i', $a)) {
                $admins2 = array_map('intval', explode('/', $a));
                if ($admins2[0] == $admin_info['admin_id']) {
                    if ($admins2[1] == 1 and !isset($contact_allowed['view'][$id])) {
                        $contact_allowed['view'][$id] = $row['full_name'];
                    }
                    if ($admins2[2] == 1 and !isset($contact_allowed['reply'][$id])) {
                        $contact_allowed['reply'][$id] = $row['full_name'];
                    }
                    if ($admins2[3] == 1 and !isset($contact_allowed['obt'][$id])) {
                        $contact_allowed['obt'][$id] = $row['full_name'];
                    }
                }
            }
        }
    }
    return $contact_allowed;
}
Exemplo n.º 8
1
 function filter_css_object($css, $panels_data, $post_id)
 {
     foreach ($panels_data['grids'] as $gi => $grid) {
         $grid_id = !empty($grid['style']['id']) ? (string) sanitize_html_class($grid['style']['id']) : intval($gi);
         $top_padding = isset($grid['style']['top_padding']) ? $grid['style']['top_padding'] : null;
         $bottom_padding = isset($grid['style']['bottom_padding']) ? $grid['style']['bottom_padding'] : null;
         // Filter the bottom margin for this row with the arguments
         if ($top_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-top' => $top_padding), 1920);
         }
         if ($bottom_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-bottom' => $bottom_padding), 1920);
         }
         $top_padding = isset($grid['style']['tablet_top_padding']) ? $grid['style']['tablet_top_padding'] : null;
         $bottom_padding = isset($grid['style']['tablet_bottom_padding']) ? $grid['style']['tablet_bottom_padding'] : null;
         // Filter the bottom margin for this row with the arguments
         if ($top_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-top' => $top_padding), 960);
         }
         if ($bottom_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-bottom' => $bottom_padding), 960);
         }
         $top_padding = isset($grid['style']['mobile_top_padding']) ? $grid['style']['mobile_top_padding'] : null;
         $bottom_padding = isset($grid['style']['mobile_bottom_padding']) ? $grid['style']['mobile_bottom_padding'] : null;
         // Filter the bottom margin for this row with the arguments
         if ($top_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-top' => $top_padding), 478);
         }
         if ($bottom_padding) {
             $css->add_row_css($post_id, $grid_id, '.lsow-row', array('padding-bottom' => $bottom_padding), 478);
         }
     }
     return $css;
 }
Exemplo n.º 9
1
function search_ac_init(&$a)
{
    if (!local_channel()) {
        killme();
    }
    $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
    $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
    $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
    if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
        $search = $_REQUEST['query'];
    }
    // Priority to people searches
    if ($search) {
        $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
        $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
    }
    $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
    $results = array();
    if ($r) {
        foreach ($r as $g) {
            $results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
        }
    }
    $r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
    if (count($r)) {
        foreach ($r as $g) {
            $results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
        }
    }
    header("content-type: application/json");
    $o = array('start' => $start, 'count' => $count, 'items' => $results);
    echo json_encode($o);
    logger('search_ac: ' . print_r($x, true));
    killme();
}
 /**
  *用户ID方式登录
  */
 public function getQuestionListAction()
 {
     //基础元素,必须参与验证
     $Config['Time'] = abs(intval($this->request->Time));
     $Config['ReturnType'] = $this->request->ReturnType ? $this->request->ReturnType : 2;
     //URL验证码
     $sign = trim($this->request->sign);
     //私钥,以后要移开到数据库存储
     $p_sign = 'lm';
     $sign_to_check = Base_common::check_sign($Config, $p_sign);
     //不参与验证的元素
     //验证URL是否来自可信的发信方
     if ($sign_to_check == $sign) {
         //验证时间戳,时差超过600秒即认为非法
         if (abs($Config['Time'] - time()) <= 600) {
             $QuestionList = $this->oSecurityAnswer->getAll();
             $result = array('return' => 1, 'QuestionList' => $QuestionList);
         } else {
             $result = array('return' => 0, 'comment' => "时间有误");
         }
     } else {
         $result = array('return' => 0, 'comment' => "验证失败,请检查URL");
     }
     if ($Config['ReturnType']) {
         echo json_encode($result);
     } else {
         //			$r = $result['return']."|".iconv('UTF-8','GBK',$result['comment']);;
         //			if($result['return']==1)
         //			{
         //				$r = $r."|".$result['LoginId']."|".$result['adult'];
         //			}
         //			echo $r;
     }
 }
Exemplo n.º 11
0
 public function get()
 {
     $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : exit;
     if ($data = $this->db->getby_id($id)) {
         if (!($str = S('dbsource_' . $id))) {
             if ($data['type'] == 1) {
                 // 自定义SQL调用
                 $get_db = Loader::model("get_model");
                 $sql = $data['data'] . (!empty($data['num']) ? " LIMIT {$data['num']}" : '');
                 $str = $get_db->query($sql);
             } else {
                 $filepath = APPS_PATH . $data['application'] . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . $data['application'] . '_tag.php';
                 if (file_exists($filepath)) {
                     $yun_tag = Loader::lib($data['application'] . ':' . $data['application'] . '_tag');
                     if (!method_exists($yun_tag, $data['do'])) {
                         exit;
                     }
                     $sql = string2array($data['data']);
                     $sql['do'] = $data['do'];
                     $sql['limit'] = $data['num'];
                     unset($data['num']);
                     $str = $yun_tag->{$data}['do']($sql);
                 } else {
                     exit;
                 }
             }
             if ($data['cache']) {
                 S('tpl_data/dbsource_' . $id, $str, $data['cache']);
             }
         }
         echo $this->_format($data['id'], $str, $data['dis_type']);
     }
 }
Exemplo n.º 12
0
function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    $cachefile = $GLOBALS["PROGRESS_FILE"];
    $logsFile = $GLOBALS["LOG_FILE"];
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($cachefile));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    if ($prc == 0) {
        echo "\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n}\nsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    $md5file = md5_file($logsFile);
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('filename','" . urlencode($_GET["filename"]) . "');\n\t\tXHR.appendData('key','" . urlencode($_GET["key"]) . "');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLayersTabsAllAfter();\n\t\tRTMMailHide();\n\t\tCacheOff();\n\t\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
    //Loadjs('$page?build-js=yes&t=$t&md5file={$_GET["md5file"]}');
}
Exemplo n.º 13
0
function sn_ube_simulator_decode_replay($str_data)
{
    $fleet_id = 0;
    $arr_data_unpacked = explode('!', $str_data);
    foreach ($arr_data_unpacked as $data_piece) {
        if (!$data_piece) {
            continue;
        }
        if ($data_piece == 'A' || $data_piece == 'D') {
            $fleet_type = $data_piece;
            continue;
        }
        $arr_unit_strings = explode(';', $data_piece);
        foreach ($arr_unit_strings as $str_unit_string) {
            if (!$str_unit_string) {
                continue;
            }
            $arr_unit_data = explode(',', $str_unit_string);
            if ($arr_unit_data[1]) {
                $unpacked[$fleet_type][$fleet_id][$arr_unit_data[0]] = intval($arr_unit_data[1]);
            }
        }
        $fleet_id++;
    }
    return $unpacked;
}
Exemplo n.º 14
0
 public function setColumnCount($columns)
 {
     if (intval($columns) > 0) {
         $this->_columnCount = intval($columns);
     }
     return $this;
 }
Exemplo n.º 15
0
 static function getList(&$params)
 {
     //get database
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
     $query->from('#__content');
     $query->where('state = 2 AND checked_out = 0');
     $query->group('created_year DESC, created_month DESC');
     // Filter by language
     if (JFactory::getApplication()->getLanguageFilter()) {
         $query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
     }
     $db->setQuery($query, 0, intval($params->get('count')));
     $rows = (array) $db->loadObjectList();
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
     $itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : '';
     $i = 0;
     $lists = array();
     foreach ($rows as $row) {
         $date = JFactory::getDate($row->created);
         $created_month = $date->format('n');
         $created_year = $date->format('Y');
         $created_year_cal = JHTML::_('date', $row->created, 'Y');
         $month_name_cal = JHTML::_('date', $row->created, 'F');
         $lists[$i] = new stdClass();
         $lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
         $lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal);
         $i++;
     }
     return $lists;
 }
Exemplo n.º 16
0
 public function init()
 {
     $model = $this->model;
     if (!$this->extra_fields) {
         $this->extra_fields = array();
     }
     if (empty($_POST['id'])) {
         $this->data = $model::model()->findAll(array('order' => 'display_order asc'));
     } else {
         $this->data = array();
         foreach ($_POST['id'] as $i => $id) {
             $item = new $model();
             $item->id = $id;
             $item->name = $_POST['name'][$i];
             $attributes = $item->getAttributes();
             if (array_key_exists('active', $attributes)) {
                 $item->active = isset($_POST['active'][$i]) || intval($id) == 0 ? 1 : 0;
             }
             foreach ($this->extra_fields as $field) {
                 $item->{$field['field']} = $_POST[$field['field']][$i];
             }
             $this->data[] = $item;
         }
     }
     return parent::init();
 }
Exemplo n.º 17
0
 public function sendData(callable $callback)
 {
     $client = new swoole_client(SWOOLE_SOCK_UDP, SWOOLE_SOCK_ASYNC);
     $client->on("connect", function ($cli) {
         $this->isConnect = true;
         $cli->send($this->data);
     });
     $client->on('close', function ($cli) {
         $this->isConnect = false;
     });
     $client->on('error', function ($cli) use($callback) {
         $this->isConnect = false;
         $cli->close();
         call_user_func_array($callback, array('r' => 1, 'key' => $this->key, 'error_msg' => 'conncet error'));
     });
     $client->on("receive", function ($cli, $data) use($callback) {
         $this->isConnect = false;
         $cli->close();
         call_user_func_array($callback, array('r' => 0, 'key' => $this->key, 'data' => $data));
     });
     if ($client->connect($this->ip, $this->port, $this->timeout)) {
         if (intval($this->timeout) > 0) {
             swoole_timer_after(intval($this->timeout) * 1000, function () use($client, $callback) {
                 if ($this->isConnect) {
                     //error_log(__METHOD__." client ===== ".print_r($client,true),3,'/tmp/client.log');
                     $client->close();
                     call_user_func_array($callback, array('r' => 2, 'key' => '', 'error_msg' => 'timeout'));
                 }
             });
         }
     }
 }
Exemplo n.º 18
0
function build()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $sock = new sockets();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        die;
    }
    $php = $unix->LOCATE_PHP5_BIN();
    @file_put_contents($pidfile, getmypid());
    progress("{get_system_informations}", 30);
    support_step1();
    progress("{APP_UFDBGUARD}", 40);
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    if ($EnableUfdbGuard == 1) {
        $ufdbguardd = $unix->find_program("ufdbguardd");
        if (is_file($ufdbguardd)) {
            shell_exec("{$php} /usr/share/artica-postfix/exec.squidguard.php --build --force --verbose >/usr/share/artica-postfix/ressources/support/build-ufdbguard.log 2>&1");
        }
    }
    progress("{get_all_logs}", 50);
    support_step2();
    progress("{get_all_logs}", 70);
    export_tables();
    progress("{compressing_package}", 90);
    support_step3();
    progress("{success}", 100);
}
Exemplo n.º 19
0
 public static function updateObjectsFromWriteResponse($objectsArray, $response)
 {
     $data = json_decode($response->getRawBody(), true);
     if ($response->getStatus() == 200) {
         $newLastModifiedVersion = $response->getHeader("Last-Modified-Version");
         if (isset($data['success'])) {
             foreach ($data['success'] as $ind => $key) {
                 $i = intval($ind);
                 $object = $objectsArray[$i];
                 $objectKey = $object->get('key');
                 if ($objectKey != '' && $objectKey != $key) {
                     throw new Exception("Item key mismatch in multi-write request");
                 }
                 if ($objectKey == '') {
                     $object->set('key', $key);
                 }
                 $object->set('version', $newLastModifiedVersion);
                 $object->synced = true;
                 $object->writeFailure = false;
             }
         }
         if (isset($data['failed'])) {
             foreach ($data['failed'] as $ind => $val) {
                 $i = intval($ind);
                 $object = $objectsArray[$i];
                 $object->writeFailure = $val;
             }
         }
     } elseif ($response->getStatus() == 204) {
         $objectsArray[0]->synced = true;
     }
 }
Exemplo n.º 20
0
 private function convertToBytes($memoryLimit)
 {
     if ('-1' === $memoryLimit) {
         return -1;
     }
     $memoryLimit = strtolower($memoryLimit);
     $max = strtolower(ltrim($memoryLimit, '+'));
     if (0 === strpos($max, '0x')) {
         $max = intval($max, 16);
     } elseif (0 === strpos($max, '0')) {
         $max = intval($max, 8);
     } else {
         $max = intval($max);
     }
     switch (substr($memoryLimit, -1)) {
         case 't':
             $max *= 1024;
         case 'g':
             $max *= 1024;
         case 'm':
             $max *= 1024;
         case 'k':
             $max *= 1024;
     }
     return $max;
 }
 /**
  * Output the content of the resource
  *
  * @param array $options An array of options for the output
  */
 public function outputContent(array $options = array())
 {
     if (empty($options['rpc_type'])) {
         $options['rpc_type'] = 'XML';
     }
     $resourceClass = 'mod' . $options['rpc_type'] . 'RPCResource';
     if (!$this->modx->resource instanceof $resourceClass) {
         $this->modx->log(modX::LOG_LEVEL_FATAL, 'Could not load ' . $options['rpc_type'] . '-RPC Server class.');
     }
     $this->modx->resource->process();
     $this->modx->resource->_output = $this->modx->resource->_content;
     /* collect any uncached element tags in the content and process them */
     $this->modx->getParser();
     $maxIterations = intval($this->modx->getOption('parser_max_iterations', null, 10));
     $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, false, '[[', ']]', array(), $maxIterations);
     $this->modx->parser->processElementTags('', $this->modx->resource->_output, true, true, '[[', ']]', array(), $maxIterations);
     if (!$this->getServer()) {
         $this->modx->log(modX::LOG_LEVEL_FATAL, 'Could not load ' . $options['rpc_type'] . '-RPC Server.');
     }
     $this->server->service();
     ob_get_level() && @ob_end_flush();
     while (ob_get_level() && @ob_end_clean()) {
     }
     exit;
 }
 /**
  * opening of the session - mandatory arguments won't be needed
  *
  * @param string $savePath
  * @param string $sessionName
  * @return bool
  */
 public function open($savePath, $sessionName)
 {
     if (!isset($this->_lifeTime)) {
         $this->_lifeTime = intval(ini_get("session.gc_maxlifetime"));
     }
     if (!isset($this->_refreshTime)) {
         $this->_refreshTime = ceil($this->_lifeTime / 3);
     }
     $this->_initSessionData = null;
     $this->_memcache = new Memcache();
     if (Kwf_Config::getValue('aws.simpleCacheCluster')) {
         $servers = Kwf_Util_Aws_ElastiCache_CacheClusterEndpoints::getCached(Kwf_Config::getValue('aws.simpleCacheCluster'));
     } else {
         if (Kwf_Cache_Simple::$memcacheHost) {
             $servers = array(array('host' => Kwf_Cache_Simple::$memcacheHost, 'port' => Kwf_Cache_Simple::$memcachePort));
         } else {
             throw new Kwf_Exception("no memcache configured");
         }
     }
     foreach ($servers as $s) {
         if (version_compare(phpversion('memcache'), '2.1.0') == -1 || phpversion('memcache') == '2.2.4') {
             // < 2.1.0
             $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
         } else {
             if (version_compare(phpversion('memcache'), '3.0.0') == -1) {
                 // < 3.0.0
                 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1, true, null, 10000);
             } else {
                 $this->_memcache->addServer($s['host'], $s['port'], true, 1, 1, 1);
             }
         }
     }
     return true;
 }
Exemplo n.º 23
0
function GetCounter()
{
    if (file_exists(COUNTER_FILE)) {
        return intval(file_get_contents(COUNTER_FILE));
    }
    return 0;
}
Exemplo n.º 24
0
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "throw") {
         return false;
     }
     if (count($args) > 2 || count($args) == 0) {
         return false;
     }
     $pl = $this->owner->getServer()->getPlayer($args[0]);
     if (!$pl) {
         $sender->sendMessage(mc::_("%1% not found", $args[0]));
         return true;
     }
     if (MPMU::apiVersion("1.12.0")) {
         $pl->teleport(new Vector3($pl->getX(), 128, $pl->getZ()));
     } else {
         $force = 64;
         if (isset($args[1])) {
             $force = intval($args[1]);
         }
         if ($force <= 4) {
             $force = 64;
         }
         $pl->setMotion(new Vector3(0, $force, 0));
     }
     return true;
 }
Exemplo n.º 25
0
 /**
  * 取消关注操作
  * @return json 返回操作后的JSON信息数据
  */
 public function unFollow()
 {
     // 安全过滤
     $fid = t($_POST['fid']);
     $res = $this->_follow_model->unFollow($this->mid, intval($fid));
     $this->ajaxReturn($res, $this->_follow_model->getError(), false !== $res);
 }
Exemplo n.º 26
0
 public static function Invite($callId, $transferUserId)
 {
     $transferUserId = intval($transferUserId);
     if ($transferUserId <= 0) {
         return false;
     }
     $res = VI\CallTable::getList(array('select' => array('ID', 'CALL_ID', 'USER_ID', 'CALLER_ID', 'CRM', 'TRANSFER_USER_ID', 'ACCESS_URL'), 'filter' => array('=CALL_ID' => $callId)));
     $call = $res->fetch();
     if (!$call) {
         return false;
     }
     if ($call['TRANSFER_USER_ID'] > 0) {
         self::Cancel($callId);
     }
     $call['TRANSFER_USER_ID'] = $transferUserId;
     VI\CallTable::update($call['ID'], array('TRANSFER_USER_ID' => $transferUserId));
     $call['USER_HAVE_PHONE'] = 'N';
     $res = CVoxImplantUser::GetList(array('select' => array('ID', 'IS_ONLINE_CUSTOM', 'UF_VI_PHONE', 'ACTIVE'), 'filter' => array('=ID' => $call['TRANSFER_USER_ID'], '=ACTIVE' => 'Y')));
     if ($userData = $res->fetch()) {
         $call['USER_HAVE_PHONE'] = $userData['UF_VI_PHONE'];
     }
     $command['COMMAND'] = 'inviteTransfer';
     $command['OPERATOR_ID'] = $call['USER_ID'];
     $command['TRANSFER_USER_ID'] = $call['TRANSFER_USER_ID'];
     $command['USER_HAVE_PHONE'] = $call['USER_HAVE_PHONE'];
     $http = new \Bitrix\Main\Web\HttpClient();
     $http->waitResponse(false);
     $http->post($call['ACCESS_URL'], json_encode($command));
     $crmData = array();
     if ($call['CRM'] == 'Y') {
         $crmData = CVoxImplantCrmHelper::GetDataForPopup($call['CALL_ID'], $call['CALLER_ID'], $transferUserId);
     }
     self::SendPullEvent(array('COMMAND' => 'inviteTransfer', 'USER_ID' => $transferUserId, 'CALL_ID' => $call['CALL_ID'], 'CALLER_ID' => $call['CALLER_ID'], 'CRM' => $crmData));
     return true;
 }
Exemplo n.º 27
0
 public function reSetCost()
 {
     $id = $this->input['id'] ? intval($this->input['id']) : 0;
     $ret = $this->obj->reSetCost($id);
     $this->addItem($ret);
     $this->output();
 }
Exemplo n.º 28
0
 function delete($oid = null)
 {
     $k = $this->_tbl_key;
     if ($oid) {
         $this->{$k} = intval($oid);
     }
     if (mosDBTable::delete($oid)) {
         $query = "DELETE FROM #__poll_data" . "\n WHERE pollid = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $query = "DELETE FROM #__poll_date" . "\n WHERE poll_id = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         $query = "DELETE from #__poll_menu" . "\n WHERE pollid = " . (int) $this->{$k};
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->_error .= $this->_db->getErrorMsg() . "\n";
         }
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 29
0
 function hookTop($params)
 {
     global $smarty;
     $smarty->assign('ENT_QUOTES', ENT_QUOTES);
     $smarty->assign('ajaxsearch', intval(Configuration::get('PS_SEARCH_AJAX')));
     return $this->display(__FILE__, 'blocksearch-top.tpl');
 }
Exemplo n.º 30
-15
 function onls()
 {
     $logdir = UC_ROOT . 'data/logs/';
     $dir = opendir($logdir);
     $logs = $loglist = array();
     while ($entry = readdir($dir)) {
         if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) {
             $logs = array_merge($logs, file($logdir . $entry));
         }
     }
     closedir($dir);
     $logs = array_reverse($logs);
     foreach ($logs as $k => $v) {
         if (count($v = explode("\t", $v)) > 1) {
             $v[3] = $this->date($v[3]);
             $v[4] = $this->lang[$v[4]];
             $loglist[$k] = $v;
         }
     }
     $page = max(1, intval($_GET['page']));
     $start = ($page - 1) * UC_PPP;
     $num = count($loglist);
     $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls');
     $loglist = array_slice($loglist, $start, UC_PPP);
     $this->view->assign('loglist', $loglist);
     $this->view->assign('multipage', $multipage);
     $this->view->display('admin_log');
 }