register from web
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

register from web

Started by coreno, 20 January, 2007, 23:52:37

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

coreno

so, i have a PHP script which will update cfg/RegisteredUsers.xml with a new registration. But, it seems that PtoakX only uses that file on startup, or it seems that way anyway. I say this because if someone registers themselves on the hub itself,  it overwrites the file to what it was before I edited it with PHP (and also appends the newly registered user). Can anyone think of some clever ways around this?

bastya_elvtars

coreno: woiuld you like to share that script with the rest of the world by the way? :)
Everything could have been anything else and it would have just as much meaning.

coreno

I was kinda thinking the same thing, save to a file and have a script reg them... but, then there would be a delay... which I guess is no big deal.

And no, I don't know LUA :( So someone would have to help me out and make the script to read the file.

I will also gladly post my PHP scripts. Give me a bit to clean it up, it's a bit messy right now :p

coreno

Wow, a bit beefier of a script than thought it was going to be haha, thanks though :) I think this will be easier for those not so technically savvy... :p

7P-Darkman

Hello friends...


I was reading here on the possibility to make the register in a HUB, through a page web, and I remembered a test that I made, times behind, with one another type of server for DC++ network. This server to possess a page web of model, that allowed to make the register in the HUB, through the site.

   
It seems that the only difficulty to use this model would be to create one profile in the Ptokax server (called "Web", in this HTML page), whom it has accepted to be able to make the register of users in the HUB.

case that it serves of inspiration for ours scripters, here code HTML of this page goes:

<html>

<head>
<title><%lua return GetHubName() lua%></title>
</head>

<body>

<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0" width="837" height="104">
    <tr>
      <td width="193" height="59" bgcolor="#F48520" colspan="2">&nbsp;</td>
      <td width="680" height="59" bgcolor="#E34704" colspan="2"><p align="left"><font size="5" face="Verdana" style="italic" color="#FFFFFF"><b>&nbsp;<em>
        <%lua return "Welcome to "..GetHubName() lua%>
      </em></b></font></p></td>
    </tr>
    <tr>
      <td width="193" height="22" bgcolor="#FAAF6B" colspan="2">&nbsp;</td>
      <td width="680" height="22" bgcolor="#F88A27" colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td width="193" height="18" bgcolor="#F48520" align="center" colspan="2"><em><font color="#FFFFFF"><strong><A href="<%lua return "http://"..GetHubAddress()..":"..GetHubPortHttp().."/" lua%>">&nbsp;HOME&nbsp;</A></strong></font></em></td>
      <td width="680" height="345" colspan="2" rowspan="5" valign="top" bgcolor="#E34704">
        <p align="left"><font size="1" face="Verdana" color="#FFFFFF"><b>
<%lua 
  local ok = nil
  local profile = "Web"
  local msg
  local t=GetAllProfiles()
  for i=1,table.getn(t) do
    if t[i]==profile then ok=1 end
  end
  if not ok then
    return "This server does not allow web registration because profile '"..profile.."' is not defined"
  else
    ok = nil
  end
  if POSTMSG then
    ok,_,nickname,password = string.find(POSTMSG,"nickname=(.+)&password=(.+)")
  end
  if ok then
    for i=1,table.getn(t) do
      if t[i]~="Default" then
        local u=GetAllRegisteredUsers(t[i])
        for j=1,table.getn(u) do
          if u[j] == nickname then ok=nil end
        end
      end
    end
    if ok then
      AddRegUser(nickname,password,profile)
      msg = "You are now registered as "..nickname..", go to dchub://"..db_hubconfig["dns"]..":"..db_hubconfig["tcp"].." and have fun"
    else
      msg = "Nick "..nickname.." is already taken, please choose another one<p>"
      msg = msg.."<form action=\"./reg.htm\" method=\"POST\">"
      msg = msg.."Nickname:    <input type=\"text\" name=\"nickname\"><p>"
      msg = msg.."Password:   <input type=\"text\" name=\"password\"><p>"
      msg = msg.."<input type=\"submit\">"
    end
  else
    msg = "Fill all the fields to register<p>"
    msg = msg.."Note to enter the hub you will need :<br>"
    msg = msg.."\160 - Minimum Share : "..GetShareUnit(GetMinShare(profile)).."<br>"
    msg = msg.."\160 - Maximum Share : "..GetShareUnit(GetMaxShare(profile)).."<br>"
    msg = msg.."\160 - Minimum Slots : "..GetMinSlots(profile).."<br>"
    msg = msg.."\160 - Maximum Slots : "..GetMaxSlots(profile).."<br>"
    msg = msg.."\160 - Minimum Slots/Hubs : "..GetSlotHubRatio(profile).."<br>"
    msg = msg.."\160 - Maximum Hubs : "..GetMaxHubs(profile).."<p>"
    msg = msg.."<form action=\"./reg.htm\" method=\"POST\">"
    msg = msg.."Nickname:    <input type=\"text\" name=\"nickname\"><p>"
    msg = msg.."Password:   <input type=\"text\" name=\"password\"><p>"
    msg = msg.."<input type=\"submit\">"
  end
  return msg
lua%>
<p>

</b></font></td>
    </tr>
    <tr>
      <td width="193" height="10" bgcolor="#F48520" align="center" colspan="2"><em><font color="#FFFFFF"><strong><A href="./stats.htm">&nbsp;STATISTICS&nbsp;</strong></font></em></td>
    </tr>
    <tr>
      <td width="193" height="11" bgcolor="#F48520" align="center" colspan="2"><em><font color="#FFFFFF"><strong><A href="./reg.htm">&nbsp;REGISTER&nbsp;</strong></font></em></td>
    </tr>
    <tr>
      <td width="193" height="1" bgcolor="#F48520" align="center" colspan="2">&nbsp;</td>
    </tr>
    <tr>
      <td width="193" height="257" bgcolor="#F48520" colspan="2"></td>
    </tr>
  </table>
  </center>
</div>
<p align="center"><font size="1" face="Verdana"><a href="http://www.dcsh.org/">www.dcsh.org</a></font></p>

</body>

</html>



I wait to have collaborated with the subject.

Respectfully,


7P-Darkman
Owner of HUB Pantanal - Brasil

coreno

#5
This is for AutoReg 1.0:
function file_register($nick, $password){
	/*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with custom PtoAkX script AutoReg 1.0:
 		http://forum.ptokax.org/index.php?topic=6750.0

    Does not return anything.Prints out a sucessful write or not.
	*****************/
	$file = "C:/path/to/file.txt"; //path to addreg.txt, including filename
	$type = "3";
	if (is_writeable($file)){
        $data = "$nick $password $type";
		if(file_put_contents($file,$data,FILE_APPEND)){
			echo "<p><b>Account $nick registered.</b>";
		}
 	}
	else{
		echo "<p>Unable to write to <tt>$file</tt><p>";
 	}
}



MISC FUNCTIONS:
function register($nick, $password){
    /*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with PtokaX 0.3.4.x
		Concept only, PtokaX will overwrite any registrations made with this
		with registrations made from the hub

		Returns true on sucess or false on fail
	*****************/
	$dir = "";      //location of PtokaX cfg folder. Include the cfg folder
					//and the trailing slash. Must be forward slashes
	$userlist = "RegisteredUsers.xml";
	
    $xml = simplexml_load_file($dir.$userlist);
    
    $RU = $xml->addChild("RegisteredUser");
	$RU->addChild('Nick',$nick);
	$RU->addChild('Password',$password);
	$RU->addChild('Profile','3');		//Change 3 to the default profile ID.
	                                    //Default: 0 = Master, 1 = Operator, 2 = VIP, 3 = Reg
	if (is_writeable($dir.$userlist)){
    	if(file_put_contents($dir.$userlist,$xml->asXML())){
			return true;
 		}
	}
	else{
		return false;
 	}
}



function search($search){
    /*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with PtokaX 0.3.4.x
		Searches current registrations and prints result
		Accepts regular expressions

		Returns true on success or false on fail
	*****************/
	$dir = "C:/dc_server/0.3.4.0.dbg/cfg/";
	//location of PtokaX cfg folder. Include the cfg folder and the trailing slash. Must be forward slashes
	$userlist = "RegisteredUsers.xml";
    $xml = simplexml_load_file($dir.$userlist);
    echo "Searching for \"<tt>$search</tt>\"...";
    $results = array();
   	for ($i=0; $i<count($xml->RegisteredUser); $i++){
		if(eregi($search,$xml->RegisteredUser[$i]->Nick)){
			$results[] = strval($xml->RegisteredUser[$i]->Nick);
  		}
 	}
 
 	foreach ($results as $name){
		echo "$name<br />";
  	}
}

nEgativE

Quote from: coreno on 21 January, 2007, 07:49:53
This is for AutoReg 1.0:
function file_register($nick, $password){
	/*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with custom PtoAkX script AutoReg 1.0:
 		http://forum.ptokax.org/index.php?topic=6750.0

    Does not return anything.Prints out a sucessful write or not.
	*****************/
	$file = "C:/path/to/file.txt"; //path to addreg.txt, including filename
	$type = "3";
	if (is_writeable($file)){
        $data = "$nick $password $type";
		if(file_put_contents($file,$data,FILE_APPEND)){
			echo "<p><b>Account $nick registered.</b>";
		}
 	}
	else{
		echo "<p>Unable to write to <tt>$file</tt><p>";
 	}
}



MISC FUNCTIONS:
function register($nick, $password){
    /*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with PtokaX 0.3.4.x
		Concept only, PtokaX will overwrite any registrations made with this
		with registrations made from the hub

		Returns true on sucess or false on fail
	*****************/
	$dir = "";      //location of PtokaX cfg folder. Include the cfg folder
					//and the trailing slash. Must be forward slashes
	$userlist = "RegisteredUsers.xml";
	
    $xml = simplexml_load_file($dir.$userlist);
    
    $RU = $xml->addChild("RegisteredUser");
	$RU->addChild('Nick',$nick);
	$RU->addChild('Password',$password);
	$RU->addChild('Profile','3');		//Change 3 to the default profile ID.
	                                    //Default: 0 = Master, 1 = Operator, 2 = VIP, 3 = Reg
	if (is_writeable($dir.$userlist)){
    	if(file_put_contents($dir.$userlist,$xml->asXML())){
			return true;
 		}
	}
	else{
		return false;
 	}
}



function search($search){
    /*****************
		Written by coreno (coreno {at} gmail.com)
		Jan. 2007
		Code may be distributed feely, please leave credits intact
		Please note any changes
		For use with PtokaX 0.3.4.x
		Searches current registrations and prints result
		Accepts regular expressions

		Returns true on success or false on fail
	*****************/
	$dir = "C:/dc_server/0.3.4.0.dbg/cfg/";
	//location of PtokaX cfg folder. Include the cfg folder and the trailing slash. Must be forward slashes
	$userlist = "RegisteredUsers.xml";
    $xml = simplexml_load_file($dir.$userlist);
    echo "Searching for \"<tt>$search</tt>\"...";
    $results = array();
   	for ($i=0; $i<count($xml->RegisteredUser); $i++){
		if(eregi($search,$xml->RegisteredUser[$i]->Nick)){
			$results[] = strval($xml->RegisteredUser[$i]->Nick);
  		}
 	}
 
 	foreach ($results as $name){
		echo "$name<br />";
  	}
}


Sorry, but how do we use this code ?

plop

doesn't php have sockets?

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

bastya_elvtars

It does, but it's optional, and in some cases it is compiled without socket support.
Everything could have been anything else and it would have just as much meaning.

nEgativE

Quote from: Mutor on 01 March, 2007, 00:30:15
It is run in a php enabled web sever.
The reg data [$file] should be saved to a
folder accessible by PtokaX.

Use the AutoReg lua script to register
users from that reg data file. We have other
scripts to do this, but all require php or
similar, which the Px inbuilt web server does
not support.

Hi Mutor.. maybe i'm doing something wrong here.. but the php code on the "my php webserver" doesn't return nothing for registering.. could u help me here ? thx.

SMF spam blocked by CleanTalk