Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Modyfikacja wtyczki Loterii
Forum PHP.pl > Forum > PHP
marbodz
Witam,
Tak jak w temacie potrzebuję zmodyfikować kod php Loterii
Link do pliku php

Mianowicie jak zrobić żeby w każdej loterii była ustalona ilość biletów do kupienia np. 100 i po sprzedaniu 100 biletów nie można więcej kupić i loteria kończy się?
Znalazłem w skrypcie komentarze "// You can choose number of tickets sold!" próbowałem wprowadzać jakieś kosmetyczne zmiany ale troche mało się znam na php.

Z góry dzięki z pomoc, może komuś się jeszcze przyda wasza porada:))

  1. <?php
  2. /*
  3.  * @component AlphaUserPoints
  4.  * @copyright Copyright (C) 2008-2012 Bernard Gilly
  5.  * @license : GNU/GPL
  6.  * @Website : <a href="http://www.alphaplug.com" target="_blank">http://www.alphaplug.com</a>
  7.  */
  8.  
  9. // Check to ensure this file is included in Joomla!
  10. defined( '_JEXEC' ) or die( 'Restricted access' );
  11.  
  12. jimport( 'joomla.plugin.plugin' );
  13.  
  14. /**
  15.  * AlphaUserPoints Content Plugin
  16.  *
  17.  * @package Joomla
  18.  * @subpackage AlphaUserPoints
  19.  * @since 1.6
  20.  */
  21.  
  22. class plgContentsysplgaup_raffle extends JPlugin
  23. {
  24.  
  25. public function onContentPrepare($context, &$article, &$params, $limitstart)
  26. {
  27. $app = JFactory::getApplication();
  28.  
  29. $db = JFactory::getDBO();
  30. $user = JFactory::getUser();
  31.  
  32. $print = JRequest::getVar('print', '');
  33. $format = JRequest::getVar('format', '');
  34.  
  35. $aupraffleid = JRequest::getVar('aupraffleid', 0, 'POST', 'int');
  36. $aupraffleuserid = JRequest::getVar('aupraffleuserid', 0, 'POST', 'int');
  37. $auprafflepoints = JRequest::getVar('auprafflepoints', 0, 'POST', 'int');
  38. $auprafflepointsremove = JRequest::getVar('auprafflepointsremove', 0, 'POST', 'int');
  39. $multipleentries = JRequest::getVar('multipleentries', 0, 'POST', 'int');
  40.  
  41. $inscription = 0;
  42. $pointstoparticipate = 0;
  43. $removepointstoparticipate = 0;
  44.  
  45. if ( $print || $format=='pdf' ) {
  46. $article->text = preg_replace( " |{AUP::RAFFLE=(.*)}| ", "", $article->text );
  47. return;
  48. }
  49.  
  50. if ($app->isAdmin()) return;
  51.  
  52. JPlugin::loadLanguage( 'com_alphauserpoints', JPATH_SITE );
  53.  
  54. $api_AUP = JPATH_SITE.DS.'components'.DS.'com_alphauserpoints'.DS.'helper.php';
  55. require_once ($api_AUP);
  56.  
  57. if ( preg_match('#{AUP::RAFFLE=(.*)}#Uis', $article->text, $m) && !$aupraffleid ) // form not sent
  58. {
  59. $raffleid = $m[1];
  60.  
  61. if ( $raffleid=='ID' ) {
  62. // sample
  63. return;
  64. }
  65.  
  66. $query = "SELECT * FROM #__alpha_userpoints_raffle WHERE `id`='$raffleid' AND `published`='1'";
  67. $db->setQuery( $query );
  68. $result = $db->loadObjectList();
  69.  
  70. if ( $result )
  71. {
  72. $inscription = $result[0]->inscription;
  73. $pointstoparticipate = $result[0]->pointstoparticipate;
  74. $removepointstoparticipate = $result[0]->removepointstoparticipate;
  75. $multipleentries = $result[0]->multipleentries;
  76. $alreadyProceeded = $result[0]->winner1;
  77.  
  78. }
  79.  
  80. // You can choose number subscriptions members
  81. //$query = "SELECT COUNT(DISTINCT userid) FROM #__alpha_userpoints_raffle_inscriptions WHERE `raffleid`='$raffleid'";
  82.  
  83. // You can choose number of tickets sold!
  84. $query = "SELECT COUNT(id) FROM #__alpha_userpoints_raffle_inscriptions WHERE `raffleid`='$raffleid'";
  85. $db->setQuery( $query );
  86. $num_subscription = $db->loadResult();
  87. $article->text .= "\n<span class=\"lottery2\">".JText::_('AUP_NUMBER_SUBSCRIPTION_CURRENT_RAFFLE'). " " . $num_subscription . "</br></br>
  88. <span style=\" font-size: 14px; color: #f0fae8;\"></span>\n";
  89.  
  90. if ( $inscription && $user->id && $alreadyProceeded==0)
  91. {
  92.  
  93. if ( !$multipleentries ) {
  94. $query = "SELECT userid FROM #__alpha_userpoints_raffle_inscriptions WHERE `userid`='$user->id' AND `raffleid`='$raffleid'";
  95. $db->setQuery( $query );
  96. $userid = $db->loadResult();
  97. } else $userid=0;
  98.  
  99.  
  100. if ( !$userid )
  101. {
  102. $registrationForm = "\n<form action=\"\" method=\"post\" name=\"RaffleForm\">\n"
  103. . "<input type=\"hidden\" name=\"aupraffleid\" id=\"aupraffleid\" value=\"".$raffleid."\" />\n"
  104. . "<input type=\"hidden\" name=\"aupraffleuserid\" id=\"aupraffleuserid\" value=\"".$user->id."\" />\n"
  105. . "<input type=\"hidden\" name=\"auprafflepoints\" id=\"auprafflepoints\" value=\"".$pointstoparticipate."\" />\n"
  106. . "<input type=\"hidden\" name=\"auprafflepointsremove\" id=\"auprafflepointsremove\" value=\"".$removepointstoparticipate."\" />\n"
  107. . "<input type=\"hidden\" name=\"multipleentries\" id=\"multipleentries\" value=\"".$multipleentries."\" />\n"
  108. . "<input class=\"button\" type=\"submit\" name=\"Submit\" value=\"".JText::_('AUP_SIGNUP_FOR_THIS_RAFFLE_NOW')."\" />\n"
  109. ."</form>\n";
  110.  
  111. if ( $pointstoparticipate )
  112. {
  113. $referreid = AlphaUserPointsHelper::getAnyUserReferreID( $user->id );
  114. $currentpoints = AlphaUserPointsHelper::getCurrentTotalPoints ( $referreid );
  115. if ( $currentpoints>=$pointstoparticipate )
  116. {
  117. $article->text .= $registrationForm;
  118. }
  119. else
  120. {
  121. $article->text .= "\n<p>".JText::_('AUP_YOUDONOTHAVEENOUGHPOINTSTOPERFORMTHISOPERATION')."</p>\n";
  122. }
  123. }
  124. else
  125. {
  126. $article->text .= $registrationForm;
  127. }
  128. }
  129. else
  130. {
  131. $article->text .= "\n<p>".JText::_('AUP_ALREADY_REGISTERED_FOR_THIS_RAFFLE')."</p>\n";
  132. }
  133.  
  134. }
  135. elseif ( $inscription && $user->id && $alreadyProceeded>0)
  136. {
  137. $article->text .= "\n<p>".JText::_('AUP_DRAW_HAS_BEEN_MADE_YOU_CANT_REGISTER')."</p>\n";
  138. $article->text = preg_replace( " |{AUP::RAFFLE=(.*)}| ", "", $article->text );
  139. return;
  140. } else {
  141. $article->text = preg_replace( " |{AUP::RAFFLE=(.*)}| ", "", $article->text );
  142. return;
  143. }
  144. }
  145. elseif ( preg_match('#{AUP::RAFFLE=(.*)}#Uis', $article->text, $m) && $aupraffleid && $aupraffleuserid )
  146. {
  147. if ( !$multipleentries ) {
  148. $query = "SELECT userid FROM #__alpha_userpoints_raffle_inscriptions WHERE `userid`='$aupraffleuserid' AND `raffleid`='$aupraffleid'";
  149. $db->setQuery( $query );
  150. $alreadyregister = $db->loadResult();
  151. } else $alreadyregister=0;
  152.  
  153. if ( !$alreadyregister )
  154. {
  155. //Save registration
  156. JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_alphauserpoints'.DS.'tables');
  157. $row = JTable::getInstance('raffle_inscriptions');
  158. $row->id = NULL;
  159. $row->raffleid = $aupraffleid;
  160. $row->userid = $aupraffleuserid;
  161. if ( !$row->store() )
  162. {
  163. JError::raiseError(500, $row->getError());
  164. }
  165. else
  166. {
  167. // remove points if necessary
  168. if ( $auprafflepointsremove && $auprafflepoints ) {
  169. AlphaUserPointsHelper::newpoints( 'sysplgaup_raffle', '', '', JText::_('AUP_LABEL_REGISTRATION_RAFFLE'), (abs($auprafflepoints)*(-1)) );
  170. }
  171. $app->enqueueMessage( JText::_('AUP_CONFIRM_RAFFLE_REGISTRATION') );
  172.  
  173. // You can choose number subscriptions members
  174. //$query = "SELECT COUNT(DISTINCT aupraffleuserid) FROM #__alpha_userpoints_raffle_inscriptions WHERE `raffleid`='$aupraffleid'";
  175. // You can choose number of tickets sold!
  176. $query = "SELECT COUNT(id) FROM #__alpha_userpoints_raffle_inscriptions WHERE `raffleid`='$aupraffleid'";
  177. $db->setQuery( $query );
  178. $num_subscription = $db->loadResult();
  179. $article->text .= "\n<p>".JText::_('AUP_NUMBER_SUBSCRIPTION_CURRENT_RAFFLE'). " " . $num_subscription . "</p>\n";
  180.  
  181. $article->text .= "\n<p>".JText::_('AUP_YOUR_SUBSCRIPTION_HAS_BEEN_REGISTERED')."</p>\n";
  182. // check new total points to play again
  183. $referreid = AlphaUserPointsHelper::getAnyUserReferreID( $user->id );
  184. $currentpoints = AlphaUserPointsHelper::getCurrentTotalPoints ( $referreid );
  185. if ( $currentpoints>=$auprafflepoints && $multipleentries )
  186. {
  187. $uri = JURI::getInstance();
  188. $url = $uri->toString();
  189. $article->text .= "\n<p><a href=\"$url\">".JText::_('AUP_SUBSCRIBE_AGAIN')."</a></p>\n";
  190. }
  191.  
  192. }
  193. } else $article->text .= "\n<p>".JText::_('AUP_ALREADY_REGISTERED_FOR_THIS_RAFFLE')."</p>\n";
  194.  
  195. }
  196.  
  197. // article text updated
  198. $article->text = preg_replace( " |{AUP::RAFFLE=(.*)}| ", "", $article->text );
  199. }
  200.  
  201. }
  202. ?>
Fifi209
Może wrzuć kod na forum a nie na jakiś dziki serwer?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.