Пример #1
1
function sync_object($object_type, $object_name)
{
    # Should only provide error information on stderr: put stdout to syslog
    $cmd = "geni-sync-wireless {$object_type} {$object_name}";
    error_log("SYNC(cmd) " . $cmd);
    $descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open($cmd, $descriptors, $pipes);
    $std_output = stream_get_contents($pipes[1]);
    # Should be empty
    $err_output = stream_get_contents($pipes[2]);
    fclose($pipes[1]);
    fclose($pipes[2]);
    $proc_value = proc_close($process);
    $full_output = $std_output . $err_output;
    foreach (split("\n", $full_output) as $line) {
        if (strlen(trim($line)) == 0) {
            continue;
        }
        error_log("SYNC(output) " . $line);
    }
    if ($proc_value != RESPONSE_ERROR::NONE) {
        error_log("WIRELESS SYNC error: {$proc_value}");
    }
    return $proc_value;
}
Пример #2
0
 function save_data($db_object, $common, $fLang_id, $_POST, $default)
 {
     $id = array();
     while (list($key, $value) = each($_POST)) {
         ${$key} = $value;
         if (ereg("^lang_", $key)) {
             $id[] = substr($key, 5);
         }
         if (ereg("^charset_", $key)) {
             $ids = split("_", $key);
             $id1 = $ids[1];
             $char[$id1] = $value;
         }
     }
     $charset_table = $common->prefix_table("language_charset");
     while (list($kk, $vv) = @each($char)) {
         $upqry = "update {$charset_table} set charset='{$vv}' where language_id='{$kk}'";
         $upqry = "replace into {$charset_table} set language_id='{$kk}',charset='{$vv}'";
         $db_object->insert($upqry);
     }
     $lang_table = $common->prefix_table("language");
     $lang = "lang_" . $fLang_id;
     for ($i = 0; $i < count($id); $i++) {
         $lan = "lang_" . $id[$i];
         $lan = ${$lan};
         $mysql = "update {$lang_table} set {$lang}='{$lan}' where lang_id='{$id[$i]}'";
         $db_object->insert($mysql);
     }
 }
Пример #3
0
 function request($info)
 {
     $httpObj = new http_class();
     $nhHttp = new nhhttp($httpObj);
     $partnerId = 10;
     //Điền partnerID đc cung cấp
     $key = 'x@l0-th1nkn3t';
     // Điền key của Partner đc cung cấp
     //print_r($_REQUEST);
     $paymentMethodList = split("\\.", trim($_REQUEST['m']));
     //print_r($paymentMethodList);
     $paymentMethod = trim($paymentMethodList[0]);
     $postValue = array();
     $postValue['o'] = "requestTransaction";
     $postValue['itemid'] = $info['product_id'];
     $postValue['itemdesc'] = urlencode($info['name']);
     $postValue['price'] = $info['price'];
     $postValue['method'] = 'Mua_ngay';
     $postValue['partnerId'] = $partnerId;
     $signal = $this->encodeSignal($postValue['itemid'] . $postValue['itemdesc'] . $postValue['price'] . $postValue['method'] . '|' . $key);
     $postValue['signal'] = $signal;
     $postValue['param'] = "";
     $return = $nhHttp->post("http://payment.xalo.vn/api", $postValue);
     $result = explode("|", $return[0]);
     return $result;
 }
Пример #4
0
function printTicketsHTMLTable($accounts, $ticketCost, $ticketTime)
{
    $output = "";
    global $ticketInformation;
    global $ticketLogoFile;
    // the $accounts array contain the username,password|| first element as it's originally
    // used to be a for CSV table header
    array_shift($accounts);
    // we align 3 tables for each row (each line)
    // for each 4th entry of a new ticket table we put it in a new row of it's own
    $trCounter = 0;
    foreach ($accounts as $userpass) {
        list($user, $pass) = split(",", $userpass);
        if ($trCounter > 2) {
            $trCounter = 0;
        }
        if ($trCounter == 2) {
            $trTextEnd = "</tr>";
        } else {
            $trTextEnd = "";
        }
        if ($trCounter == 0) {
            $trTextBeg = "<tr>";
        } else {
            $trTextBeg = "";
        }
        $output .= "\n\t\t\t{$trTextBeg}\n\t\t\t\t<td>\n\t\t\t\t\t<table border='1' cellpadding='1' cellspacing='1' height='140' width='211'>\n\t\t\t\t\t\t<tbody>\n\t\t\t\t\t\t<tr align='center'>\n\t\t\t\t\t\t\t<td colspan='2'>\n\t\t\t\t\t\t\t\t<img src='{$ticketLogoFile}' alt='Logo' />\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<b>Login</b>: \n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<font size='2'>\n\t\t\t\t\t\t\t\t{$user}\n\t\t\t\t\t\t\t\t</font>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<b>Password</b>:\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<font size='2'>\n\t\t\t\t\t\t\t\t{$pass}\n\t\t\t\t\t\t\t\t</font>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<b>Validity</b>:\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<font size='2'>\n\t\t\t\t\t\t\t\t{$ticketTime}\n\t\t\t\t\t\t\t\t</font>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<b>Price</b>:\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t<font size='2'>\n\t\t\t\t\t\t\t\t{$ticketCost}\n\t\t\t\t\t\t\t\t</font>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan='2' valign='top'>\n\t\t\t\t\t\t\t\t<font size='1'>\n\t\t\t\t\t\t\t\t{$ticketInformation}\n\t\t\t\t\t\t\t\t</font>\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</tbody>\n\t\t\t\t\t</table>\n\t\t\t\t\t\n\t\t\t\t</td>\n\t\t\t{$trTextEnd}\n\t\t";
        $trCounter++;
    }
    print "\n\t\t <style type='text/css'>\n\t\t\t@page { size:landscape; margin-top:20cm; margin-right:0cm; margin-left:0cm; margin-bottom: 0px; marks:cross;}\n\t\t</style>\n\t\t<html><body> \n\t\t\t<table style='maring-top: 15px; margin-left: auto; margin-right: auto;' \n\t\t\t\t\tcellspacing='15'>\n\t\t\t\t<tbody>\n\t\t\t\t\t\t\t{$output}\n\t\t\t\t</tbody>\n\t\t\t</table>\t\n\t\t</body></html>\n\t";
}
Пример #5
0
 function WriteHTML($html)
 {
     //HTML parser
     $html = str_replace("\n", ' ', $html);
     $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($a as $i => $e) {
         if ($i % 2 == 0) {
             //Text
             if ($this->HREF) {
                 $this->PutLink($this->HREF, $e);
             } else {
                 $this->Write(5, $e);
             }
         } else {
             //Tag
             if ($e[0] == '/') {
                 $this->CloseTag(strtoupper(substr($e, 1)));
             } else {
                 //Extract properties
                 $a2 = split(' ', $e);
                 $tag = strtoupper(array_shift($a2));
                 $prop = array();
                 foreach ($a2 as $v) {
                     if (ereg('^([^=]*)=["\']?([^"\']*)["\']?$', $v, $a3)) {
                         $prop[strtoupper($a3[1])] = $a3[2];
                     }
                 }
                 $this->OpenTag($tag, $prop);
             }
         }
     }
 }
Пример #6
0
 function quote($method = '')
 {
     global $order, $shipping_weight, $shipping_num_boxes;
     if (!$order) {
         $order = new order();
         $shipping_weight = $_SESSION['cart']->show_weight();
     }
     $order_delivery_country = $order->delivery['country'];
     if (MODULE_SHIPPING_TABLE_MODE == 'price') {
         $order_total = $_SESSION['cart']->show_total();
     } else {
         $order_total = $shipping_weight;
     }
     $table_cost = split("[:,]", MODULE_SHIPPING_TABLE_COST);
     $size = sizeof($table_cost);
     for ($i = 0, $n = $size; $i < $n; $i += 2) {
         if ($order_total <= $table_cost[$i]) {
             $shipping = $table_cost[$i + 1];
             break;
         }
     }
     if (MODULE_SHIPPING_TABLE_MODE == 'weight') {
         $shipping = $shipping * $shipping_num_boxes;
     }
     $this->quotes = array('id' => $this->code, 'module' => MODULE_SHIPPING_TABLE_TEXT_TITLE, 'methods' => array(array('id' => $this->code, 'title' => MODULE_SHIPPING_TABLE_TEXT_WAY, 'cost' => $shipping + MODULE_SHIPPING_TABLE_HANDLING)));
     if ($this->tax_class > 0) {
         $this->quotes['tax'] = olc_get_tax_rate($this->tax_class, $order_delivery_country['id'], $order->delivery['zone_id']);
     }
     if (olc_not_null($this->icon)) {
         $this->quotes['icon'] = olc_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
Пример #7
0
 function open($database, $host, $user, $password)
 {
     $connect_string = "";
     if (!$database) {
         return 0;
     }
     $host = split(":", $host);
     if ($host[0]) {
         $connect_string .= "host={$host['0']}";
     }
     if (isset($host[1])) {
         $connect_string .= " port={$host['1']}";
     }
     if ($user) {
         $connect_string .= " user={$user} ";
     }
     if ($password) {
         $connect_string .= " password={$password} ";
     }
     $connect_string .= " dbname={$database}";
     $this->connect_id = @pg_Connect($connect_string);
     if ($this->connect_id) {
         @pg_exec($this->connect_id, "SET DateStyle TO 'ISO'");
     }
     return $this->connect_id;
 }
Пример #8
0
 public function isMatch($path)
 {
     if ($this->route == $path) {
         return true;
     }
     // Should be split up, filling the params should be done later!
     if ($this->isDynamic) {
         $route = split('/', $this->route);
         $path = split('/', $path);
         if (count($route) == count($path)) {
             $match = true;
             $params = [];
             for ($i = 0; $i < count($route); $i++) {
                 if (strpos($route[$i], ':') !== false) {
                     $params[$route[$i]] = $path[$i];
                 } elseif ($route[$i] != $path[$i]) {
                     $match = false;
                 }
             }
             if ($match) {
                 $this->params = $params;
                 return true;
             }
         }
     }
     return false;
 }
 function preProcessNode($n)
 {
     /* remove existing poshRDF hooks */
     $n['a']['class'] = isset($n['a']['class']) ? preg_replace('/\\s?rdf\\-(s|p|o|o-xml)/', '', $n['a']['class']) : '';
     if (!isset($n['a']['rel'])) {
         $n['a']['rel'] = '';
     }
     /* inject poshRDF hooks */
     foreach ($this->terms as $term => $infos) {
         if (!in_array('rel', $infos) && $this->hasClass($n, $term) || $this->hasRel($n, $term)) {
             if ($this->v('scope', '', $infos)) {
                 $infos[] = 'p';
             }
             foreach (array('s', 'p', 'o', 'o-xml') as $type) {
                 if (in_array($type, $infos)) {
                     $n['a']['class'] .= ' rdf-' . $type;
                     $n['a']['class'] = preg_replace('/(^|\\s)' . $term . '(\\s|$)/s', '\\1mf-' . $term . '\\2', $n['a']['class']);
                     $n['a']['rel'] = preg_replace('/(^|\\s)' . $term . '(\\s|$)/s', '\\1mf-' . $term . '\\2', $n['a']['rel']);
                 }
             }
         }
     }
     $n['a']['class m'] = split(' ', $n['a']['class']);
     $n['a']['rel m'] = split(' ', $n['a']['rel']);
     return $n;
 }
Пример #10
0
  function getTemplateFileName () {
    $request = CRM_Utils_System::currentPath();
    if (false !== strpos($request, '..')) {
      die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
    }

    $request = split ('/',$request);
    $tplfile = NULL;
    $smarty= CRM_Core_Smarty::singleton( );
    $smarty->assign("options",array());
    if (CRM_Utils_Array::value(2, $request)) {
      $tplfile = _civicrm_api_get_camel_name($request[2]);
      $tplfile = explode('?', $tplfile);
      $tpl = 'dataviz/'.$tplfile[0].'.tpl';
    }
    if (CRM_Utils_Array::value(3, $request)) {
      $r3 = _civicrm_api_get_camel_name($request[3]);
      $smarty->assign("id",$r3);
    }
    if (!$tplfile) {
      $tpl = "CRM/Civizualise/Page/Main.tpl";
    }
    if( !$smarty->template_exists($tpl) ){
      header("Status: 404 Not Found");
      die ("Can't find the requested template file templates/$tpl");
    }
    return $tpl;
  }
Пример #11
0
function dnpt($ext_ip, $ext_prefix, $int_prefix)
{
    $debug = false;
    // This is not a complete solution!!!!!!!!!!!!!!!!!!!!!!!!!!
    $ext_prefix = str_replace(":", "", $ext_prefix);
    $int_prefix = str_replace(":", "", $int_prefix);
    // hehe
    $sauce = hexdec(split(":", $ext_ip)[4]);
    $ext_c = icmpChecksum(hex2bin($ext_prefix));
    $int_c = icmpChecksum(hex2bin($int_prefix));
    if ($debug) {
        print_r(unpack('n', $int_c));
    }
    $diff = unpack('n', $ext_c)[1] - unpack('n', $int_c)[1];
    if ($diff < 0) {
        $diff = 0xffff + $diff;
    }
    $diff = $sauce - $diff;
    if ($debug) {
        print bin2hex($ext_c);
        print "\n";
        print bin2hex($int_c);
        print "\n";
        print dechex($diff);
        print "\n";
    }
    $out = split(":", $ext_ip);
    $out[4] = dechex($diff);
    $out = join($out, ":");
    return $out;
}
Пример #12
0
 private function _sendPearMail($from, $to, $subject, $message)
 {
     require_once 'Xinc/Ini.php';
     try {
         $smtpSettings = Xinc_Ini::getInstance()->get('email_smtp');
     } catch (Exception $e) {
         $smtpSettings = null;
     }
     if ($smtpSettings != null) {
         $mailer = Mail::factory('smtp', $smtpSettings);
     } else {
         $mailer = Mail::factory('mail');
     }
     $recipients = split(',', $to);
     $headers = array();
     if (isset($smtpSettings['localhost'])) {
         $from = str_replace('@localhost', '@' . $smtpSettings['localhost'], $from);
     }
     $headers['From'] = $from;
     $headers['Subject'] = $subject;
     $res = $mailer->send($recipients, $headers, $message);
     if ($res === true) {
         return $res;
     } else {
         return false;
     }
 }
Пример #13
0
 /**
  * Does the component match the given selector?
  *
  * @param string $c_name    The component name.
  * @param string $c_channel The component channel.
  * @param string $selector  The selector.
  *
  * @return boolen True if the component matches.
  */
 public static function matches($c_name, $c_channel, $selector)
 {
     $selectors = split(',', $selector);
     if (in_array('ALL', $selectors)) {
         return true;
     }
     foreach ($selectors as $selector) {
         if (empty($selector)) {
             continue;
         }
         if (strpos($selector, '/') !== false) {
             list($channel, $name) = split('/', $selector, 2);
             if ($c_channel == $channel && $c_name == $name) {
                 return true;
             }
             continue;
         }
         if (substr($selector, 0, 8) == 'channel:') {
             if ($c_channel == substr($selector, 8)) {
                 return true;
             }
             continue;
         }
         if ($c_name == $selector) {
             return true;
         }
     }
     return false;
 }
Пример #14
0
function ascii_j($p, $o, $res = '')
{
    list($p, $o) = ajxp($res, $p, $o);
    //build
    if ($o) {
        $ret = ascii_arr($o);
        $r = explode(' ', $o);
    } else {
        if ($p) {
            list($start, $length) = split("-", $p);
        } else {
            $start = 128;
            $length = 1000;
        }
        for ($i = $start; $i <= $start + $length; $i++) {
            $r[] = $i;
        }
        $ret .= ascii_menu($start, $length);
    }
    //signs
    foreach ($r as $k => $v) {
        if ($v) {
            $bt .= ljb('', 'insert', $v . ' ', chr_b($v)) . ' ';
        }
    }
    $ret .= divs('font-size:medium; line-height:140%;', $bt);
    return $ret;
}
Пример #15
0
function returnMacAddress($remoteIp)
{
    exec("/usr/sbin/arp -n", $arpSplitted);
    $ipFound = false;
    // Cicle the array to find the match with the remote ip address
    foreach ($arpSplitted as $value) {
        // Split every arp line, this is done in case the format of the arp
        // command output is a bit different than expected
        $valueSplitted = split(" ", $value);
        foreach ($valueSplitted as $spLine) {
            if (preg_match("/{$remoteIp}/", $spLine)) {
                $ipFound = true;
            }
            // The ip address has been found, now rescan all the string
            // to get the mac address
            if ($ipFound) {
                // Rescan all the string, in case the mac address, in the string
                // returned by arp, comes before the ip address
                reset($valueSplitted);
                foreach ($valueSplitted as $spLine) {
                    $pg = preg_match("/[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f][:-]" . "[0-9a-f][0-9a-f]/i", $spLine);
                    if ($pg) {
                        return $spLine;
                    }
                }
            }
            $ipFound = false;
        }
    }
    return false;
}
Пример #16
0
 function network()
 {
     $netstat_b = execute_program('netstat', '-nbdi | cut -c1-25,44- | grep Link | grep -v \'* \'');
     $netstat_n = execute_program('netstat', '-ndi | cut -c1-25,44- | grep Link | grep -v \'* \'');
     $lines_b = split("\n", $netstat_b);
     $lines_n = split("\n", $netstat_n);
     $results = array();
     for ($i = 0, $max = sizeof($lines_b); $i < $max; $i++) {
         $ar_buf_b = preg_split("/\\s+/", $lines_b[$i]);
         $ar_buf_n = preg_split("/\\s+/", $lines_n[$i]);
         if (!empty($ar_buf_b[0]) && !empty($ar_buf_n[3])) {
             $results[$ar_buf_b[0]] = array();
             $results[$ar_buf_b[0]]['rx_bytes'] = $ar_buf_b[3];
             $results[$ar_buf_b[0]]['rx_packets'] = $ar_buf_n[3];
             $results[$ar_buf_b[0]]['rx_errs'] = $ar_buf_n[4];
             $results[$ar_buf_b[0]]['rx_drop'] = $ar_buf_n[8];
             $results[$ar_buf_b[0]]['tx_bytes'] = $ar_buf_b[4];
             $results[$ar_buf_b[0]]['tx_packets'] = $ar_buf_n[5];
             $results[$ar_buf_b[0]]['tx_errs'] = $ar_buf_n[6];
             $results[$ar_buf_b[0]]['tx_drop'] = $ar_buf_n[8];
             $results[$ar_buf_b[0]]['errs'] = $ar_buf_n[4] + $ar_buf_n[6];
             $results[$ar_buf_b[0]]['drop'] = $ar_buf_n[8];
         }
     }
     return $results;
 }
Пример #17
0
 /**
  * Index action
  *
  */
 public function indexAction()
 {
     $model = $this->_getPhotoModel();
     // Arrgh, not really DRY but what the hell, move to model...
     // Created at
     $createdAt = array();
     $prevYear = 0;
     foreach ($model->fetchArchive() as $data) {
         $split = split('-', $data['date']);
         if ($split[0] != $prevYear) {
             $months = array();
         }
         $months[$split[1]] = $data['count'];
         $createdAt[$split[0]] = $months;
         $prevYear = $split[0];
     }
     // Taken at
     $takenAt = array();
     $prevYear = 0;
     foreach ($model->fetchArchive('taken_on') as $data) {
         $split = split('-', $data['date']);
         if ($split[0] != $prevYear) {
             $months = array();
         }
         $months[$split[1]] = $data['count'];
         $takenAt[$split[0]] = $months;
         $prevYear = $split[0];
     }
     $this->view->createdAt = $createdAt;
     $this->view->takenAt = $takenAt;
 }
Пример #18
0
function read_history($history_file, $history_pos, $repo_path)
{
    $fp = fopen($history_file, "r") or die("Unable to open file!");
    $pos = -2;
    // Skip final new line character (Set to -1 if not present)
    $lines = array();
    $currentLine = '';
    while (-1 !== fseek($fp, $pos, SEEK_END)) {
        $char = fgetc($fp);
        if (PHP_EOL == $char) {
            $lines[] = $currentLine;
            $currentLine = '';
        } else {
            $currentLine = $char . $currentLine;
        }
        $pos--;
    }
    list($result, $build_id, $branch, $commit_id, $ci_pipeline_time) = split('[|]', $lines[$history_pos]);
    list($dummy, $result) = split('[:]', $result);
    $result = trim($result);
    list($dummy, $build_id) = split('[:]', $build_id);
    $build_id = trim($build_id);
    list($dummy, $branch) = split('[:]', $branch);
    $branch = trim($branch);
    list($dummy, $commit_id) = split('[:]', $commit_id);
    $commit_id = substr(trim($commit_id), -10);
    list($dummy, $ci_pipeline_time) = split('[:]', $ci_pipeline_time);
    $ci_pipeline_time = substr(trim($ci_pipeline_time), -10);
    $history = array("result" => $result, "build_id" => $build_id, "branch" => $branch, "commit_id" => $commit_id, "artifact_path" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}", "log" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}/ci.log", "iso" => "{$repo_path}/ci_fuel_opnfv/artifact/{$branch}/{$build_id}/opnfv-{$build_id}.iso", "ci_pipeline_time" => $ci_pipeline_time);
    return $history;
}
 public function GetFEventListHtml()
 {
     $event = M('event');
     // 查询当前所有的工作状态并且分页
     $count = $event->count();
     $page = new \Think\Page($count, C('PAGE_COUNT'), 'p1');
     $page->setP('p1');
     $orderby['eventid'] = 'desc';
     $list = $event->order($orderby)->limit($page->firstRow . ',' . $page->listRows)->select();
     // 进行返回前的处理
     for ($i = 0; $i < count($list); $i++) {
         $list[$i]['overtime'] = split(' ', $list[$i]['overtime'])[0];
         $timeNow = date("Y-m-d h:i:s");
         $overtime = $list[$i]['overtime'];
         if ($timeNow < $overtime) {
             $list[$i]['overtimestatus'] = 0;
         } else {
             $list[$i]['overtimestatus'] = 1;
         }
     }
     // 		dump ( $list );
     // 		return;
     $this->assign('list', $list);
     // 赋值数据集
     $this->assign('page', $page->show());
     // 赋值分页输出
     $this->display();
 }
Пример #20
0
 /**
  * FUnction to add git repository for the user
  * @event object
  * @return msg
  **/
 function eventAddGitRepo(EventControler $evtcl)
 {
     //$msg = '';
     $goto = $evtcl->goto;
     //check if the below is already exist
     //if(!$this->checkIfGitRepositoryExist($evtcl->repo_name, $evtcl->repo_url,$evtcl->iduser)) {
     if (!$this->checkIfGitRepositoryExist($evtcl->repo_url, $evtcl->iduser)) {
         //echo $evtcl->repo_name.",".$evtcl->repo_url."--".$evtcl->iduser;die();
         $repo_name1 = split('/', $evtcl->repo_url);
         $size = sizeof($repo_name1);
         $repo_name = split('\\.git', $repo_name1[$size - 1]);
         //$path = getcwd()."/plugin/Git/";
         $path = "plugin/Git/repos/";
         $path .= $repo_name[0];
         //echo $path;die();
         if (is_dir($path)) {
             $sql = "INSERT INTO user_gitrepo(`iduser`,`git_repo`,`git_repourl`)\n\t\t\t\t  VALUES(" . $evtcl->iduser . ",'" . $repo_name[0] . "','" . $evtcl->repo_url . "')";
             $this->query($sql);
             //echo "git clone ".$evtcl->repo_url."";die();
             //echo "git clone ".$evtcl->repo_url."  $path".$evtcl->repo_name."";die();
             //system("git clone ".$evtcl->repo_url."  $path".$evtcl->repo_name."");
             $_SESSION['msg'] = "New Git Repository has been added successfully.";
         } else {
             $_SESSION['msg'] = 'Need do <b>git clone ' . $evtcl->repo_url . '</b> inside /plugin/Git/repos/ folder before adding the Git Repository<br /><br />';
         }
     } else {
         $_SESSION['msg'] = "Duplicate Entry, Git Repository Already Exist Please check Repository Name or URL to avoid the duplicates.";
     }
     //echo $msg;
     $evtcl->setDisplayNext(new Display($goto));
 }
Пример #21
0
function diff2($page1, $page2, $type = 'sidediff')
{
    if ($type == 'htmldiff') {
        global $tikilib, $prefs;
        //$search = "#(<[^>]+>|\s*[^\s<]+\s*|</[^>]+>)#";
        $search = "#(<[^>]+>|[,\"':\\s]+|[^\\s,\"':<]+|</[^>]+>)#";
        preg_match_all($search, $page1, $out, PREG_PATTERN_ORDER);
        $page1 = $out[0];
        preg_match_all($search, $page2, $out, PREG_PATTERN_ORDER);
        $page2 = $out[0];
    } else {
        $page1 = split("\n", $page1);
        $page2 = split("\n", $page2);
    }
    $z = new Text_Diff($page1, $page2);
    if ($z->isEmpty()) {
        $html = '';
    } else {
        $context = 2;
        $words = 1;
        if (strstr($type, "-")) {
            list($type, $opt) = explode("-", $type, 2);
            if (strstr($opt, "full")) {
                $context = sizeof($page1);
            }
            if (strstr($opt, "char")) {
                $words = 0;
            }
        }
        //echo "<pre>";print_r($z);echo "</pre>";
        if ($type == 'unidiff') {
            require_once 'renderer_unified.php';
            $renderer = new Text_Diff_Renderer_unified($context);
        } else {
            if ($type == 'inlinediff') {
                require_once 'renderer_inline.php';
                $renderer = new Text_Diff_Renderer_inline($context, $words);
            } else {
                if ($type == 'sidediff') {
                    require_once 'renderer_sidebyside.php';
                    $renderer = new Text_Diff_Renderer_sidebyside($context, $words);
                } else {
                    if ($type == 'bytes' && $prefs['feature_actionlog_bytes'] != 'y') {
                        require_once 'renderer_bytes.php';
                        $renderer = new Text_Diff_Renderer_bytes();
                    } else {
                        if ($type == 'htmldiff') {
                            require_once 'renderer_htmldiff.php';
                            $renderer = new Text_Diff_Renderer_htmldiff(sizeof($page1));
                        } else {
                            return "";
                        }
                    }
                }
            }
        }
        $html = $renderer->render($z);
    }
    return $html;
}
Пример #22
0
 public function start()
 {
     while ($this->exitCount < 20000) {
         $this->exitCount++;
         $out = "";
         $line = "";
         while ($line = fgets(STDIN)) {
             if (strpos($line, ';') !== false) {
                 break;
             }
             $out .= $line;
         }
         // Parses the input
         $input = split("\n", $out);
         $player = $input[0];
         $air = $input[1];
         $score = $input[2];
         $width = $input[3];
         $height = $input[4];
         if ($air == null || $width == null || $height == null) {
             break;
         }
         $map = array();
         for ($y = 0; $y < $height; $y++) {
             $this->map[$y] = str_split($input[$y + 5]);
         }
         $this->run();
     }
 }
Пример #23
0
 public function parseParams()
 {
     global $_GET;
     // get zoom from GET paramter
     $this->zoom = $_GET['zoom'] ? intval($_GET['zoom']) : 0;
     if ($this->zoom > 18) {
         $this->zoom = 18;
     }
     // get lat and lon from GET paramter
     list($this->lat, $this->lon) = split(',', $_GET['center']);
     $this->lat = floatval($this->lat);
     $this->lon = floatval($this->lon);
     // get zoom from GET paramter
     if ($_GET['size']) {
         list($this->width, $this->height) = split('x', $_GET['size']);
         $this->width = intval($this->width);
         $this->height = intval($this->height);
     }
     if ($_GET['markers']) {
         $markers = split('%7C|\\|', $_GET['markers']);
         foreach ($markers as $marker) {
             list($markerLat, $markerLon, $markerImage) = split(',', $marker);
             $markerLat = floatval($markerLat);
             $markerLon = floatval($markerLon);
             $markerImage = basename($markerImage);
             $this->markers[] = array('lat' => $markerLat, 'lon' => $markerLon, 'image' => $markerImage);
         }
     }
     if ($_GET['maptype']) {
         if (array_key_exists($_GET['maptype'], $this->tileSrcUrl)) {
             $this->maptype = $_GET['maptype'];
         }
     }
 }
Пример #24
0
function plgexample_poller_bottom () {
        global $config;
        /* **** BEGIN example starting an other PHP commands file here "poller_cmd_plgexample.php" */
#        include_once($config["base_path"] . "/lib/poller.php");
#        include_once($config["base_path"] . "/lib/data_query.php");
#        include_once($config["base_path"] . "/lib/graph_export.php");
#        include_once($config["base_path"] . "/lib/rrd.php");
#        $command_string = read_config_option("path_php_binary");
#        $extra_args = "-q " . $config["base_path"] . "/plugins/plgexample/poller_cmd_plgexample.php";
#        exec_background($command_string, "$extra_args");
        /* **** END example starting an other PHP commands file */

        /* otherwise start your commands here */
	/* record the start time */
	list($micro,$seconds) = split(" ", microtime());
	$start = $seconds + $micro;

	/* perform all thold checks */
	$tholds = plgexample_check_all_thresholds ();
	$hosts  = plgexample_update_host_status ();
	plgexample_cleanup_log ();

	/* record the end time */
	list($micro,$seconds) = split(" ", microtime());
	$end = $seconds + $micro;

	/* log statistics */
	$thold_stats = sprintf("Time:%01.4f plgexample:%s Hosts:%s", $end - $start, $tholds, $hosts);
	cacti_log(strtoupper('plgexample').' STATS: ' . $plgexample_stats, false, 'SYSTEM');
	db_execute("REPLACE INTO settings (name, value) VALUES ('stats_plgexample', '$plgexample_stats')");
}
Пример #25
0
 public function stats($bitlyUrl)
 {
     // Take only first hash or url. Ignore others.
     $a = split(',', $bitlyUrl);
     $postFields = '&hash=' . $this->getHash($a[0]);
     return $this->process('stats', $postFields);
 }
Пример #26
0
function get_device_useragent($device)
{
    global $astman;
    $response = $astman->send_request('Command', array('Command' => "sip show peer {$device}"));
    $astout = explode("\n", $response['data']);
    $ua = "";
    foreach ($astout as $entry) {
        if (eregi("useragent", $entry)) {
            list(, $value) = split(":", $entry);
            $ua = trim($value);
        }
    }
    if ($ua) {
        if (stristr($ua, "Aastra")) {
            return "aastra";
        }
        if (stristr($ua, "Grandstream")) {
            return "grandstream";
        }
        if (stristr($ua, "snom")) {
            return "snom";
        }
        if (stristr($ua, "Cisco")) {
            return "cisco";
        }
        if (stristr($ua, "Polycom")) {
            return "polycom";
        }
    }
    return null;
}
Пример #27
0
 function getTopLevelCategories()
 {
     global $wgCategoriesArticle;
     wfLoadExtensionMessages('Sitemap');
     $results = array();
     $revision = Revision::newFromTitle(Title::newFromText(wfMsg('categories_article')));
     if (!$revision) {
         return $results;
     }
     // INTL: If there is a redirect to a localized page name, follow it
     if (strpos($revision->getText(), "#REDIRECT") !== false) {
         $revision = Revision::newFromTitle(Title::newFromRedirect($revision->getText()));
     }
     $lines = split("\n", $revision->getText());
     foreach ($lines as $line) {
         if (preg_match('/^\\*[^\\*]/', $line)) {
             $line = trim(substr($line, 1));
             switch ($line) {
                 case "Other":
                 case "wikiHow":
                     break;
                 default:
                     $results[] = $line;
             }
         }
     }
     return $results;
 }
Пример #28
0
function scrapeGoogle($q)
{
    $q = urlencode($q);
    $url = "http://www.google.com/uds/GwebSearch?callback=google.search.WebSearch.RawCompletion&context=0&lstkp=0&rsz=large&hl=en&source=gsc&gss=.com&sig=c1cdabe026cbcfa0e7dc257594d6a01c&q={$q}%20site%3Awikihow.com&gl=www.google.com&qid=124c49541548cd45a&key=ABQIAAAAYdkMNf23adqRw4vVq1itihTad9mjNgCjlcUxzpdXoz7fpK-S6xTT265HnEaWJA-rzhdFvhMJanUKMA&v=1.0";
    $contents = file_get_contents($url);
    #echo $q . "\n";
    $result = preg_match_all('@unescapedUrl":"([^"]*)"@u', $contents, $matches);
    $ids = array();
    $params = split("{", $contents);
    #print_r($params); exit;
    #echo $contents; echo "$q\n"; print_r($matches); exit;
    #print_r($matches);
    foreach ($matches[1] as $m) {
        $m = str_replace('http://www.wikihow.com/', '', $m);
        $r = Title::newFromURL($m);
        if ($r == '') {
            continue;
        }
        if (!$r) {
            echo "Couldn't make title out of {$r}\n";
            continue;
        } else {
            if ($r->getNamespace() != NS_MAIN) {
                continue;
            } else {
                if ($r->getArticleID() > 0) {
                    $ids[] = $r->getArticleID();
                    #echo "adding link from {$r->getText()} to " . urldecode($q) . "\n";
                }
            }
        }
    }
    return $ids;
}
 function execute($requests)
 {
     if (!OPENPNE_USE_ALBUM) {
         handle_kengen_error();
     }
     $v = array();
     $target_c_album_image_ids = $requests['target_c_album_image_ids'];
     // アルバム写真が選択されていない場合はエラー
     if (!$target_c_album_image_ids) {
         admin_client_redirect('edit_album_image_list', "アルバム写真が選択されていません");
     }
     $id_ary = split(":", $target_c_album_image_ids);
     $album_image_list = array();
     foreach ($id_ary as $id) {
         $album_image = db_album_image_get_c_album_image4id($id);
         if (!$album_image) {
             admin_client_redirect('edit_album_image_list', '指定されたアルバムは存在しません');
         }
         $member = db_member_c_member4c_member_id($album_image['c_member_id']);
         $album_image['c_member'] = $member;
         array_push($album_image_list, $album_image);
     }
     $this->set('album_image_list', $album_image_list);
     $this->set('target_c_album_image_ids', $target_c_album_image_ids);
     $this->set($v);
     return 'success';
 }
Пример #30
0
 function dspSkinCSS_PageDidLoad()
 {
     // determine skin type/skin/theme
     $cssTemplate = $skinName = $skinThemeName = NULL;
     @(list(, , , $cssTemplate, $skinTypeName, $skinName, $skinThemeName) = split('/', $_SERVER['PATH_INFO']));
     $cssFilePath = WFWebApplication::appDirPath(WFWebApplication::DIR_SKINS) . '/' . $skinTypeName . '/' . $skinName . '/' . $cssTemplate;
     if (!file_exists($cssFilePath)) {
         header("HTTP/1.0 404 Not Found");
         print "No css file at: {$cssFilePath}";
         exit;
     }
     // set the skin's wrapper information
     $skin = $this->invocation->rootSkin();
     $skin->setDelegateName($skinTypeName);
     $skin->setSkin($skinName);
     $skin->setTemplateType(WFSkin::SKIN_WRAPPER_TYPE_RAW);
     $skin->setValueForKey($skinThemeName, 'skinThemeName');
     // load the theme vars into our smarty for this module
     $this->requestPage->assign('skinThemeVars', $skin->valueForKey('skinManifestDelegate')->loadTheme($skinThemeName));
     $this->requestPage->assign('cssFilePath', $cssFilePath);
     $this->requestPage->assign('skinDir', $skin->getSkinDir());
     $this->requestPage->assign('skinDirShared', $skin->getSkinDirShared());
     header("Content-Type: text/css");
     // make CSS cacheable for a day at least
     $seconds = 24 * 60 * 60;
     // cache control - we can certainly safely cache the search results for 15 minutes
     header('Pragma: ');
     // php adds Pragma: nocache by default, so we have to disable it
     header('Cache-Control: max-age=' . $seconds);
     // Format: Fri, 30 Oct 1998 14:19:41 GMT
     header('Expires: ' . gmstrftime("%a, %d %b %Y %T ", time() + $seconds) . ' GMT');
 }