Author Topic: integracion base de datos y registro  (Read 9232 times)

0 Members and 1 Guest are viewing this topic.

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
integracion base de datos y registro
« on: October 14, 2006, 10:55:11 PM »
podria ser posible, agregar un script en php, a la base de datos de 4images y como podria hacerce esto, es decir tengo un script en php sin registro de usuarios,y me gustaria que se registraran desde 4images e ingresar al script de webcams.
espero haberme explicado bien.

gracias
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: integracion base de datos y registro
« Reply #1 on: October 15, 2006, 01:13:03 AM »
Saludos,,,

Prueba a insertar este código despues de <?php

Code: [Select]
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');

if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
  show_error_page($lang['no_permission']);
  exit;
}

excitex2

Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: integracion base de datos y registro
« Reply #2 on: October 16, 2006, 07:13:38 PM »
gracias excitex2 te pongo los codigos del script,

congif.php

Quote
<?php
$version="Version 2.0";

################ BEGIN CONFIGURATION EDITS HERE ################

# MySQL schtuff
$db_host = "localhost";
$db_name = "mibase";
$db_username = "mi_username";
$db_pass = "pass";

#SQL Table Pefix - Change this if you are using multiple portals.
$prefix = "eroticscam";

# Web Address - NO ENDING SLASH
$website = "http://miweb/index.php";

# Full Path to Portal - STARTING SLASH REQUIRED - NO ENDING SLASH
$pathtoportal = "/url_path/sitio";

# Website Title
$title = "titulo-";

# Default Height and Width of cam images
$defaultheight=240;
$defaultwidth=320;

# Set this to the number of columns per page.
$cols = 3;

# Set this to the number of seconds to refresh.
$refresh = 30;

# Set this to "1" to e-mail you when a cam is submitted, and set
# your email
$mailonsubmit = 1;
$adminemail = "admin@mimail.com";

# Thumbnail size - set this to what you want the thumbnails
# division size to be. ie: setting this to three will make the
# thumbnail's size be the defailt image size divided by three
$thumbnailsize = 2;

# Date Lookups - set this 1 to enable date look ups for cam images.
# Note that this will slow down your portal IMMENSELY. To disable,
# set this to zero.
$datelookups = 0;

# Default number of cams per page
$default_camsperpage = 12;

# Main Border Color
$bordercolor1="#004098";

# Main Table BG Color
$bgcolor1="#C1DBFF";

# Individual Cam Border Color
$bordercolor2="#004098";

# Individual Cam Table BG Color
$bgcolor2="#85B9FF";

# THE FOLLOWING TWO OPTIONS ARE ONLY AVAILIBLE FOR TWEAKING, NO
# REAL REASON TO CHANGE THEM. DOING SO WILL RESULT IN A BROKEN
# CAM PORTAL (and that would suck!)

# Default starting number
$default_start = 1;

# Default ending number (set to same as cams per page)
$default_end = $default_camsperpage;

# Seconds Old (internal function, DO NOT CHANGE)
$old="999999999";

?>


index.php

Quote
<?php
if (!empty($_GET)) {
extract($_GET);
} else if (!empty($HTTP_GET_VARS)) {
extract($HTTP_GET_VARS);
}

if (!empty($_POST)) {
extract($_POST);
} else if (!empty($HTTP_POST_VARS)) {
extract($HTTP_POST_VARS);
}

include('config.php');
$fp = fopen("head.tpl","r");
while (!feof ($fp)) {
$o_head .= fgets($fp, 4096);
}
fclose ($fp);
$output = str_replace("%TITLE%",$title,$o_head);
echo $output;
function get_age($addr)
{
   global $old;
   $addrsplit=split("http://",$addr);
   $split2=split("/",$addrsplit[1],2);
   $domain=$split2[0];
   $file=$split2[1];
   $fp = @fsockopen ("$domain", 80, $errno, $errstr, 30);
   @fputs ($fp, "HEAD /$file HTTP/1.0\r\nHost: $domain\r\n\r\n");
   for ($count=0; $count<8; $count++)
      {
      $string = @fread ($fp,128);
      $header = "$header|$string";
      }
   @fclose($fp);
   $header_array = split("dified:",$header);
   $header_array = split("ETag",$header_array[1]);
   $mod = $header_array[0];
   @fclose ($fp);
   if($mod=="")
      {$unknown[0]="Unknown";
      $unknown[1]= $old;
      return $unknown;}
   else
      {
      $date2=split(", ",$mod);
      $realdate=split(" GMT",$date2[1]);
      list($day, $month, $year) = explode(" ", $realdate[0], 4);
      if ($month=="Jan")
         {$monnum="01";}
      else if ($month=="Feb")
         {$monnum="02";}
      else if ($month=="Mar")
         {$monnum="03";}
      else if ($month=="Apr")
         {$monnum="04";}
      else if ($month=="May")
         {$monnum="05";}
      else if ($month=="Jun")
         {$monnum="06";}
      else if ($month=="Jul")
         {$monnum="07";}
      else if ($month=="Aug")
         {$monnum="08";}
      else if ($month=="Sep")
         {$monnum="09";}
      else if ($month=="Oct")
         {$monnum="10";}
      else if ($month=="Nov")
         {$monnum="11";}
      else if ($month=="Dec")
         {$monnum="12";}
      $realdate2 = explode(" ", $realdate[0], 4);
      list($hour, $minute, $second) = explode(":", $realdate2[3], 3);
      $curr=time();
      $lm = gmmktime($hour, $minute, $second, $monnum, $day, $year, -1);
      $time=($curr - $lm);
      $weeks=$time/604800;
      $days=($time%604800)/86400;
      $hours=(($time%604800)%86400)/3600;
      $minutes=((($time%604800)%86400)%3600)/60;
      $seconds=(((($time%604800)%86400)%3600)%60);
      $timestring='';
      if(intval($weeks)) $timestring.=intval($weeks)."w ";
      if(intval($days)) $timestring.=intval($days)."d ";
      if(intval($hours)) $timestring.=intval($hours)."h ";
      if(intval($minutes)) $timestring.=intval($minutes)."m";
      if(!intval($minutes)&&!intval($hours)&&!intval($days)&&!intval($weeks)) $timestring.=" ".intval($seconds)."s";
      $timestring.='';
      $time1 = array($timestring." ago",$time);
      return($time1);
      }
   }
$dbi = mysql_connect($db_host, $db_username, $db_pass);
mysql_select_db("$db_name",$dbi);
if($submit == "1")
{
   
   $fp = fopen("w_submit.tpl","r");
   while (!feof ($fp)) {
   $w_submit .= fgets($fp, 4096);
   }
   fclose ($fp);
   $output = str_replace("%W_TITLE%",$title,$w_submit);
   $output = str_replace("%W_NUMOFCAMS%",$numofcams,$output);
   $output = str_replace("%W_BORDERCOLOR_1%",$bordercolor1,$output);
   $output = str_replace("%W_BORDERCOLOR_2%",$bordercolor2,$output);
   $output = str_replace("%W_BGCOLOR_1%",$bgcolor1,$output);
   $output = str_replace("%W_BGCOLOR_2%",$bgcolor2,$output);
   if(empty($camurl) or empty($camname) or empty($email))
   {
      echo $output;
   }
   else {
      global $user_prefix, $dbi;
      $result = mysql_query("insert into ".$prefix."_cams_temp values ('$camname','$email','$camurl','$url')", $dbi);
      if(!$result) {echo "There was an error. Sheet!<br>";}
      else {
         echo "Thanks. You'll get an e-mail when you're added. <a href=\"?\">Click here</a> to go back to the main menu.<br><br>";
         if ($mailonsubmit == "1")
         {
            mail($adminemail, "New Cam Submission", "You have a new cam submission, please approve it or them.\n\n-$title","Content-type: text/html; charset=iso-8859-1\r\n");
         }
         else {};
           }
   }
}
else {
   echo "<script type=text/javascript>setTimeout('document.location=document.location',".$refresh."000);</script>";   $h=$defaultheight/$thumbnailsize;
   $w=$defaultwidth/$thumbnailsize;
   global $user_prefix, $dbi;
   $result = mysql_query("select camname from ".$prefix."_cams", $dbi);
   $numofcams = mysql_num_rows($result);
   if(!isset($sortby))
      {
      if ($datelookups=="1")
         {
         $sortby="date";
         }
      else
         {
         $sortby="joined";
         }
      }
   if(!isset($start)){$start=1;}
   $end=($start + $default_camsperpage)-1;
   $camsperpage=$default_camsperpage;
   if($start=="all")
      {
      $start=1;
      if($numofcams<=$default_camsperpage)
         {
         $end=$default_camsperpage;
         }
      else
         {
         $end=$numofcams;
         }
      }
   if ($datelookups=="1")
      {
      $w_sortbar = "<a href=?sortby=date&start=$start>Last Updated</a> or ";
      }
   else
      {
      $w_sortbar = "";
      };
   $w_sortbar .= "<a href=?sortby=joined&start=$start>Join Date</a> or <a href=?sortby=alpha&start=$start>Name</a>";
   $w_pagelinks = "";
   for ($e=0; $e < ($numofcams/$camsperpage); $e++)
   {
      $g = 1+($camsperpage*$e);
      $f = $g+($camsperpage-1);
      $num=$e+1;
      $w_pagelinks .= "<a href=?start=$g&sortby=$sortby>$num</a> ";
   }
   $w_pagelinks .= "<a href=?start=all&sortby=$sortby>All</a></table>";   
   for($z=0;$z<=$numofcams-1;$z++)   
      {
      $z2 = $z+1;
      $result1 = mysql_query("select camname, camurl, url, email, noupdate, id from ".$prefix."_cams limit $z,$z2", $dbi);
      $temp2[$z] = mysql_fetch_array($result1);
      $webcam1[$z]["camname"] = $temp2[$z][0];
      $webcam1[$z]["camurl"] = $temp2[$z][1];
      $webcam1[$z]["url"] = $temp2[$z][2];
      $webcam1[$z]["email"] = $temp2[$z][3];
      $webcam1[$z]["noupdate"] = $temp2[$z][4];
      $webcam1[$z]["id"] = $temp2[$z][5];
      if ($webcam1[$z]["noupdate"]=="1" OR $datelookups=="0"){$webcam1[$z]["date"]="Unknown";$webcam1[$z]["stamp"]=$old;}
      else
         {
         $temp = get_age($webcam1[$z]["camurl"]);
         $webcam1[$z]["date"] = $temp[0];
         $webcam1[$z]["stamp"] = $temp[1];
         }      
      }
   function array_csort($marray, $column)
      {
      foreach ($marray as $row)
         {
         $sortarr[] = $row[$column];
         }
      array_multisort($sortarr, $marray);
      return $marray;
      }
   if($numofcams=="0")
      {}
   else
      {
      if($sortby=="date")
         {
         $webcam=array_csort($webcam1,"stamp");
         }
      else if($sortby=="joined")
            {
         $webcam=array_csort($webcam1,"id");
         }
      else if($sortby=="alpha")
         {
         $webcam=array_csort($webcam1,"camname");
         }
      }
   $fp = fopen("w_cell.tpl","r");
   while (!feof ($fp)) {
       $webcam_cell .= fgets($fp, 4096);
    }
   fclose ($fp);
   $fp = fopen("w_head.tpl","r");
   while (!feof ($fp)) {
       $webcam_head .= fgets($fp, 4096);
    }
   fclose ($fp);
   $foot .="<center><a href=\"http://neenmo.com/nPortal\" target=\"_blank\">nPortal</a> $version</center>";
   $fp = fopen("foot.tpl","r");
   while (!feof ($fp)) {
       $foot .= fgets($fp, 4096);
    }
   fclose ($fp);
   $output = str_replace("%W_TITLE%",$title,$webcam_head);
   $output = str_replace("%W_NUMOFCAMS%",$numofcams,$output);
   $output = str_replace("%START%",$start,$output);
   $output = str_replace("%END%",$end,$output);
   $output = str_replace("%W_SORTBAR%",$w_sortbar,$output);
   $output = str_replace("%W_PAGELINKS%",$w_pagelinks,$output);
   $output = str_replace("%W_BORDERCOLOR_1%",$bordercolor1,$output);
   $output = str_replace("%W_BORDERCOLOR_2%",$bordercolor2,$output);
   $output = str_replace("%W_BGCOLOR_1%",$bgcolor1,$output);
   $output = str_replace("%W_BGCOLOR_2%",$bgcolor2,$output);
   echo $output;
   for($m=$start-1; $m < $end; $m++)
      {
         if ($webcam[$m]["camurl"] == "")
            {
            $w_camname = "SUBMIT YOUR CAM!";
            $w_camurl = "submit.gif";
            $w_url_link = "- <a href=?submit=1>Submit your cam!</a>";
            $w_email_link = "";
            $w_updated = "";
            }
         else
            {
            $w_camurl = $webcam[$m]["camurl"];
            $w_camname = $webcam[$m]["camname"];
            if (empty($webcam[$m]["url"]))
               {
               $w_url_link = "NO URL";
               }
            else
               {
               $w_url_link = "<a href={$webcam[$m]["url"]} target=_blank>URL</a>";
               }
            if (empty($webcam[$m]["email"]))
               {
               $w_email_link = "NO E-MAIL<br>";
               }
            else
               {
               $w_email_link = "<a href=\"mailto:{$webcam[$m]["email"]}\">E-MAIL</a><br>";
               }
            if ($datelookups=="1")
               {
               $w_updated = "Last Updated:<br> {$webcam[$m]["date"]}";
               }
            else
               {
               $w_updated = "";
               }
            }
         $output = str_replace("%W_NAME%",$w_camname,$webcam_cell);
         $output = str_replace("%W_CAMURL%",$w_camurl,$output);
         $output = str_replace("%W_WIDTH%",$w,$output);
         $output = str_replace("%W_HEIGHT%",$h,$output);
         $output = str_replace("%W_BORDERCOLOR_1%",$bordercolor1,$output);
         $output = str_replace("%W_BORDERCOLOR_2%",$bordercolor2,$output);
         $output = str_replace("%W_BGCOLOR_1%",$bgcolor1,$output);
         $output = str_replace("%W_BGCOLOR_2%",$bgcolor2,$output);
         $output = str_replace("%W_URL_LINK%",$w_url_link,$output);
         $output = str_replace("%W_EMAIL_LINK%",$w_email_link,$output);
         $output = str_replace("%W_UPDATED%",$w_updated,$output);
         echo "$output\n";
         $count = $count+1;
         if ($count == $cols)
            {
            echo "\n\n</tr><tr><td><br></td></tr><tr>\n\n\n";
            $count=0;
         }
         else
            {};
         }
      echo "</table><br><br></center>";
   };
echo $foot;
?>

install.php

Quote
<?
if (!empty($_GET)) {
extract($_GET);
} else if (!empty($HTTP_GET_VARS)) {
extract($HTTP_GET_VARS);
}

if (!empty($_POST)) {
extract($_POST);
} else if (!empty($HTTP_POST_VARS)) {
extract($HTTP_POST_VARS);
}

include('config.php');

echo "<html><head><title>nPortal Version $version Installation</title></head><body>";
echo "<center><h1>nPortal Version $version Installation</h1></center>\n<hr width=\"85%\" align=\"center\"><br>";

if($go=="yes")
{
   echo "<h3>Installing...</h3>";
   $dbi = mysql_connect($db_host, $db_username, $db_pass);
   mysql_select_db("$db_name",$dbi);
   echo "<font face=\"monospace\">Creating Main Cam Table <b>".$prefix."_cams</b>...</font>";
   $sql = 'CREATE TABLE ';
   $sql .=   $prefix;
   $sql .= '_cams( camname varchar( 60 ) NOT NULL default \'\', email varchar( 255 ) NOT NULL default \'\', camurl varchar( 255 ) NOT NULL default \'\', url varchar( 255 ) NOT NULL default \'\', id int( 11 ) NOT NULL default \'\'auto_increment, noupdate tinyint( 11 ) NOT NULL default \'0\', PRIMARY KEY ( id ) ) TYPE = MYISAM ';    
   $result = mysql_query($sql);
   if(!$result){echo "<font color=\"red\" face=\"monospace\">Error!</font><br><br>\n\n";die();}
   else {echo "<font color=\"green\" face=\"monospace\">Success!</font><br><br>\n\n";}

   echo "<font face=\"monospace\">Creating Temp Cam Table <b>".$prefix."_cams_temp</b>...</font>";
   $sql = 'CREATE TABLE ';
   $sql .=   $prefix;
   $sql .= '_cams_temp(camname varchar(60) NOT NULL default \'\', email varchar(255) NOT NULL default \'\', camurl varchar(255) NOT NULL default \'\', url varchar(255) NOT NULL default \'\' ) TYPE=MyISAM ';    
   $result = mysql_query($sql);
   if(!$result){echo "<font color=\"red\" face=\"monospace\">Error!</font><br><br>\n\n";die();}
   else {echo "<font color=\"green\" face=\"monospace\">Success!</font><br><br>\n\n";}
?>

password.php

Quote
<?

$path_parts = realpath("index.php");
$path=str_replace("/index.php","",$path_parts);
echo "This is what you need to put in your \".htaccess\" file:<br><br><pre>";
echo "AuthUserFile \"$path/admin/.htpasswd\"\n";
echo "AuthGroupFile /dev/null
AuthName \"Portal Admin\"
AuthType Basic
require valid-user</pre>";

echo"Next, cick here <a href=\"http://www.flash.net/cgi-bin/pw.pl\" target=\"_blank\">here</a> and pick a username / password. Paste ONLY the line in <b>bold</b> into your \".htpassword\" file. Upload both into the \"admin\" folder (they might not show up in your FTP client, but don't worry, they are there), and biggity bam, you're ready to go.";

?>

en el admin tengo tres archivos un index.php, .htaccess y .htpasswd

en cada pagina meteria el codigo que me haz proporcionado dentro del script

los archivos del template son .tpl
?
Gracias de nuevo
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: integracion base de datos y registro
« Reply #3 on: October 18, 2006, 12:27:06 AM »
Saludos,,,

Pero este script,,, trabaja con la base de daots de 4images???????

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: integracion base de datos y registro
« Reply #4 on: October 20, 2006, 08:08:52 PM »
no, lo tengo instalado en otra base de datos, dentro de mis archivos o ruta, y lo jalo mediante un iframe, aunque no se si sirva para usarse enlazado con 4images, asi como fue creado podria desenlazarse o decifrar el codigo, para una nueva version de 4images 1.7.4 se mira simple aunque de php aun no me graduo.
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?



Offline excitex2

  • Addicted member
  • ******
  • Posts: 1.590
  • He desactivado la galería y el buscador
    • View Profile
Re: integracion base de datos y registro
« Reply #5 on: October 21, 2006, 01:32:04 AM »
Saludos,,,

Pues si no lo tienes instalado en la misma base de datos,,, mal lo tenemos para integrarlo,, las sesiones no pueden ser la misma y eso es una de las condiciones para poder integrar otro script a 4images.

excitex2
Lo importante no es saber,,, lo importante es tener el E-Mail de quien sabe

Offline masterred

  • Sr. Member
  • ****
  • Posts: 494
    • View Profile
Re: integracion base de datos y registro
« Reply #6 on: October 23, 2006, 06:21:10 PM »
hola
en realidad es un archivo simple, es decir, no consta de session, ni de otras cosas, solo los archivos que te puse, y desde luego los tpl.

hasta pronto
Apache/2.2.21 (Win32)
PHP/5.3.5
Mysql Version: 5.5.19
4images Version: 1.7.?