Пример #1
0
    function draw_performance_footer()
    {
        global $config_show_performance_footer, $querycount, $querytime, $querylog, $pagename, $hook_cache_hits, $hook_cache;
        $performance_footer_id = uniqid("performance");
        if ($config_show_performance_footer) {
            $querylog = sortmulti($querylog, "time", "desc", FALSE, FALSE);
            # --- If configured (for debug/development only) show query statistics
            ?>
	<?php 
            if ($pagename == "collections") {
                ?>
<br/><br/><br/><br/><br/><br/><br/>
	<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><div style="float:left;"><?php 
            } else {
                ?>
<div style="float:right; margin-right: 10px;"><?php 
            }
            ?>
	<table class="InfoTable" style="float: right;margin-right: 10px;">
	<tr><td>Page Load</td><td><?php 
            show_pagetime();
            ?>
</td></tr>
	<?php 
            if (isset($hook_cache_hits) && isset($hook_cache)) {
                ?>
		<tr><td>Hook cache hits</td><td><?php 
                echo $hook_cache_hits;
                ?>
</td></tr>	
		<tr><td>Hook cache entries</td><td><?php 
                echo count($hook_cache);
                ?>
</td></tr>
		<?php 
            }
            ?>
	<tr><td>Query count</td><td><?php 
            echo $querycount;
            ?>
</td></tr>
	<tr><td>Query time</td><td><?php 
            echo round($querytime, 4);
            ?>
</td></tr>
	<?php 
            $dupes = 0;
            foreach ($querylog as $query => $values) {
                if ($values['dupe'] > 1) {
                    $dupes++;
                }
            }
            ?>
	<tr><td>Dupes</td><td><?php 
            echo $dupes;
            ?>
</td></tr>
	<tr><td colspan=2><a href="#" onClick="document.getElementById('querylog<?php 
            echo $performance_footer_id;
            ?>
').style.display='block';return false;">&gt;&nbsp;details</a></td></tr>
	</table>
	<table class="InfoTable" id="querylog<?php 
            echo $performance_footer_id;
            ?>
" style="display: none; float: <?php 
            if ($pagename == 'collections') {
                ?>
left<?php 
            } else {
                ?>
right<?php 
            }
            ?>
; margin: 10px;">
	<?php 
            foreach ($querylog as $query => $values) {
                if (substr($query, 0, 7) != "explain" && $query != "show warnings") {
                    $show_warnings = false;
                    if (strtolower(substr($query, 0, 6)) == "select") {
                        $explain = sql_query("explain extended " . $query);
                        /*$warnings=sql_query("show warnings");
                        		$show_warnings=true;*/
                    }
                    ?>
		<tr><td align="left"><div style="word-wrap: break-word; width:350px;"><?php 
                    echo $query;
                    if ($show_warnings) {
                        foreach ($warnings as $warning) {
                            echo "<br /><br />" . $warning['Level'] . ": " . htmlentities($warning['Message']);
                        }
                    }
                    ?>
</div></td><td>&nbsp;
		<table class="InfoTable">
		<?php 
                    if (strtolower(substr($query, 0, 6)) == "select") {
                        ?>
<tr>
			<?php 
                        foreach ($explain[0] as $explainitem => $value) {
                            ?>
				<td align="left">   
				<?php 
                            echo $explainitem;
                            ?>
<br /></td><?php 
                        }
                        ?>
</tr><?php 
                        for ($n = 0; $n < count($explain); $n++) {
                            ?>
<tr><?php 
                            foreach ($explain[$n] as $explainitem => $value) {
                                ?>
				<td align="left">   
					<?php 
                                echo str_replace(",", ", ", $value);
                                ?>
</td><?php 
                            }
                            ?>
</tr><?php 
                        }
                    }
                    ?>
		</table>
		</td><td><?php 
                    echo round($values['time'], 4);
                    ?>
</td>
		</td><td><?php 
                    echo $values['dupe'] > 1 ? '' . $values["dupe"] . 'X' : '1';
                    ?>
</td></tr>
		<?php 
                }
            }
            ?>
	</table>
	</div>
	<?php 
        }
    }
Пример #2
0
 function univisionID($id)
 {
     dbug('univisionID');
     $ret = 'http://cdn-download.mcm.univision.com/videos_mcm/' . $id . '.js';
     dbug('url=' . $ret);
     $ret = CargaWebCurl($ret);
     if (enString($ret, "Access Denied")) {
         setErrorWebIntera("El vídeo de Univisión está bloqueado.");
         return;
     }
     $obtenido = array('enlaces' => array());
     //imagen
     $imagen = entre1y2($ret, '"src_image_url":"', '"');
     $imagen = strtr($imagen, array('\\' => ''));
     dbug('imagen=' . $imagen);
     //titulo
     $titulo = entre1y2($ret, '"def_title":"', '"');
     $titulo = jsonRemoveUnicodeSequences($titulo);
     $titulo = limpiaTitulo($titulo);
     dbug('titulo=' . $titulo);
     if (!enString($ret, '"published_urls":[]')) {
         dbug('No aparece "published_urls":[]');
         $json = substr($ret, strposF($ret, '('));
         $json = substr($json, 0, strrpos($json, ')'));
         dbug_($json);
         $json = json_decode($json, true);
         dbug_r($json);
         $urls = array();
         if (isset($json['published_urls'])) {
             foreach ($json['published_urls'] as &$url) {
                 if (enString($url['embed_url'], '.mp4')) {
                     $u =& $url['embed_url'];
                     dbug_($u);
                     $p = strrposF($u, '_');
                     $f = strpos($u, '.', $p);
                     $calidad = substr($u, $p, $f - $p);
                     $urls[] = array($u, $calidad);
                 }
             }
         }
         dbug('urls: ' . count($urls));
         //ya tenemos las urls en formato: /120615_2708697_El_Talisman_Capitulo_98_99___Ultimo_capitulo_1339800465_2000.mp4
         //ordenar
         if (count($urls) > 0) {
             $urls = sortmulti($urls, 1, "123", true);
         }
     }
     if (enString($ret, '"published_urls":[]') || isset($urls) && count($urls) === 0) {
         dbug('No se pueden encontrar urls. Usando método 2');
         // http://vmscdn-download.s3.amazonaws.com/videos_mcm/variant/2912557.m3u8
         $m3u8FuenteUrls = 'http://vmscdn-download.s3.amazonaws.com/videos_mcm/variant/' . $id . '.m3u8';
         dbug('$m3u8FuenteUrls = ' . $m3u8FuenteUrls);
         $m3u8FuenteUrls = CargaWebCurl($m3u8FuenteUrls);
         dbug($m3u8FuenteUrls);
         preg_match('@http://.*media(.*?)_[0-9]{3,4}.m3u8@', $m3u8FuenteUrls, $matches);
         dbug_r($matches);
         $urlBase = $matches[1];
         $calidades = array(2000, 1200, 810, 800, 510, 500, 270, 150);
         $urls = array();
         foreach ($calidades as $calidad) {
             $urlT = 'http://h.univision.com/media' . $urlBase . '_' . $calidad . '.mp4';
             $urls[] = array($urlT, $calidad);
         }
         //ya tenemos las urls en formato: /120615_2708697_El_Talisman_Capitulo_98_99___Ultimo_capitulo_1339800465_2000.mp4
         //ya está ordenado
     }
     $urls_length = count($urls);
     for ($i = 0; $i < $urls_length; $i++) {
         if ($urls[$i][1] == 2000) {
             $preContext = array('http' => array('method' => 'HEAD', 'header' => "User-agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0\r\n" . "Connection: close\r\n" . "Accept-Language: es-ES,es;en-US;en\r\n" . "Accept: text/html,application/xhtml+xml,application/xml\r\n", 'timeout' => 5, 'ignore_errors' => '1'));
             $preContext = stream_context_create($preContext);
             if (file_get_contents($urls[$i][0], false, $preContext) === false) {
                 dbug('no se puede abrir la url de calidad 2000');
                 continue;
             }
             dbug_r($http_response_header);
             if (strpos($http_response_header[0], ' 404 ')) {
                 dbug('la url de calidad 2000 da 404');
                 continue;
             }
         }
         if (esVideoAudioAnon($urls[$i][0])) {
             $obtenido['enlaces'][] = array('url' => $urls[$i][0], 'url_txt' => 'Calidad: ' . $urls[$i][1] . " Kbps", 'tipo' => 'http');
         }
     }
     for ($i = 0, $ii = count($json['captions']); $i < $ii; $i++) {
         if ($json['captions'][$i]['language'] === 'es') {
             $url = $json['captions'][$i]['url'];
             $obtenido['enlaces'][] = array('url_txt' => 'Subtítulos en formato ' . substr($url, strrposF($url, '.')), 'url' => $url, 'tipo' => 'srt');
         }
     }
     $obtenido['titulo'] = $titulo;
     $obtenido['imagen'] = $imagen;
     $obtenido['alerta_especifica'] = 'Si no puedes descargar el vídeo necesitas usar proxy.<br/>Descarga el programa ultrasurf (<a href="https://ultrasurf.us/download/u.zip">Descargar ultrasurf</a>), descomprime el archivo, ejecuta el programa y una vez hecho intenta descargar el vídeo de nuevo.<br/>Si 2000kbps da error prueba 1200kbps.';
     finalCadena($obtenido, false);
 }
Пример #3
0
 function SelectBestNeurons($n)
 {
     //Computing average fitness of neuron in all evolved networks
     for ($i = 0; $i < count($n); $i++) {
         $n[$i]['avg_fitness'] = $n[$i]['fitness'] / $n[$i]['trials'];
     }
     //Ranging neurons from best to worst
     $n = sortmulti($n, 'avg_fitness', 'desc');
     //Selecting
     $winners_count = count($n) / 4;
     if ($winners_count < 4) {
         $winners_count = 4;
     }
     return array_slice($n, 0, $winners_count);
 }
      </p>
     </div>
    </form>
    <div id="clear-both"></div>
   </div>
   <div id="color-wrappage">
<?php 
// Sort the array by hue initially, calculate the section size, and chunk into sections
$colors = sortmulti($colors, 'h', 'desc');
$num = ceil(count($colors) / $sections);
$colors = array_chunk($colors, $num, true);
//  Display the number of generated colors after pulling unique so we can see if it's pulling enough
echo "<h4>{$total} Colors Generated -> HOVER for color info, CLICK to copy hex code to clipboard</h4>";
// DISPLAY CODE & HSL Calculations from decimals, sort by given data, cycle through the new array and display the colors
for ($i = 0; $i < $sections; $i++) {
    $arr = sortmulti($colors[$i], $sort1, $sort2);
    foreach ($arr as $key => $val) {
        $hue = round(360 * $colors[$i][$key]['h']) . "&deg;";
        $saturation = round(100 * $colors[$i][$key]['s']) . "%";
        if ($saturation > 100) {
            $saturation = "100%";
        }
        //  This fixed an error where this value got f****d up like this: 1.0E+21%  <-- what the f**k is that anyways?
        $lightness = round(100 * $colors[$i][$key]['l']) . "%";
        // Display divs and put color values in the title attribute, and display that shit so people can read/copy it for f**k's sake
        echo "\n   <div class=\"copy-target cursor-pointer\" data-clipboard-text=\"#" . $colors[$i][$key]['x'] . "\" id=\"color\" title=\"HEX: #" . $colors[$i][$key]['x'] . ", HSL: ({$hue}, {$saturation}, {$lightness})\" style=\"background:#" . $colors[$i][$key]['x'] . ";width:" . $size . ";height:" . $size . "px;\"></div>";
    }
    echo "\n\n   <div id=\"spacer\" title=\"This is just to space out the HUE sections. Nothing to see here. Stop reading.\">&nbsp;</div>\n";
}
unset($digits, $n, $hue, $saturation, $lightness, $total);
//  \m/