<commit_before><?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="punch_o_matic" active="1">
	<title>3DG - Nick Changer</title>
	<description>Allow normal users change his username over a time period</description>
	<version>0.2</version>
	<url>http://foros.3dgames.com.ar/</url>
	<versioncheckurl></versioncheckurl>
	<dependencies>
	</dependencies>
	<codes>
		<code version="0.1">
		  <installcode><![CDATA[$db->hide_errors();

      # Log for all the usernames changes
      $vbulletin->db->query_write("CREATE TABLE IF NOT EXISTS `". TABLE_PREFIX ."nick_changer_usernames` (
          `id` INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
          `userid` INT(10) NOT NULL,
          `username` VARCHAR(50) NOT NULL,
          `dateline` INT(10) NOT NULL)
          ");
      $vbulletin->db->query_write("ALTER TABLE `". TABLE_PREFIX ."nick_changer_usernames` ADD INDEX ( `userid` )");

      $vbulletin->db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` ADD `nick_changer_last_change` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL");

      $db->show_errors();]]>
      </installcode>
      <uninstallcode><![CDATA[$db->hide_errors();

      $vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "nick_changer_usernames");
      $vbulletin->db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP COLUMN `nick_changer_last_change`");

      $db->show_errors();]]>
      </uninstallcode>
    </code>
    <code version="0.2">
      <installcode><![CDATA[$db->hide_errors();
      $db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` ADD `nick_changer_last_username` varchar( 100 )");

      $changes = $db->query_read("SELECT userid, username FROM `".TABLE_PREFIX."nick_changer_usernames` ORDER BY id ASC");
      while ($change = $db->fetch_array($changes)) {
        $db->query_write("UPDATE `".TABLE_PREFIX."user` SET nick_changer_last_username='".$db->escape_string($change['username'])."' where userid=".$change['userid']);
      }
      $db->show_errors();]]>
      </installcode>
      <uninstallcode><![CDATA[$db->hide_errors();
      $db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` DROP COLUMN `nick_changer_last_username`");
      $db->show_errors();]]>
      </uninstallcode>
    </code>
  </codes>
  <templates>
		<template name="nick_changer_javascript" templatetype="template" version="0.1"><![CDATA[
		  <script type="text/javascript" src="clientscript/nick_changer.js"></script>
		  ]]>
		</template>
  	<template name="nick_changer_usernamebit" templatetype="template" date="" username="" version="0.1"><![CDATA[
  	  <span>$username</span> |
  	  ]]>
  	</template>
	  <template name="nick_changer_last_usernames" templatetype="template" date="" username="" version="0.1"><![CDATA[
      <!-- usernames row -->
      <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
      <tr>
      	<td class="thead">$vbphrase[nick_changer_last_usernames]</td>
      </tr>
      <tr>
      	<td class="panelsurround" title="$vbphrase[nick_changer_last_usernames]">
      	  <div class="panel" align="center">
    	      | $usernames
    	    </div>
      	</td>
      </tr>
      </table>
      <!-- / usernames row -->
      <br />
      ]]>
    </template>
  	<template name="nick_changer_form" templatetype="template" date="0" username="" version="0.1"><![CDATA[
      <form action="nick_changer.php?do=dochance_username" method="post" name="vbform">
      <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
      <tr>
      	<td class="tcat">$vbphrase[username]</td>
      </tr>
      <tr>
      	<td class="panelsurround" align="center">
      	<div class="panel">
      	  $vbphrase[nick_changer_username_desc]
      	</div>
      	<div class="panel">
      	  $vbphrase[nick_changer_username] : 
      		<input type="text" name="username" value="$url" onblur="nick_changer_check_availability(this.value);" />
      		<img id="nick_changer_spinner" alt="Spinner" src="/images/nick_changer_spinner.gif" style="display:none;" />
      		<br />
      	</div>

    		<div class="panel" id="nick_changer_available">
    		</div>

      	<div class="panel">
      	  <input type="checkbox" name="username_confirmation" id="username_confirmation" value="1" />
      	  <label for="username_confirmation">$vbphrase[nick_changer_username_confirmation]</label>
      	</div>

  			<input type="submit" class="button" value="$vbphrase[save]" accesskey="s" tabindex="1" />
      	</td>
      </tr>
      </table>
      </form>
      ]]>
    </template>
  	<template name="nick_changer_no_permission" templatetype="template" date="0" username="" version="0.1"><![CDATA[
        <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
        <tr>
        	<td class="tcat">$vbphrase[nick_changer_username]</td>
        </tr>
        <tr>
        	<td class="panelsurround" align="center">
          	<div class="panel">
          	  $vbphrase[nick_changer_no_permission]
          	</div>
          	
          	<div class="panel">
          	  $days
          	</div>
        	</td>
        </tr>
        </table>
        </form>
      ]]>
    </template>
    <template name="nick_changer_usernote" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[[b]$vbphrase[nick_changer_usernote_text][/b] $old_username]]>
    </template>
    <template name="nick_changer_check_error" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[
	    <img src='images/nick_changer_error.gif' align='bottom' />
	    <span style='font-size: 16px; line-height: 16px;'>Already registered</span>
      ]]>
    </template>
    <template name="nick_changer_check_ok" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[
      <img src='images/nick_changer_ok.gif' align='bottom' />
      <span style='font-size: 16px; line-height: 16px;'>Username available</span>
      ]]>
    </template>
  </templates>
  <plugins>
    <plugin active="1" executionorder="5">
      <title><![CDATA[Show the previous username in postbit]]></title>
      <hookname>postbit_display_complete</hookname>
      <phpcode><![CDATA[
        global $vbphrase, $vbulletin;
        $seconds = $vbulletin->options['nick_changer_show_last_username']*86400;
        if ($vbulletin->options['nick_changer_show_last_username'] > 0) {
          if ((intval($this->post['nick_changer_last_change']) - TIMENOW + $seconds > 0) && !empty($this->post['nick_changer_last_username'])) {
            $template_hook[postbit_userinfo_left]	.= construct_phrase($vbphrase['nick_changer_previous_username'], $this->post['nick_changer_last_username']);
          }
        }
        ]]></phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title><![CDATA[Set nick_changer_last_change as valid field to users]]></title>
      <hookname>userdata_start</hookname>
      <phpcode><![CDATA[$this->validfields['nick_changer_last_change'] = array(TYPE_UINT, REQ_NO);
        $this->validfields['nick_changer_last_username'] = array(TYPE_STR, REQ_NO);]]></phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Add navbit for User options panel</title>
      <hookname>usercp_nav_start</hookname>
      <phpcode><![CDATA[
        $cells[] = 'nick_changer';
        ]]>
      </phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Fetch data for profile</title>
      <hookname>member_start</hookname>
      <phpcode><![CDATA[
        require(DIR . '/includes/functions_nick_changer.php');
        $last_usernames = fetch_usernames_for_user($vbulletin->GPC['userid']);
        ]]>
      </phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Show old usernames</title>
      <hookname>member_complete</hookname>
      <phpcode><![CDATA[
        $usernames = '';
        if (count($last_usernames) > 0) {
          foreach($last_usernames as $username) {<commit_msg>Show the previous username when read PM.<commit_after><?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="punch_o_matic" active="1">
	<title>3DG - Nick Changer</title>
	<description>Allow normal users change his username over a time period</description>
	<version>0.3</version>
	<url>http://foros.3dgames.com.ar/</url>
	<versioncheckurl></versioncheckurl>
	<dependencies>
	</dependencies>
	<codes>
		<code version="0.1">
		  <installcode><![CDATA[$db->hide_errors();

      # Log for all the usernames changes
      $vbulletin->db->query_write("CREATE TABLE IF NOT EXISTS `". TABLE_PREFIX ."nick_changer_usernames` (
          `id` INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
          `userid` INT(10) NOT NULL,
          `username` VARCHAR(50) NOT NULL,
          `dateline` INT(10) NOT NULL)
          ");
      $vbulletin->db->query_write("ALTER TABLE `". TABLE_PREFIX ."nick_changer_usernames` ADD INDEX ( `userid` )");

      $vbulletin->db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` ADD `nick_changer_last_change` INT( 10 ) UNSIGNED DEFAULT '0' NOT NULL");

      $db->show_errors();]]>
      </installcode>
      <uninstallcode><![CDATA[$db->hide_errors();

      $vbulletin->db->query_write("DROP TABLE IF EXISTS " . TABLE_PREFIX . "nick_changer_usernames");
      $vbulletin->db->query_write("ALTER TABLE " . TABLE_PREFIX . "user DROP COLUMN `nick_changer_last_change`");

      $db->show_errors();]]>
      </uninstallcode>
    </code>
    <code version="0.2">
      <installcode><![CDATA[$db->hide_errors();
      $db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` ADD `nick_changer_last_username` varchar( 100 )");

      $changes = $db->query_read("SELECT userid, username FROM `".TABLE_PREFIX."nick_changer_usernames` ORDER BY id ASC");
      while ($change = $db->fetch_array($changes)) {
        $db->query_write("UPDATE `".TABLE_PREFIX."user` SET nick_changer_last_username='".$db->escape_string($change['username'])."' where userid=".$change['userid']);
      }
      $db->show_errors();]]>
      </installcode>
      <uninstallcode><![CDATA[$db->hide_errors();
      $db->query_write("ALTER TABLE `". TABLE_PREFIX ."user` DROP COLUMN `nick_changer_last_username`");
      $db->show_errors();]]>
      </uninstallcode>
    </code>
  </codes>
  <templates>
		<template name="nick_changer_javascript" templatetype="template" version="0.1"><![CDATA[
		  <script type="text/javascript" src="clientscript/nick_changer.js"></script>
		  ]]>
		</template>
  	<template name="nick_changer_usernamebit" templatetype="template" date="" username="" version="0.1"><![CDATA[
  	  <span>$username</span> |
  	  ]]>
  	</template>
	  <template name="nick_changer_last_usernames" templatetype="template" date="" username="" version="0.1"><![CDATA[
      <!-- usernames row -->
      <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
      <tr>
      	<td class="thead">$vbphrase[nick_changer_last_usernames]</td>
      </tr>
      <tr>
      	<td class="panelsurround" title="$vbphrase[nick_changer_last_usernames]">
      	  <div class="panel" align="center">
    	      | $usernames
    	    </div>
      	</td>
      </tr>
      </table>
      <!-- / usernames row -->
      <br />
      ]]>
    </template>
  	<template name="nick_changer_form" templatetype="template" date="0" username="" version="0.1"><![CDATA[
      <form action="nick_changer.php?do=dochance_username" method="post" name="vbform">
      <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
      <tr>
      	<td class="tcat">$vbphrase[username]</td>
      </tr>
      <tr>
      	<td class="panelsurround" align="center">
      	<div class="panel">
      	  $vbphrase[nick_changer_username_desc]
      	</div>
      	<div class="panel">
      	  $vbphrase[nick_changer_username] : 
      		<input type="text" name="username" value="$url" onblur="nick_changer_check_availability(this.value);" />
      		<img id="nick_changer_spinner" alt="Spinner" src="/images/nick_changer_spinner.gif" style="display:none;" />
      		<br />
      	</div>

    		<div class="panel" id="nick_changer_available">
    		</div>

      	<div class="panel">
      	  <input type="checkbox" name="username_confirmation" id="username_confirmation" value="1" />
      	  <label for="username_confirmation">$vbphrase[nick_changer_username_confirmation]</label>
      	</div>

  			<input type="submit" class="button" value="$vbphrase[save]" accesskey="s" tabindex="1" />
      	</td>
      </tr>
      </table>
      </form>
      ]]>
    </template>
  	<template name="nick_changer_no_permission" templatetype="template" date="0" username="" version="0.1"><![CDATA[
        <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
        <tr>
        	<td class="tcat">$vbphrase[nick_changer_username]</td>
        </tr>
        <tr>
        	<td class="panelsurround" align="center">
          	<div class="panel">
          	  $vbphrase[nick_changer_no_permission]
          	</div>
          	
          	<div class="panel">
          	  $days
          	</div>
        	</td>
        </tr>
        </table>
        </form>
      ]]>
    </template>
    <template name="nick_changer_usernote" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[[b]$vbphrase[nick_changer_usernote_text][/b] $old_username]]>
    </template>
    <template name="nick_changer_check_error" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[
	    <img src='images/nick_changer_error.gif' align='bottom' />
	    <span style='font-size: 16px; line-height: 16px;'>Already registered</span>
      ]]>
    </template>
    <template name="nick_changer_check_ok" templatetype="template" date="0" username="" version="0.1">
      <![CDATA[
      <img src='images/nick_changer_ok.gif' align='bottom' />
      <span style='font-size: 16px; line-height: 16px;'>Username available</span>
      ]]>
    </template>
  </templates>
  <plugins>
    <plugin active="1" executionorder="5">
      <title><![CDATA[Show the previous username in postbit]]></title>
      <hookname>postbit_display_complete</hookname>
      <phpcode><![CDATA[
        global $vbphrase, $vbulletin;
        $seconds = $vbulletin->options['nick_changer_show_last_username']*86400;
        if ($vbulletin->options['nick_changer_show_last_username'] > 0) {
          if ((intval($this->post['nick_changer_last_change']) - TIMENOW + $seconds > 0) && !empty($this->post['nick_changer_last_username'])) {
            $template_hook[postbit_userinfo_left]	.= construct_phrase($vbphrase['nick_changer_previous_username'], $this->post['nick_changer_last_username']);
          }
        }
        ]]></phpcode>
    </plugin>
		<plugin active="1" executionorder="5">
			<title>Show the previous username in pm</title>
			<hookname>private_showpm_start</hookname>
			<phpcode><![CDATA[global $vbphrase, $vbulletin;
        $seconds = $vbulletin->options['nick_changer_show_last_username']*86400;
        if ($vbulletin->options['nick_changer_show_last_username'] > 0) {
          if ((intval($pm['nick_changer_last_change']) - TIMENOW + $seconds > 0) && !empty($pm['nick_changer_last_username'])) {
            $template_hook[postbit_userinfo_left]	.= construct_phrase($vbphrase['nick_changer_previous_username'], $pm['nick_changer_last_username']);
          }
        }]]></phpcode>
		</plugin>
    <plugin active="1" executionorder="5">
      <title><![CDATA[Set nick_changer_last_change as valid field to users]]></title>
      <hookname>userdata_start</hookname>
      <phpcode><![CDATA[$this->validfields['nick_changer_last_change'] = array(TYPE_UINT, REQ_NO);
        $this->validfields['nick_changer_last_username'] = array(TYPE_STR, REQ_NO);]]></phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Add navbit for User options panel</title>
      <hookname>usercp_nav_start</hookname>
      <phpcode><![CDATA[
        $cells[] = 'nick_changer';
        ]]>
      </phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Fetch data for profile</title>
      <hookname>member_start</hookname>
      <phpcode><![CDATA[
        require(DIR . '/includes/functions_nick_changer.php');
        $last_usernames = fetch_usernames_for_user($vbulletin->GPC['userid']);
        ]]>
      </phpcode>
    </plugin>
    <plugin active="1" executionorder="5">
      <title>Show old usernames</title>
      <hookname>member_complete</hookname>
      <phpcode><![CDATA[
        $usernames = '';
        if (count($last_usernames) > 0) {
          foreach($last_usernames as $username) {
{'fraction_non_alphanumeric': 0.1721944035346097, 'fraction_numerical': 0.011251840942562591, 'mean_word_length': 3.54389721627409, 'pattern_counts': {'":': 0, '<': 354, '<?xml version=': 2, '>': 426, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1746533', 'n_tokens_mistral': 5864, 'n_tokens_neox': 5587, 'n_words': 907}