Are you a regular stikked user? Signup so you can keep track of your pastes!
  1. <?php
  2. // Variaveis gerais
  3.  
  4. /*
  5. function ReturnLog() {
  6.         global $_COOKIE;
  7.         if ($_COOKIE['uid'] > 0) {
  8.                 $r= MySQL_dados("id,nome","usuarios","","id='".$_COOKIE['uid']."'","","");
  9.                 if ($r[0] > 0) return '<b>Hola</b> <a href="/profile" style="font-size:11px; text-decoration:none; color:#17b9da;">'.$r[1].'&nbsp;!</a>';
  10.                 else return '&nbsp;';  
  11.         }
  12.         else return '&nbsp;';  
  13. }
  14. */
  15.  
  16. function ReturnLog() {
  17.         if (isset($_SESSION['user']) && $_SESSION['user']['id_usuario']) {
  18.                 $ret = '<b>Hola</b> <a href="/profile" style="font-size:11px; text-decoration:none; color:#17b9da;">'.$_SESSION['user']['nome'].'&nbsp;!</a>';
  19.                 return $ret;
  20.         }
  21.         else return '&nbsp;';  
  22. }
  23.  
  24. function verArr($arr) {
  25.     echo "<PRE>";
  26.     print_r($arr);
  27.     echo "</PRE>";
  28. }
  29.  
  30. function ExibeCanais($cods) {
  31.        
  32.         $r_canais= MySQL_lista("id_canal,nome","canais","","ativo='1'","","");
  33.         for ($i = 0; $i < sizeof($r_canais); $i++) {
  34.         $GeralCanais[$r_canais[$i]['id_canal']] = $r_canais[$i]['nome'];
  35.         }
  36.  
  37.         $canais_arqui = explode("-", strtolower($cods));
  38.         $canais_arqui   = array_unique($canais_arqui);
  39.         //print_r($canais_arqui);
  40.         for ($i=0; $i < count($canais_arqui);$i++) {
  41.                 $canaisTmp .= '<a href="'.URL_SITE .'/categorias='. $canais_arqui[$i] .'" class="LinkTags">'.$GeralCanais[$canais_arqui[$i]] .'</a> ';
  42.         }
  43.         //echo $canaisTmp;
  44.         return $canaisTmp;
  45. }
  46.  
  47. function ExibeChaves($tags,$limit = 10) {
  48.         //$canaisTmp = '&nbsp;';
  49.         $tags = str_replace('.', ' ', $tags);
  50.         $tags = str_replace(',', ' ', $tags);
  51.  
  52.         $tags_arqui = explode(" ", strtolower($tags));
  53.         $tags_arqui     = array_unique($tags_arqui);
  54.         $i=0;
  55.         foreach ($tags_arqui as $tags_novos_indice => $tags_novos_valor ) {
  56.                 if (empty($limit)) $tags_local .= '<a href="'.URL_SITE .'/busca='. (str_replace(' ', "+",trim($tags_novos_valor))) .'" class="LinkTags">'.trim($tags_novos_valor) .'</a> ';
  57.                 elseif ($i <= $limit) {
  58.                         $i++;
  59.                         $canaisTmp .= '<a href="'.URL_SITE .'/busca='. str_replace(' ', "+", (trim($tags_novos_valor))) .'" class="LinkTags">'.trim($tags_novos_valor) .'</a> ';
  60.                 }
  61.         }
  62.         return $canaisTmp;
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. function getClaves($tags,$limit = 10,$css) {
  73.         //$canaisTmp = '&nbsp;';
  74.         $tags = str_replace('.', ' ', $tags);
  75.         $tags = str_replace(',', ' ', $tags);
  76.  
  77.         $tags_arqui = explode(" ", strtolower($tags));
  78.         $tags_arqui     = array_unique($tags_arqui);
  79.         $i=0;
  80.         foreach ($tags_arqui as $tags_novos_indice => $tags_novos_valor ) {
  81.                 if (empty($limit)) $tags_local .= '<a href="'.URL_SITE .'/busca='. (str_replace(' ', "+",trim($tags_novos_valor))) .'" class="LinkTags">'.trim($tags_novos_valor) .'</a> ';
  82.                 elseif ($i <= $limit) {
  83.                         $i++;
  84.                         $canaisTmp .= '<a href="'.URL_SITE .'/busca='. str_replace(' ', "+", (trim($tags_novos_valor))) .'" style="color:'.$css.'; text-decoration:none;">'.trim($tags_novos_valor) .'</a> ';
  85.                 }
  86.         }
  87.         return $canaisTmp;
  88. }
  89.  
  90.  
  91. function NmThumb($ID_User,$NmFile,$Ext) { // eliminar esta funcion
  92. //      $thumb = URL_FOTOS.'/100_'.md5($ID_User."_".$NmFile.$Ext).'.jpg';
  93.         $thumb = URL_DATA_CONT.'/'.$ID_User.'/100_'.md5($ID_User."_".$NmFile.$Ext).'.jpg';
  94. //      if ($Ext == '.jpg')     $thumb = URL_FOTOS.'/100_'.md5($ID_User."_".$NmFile.$Ext).'.jpg';
  95.         return $thumb;
  96. }      
  97.  
  98. function PreHomeThumb($ID_User,$NmFile,$Ext) {
  99.         $thumb = URL_DATA_CONT.'/'.$ID_User.'/prehome_'.md5($ID_User."_".$NmFile.$Ext).'.jpg';
  100.         return $thumb;
  101. }      
  102.  
  103. function GetExt($nm) {
  104.         $ext = '';
  105.         $pos = strripos($nm,".");
  106.         $ext = substr($nm, $pos+1);
  107.         return $ext;
  108. }
  109.  
  110. function ShowTime($seg) {
  111.         $TimeTemp = $seg;
  112.         $hora = intval($TimeTemp / 3600);
  113.         $TimeTemp = $TimeTemp - (3600*$hora);
  114.         $min  = intval($TimeTemp / 60);
  115.         $seg  = $TimeTemp - (60*$min);
  116.         $return = '';
  117.         if ($hora > 0)$return .= $hora.':';
  118.         $return .= AddZero($min,2).':'.AddZero($seg,2);
  119.         return $return;
  120. }
  121.        
  122. function SetTpl($base, $var, $text) {
  123.         return str_replace($var, $text, $base);
  124. }
  125.  
  126. function AddZero($num = 0, $i) {
  127.         $dif = $i - strlen($num);
  128.         if ($dif > 0) {
  129.                 $N = "";
  130.                 for ($x = 0;$x < $dif;$x++) $N .= "0";
  131.         }
  132.         return $N . $num;
  133. }
  134.  
  135. function ValidDate($dt) {
  136.         @$data=explode("/","$dt");
  137.         return @$res=checkdate($data[1],$data[0],$data[2]);
  138. }
  139.  
  140. function reduz_dias($dt, $dias) {
  141.     $dt_array = @explode("-",$dt);
  142.     $time = @mktime(0,0,0,$dt_array[1], $dt_array[2], $dt_array[0]);
  143.     $time = $time - (86400 * $dias);
  144.     return @date("Y-m-d", $time);
  145. }
  146.  
  147. function CalcIdade($dt) {
  148.         $dt_nasc  = explode("-", $dt);
  149.         $dt_atual = Array(Date("Y"),Date("m"),Date("d"));
  150.         $dif_ano  = $dt_atual[0] - $dt_nasc[0];
  151.         if ($dt_atual[1] < $dt_nasc[1]) $dif_ano--;
  152.         else {
  153.                 if ($dt_atual[1] == $dt_nasc[1]) {
  154.                         if ($dt_atual[2] < $dt_nasc[2]) $dif_ano--;
  155.                 }
  156.         }
  157.         return $dif_ano;
  158. }
  159.  
  160. function FormatDate($data = "0000-00-00 00:00:00",$format="D/M/Y h:m:s") {
  161.         if ($data == "0000-00-00 00:00:00" || $data == "0000-00-00" || $data == '')
  162.         return '&nbsp;';
  163.         else {
  164.        
  165.         if (strlen($data) > 10) {
  166.                 $dt  = explode("-", $data);
  167.                 $hr0 = explode(" ",$dt[2]);
  168.                 $hr  = explode(":",$hr0[1]);
  169.                 $format = str_replace('Y', $dt[0],$format);
  170.                 $format = str_replace('M', $dt[1],$format);
  171.                 $format = str_replace('D', $hr0[0],$format);
  172.  
  173.                 $format = str_replace('h', $hr[0],$format);
  174.                 $format = str_replace('m', $hr[1],$format);
  175.                 $format = str_replace('s', $hr[2],$format);
  176.         }
  177.         else {
  178.                 $dt = explode("-", $data);
  179.                 $format = str_replace('Y', $dt[0],$format);
  180.                 $format = str_replace('M', $dt[1],$format);
  181.                 $format = str_replace('D', $dt[2],$format);
  182.                 $format = str_replace(' h:m:s', '',$format);
  183.         }
  184.         return $format;
  185.         }
  186. }
  187.  
  188. function GetFinishDayMonth($m,$y) {
  189.         $date = mktime(0,0,0,$m+1, 1-1, $y);
  190.         return date("d",$date);
  191. }
  192.  
  193. function GetMonthYearDts($dt1='00/00/0000',$dt2='00/00/0000') {
  194.         global $_SESSION;
  195.         $_dt1 = explode("/",$dt1); // dd-mm-yyyy
  196.         $_dt2 = explode("/",$dt2);
  197.         if ($_SESSION["L"] == 'ing') {
  198.                 // m/d/y
  199.                 $_dt1ing = $_dt1;
  200.                 $_dt2ing = $_dt2;
  201.                 //
  202.                 $_dt1[0] = $_dt1ing[1];
  203.                 $_dt1[1] = $_dt1ing[0];
  204.                 $_dt2[0] = $_dt2ing[1];
  205.                 $_dt2[1] = $_dt2ing[0];
  206.         }
  207.        
  208.        
  209. //      print_r($_dt1);
  210. //      print_r($_dt2);
  211.        
  212.        
  213.         $date1 = mktime(0,0,0,$_dt1[1], $_dt1[0], $_dt1[2]);
  214.         $date2 = mktime(0,0,0,$_dt2[1], $_dt2[0], $_dt2[2]);
  215.        
  216.         if ($_dt2[1] > $_dt1[1]) {
  217.                 $dates[$_dt1[1].'_'.$_dt1[2]] = array($_dt1[2].'-'.$_dt1[1].'-'.$_dt1[0],$_dt1[2].'-'.$_dt1[1].'-'.GetFinishDayMonth($_dt1[1],$_dt1[2]));
  218.                 $date1 = mktime(0,0,0,$_dt1[1]+1, $_dt1[0], $_dt1[2]);
  219.                 while ($date2 >= $date1) {
  220.                        
  221.                         $_dt1 = explode("/",date("d/m/Y",$date1)); // dd-mm-yyyy
  222.                         if ($_dt2[1] > $_dt1[1])
  223.                                 $dates[$_dt1[1].'_'.$_dt1[2]] = array($_dt1[2].'-'.$_dt1[1].'-'.$_dt1[0],$_dt1[2].'-'.$_dt1[1].'-'.GetFinishDayMonth($_dt1[1],$_dt1[2]));
  224.                         else
  225.                                 $dates[$_dt1[1].'_'.$_dt1[2]] = array($_dt1[2].'-'.$_dt1[1].'-'.$_dt1[0],$_dt2[2].'-'.$_dt2[1].'-'.$_dt2[0]);
  226.                         // incrementa
  227.                                
  228. //                      $limite++;
  229.                         $date1 = mktime(0,0,0,$_dt1[1]+1, $_dt1[0], $_dt1[2]);
  230.                 }
  231.         }
  232.         else $dates[$_dt1[1].'_'.$_dt1[2]] = array($_dt1[2].'-'.$_dt1[1].'-'.$_dt1[0],$_dt2[2].'-'.$_dt2[1].'-'.$_dt2[0]);
  233.        
  234. //print_r($dates);
  235.        
  236.         return $dates;
  237.        
  238. //      $dates['03_2007'] = '';
  239.        
  240.        
  241. }
  242.  
  243. function ClearText($txt) {
  244.         return trim(addslashes(strip_tags($txt)));
  245. }
  246.  
  247. function FloatDefault ($vl = '0.0',$cifra = true) { // Dolar (U$)
  248. //      global $_SESSION;
  249.         if ($cifra)     return 'U$&nbsp;'.number_format($vl,2,'.',',');
  250.         else            return number_format($vl,2,'.',',');
  251. }
  252.  
  253. function valida_mail($mail) {
  254.         return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@([0-9a-z](-?[0-9a-z])*\.)+[a-z]{2}([zmuvtg]|fo|me)?$",$mail);
  255. }
  256.  
  257. function Limit($txt, $n) {
  258.     if ($n < strlen($txt)) {
  259.       $t = substr($txt,0,$n);
  260.     } else $t = $txt;
  261.     if (($t != "") && (strlen($txt) > strlen($t))) $t .= "...";
  262.     return $t;
  263. }
  264.  
  265. function envia_Email($para, $titulo, $mensagem, $layout="", $remetente="") {
  266.  
  267.         ini_set("sendmail_from", $remetente);
  268.  
  269.         $_sender = str_replace('http://', '', 'www.tnylagente.com.ar');
  270.  
  271.         $headers  = "MIME-Version: 1.0\n";
  272.         $headers .= "From: $remetente\n";
  273.         $headers .= "Reply-To: $remetente\n";
  274.         $headers .= "Date: ".date("r")."\n";
  275.         $headers .= "Subject: $titulo\n";
  276.         $headers .= "Return-Path: $remetente\n";
  277.         $headers .= "Delivered-to: $remetente\n";
  278.         $headers .= "Content-type: text/html; charset=UTF-8\n";
  279.         $headers .= "Sender: $remetente\n";
  280.         $headers .= "Importance: High\n";
  281.         $headers .= "X-Priority: 1\n";
  282.         $headers .= "X-Sender: $remetente\n";
  283.         $headers .= "X-MSMail-Priority: High\n";
  284.         $headers .= "X-Mailer: php_".phpversion()."\n";
  285.         $headers .= "Organization: tnylagente.com.ar - $_sender\n";
  286.         $headers .= "Message-ID: <".date("YmdHis")."@".$_sender.">\n";
  287.  
  288.         if ( !empty($layout)) {
  289.                 $corpo = $layout;
  290.                 $corpo = str_replace("{titulo}", $titulo, $corpo);
  291.                 $corpo = str_replace("{conteudo}", $mensagem, $corpo);
  292.         } else {
  293.                 $corpo =
  294.             '
  295.                         <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  296.                         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  297.  
  298.                         <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt">
  299.                                 <head>
  300.                                         <title>'.$titulo.'</title>
  301.                                         <meta name="resource-type" content="document" />
  302.                                         <meta http-equiv="pragma" content="no-cache" />
  303.                                         <meta name="revisit-after" content="1" />
  304.                                         <meta name="classification" content="Internet" />
  305.                                         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  306.                                         <meta name="author" content="tnylagente.com.ar" />
  307.                                         <meta name="robots" content="ALL" />
  308.                                         <meta name="distribution" content="Global" />
  309.                                         <meta name="rating" content="General" />
  310.                                         <meta name="language" content="pt-br" />
  311.                                         <meta name="doc-class" content="Completed" />
  312.  
  313.                                         <meta name="doc-rights" content="Public" />
  314.                                 </head>
  315.  
  316.                                 <body>
  317.                                 '.$mensagem.'
  318.                                 </body>
  319.                         </html>
  320.                         ';
  321.                                         //<meta name="author" content="'.$this->nome.'['.$this->endereco.']" />
  322.  
  323.         }
  324.         $cadena .= $headers."\r\n\r\n";
  325.     $cadena .= $para."\r\n";
  326.     $cadena .= $titulo."\r\n";
  327.     $cadena .= $corpo."\r\n";
  328.     $cadena .= "==============================================================\r\n";
  329.     $cadena .= "==============================================================\r\n\r\n\r\n";
  330.     /*
  331.     $fh = fopen(DIR_TEMP.'/emails_funcion_envia_Email.txt', 'a');
  332.     fwrite($fh,$cadena);
  333.     fclose($fh);
  334.         */
  335.         if (@mail("$para", "$titulo", "$corpo", "$headers")) return true; else return false;
  336. }
  337.  
  338.  
  339. function XMLFindPais($cod) {
  340.         global $sub;
  341.         $mypais = @simplexml_load_string(@file_get_contents($sub.'XMLs/default/paises.xml'));
  342.         $total = count($mypais);
  343.         for($i=0;$i<$total;$i++) {
  344.                 if ($mypais->pais[$i]->cod == $cod) return  utf8_decode($mypais->pais[$i]->nome);
  345.         }
  346.         return '-';
  347. }
  348.  
  349. function XMLFindUF($pais,$cod) {
  350.         global $sub;
  351.         $mypais = @simplexml_load_string(@file_get_contents($sub.'XMLs/default/ufs_'.$pais.'.xml'));
  352.         $total = count($mypais);
  353.         for($i=0;$i<$total;$i++) {
  354.                 if ($mypais->uf[$i]->cod == $cod) return  utf8_decode($mypais->uf[$i]->nome);
  355.         }
  356.         return '-';
  357. }
  358.  
  359. function XMLFindCid($pais,$uf,$cod) {
  360.         global $sub;
  361.         $mypais = @simplexml_load_string(@file_get_contents($sub.'XMLs/default/cids_'.$pais.'_'.$uf.'.xml'));
  362.         $total = count($mypais);
  363.         for($i=0;$i<$total;$i++) {
  364.                 if ($mypais->uf[$i]->cod == $cod) return  utf8_decode($mypais->uf[$i]->nome);
  365.         }
  366.         return '-';
  367. }
  368.  
  369. function generaXMLCanal($name, $videos) {
  370.     if (is_array($videos) && $cntvideos = count($videos)) {
  371.         $cntvideos = count($videos);
  372.        
  373.         $xml  = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
  374.         $xml .= "   <videos>\n";
  375.         $xml .= "   <cant>".$cntvideos."</cant>\n";
  376.        
  377.         $cntvideos = 30; // Solo quieren mostrar 30 posts asi que armo el xml con 30 posts
  378.        
  379.         for ($i=0 ; $i < $cntvideos ; $i++) {
  380.             $xml .= "      <video>\n";
  381.             foreach ($videos[$i] as $campo => $valor) {
  382.                 $Encoding       = mb_detect_encoding( $valor );
  383.                 $StrFinal   = mb_convert_encoding($valor, 'UTF-8', $Encoding);
  384.                 $StrFinal = $valor;
  385.                 $xml .= "          <$campo><![CDATA[$StrFinal]]></$campo>\n";
  386.             }
  387.             $xml .= "      </video>\n";
  388.         }
  389.         $xml .= "   </videos>\n";
  390.         $fh = fopen($name,'w');
  391.         fwrite($fh,$xml);
  392.         fclose();
  393.         chmod($name,0664);
  394.         return 1;
  395.     } else {
  396.         return 0;
  397.     }
  398.        
  399. }
  400.  
  401.  
  402. function generaXMLAmigos($name, $videos, $limite=0) {
  403.     if (is_array($videos)) {
  404.         $cntvideos = count($videos);
  405.                                 if ($limite==0) $limite = $cntvideos;
  406.                                        
  407.         $xml  = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
  408.         $xml .= "   <amigos_ultimos>\n";
  409.         $xml .= "   <cant>".$cntvideos."</cant>\n";
  410.        
  411.         for ($i=0 ; $i < $limite ; $i++) {
  412.                 if ($i < $cntvideos)
  413.                 {
  414.             $xml .= "      <amigo_ultimo>\n";
  415.             foreach ($videos[$i] as $campo => $valor) {
  416.                 $Encoding       = mb_detect_encoding( $valor );
  417.                 $StrFinal   = mb_convert_encoding($valor, 'UTF-8', $Encoding);
  418.                 $StrFinal = $valor;
  419.                 $xml .= "          <$campo><![CDATA[$StrFinal]]></$campo>\n";
  420.             }
  421.             $xml .= "      </amigo_ultimo>\n";
  422.           }
  423.         }
  424.         $xml .= "   </amigos_ultimos>\n";
  425.         $fh = fopen($name,'w');
  426.         fwrite($fh,$xml);
  427.         fclose();
  428.         chmod($name,0664);
  429.         return 1;
  430.     } else {
  431.         return 0;
  432.     }
  433.        
  434. }
  435.  
  436.  
  437.  
  438. function getCanales($canales,$css) {
  439.        
  440.         require_once("functions_MySQL.php");
  441.   $canales = explode("-",$canales);
  442.        
  443.                
  444.    $campos = "c.id_canal,c.nome";
  445.          $tabela = "canais AS c";
  446.  
  447.         for ($i=0; $i< sizeof($canales); $i++) {
  448.            if($i==0)
  449.            $filtro = "c.id_canal='".$canales[$i]."'";
  450.            else
  451.            $filtro .= " or c.id_canal='".$canales[$i]."'";
  452.   }
  453.    
  454.     $canal = MySQL_lista($campos,$tabela,"",$filtro,"");
  455.    
  456.           for($j=0; $j<sizeof($canal); $j++){
  457.             $canais .='<a href="'.URL_SITE .'/categorias='.$canal[$j]['id_canal'].'"  style="text-decoration:none; color:'.$css.'">'.$canal[$j]['nome'].'</a>&nbsp;';
  458.         }
  459.  
  460.         return $canais;
  461. }
  462.  
  463. function generaXMLtodos($name, $videosA, $campos='videos', $limite = 300) {
  464.  
  465.     if (is_array($videosA)) {
  466.  
  467.       // total que se incluye en todos los xml para paginacion
  468.       $cntvideos = count($videosA);
  469.       // partimos en vectores con limite de 300 por defecto
  470.       $v_todos = array_chunk($videosA,$limite);
  471.  
  472.                         $camp = substr($campos,0,(strlen($campos)-1));
  473.                                    
  474.       $n = 0;
  475.       // escribimos xml                                              
  476.       foreach($v_todos as $videos)
  477.       {    
  478.         $xml  = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
  479.         $xml .= "   <$campos>\n";
  480.         $xml .= "   <cant>".$cntvideos."</cant>\n";
  481.                    
  482.         for ($i=0 ; $i < $limite ; $i++) {
  483.           if ($i < $cntvideos)
  484.           {
  485.             $xml .= "      <$camp>\n";
  486.             foreach ($videos[$i] as $campo => $valor) {
  487.                 $Encoding       = mb_detect_encoding( $valor );
  488.                 $StrFinal   = mb_convert_encoding($valor, 'UTF-8', $Encoding);
  489.                 $StrFinal = $valor;
  490.               $xml .= "          <$campo><![CDATA[$StrFinal]]></$campo>\n";
  491.             }
  492.             $xml .= "      </$camp>\n";
  493.           }
  494.         }
  495.         $xml .= "   </$campos>\n";
  496.         $fh = fopen($name.$n.'.xml','w');
  497.         fwrite($fh,$xml);
  498.         fclose();
  499.         chmod($name.$n.'.xml',0664);
  500.         $n++;
  501.       }
  502.       return 1;
  503.     } else {
  504.       return 0;
  505.     }
  506. }
  507.  
  508. function setJs($js_file,$tmpLayout)
  509. {
  510.         $jsLine   = '<script src="'.$js_file.'" type="text/javascript"></script>
  511. </head>';
  512.         return eregi_replace("</head>", $jsLine, $tmpLayout);
  513. }
  514.  
  515. function setCss($css_file,$tmpLayout)
  516. {
  517.         $cssLine   = '<link rel="stylesheet" type="text/css" href="'.$css_file.'" />
  518. </head>';
  519.         return eregi_replace("</head>", $cssLine, $tmpLayout);
  520. }
  521.  
  522. ?>

Reply to "Estoe s un titulo"

Here you can reply to the paste above

Create a snipurl

Make Private

Feeling clever? Set some advanced options.