Exemple #1
0
function post2emoncms($json)
{
    $url = "/emoncms3/api/post?apikey=ae903ccd020f6b05f94cb6f7ca86bd93&json=" . $json;
    echo $url;
    echo "\r\n";
    getcontent("127.0.0.1", 80, $url);
}
Exemple #2
0
function bottled()
{
    global $db;
    $storeInfo = $db->table('csm_store_tall_copy')->setFiles(array('id', 'shop_title', 'shop_url', 'user_id'))->order('rand()')->where(array('t_type' => 1))->limit(1)->selectOne();
    $newInfo = $db->table('csm_ul_wx')->setFiles(array('url', 'id'))->where(array('t_type' => 1))->order('id desc')->limit(1)->selectOne();
    if ($storeInfo && $newInfo) {
        $content = getcontent($newInfo['url'], $newInfo['id']);
        $pids = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
        $piddd = $pids[rand(0, 11)];
        $re = $db->table('a_tmall_wx')->insert(array('title' => $content['title'], 'content' => $content['content'], 'createtime' => time(), 'shop_title' => $storeInfo['shop_title'], 'shop_pic' => $storeInfo['shop_url'], 'shop_user_id' => $storeInfo['user_id'], 'shop_id' => $storeInfo['id'], 'wx_id' => $newInfo['id'], 'pid' => $piddd));
        if ($re) {
            $db->table('csm_store_tall_copy')->where(array('id' => $storeInfo['id']))->delete();
            $db->table('csm_ul_wx')->where(array('id' => $newInfo['id']))->update(array('t_type' => 2));
            echo 1;
        } else {
            echo 2;
        }
    }
}
Exemple #3
0
     }
 }
 $configContent = getcontent(cfgFilePath . cfgDefaultConfig);
 $configContent = str_replace('DATABASE_SERVER', $_POST['databaseserver'], $configContent);
 $configContent = str_replace('DATABASE_USER', $_POST['databaseuser'], $configContent);
 $configContent = str_replace('DATABASE_PASS', $_POST['databasepassword'], $configContent);
 $configContent = str_replace('DATABASE_NAME', $_POST['database'], $configContent);
 $configContent = str_replace('DATABASE_PRE', $_POST['tablepre'], $configContent);
 $configContent = str_replace('GDFONT', $_POST['gdfont'], $configContent);
 $configContent = str_replace('ADMINNAME', $_POST['username'], $configContent);
 $configContent = str_replace('ADMINPASS', $_POST['password'], $configContent);
 if (!$error) {
     $fp = fopen(cfgIncludeDir . 'config.inc.php', 'w');
     fwrite($fp, trim($configContent));
     fclose($fp);
     $sqlData = getcontent(cfgFilePath . cfgSqlData);
     installdb($sqlData, $_POST['deldb']);
     if ($error) {
         $contents = '<center><br><BR>TITLE<BR></center>';
         $title = '<b>' . $errorInfo . '</b><br><br>';
         $contents = str_replace('TITLE', $title, $contents);
         $finish = 'style="display:none" >&nbsp;&nbsp;<input type="submit" class="button" value="&nbsp;关	闭&nbsp;" ';
         showform('index.php?step=finish', '安装过程发生错误', '请根据信息检查错误。', $contents, '', $finish);
         exit;
     }
     $fp = fopen('install.lock', 'w+');
     fclose($fp);
     $contents = '&nbsp;&nbsp;<b>安装完成</b><br><br>';
     $contents .= '&nbsp;&nbsp;<b><font color="red">请检查 install 目录是否存在.<br>';
     $contents .= '&nbsp;&nbsp;如果存在请立即删除,以防别人利用此程序获得您的相关资料.</font></b><br></p>';
     $finish = 'style="display:none" >&nbsp;&nbsp;<input type="submit" class="button" value="&nbsp;关	闭&nbsp;" ';
$verificacion_vehiculo = strtoupper($_POST["verificacion_vehiculo"]);
$km_vehiculo = $_POST["km_vehiculo"];
$renl_vehiculo = $_POST["renl_vehiculo"];
$tiposerv_vehiculo = $_POST["tiposerv_vehiculo"];
$edofisico_vehiculo = strtoupper($_POST["edofisico_vehiculo"]);
sleep(2);
/*pa q se tarde*/
$objUnidadT = new UnidadDeTransporte();
/*objeto de la clase unidad de transporte*/
$respuesta = new stdclass();
/*se crea la variable para la respuesta json*/
if ($objUnidadT->insertarUnidadDeTransporte($noeco_vehiculo, $noinv_vehiculo, $localidad_vehiculo, $municipio_vehiculo, $marca_vehiculo, $tipo_vehiculo, $modelo_vehiculo, $placas_vehiculo, $km_vehiculo, $noid_vehiculo, $nomotor_vehiculo, $nocilintros_vehiculo, $renl_vehiculo, $aseguradora_vehiculo, $poliza_vehiculo, $exped_vehiculo, $vigencia_vehiculo, $verificacion_vehiculo, $tiposerv_vehiculo, $edofisico_vehiculo) == true) {
    /*se llama a la fucion insertar y devuelve el resultado true o false*/
    $respuesta->informe = "Se ha Insertado un Nuevo Vehiculo";
} else {
    $respuesta->informe = "Error al Intentar Insertar Vehiculo<br> Revisa los Datos y Vuelve a Intentar";
}
function getcontent($enlace)
{
    /*para obtener el 'echo' del otro archivo*/
    ob_start();
    include $enlace;
    $out = ob_get_clean();
    return $out;
}
$respuesta->tabla = getcontent('unidad_de_transporte_Muestra.php');
/*implementacion de la funcion get contente para almacenar en una variable*/
$respuestajson = json_encode($respuesta);
/*se convierte a json*/
echo $respuestajson;
/*imprime respuesta convertida*/
         fprintf($f, $frequency . "b");
         echo "Frequency set: " . $frequency . "\n";
     }
     if ($settings->baseid != $baseid) {
         $baseid = $settings->baseid;
         fprintf($f, $baseid . "i");
         echo "Base station set: " . $baseid . "\n";
     }
     $raspberrypi->set_running();
 }
 if (time() - $remotetimer > 30 && $settings->remotesend == true) {
     $remotetimer = time();
     $remotedata .= "]";
     echo "Sending remote data";
     //echo $remotedata."\n";
     getcontent($settings->remotedomain, 80, $settings->remotepath . "/input/bulk.json?apikey=" . $settings->remoteapikey . "&data=" . $remotedata);
     $ni = 0;
     $remotedata = "[";
     $start_time = time();
 }
 $data = fgets($f);
 if ($data && $data != "\n") {
     if ($data[0] == ">") {
         echo "MESSAGE RX:" . $data;
         $data = trim($data);
         $len = strlen($data);
         /*
         For some as yet unknown reason periodically when sending data out from the rfm12pi
                   and maybe as part of the script the rfm12pi settings get set unintentionally. 
                   It has been suggested that this could be due to the data string to be sent being
                   corrupted and turning into a settings string.
 }
 for ($i = 0; $i < 1000; $i++) {
     if (!strstr($goodtemplate, "{manytext_all}")) {
         break 1;
     }
     $pageparse = getcontent($key, "2");
     if (strlen($pageparse) <= 10) {
         $pageparse = getcontent2($key, "4");
     }
     $goodtemplate = preg_replace("/{manytext_all}/", $pageparse, $goodtemplate, 1);
 }
 for ($i = 0; $i < 1000; $i++) {
     if (!strstr($goodtemplate, "{minitext_all}")) {
         break 1;
     }
     $pageparse = getcontent($key, "1");
     $pageparsemini = explode(".", $pageparse);
     srand((double) microtime() * 1000000);
     shuffle($pageparsemini);
     $pageparsemini = array_slice($pageparsemini, 0, 5);
     $pageparsemini = implode(".", $pageparsemini);
     if (strlen($pageparsemini) <= 10) {
         $pageparse = getcontent2($key, "1");
         $pageparsemini = explode(".", $pageparse);
         srand((double) microtime() * 1000000);
         shuffle($pageparsemini);
         $pageparsemini = array_slice($pageparsemini, 0, 5);
         $pageparsemini = implode(".", $pageparsemini);
     }
     $goodtemplate = preg_replace("/{minitext_all}/", $pageparse, $goodtemplate, 1);
 }
Exemple #7
0
    curl_setopt($curl, CURLOPT_USERAGENT, 'Baiduspider+(+http://www.google.com/search/spider.htm)');
    //伪装成百度蜘蛛
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    //抓取转跳
    curl_setopt($curl, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
    //gzip解压
    curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)");
    $data = curl_exec($curl);
    // $infos = (curl_getinfo($curl));//返回抓取网页参数的值(数组);
    curl_close($curl);
    return $data;
}
$furl = 'http://dongtaiwang.com/loc/download.php';
$udata = @getcontent($furl);
$fgpattern = "|<div id=\"image_center\" align=\"center\"><a href=\"([^\\s]*)\"\\sclass=\"download\" target=\"_blank\">免费下载(.*?)</a></div>|";
preg_match_all($fgpattern, $udata, $fgarr);
//使用正则匹配所有href=
$title = $fgarr[2][0];
$fgdurl = 'http://dongtaiwang.com' . $fgarr[1][0];
echo '<pre><BR>FG最新版本:' . $title;
echo '<BR>下载地址:' . $fgdurl . '</pre>';
//放到任何支持PHP curl的空间即可直接下载FQ工具
if ($fgdurl) {
    $content = @getcontent($fgdurl);
    header('cache-control:public');
    header('content-type:application/octet-stream');
    header('content-disposition:attachment; filename=' . basename($fgdurl));
    echo $content;
}
function fallback_parser($url, $page_source)
{
    // get charset
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 GTB5");
    $c = curl_exec($ch);
    $content_type = curl_getinfo($ch, CURLINFO_CONTENT_TYPE);
    curl_close($ch);
    if (stristr($content_type, 'charset')) {
        $charset = substr($content_type, strpos($content_type, 'charset') + 8);
        if (strstr($charset, ';')) {
            $charset = substr($charset, 0, strpos($charset, ';'));
        }
    } else {
        $charset = mb_detect_encoding($page_source);
    }
    // fetch through readability
    $postfields = 'token=&extensionType=addon&extensionVersion=2.4&extensionBrowser=firefox&fromEmbed=0&legacyBookmarklet=0&url=' . urlencode($url) . '&doc=' . urlencode($page_source) . '&charset=' . $charset . '&read=1';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "http://www.readability.com/articles/queue");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:23.0) Gecko/20100101 Firefox/23.0");
    $c = curl_exec($ch);
    curl_close($ch);
    $readability_article_id = getcontent($c, 'Location: http://www.readability.com/articles/', "\n");
    $html = str_get_html(file_get_contents('http://www.readability.com/articles/' . trim($readability_article_id['content']) . '?readbar=1'));
    // get content
    $h1 = $html->find("h1.entry-title", 0)->innertext;
    $body = $html->find("div.entry-content", 0)->innertext;
    $source_html = str_get_html($page_source);
    $title = $source_html->find("title", 0)->innertext;
    // unnest img:s from p:s (to remove indent)
    $body = str_get_html($body);
    foreach ($body->find('p') as $p) {
        if (count($p->find('img')) == 1) {
            $orig_p = $p->outertext;
            $img = $p->find('img', 0)->outertext;
            $p->find('img', 0)->outertext = '';
            if (strlen($p->outertext < 4)) {
                $p->outertext = $img;
            } else {
                $p->outertext = $orig_p;
            }
        }
    }
    // remove flattr-buttons (flattr are capitalist scum)
    foreach ($body->find('a.FlattrButton') as $flattrbtn) {
        $flattrbtn->outertext = '';
    }
    // wrap in article structure
    $content = '<div class="article"><h1>' . $h1 . '</h1>' . $body . '<address><a href="' . $url . '">' . $title . '</a></address></div>';
    return $content;
}