Example #1
0
      <?php 
media('Py4Inf-10-Tuples');
?>
       <p>Worked Exercise Screencasts: <a href="<?php 
echo $afs;
?>
/books/py4inf/exercises/Py4Inf-ex-10.mp4" target="_blank">Top-5 Words</a>
       </p>
    </div>
  </li>
  <li class="accordion-item">
    <a href="#panel17d" role="tab" class="accordion-title" id="panel1d-heading" aria-controls="panel17d">
      <h4>Chapter 11: Regular Expressions</h4></a>
    <div id="panel17d" class="accordion-content" role="tabpanel" data-tab-content aria-labelledby="panel17d-heading">
      <?php 
media('Py4Inf-11-Regex');
?>
,
      <br><a href="lectures/Py4Inf-11-Regex-Guide.pdf" target="_new">Regex-Guide</a>
        </p>
    </div>
  </li>
  <li class="accordion-item">
    <a href="#panel18d" role="tab" class="accordion-title" id="panel1d-heading" aria-controls="panel18d">
      <h4>Internet History, Technology, and Security</h4></a>
    <div id="panel18d" class="accordion-content" role="tabpanel" data-tab-content aria-labelledby="panel18d-heading">
      <p>When I teach from this book I spend two weeks on <a href="https://www.coursera.org/course/insidetheinternet" target="_blank">Internet History, Technology, and Security</a> between Chapters 11 and 12. Talking about history and technology allows the students to take a mental break from programming and lays the ground work for the second half of the book.
        </p>
    </div>
  </li>
  <li class="accordion-item">
<?php

include "repaso24.php";
$fun = suma(1, 2, 3, 4, 5, 6, 7);
$fun2 = suma(2, 2, 2, 2, 2);
echo "la suma da {$fun}<br>";
$fun = media(2, 5, 6, 4, 2, 8);
echo "la media da {$fun}<br>";
$fun = sumaPares(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
echo "la suma de los numeros pares da {$fun}<br>";
<?php

function media($v)
{
    $suma = 0;
    $media = 0;
    $contador = 0;
    for ($i = 0; $i < sizeof($v); $i++) {
        echo "Valor de la posicion " . $i . " : " . $v[$i] . "</br>";
        if ($v[$i] >= 0) {
            $suma = $suma + $v[$i];
            $contador++;
        } elseif ($v[$i] == -1) {
            break;
        }
    }
    if ($contador == 0) {
        echo "No puede calcular la media";
        return -1;
    }
    $media = $suma / $contador;
    return $media;
}
$func = media(array(0, -2, 0, -1, 5, 6));
echo $func;
Example #4
0
 function initTwig($file = null)
 {
     $dirs = $this->getDirs();
     /**
      * We need to duplicate every dir for proper relative includes ...
      *
      *
      */
     if ($file) {
         $tempDirs = $dirs;
         foreach ($dirs as $dir) {
             $partDir = realpath($dir) . path('ds');
             $tempDir = $partDir . substr(str_replace('\\', path('ds'), $file), 0, strrpos($file, path('ds')));
             if (is_dir($tempDir)) {
                 $tempDirs[] = $tempDir;
             }
         }
         $dirs = array_unique($tempDirs);
     }
     $this->twig = new TwigEnv(new Twig_Loader_Chain([new Twig_Loader_Filesystem($dirs), new \Twig_Loader_String()]), ['debug' => dev()]);
     $this->twig->addExtension(new Twig_Extension_StringLoader());
     /**
      * This should be added to Dev environment Provider.
      */
     $this->twig->addExtension(new Twig_Extension_Debug());
     /**
      * This should be added to Framework/Inter Provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('__', function ($key, $data = [], $lang = null) {
         return __($key, $data, $lang);
     }, ['is_safe' => ['html']]));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('config', function ($text, $default = null) {
         return config($text, $default);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('flash', function ($key, $delete = true) {
         return context()->getOrCreate(Flash::class)->get($key, $delete);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('url', function ($url, $params = [], $absolute = false) {
         return context()->get(Router::class)->make($url, $params, $absolute);
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('dev', function () {
         return dev();
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('implicitDev', function () {
         return implicitDev();
     }));
     $this->twig->addFunction(new Twig_SimpleFunction('prod', function () {
         return prod();
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('media', function ($file, $path = null, $relative = true, $base = null) {
         return media($file, $path, $relative, $base);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('relativePath', function ($key) {
         return relativePath($key);
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFunction(new Twig_SimpleFunction('select', function ($options, $attributes = [], $valueKey = null) {
         $select = new Select();
         $select->setAttributes($attributes ?? []);
         foreach ($options as $key => $option) {
             $select->addOption($valueKey ? $option->id : $key, $valueKey ? $option->{$valueKey} : $option);
         }
         return $select;
     }));
     /**
      * This should be added to Framework provider.
      */
     $this->twig->addFilter(new Twig_SimpleFilter('price', function ($price) {
         if (is_null($price)) {
             $price = 0.0;
         }
         $localeManager = resolve(Locale::class);
         return number_format($price, 2, $localeManager->getDecimalPoint(), $localeManager->getThousandSeparator()) . ' €';
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('roundPrice', function ($price) {
         if (is_null($price)) {
             $price = 0.0;
         }
         $localeManager = resolve(Locale::class);
         return trim((string) number_format($price, 2, $localeManager->getDecimalPoint(), $localeManager->getThousandSeparator()), '0') . ' €';
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('datetime', function ($date) {
         return (new Carbon($date))->format(resolve(Locale::class)->getDatetimeFormat());
     }));
     $this->twig->addFilter(new Twig_SimpleFilter('date', function ($date) {
         return (new Carbon($date))->format(resolve(Locale::class)->getDateFormat());
     }));
     $this->twig->getExtension('core')->setDateFormat(resolve(Locale::class)->getDateFormat(), '%d days');
 }
Example #5
0
function soma()
{
    $x = 5;
    $y = 1;
    echo $x + $y . "<hr>";
}
function media($p1, $p2, $p3)
{
    return $resultado = ($p1 + $p2 + $p3) / 3;
}
$alunos[0]["Nome"] = "Pedro";
$alunos[0]["Media"] = media(6, 8, 3);
$alunos[1]["Nome"] = "Maria";
$alunos[1]["Media"] = media(8, 5, 10);
$alunos[2]["Nome"] = "Diego";
$alunos[2]["Media"] = media(6, 8, 7);
function passou($valor)
{
    if ($valor >= 7) {
        return $passou = '<font color="blue">' . $valor . '</font><br/>';
    } else {
        return $passou = '<font color="red">' . $valor . '</font><br/>';
    }
}
function printMedias($a)
{
    for ($i = 0; $i < count($a); $i++) {
        echo "<b>Nome do Aluno:</b> " . $a[$i]["Nome"] . "<br/>";
        echo "<b>Media final:</b>" . passou($a[$i][Media]);
    }
}
        include "" . $template_dir . "/html/100_all-media result-header.html";
        //  get all media results of this page and present them as result listing
        $all = '1';
        $mode = '1';
        $media_results = array();
        $image_results = image($query, $link, 'image', $all, $urlx, $title, $image_dir, 'allImages', 'normSearch', 'camera60.gif', $mode, $media_only, $type, $category, $catid, $mark, $db, $prefix, $domain);
        //  prepare media results for XML output file
        if ($image_results && $out == 'xml') {
            $media_results = $image_results;
        }
        $audio_results = media($query, $link, 'audio', $all, $urlx, $title, $image_dir, 'foundAudio', 'normSearch', 'notes60.gif', $mode, $media_only, $type, $category, $catid, $mark, $db, $prefix, $domain);
        //  prepare media results for XML output file
        if ($audio_results && $out == 'xml') {
            $media_results = array_merge($media_results, $audio_results);
        }
        $video_results = media($query, $link, 'video', $all, $urlx, $title, $image_dir, 'foundVideo', 'normSearch', 'film60.gif', $mode, $media_only, $type, $category, $catid, $mark, $db, $prefix, $domain);
        //  prepare media results for XML output file
        if ($video_results && $out == 'xml') {
            $media_results = array_merge($media_results, $video_results);
        }
        //  if activated, prepare the XML result file
        if ($out == 'xml' && $xml_name) {
            media_xml($media_results, count($media_results), $query, round(getmicrotime() - $start_all, 3));
        }
        echo "\n                <br /><br />\n                <a class=\"navup\" href=\"#top\" title=\"Jump to Page Top\">" . $sph_messages['top'] . "</a>\n                ";
        break;
}
// if selected in Admin settings, show 'Most Popular Searches'
if ($most_pop == 1) {
    $bgcolor = 'odrow';
    $count = 0;
Example #7
0
# func_get_args & func_num_args
function somaTudo()
{
    $lista = func_get_args();
    $qntd = func_num_args();
    $total = 0;
    // 1 método
    //for ($i = 0; $i < $qntd; $i++) {
    //	$total += $lista[$i];
    //}
    // 2 método
    foreach ($lista as $item) {
        $total += $item;
    }
    echo "<br> {$total}";
}
somaTudo(1, 2, 3, 4, 5, 6);
# Funções variádicas
function media(...$valores)
{
    $total = array_sum($valores) / count($valores);
    return $total;
}
echo "<br>" . media(10, 10, 10);
# Retorno de Valores
function cubo($num)
{
    $x = $num * $num * $num;
    return $x;
}
echo "<br>" . cubo(5);
<?php

include "repaso22.php";
$v = array(7, 5, 9, 7, 2, 4, 5, 6, 5, 4, 8, 3, 1, 5);
$fun = suma($v);
echo "La suma del vector da: {$fun} <br>";
$fun = media($v);
echo "La media del vector da: {$fun} <br>";
$fun = sumaPares($v);
echo "La suma de los pares numeros pares del vector da: {$fun} <br>";
$fun = mediaPares($v);
echo "La media de los pares numeros pares del  del vector da: {$fun} <br>";
$fun = mediaImpares($v);
echo "La media de los pares numeros impares del  del vector da: {$fun} <br>";
$indicador = 1;
$fun = sumaPosiciones($v, $indicador);
if ($indicador == 1) {
    echo "La suma de las posiciones pares da: {$fun} <br>";
} else {
    echo "La suma de las posiciones impares da: {$fun} <br>";
}
$valor = 3;
$fun = contadorMayorQue($v, $valor);
echo "Hay {$fun} numeros mayores que {$valor} <br>";
$valor = 3;
$fun = contadorMenorQue($v, $valor);
echo "Hay {$fun} numeros mayores que {$valor} <br>";
$fun = maximo($v);
echo "El numero mas grande es: {$fun} <br>";
$fun = minimo($v);
echo "El numero mas pequeño es: {$fun} ";
<?php

echo "El total es: " . media(1, 3, 1, 3, 1, 3);
function media()
{
    $numeroArgumentos = func_num_args();
    $contadorNumeros = 0;
    $total = 0;
    for ($i = 0; $i < $numeroArgumentos; $i++) {
        $argumento = func_get_arg($i);
        if (is_numeric($argumento)) {
            $total += $argumento;
            $contadorNumeros++;
        }
    }
    return $total;
}
<?php

function media($p1, $p2, $p3, $p4)
{
    $risultato = ($p1 + $p2 + $p3 + $p4) / 4;
    return $risultato;
}
$media = media(6, 5, 7, 2);
echo "il risultato è " . $media;
Example #11
0
/**
 * Display avatar
 *
 * @param $url
 * @return string
 */
function categoryIcon($url)
{
    return $url ? media($url) : assetTheme('assets/img/categories/default.png');
}
Example #12
0
<!DOCTYPE html>
<html lang="">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="stylesheet" type="text/css" href=" ">
    </head>
    <body>
      <?php 
function media($v)
{
    $sum = 0;
    for ($i = 0; $i < sizeof($v); $i++) {
        $sum += $v[$i];
    }
    return $sum / sizeof($v);
}
$data = array(13, 54, 58, 8, 5, 2);
echo "la media es " . media($data);
?>
    </body>
</html>
Example #13
0
function reply_cb($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    $time = $w->get_creattime();
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $pic = urldecode(xiaojo("&" . $PicUrl, $from, $to));
            //$w->set_funcflag();
            return $pic;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    if ($w->get_event_type() == "subscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        include "sub.php";
                        $sisi = "title|【{$nickname}】欢迎关注我们的平台#pic|http://f.hiphotos.baidu.com/pic/w%3D230/sign=a34574e90d3387449cc5287f610ed937/30adcbef76094b36f9ce3154a2cc7cd98d109d2e.jpg@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                        //开场百
                        $sub = media(urldecode($sisi));
                        if ($nickname == "") {
                            $sub = "欢迎关注,回复1进入上墙模式";
                        }
                        return $sub;
                        //include './baeinsert.php';//可以在这里进行保存的
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        $unsub = media(urldecode(MOREN));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = xiaojo($menukey, $from, $to);
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    $content = trim($request['Content']);
    $firsttime = $content;
    if ($content !== "") {
        //$w->set_funcflag(); //如果有必要的话,加星标,方便在web处理
        $content = $w->biaoqing($content);
        //表情处理
        if (strstr($content, FLAG)) {
            $w->set_funcflag();
        }
        /*
        //执行判断,1进入上墙系统,2是投票
        //
        */
        $sql_check = "SELECT * FROM `weixin_flag` where `openid` = '{$from}'";
        $query_check = mysql_query($sql_check);
        $check = mysql_fetch_row($query_check);
        if (!$check[0]) {
            $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
            mysql_query($sql_flag);
        }
        if ($content == '取消' || $content == '退出') {
            $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
            $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
            mysql_query($sql_flag);
        }
        if ($check[1] == 1) {
            if ($content == '取消' || $content == '退出') {
                $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_flag);
            } else {
                file_get_contents("http://www.bestchoice88.com/Wall/1.php");
                //该地址为1.php上传后的地址
                $sql_name = "UPDATE  `weixin_flag` SET `nickname` = '{$nicheng}'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_name);
                $reply = "title|发送成功#pic|#url|{$weixin_wxq}@title|你已经成功发送,等待审核通过即可上墙了\n\nPs:点击查看大屏幕#url|{$weixin_wxq}@title|回复【取消】或【退出】返回主菜单";
            }
        }
        if ($check[1] == '2' || $check[1] == '4') {
            $sql_vote_check = "SELECT * FROM `weixin_flag` where `openid` = '{$from}'";
            $query_vote_check = mysql_query($sql_vote_check);
            $vote_check = mysql_fetch_row($query_vote_check);
            $vote_check = $vote_check[2];
            $sql_vote = "SELECT * FROM `weixin_vote` ";
            $query_vote = mysql_query($sql_vote);
            if ($content == '取消' || $content == '退出') {
                $reply = "title|欢迎关注{$weixin_name}#pic|@title|1.\t上墙#pic|@title|2.\t投票#pic|@title|回复对应的数字进入对应的模块#pic|@title|回复【取消】或【退出】返回主菜单";
                $sql_flag = "UPDATE  `weixin_flag` SET `flag` = '-1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_flag);
            } elseif ($content == '投票' && $vote_check == '1') {
                while ($vote = mysql_fetch_row($query_vote)) {
                    $name = $vote[1];
                    $id = $vote[0];
                    $idout .= "【" . $id . "】" . $name . "\n";
                }
                $reply = "title|投票系统\n每人只能投一票#pic|@title|输入选手名字面的序号进行投票\n\n" . $idout . "@title|回复【取消】或【退出】返回主菜单";
            } elseif ($vote_check !== '9' && ($content == '1' || $content == '2' || $content == '3' || $content == '4' || $content == '5' || $content == '6' || $content == '7' || $content == '8' || $content == '9' || $content == '10' || $content == '11' || $content == '12' || $content == '13' || $content == '14' || $content == '15')) {
                $sql_tou = "UPDATE  `weixin_vote` SET `res` = `res`+1  WHERE  `id` =  '{$content}';";
                mysql_query($sql_tou);
                $sql_vote_yes = "UPDATE  `weixin_flag` SET `vote` = '9'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_vote_yes);
                $sql_vote = "SELECT * FROM `weixin_vote` WHERE  `id` =  '{$content}';";
                $query_vote = mysql_query($sql_vote);
                $vote = mysql_fetch_row($query_vote);
                $name = $vote[1];
                $res = $vote[2];
                $reply = "title|投票成功#pic|#url|{$weixin_vote}@title|你成功地把宝贵的一票投给了\n\n【{$content}】号选手【{$name}】\n\nTa目前有【{$res}】票\n\n点击得票查看详情#url|{$weixin_vote}@title|发送【结果】查看最新数据#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } elseif ($vote_check == '9' && ($content == '1' || $content == '2' || $content == '3' || $content == '4' || $content == '5' || $content == '6' || $content == '7' || $content == '8' || $content == '9' || $content == '10' || $content == '11' || $content == '12' || $content == '13' || $content == '14' || $content == '15')) {
                $sql_vote = "SELECT * FROM `weixin_vote` WHERE  `id` =  '{$content}';";
                $query_vote = mysql_query($sql_vote);
                $vote = mysql_fetch_row($query_vote);
                $name = $vote[1];
                $res = $vote[2];
                $reply = "title|投票失败\n每人只能投一票#pic|#url|{$weixin_vote}@title|你已经投了1票给\n\n【{$content}】号选手【{$name}】\n\nTa目前有【{$res}】票\n\n点击查看得票详情#url|{$weixin_vote}@title|发送【结果】查看最新数据#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } elseif ($content == '结果' && $vote_check == '9' || $content == '投票' && $vote_check == '9') {
                while ($vote = mysql_fetch_row($query_vote)) {
                    $name = $vote[1];
                    $res = $vote[2];
                    $resout .= $name . "------>    【" . $res . "】票\n";
                }
                $reply = "title|你已经投过票了\n每人只能投一票#pic|#url|{$weixin_vote}@title|投票结果\n\n" . $resout . "\n\n点击得票查看详情#url|{$weixin_vote}@title|回复【取消】或【退出】返回主菜单";
            } else {
                $reply = "title|投票模式#pic|@title|你已经进入了投票模式\n\n发送【投票】进行投票,每人一票\n\n点击查看得票详情@title|回复【取消】或【退出】返回主菜单";
            }
        }
        if ($check[1] !== '1' && $check[1] !== '2') {
            if ($content == "1") {
                $sql_check = "UPDATE  `weixin_flag` SET `flag` = '1'  WHERE  `openid` =  '{$from}';";
                mysql_query($sql_check);
                $reply = "title|上墙模式#pic|#url|{$weixin_wxq}@title|你已经进入了上墙模式\n\n直接发送内容就可以有机会上墙了#url|{$weixin_wxq}@title|回复【取消】或【退出】返回主菜单#url|{$weixin_wxq}";
            } else {
                if ($content == "2") {
                    $sql_check = "UPDATE  `weixin_flag` SET `flag` = '2'  WHERE  `openid` =  '{$from}';";
                    mysql_query($sql_check);
                    $reply = "title|投票模式#pic|#url|{$weixin_vote}@title|你已经进入了投票模式\n\n发送【投票】进行投票,每人一票@title|回复【取消】或【退出】返回主菜单";
                } else {
                    $reply = MOREN;
                }
            }
        }
        /*
                
        		if($reply=="")
        		{
        			$reply = MOREN ;
        		}*/
        $reply = media(urldecode($reply));
        return $reply;
    } else {
        return MOREN;
    }
}
<?php

function media($v)
{
    $suma = 0;
    $media = 0;
    $contador = 0;
    for ($i = 0; $i < sizeof($v); $i++) {
        echo "Valor de la posicion " . $i . " : " . $v[$i] . "</br>";
        if ($v[$i] >= 0) {
            $suma = $suma + $v[$i];
            $contador++;
        } elseif ($v[$i] == -1) {
            break;
        }
    }
    if ($contador == 0) {
        echo "No puede calcular la media";
        return -1;
    }
    $media = $suma / $contador;
    //echo "$media";
    return $media;
}
$func = media(array(2, 2, 1, 4, 5, -6));
echo $func;
?>
 
					
					</a></div> 
					
					<div id="playlist"><a href="music.php"></a></div>
					<div id="type"    ><a href="music.php"><img src="img/back.png" width="28" height="28"/></a></div>
					
	</div>
	
<?php 
$send = $_GET['send'];
$back_folder = $_GET['back'];
if ($send == "1") {
    media();
    $curl = media("{$json}");
    //echo $curl;
    $array = json_decode($curl, true);
    $results = $array['result']["shares"];
    foreach ($results as $value) {
        $img_thumb_cambia = 'core/img/musica/Folder.png';
        echo ' 
					<div id="info_file">
						
							<div id="title"   ><a href="?media=music&send=' . ($send + 1) . '&directory=' . $value['file'] . '&back=1" onMouseOver="window.parent.document.getElementById(\'img_cambia\').src=(';
        echo "'{$img_thumb_cambia}'";
        echo ');" onmouseout="window.parent.document.getElementById(\'img_cambia\').src=(';
        echo "'css/img/xbmc.png'";
        echo ');">&ensp;&ensp;&ensp; ' . $value['label'] . '</a></div> 
							<div id="playlist"><a href="?media=music&send=' . ($send + 1) . '&directory=' . $value['file'] . '&back=1"></a></div>
							<div id="type"    ><a href="?media=music&send=' . ($send + 1) . '&directory=' . $value['file'] . '&back=1">';
Example #16
0
function reply_cb($request, $w)
{
    $to = $request['ToUserName'];
    $from = $request['FromUserName'];
    $time = $w->get_creattime();
    if ($w->get_msg_type() == "location") {
        $lacation = "x@" . (string) $request['Location_X'] . "@" . (string) $request['Location_Y'];
        $lacation = urlencode(str_replace('\\.', '\\\\.', $lacation));
        $lacation = urldecode(xiaojo($lacation, $from, $to));
        return $lacation;
    } else {
        if ($w->get_msg_type() == "image") {
            $PicUrl = $request['PicUrl'];
            $pic = urldecode(xiaojo("&" . $PicUrl, $from, $to));
            //$w->set_funcflag();
            return $pic;
        } else {
            if ($w->get_msg_type() == "voice") {
                return array("title" => "你好", "description" => "亲爱的主人", "murl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3", "hqurl" => "http://weixen-file.stor.sinaapp.com/b/xiaojo.mp3");
            } else {
                if ($w->get_msg_type() == "event") {
                    if ($w->get_event_type() == "subscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        return media(urldecode(MOREN));
                    } elseif ($w->get_event_type() == "unsubscribe") {
                        $sql_flag = "replace`weixin_flag` (`openid`,`flag`,`vote`,`nickname`) VALUES ('{$from}','-1','1','{$nicheng}')";
                        mysql_query($sql_flag);
                        $unsub = media(urldecode(MOREN));
                        return $unsub;
                    } elseif ($w->get_event_type() == "click") {
                        $menukey = $w->get_event_key();
                        $menu = xiaojo($menukey, $from, $to);
                        return $menu;
                    } else {
                        $menukey = $w->get_event_key();
                        return $menukey;
                    }
                }
            }
        }
    }
    $content = trim($request['Content']);
    $firsttime = $content;
    if ($content !== "") {
        //$w->set_funcflag(); //如果有必要的话,加星标,方便在web处理
        $content = $w->biaoqing($content);
        //表情处理
        if (strstr($content, FLAG)) {
            $w->set_funcflag();
        }
        /*话题判断函数开始*/
        function startsWith($haystack, $needle, $case = false)
        {
            if ($case) {
                return strcmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
            }
            return strcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
        }
        /*话题判断函数结束*/
        include "db.php";
        if (startsWith($content, $huati)) {
            file_get_contents(Web_ROOT . "/moni/test.php");
            $sql_name = "UPDATE  `weixin_flag` SET `nickname` = '{$nicheng}'  WHERE  `openid` =  '{$from}';";
            mysql_query($sql_name);
            $reply = "title|发送成功#pic|#url|{$weixin_wxq}@title|你已经成功发送,审核通过即可上墙!PS:点击我,查看微信墙!";
        }
        /*
                
        		if($reply=="")
        		{
        			$reply = MOREN ;
        		}*/
        $reply = media(urldecode($reply));
        return $reply;
    } else {
        return MOREN;
    }
}
Example #17
0
/**
 * Generate rectangle ad
 *
 * @return \Illuminate\Foundation\Application|mixed|string
 */
function generateRectangleAd()
{
    if (setting('rectangle-ad-image', false)) {
        return '<img src="' . media(setting('rectangle-ad-image')) . '" alt="."/>';
    }
    if (setting('rectangle-ad-code', false)) {
        return setting('rectangle-ad-code');
    }
    return '<img src="' . assetTheme('assets/img/ad-rect.png') . '" alt=".">';
}
Example #18
0
<html>
	<?php 
include_once "{$_SERVER['DOCUMENT_ROOT']}/workspace/Estudos/head.php";
include_once $_SERVER['DOCUMENT_ROOT'] . '/workspace/Estudos/functions/html.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/workspace/Estudos/menu.php';
?>
		<body>
			<div class="container" style="margin-top: 60px">
		<?php 
if (isset($_POST['enviar'])) {
    echo '<h1>O maior número lido é: ' . verificaMaior(30) . '</h1>';
    echo '<h1>O menor número lido é: ' . verificaMenor(30) . '</h1>';
    echo '<h1>A média dos número é: ' . media(30) . '</h1>';
} else {
    gerarInputNumero(30);
}
?>
			</div>
		</body>	
</html>
Example #19
0
/*function soma(){
    $x = 5;
    $y = 6;
    echo $x + $y."<br/>";
}

$x = 10; //Global

function soma($x=0,$y=0) {
    //$x -> escopo. Trabalha apenas dentro dessa função.
    echo $x + $y;
}

soma();*/
//Formatos que podemos passar nossos parametros: int, "string", false/true, null, array(), objetos
function media($p1, $p2, $p3, $p4)
{
    $resultado = ($p1 + $p2 + $p3 + $p4) / 4;
    return $resultado;
}
$alunos[0]["nome"] = "Pedrinho";
$alunos[0]["media"] = media(10, 4, 5, 8);
$alunos[1]["nome"] = "Marco";
$alunos[1]["media"] = media(10, 2, 8, 9);
$alunos[2]["nome"] = "Maira";
$alunos[2]["media"] = media(10, 9, 8, 10);
for ($i = 0; $i < count($alunos); $i++) {
    echo "<b>Nome do Aluno: </b>" . $alunos[$i]["nome"] . "<br>";
    echo "<b>Media final: </b>" . $alunos[$i]["media"] . "<br><br>";
}
<?php

include "libreria22.php";
$vSuma = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vMedia = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vSumaPares = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vmediaPares = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vMediaImpares = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vSumaPosiciones = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vContadorMayoresQue = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vContadorMenoresQue = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vMaximo = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$vMinimo = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
$fun = suma($vSuma);
echo "la suma da {$fun}<br>";
$fun = media($vMedia);
echo "la media da {$fun}<br>";
$fun = sumaPares($vSumaPares);
echo "la suma de los numeros pares da {$fun}<br>";
$fun = mediaPares($vmediaPares);
echo "la media de los numeros pares da {$fun}<br>";
$fun = mediaImpares($vMediaImpares);
echo "la media de los numeros impares da {$fun}<br>";
$indicador = 1;
$fun = sumaPosiciones($vSumaPosiciones, $indicador);
if ($indicador == 1) {
    echo "la suma de las posiciones de los numeros pares da {$fun}<br>";
} else {
    echo "la suma de las posiciones de los numeros impares da {$fun}<br>";
}
$fun = contadorMayoresQue($vContadorMayoresQue);
    echo media($q_bi_b, $total_series);
    ?>
</td>
                        <td><?php 
    echo media($p_bi_l, $total_series);
    ?>
</td>
                        <td><?php 
    echo media($s_bi_l, $total_series);
    ?>
</td>
                        <td><?php 
    echo media($t_bi_l, $total_series);
    ?>
</td>
                        <td><?php 
    echo media($q_bi_l, $total_series);
    ?>
</td>
                    </tr>
                </tbody>
            </table>
        </div>
        <br>
        <br>
        <br>
        <br>
        <?php 
}
?>
</div>
Example #22
0
<?php

/*
Cсlculo da mщdia ponderada
Autor:
    ?
Colaborador:
    Karlisson Bezerra
Tipo:
    math
Descriчуo:
    Calcula a mщdia ponderada - щ um algoritmo
    comum em qualquer curso de introduчуo р programaчуo,
    que pode variar de acordo com os pesos.
Complexidade:  
    O(1)
Dificuldade:
    facil
*/
function media($n1, $n2, $n3)
{
    $p1 = 4;
    $p2 = 5;
    $p3 = 6;
    return ($n1 * $p1 + $n2 * $p2 + $n3 * $p3) / ($p1 + $p2 + $p3);
}
print media(7.0, 8.0, 10.0);
Example #23
0
function xiaojo($key, $from, $to)
{
    global $yourdb, $yourpw;
    $key = urlencode($key);
    $yourdb = urlencode($yourdb);
    $from = urlencode($from);
    $to = urlencode($to);
    $post = "chat=" . $key . "&db=" . $yourdb . "&pw=" . $yourpw . "&from=" . $from . "&to=" . $to;
    $api = "http://www.xiaojo.com/api5.php";
    $replys = curlpost($post, $api);
    $reply = media(urldecode($replys));
    //多媒体转换
    return $reply;
}
Example #24
0
<?php

echo "La media es: " . media(1, 3, array(1, 3, "Hola", 1), 3, 1, 3);
function media()
{
    $numeroArgumentos = func_num_args();
    $contadorNumeros = 0;
    $total = 0;
    for ($i = 0; $i < $numeroArgumentos; $i++) {
        $argumento = func_get_arg($i);
        if (is_array($argumento)) {
            for ($j = 0; $j < count($argumento); $j++) {
                if (is_numeric($argumento[$j])) {
                    $total += $argumento[$j];
                    $contadorNumeros++;
                }
            }
        } else {
            if (is_numeric($argumento)) {
                $total += $argumento;
                $contadorNumeros++;
            }
        }
    }
    return $total / $contadorNumeros;
}
<?php

include "libreria24.php";
$fun = suma(1, 1, 1, 1, 1, 1);
$fun2 = suma(2, 2, 2, 2);
echo "la suma da {$fun}<br>";
$fun = media(4, 5, 6, 6, 4, 5);
echo "la media da {$fun}<br>";
$fun = sumaPares(1, 2, 3, 5, 4, 8, 6, 9, 7);
echo "la suma de los numeros pares da {$fun}<br>";
Example #26
0
 protected function createElementByType($type, $name, Field $field)
 {
     $auto = ['id', 'hidden', 'email', 'password', 'text', 'textarea', 'editor', 'integer', 'decimal'];
     if (in_array($type, $auto)) {
         return $this->{'add' . ucfirst($type)}($name);
     } elseif (in_array($type, ['file', 'pdf'])) {
         $dir = $field->getAbsoluteDir($field->getSetting('pckg.dynamic.field.dir'), $field->getSetting('pckg.dynamic.field.privateUpload'));
         $fullPath = $this->record->{$field->field} ? media($this->record->{$field->field}, null, true, $dir) : null;
         if ($field->getSetting('pckg.dynamic.field.uploadDisabled')) {
             $element = $this->addDiv();
             if ($field->getSetting('pckg.dynamic.field.generateFileUrl')) {
                 $element->addChild('<a class="btn btn-info btn-md" title="Generate ' . $type . '" href="' . $field->getGenerateFileUrlAttribute($this->record) . '"><i class="fa fa-refresh" aria-hidden="true"></i> Generate ' . $type . '</a>');
             }
             if ($this->record->{$field->field}) {
                 $element->addChild('&nbsp;&nbsp;<a class="btn btn-success btn-md" title="Download ' . $type . '" href="' . $fullPath . '"><i class="fa fa-download" aria-hidden="true"></i> Download ' . $this->record->{$field->field} . '</a>');
             }
         } else {
             $element = $this->addFile($name);
             $element->setPrefix('<i class="fa fa-file' . ($type == 'pdf' ? '-pdf' : '') . '-o" aria-hidden="true"></i>');
             if ($fullPath) {
                 $element->setAttribute('data-image', $fullPath);
             }
             $element->setAttribute('data-type', $type);
         }
         return $element;
     } elseif ($type == 'picture') {
         $element = $this->addPicture($name);
         $element->setPrefix('<i class="fa fa-picture-o" aria-hidden="true"></i>');
         $element->setAttribute('data-url', url('dynamic.records.field.upload', ['table' => $this->table, 'field' => $field, 'record' => $this->record]));
         $dir = $field->getAbsoluteDir($field->getSetting('pckg.dynamic.field.dir'));
         $element->setAttribute('data-image', img($this->record->{$field->field}, null, true, $dir));
         $element->setAttribute('data-type', 'picture');
         return $element;
     } elseif ($type == 'datetime') {
         $element = $this->addDatetime($name);
         $element->setPrefix('<i class="fa fa-calendar" aria-hidden="true"></i>');
         return $element;
     } elseif ($type == 'date') {
         $element = $this->addDate($name);
         $element->setPrefix('<i class="fa fa-calendar" aria-hidden="true"></i>');
         return $element;
     } elseif ($type == 'time') {
         $element = $this->addTime($name);
         $element->setPrefix('<i class="fa fa-clock-o" aria-hidden="true"></i>');
         return $element;
     } elseif (in_array($type, ['slug', 'order', 'hash'])) {
         return $this->addText($name);
     } elseif (in_array($type, ['json'])) {
         return $this->addTextarea($name);
     } elseif ($type == 'boolean') {
         return $this->addCheckbox($name);
     } elseif ($type == 'select') {
         if ($this->record && ($relation = $field->getRelationForSelect($this->record, $this->foreignRecord))) {
             $element = $this->addSelect($name);
             /**
              * @T00D00 - add setting for select placeholder for speciffic field
              */
             $element->addOption(null, ' -- select value -- ');
             foreach ($relation as $id => $value) {
                 $element->addOption($id, str_replace(['<br />', '<br/>', '<br>'], ' - ', $value));
             }
             return $element;
         } else {
             return $this->{'addText'}($name);
         }
     } else {
         dd('Unknown dynamic form type: ' . $type);
     }
 }