function show_listen($row)
{
    extract($row);
    print listname($name_kurz, $name_lang) . " & {$stimmen} & " . percent($stimmen, $summe) . "\\% & {$hoechstzahl} & {$sitze} &" . ($los > 0 ? "(+1)" : "") . "\\\\\n";
}
Exemple #2
0
    if ($_POST["password"] != $curpwd[0]) {
    	$storepassword = '******'.$newpassword.'"';
      Sql_query("update {$tables["user"]} set passwordchanged = now(),$storepassword where id = $userid");
    } else {
    	$storepassword = "";
    }
  } else {
  	$storepassword = "";
  }

  # subscribe to the lists
  if (is_array($_POST["list"])) {
    while(list($key,$val)= each($_POST["list"])) {
      if ($val == "signup") {
        $result = Sql_query("replace into {$tables["listuser"]} (userid,listid,entered) values($userid,$key,now())");
        $lists .= "\n  * ".listname($key);
      }
    }
  }

  # remember the users attributes
  # make sure to only remember the ones from this subscribe page
  $attids = join(',',$attributes);
  $attids = substr($attids,0,-1);
  if ($attids && $attids != "") {
    $res = Sql_Query("select * from ".$tables["attribute"]." where id in ($attids)");
    while ($row = Sql_Fetch_Array($res)) {
      if ($row["tablename"] != "")
        $fieldname = $row["tablename"];
      else
        $fieldname = "attribute" .$row["id"];
 /**
  * Add a Subscriber with lists.
  * 
  * <p><strong>Parameters:</strong><br/>
  * [*email] {string} the email address of the Subscriber.<br/>
  * [*foreignkey] {string} Foreign key.<br/>
  * [*htmlemail] {integer} 1=html emails, 0=no html emails.<br/>
  * [*subscribepage] {integer} subscribepage to sign up to.<br/>
  * [*lists] {string} comma-separated list IDs.<br/>
  * </p>
  * <p><strong>Returns:</strong><br/>
  * The added Subscriber.
  * </p>
  */
 public static function subscribe()
 {
     $sql = 'INSERT INTO ' . $GLOBALS['tables']['user'] . ' 
       (email, htmlemail, foreignkey, subscribepage, entered, uniqid) 
       VALUES (:email, :htmlemail, :foreignkey, :subscribepage, now(), :uniqid);';
     $uniqueID = Common::createUniqId();
     $subscribePage = sprintf('%d', $_REQUEST['subscribepage']);
     if (!validateEmail($_REQUEST['email'])) {
         Response::outputErrorMessage('invalid email address');
     }
     $listNames = '';
     $lists = explode(',', $_REQUEST['lists']);
     try {
         $db = PDO::getConnection();
         $stmt = $db->prepare($sql);
         $stmt->bindParam('email', $_REQUEST['email'], PDO::PARAM_STR);
         $stmt->bindParam('htmlemail', $_REQUEST['htmlemail'], PDO::PARAM_BOOL);
         /* @@todo ensure uniqueness of FK */
         $stmt->bindParam('foreignkey', $_REQUEST['foreignkey'], PDO::PARAM_STR);
         $stmt->bindParam('subscribepage', $subscribePage, PDO::PARAM_INT);
         $stmt->bindParam('uniqid', $uniqueID, PDO::PARAM_STR);
         $stmt->execute();
         $subscriberId = $db->lastInsertId();
         foreach ($lists as $listId) {
             $stmt = $db->prepare('replace into ' . $GLOBALS['tables']['listuser'] . ' (userid,listid,entered) values(:userid,:listid,now())');
             $stmt->bindParam('userid', $subscriberId, PDO::PARAM_INT);
             $stmt->bindParam('listid', $listId, PDO::PARAM_INT);
             $stmt->execute();
             $listNames .= "\n  * " . listname($listId);
         }
         $subscribeMessage = getUserConfig("subscribemessage:{$subscribePage}", $subscriberId);
         $subscribeMessage = str_replace('[LISTS]', $listNames, $subscribeMessage);
         $subscribePage = sprintf('%d', $_REQUEST['subscribepage']);
         sendMail($_REQUEST['email'], getConfig("subscribesubject:{$subscribePage}"), $subscribeMessage);
         addUserHistory($_REQUEST['email'], 'Subscription', 'Subscription via the Rest-API plugin');
         $db = null;
         self::SubscriberGet($subscriberId);
     } catch (\Exception $e) {
         Response::outputError($e);
     }
 }