当前位置: 首页>>代码示例>>PHP>>正文


PHP Sql_Insert_Id函数代码示例

本文整理汇总了PHP中Sql_Insert_Id函数的典型用法代码示例。如果您正苦于以下问题:PHP Sql_Insert_Id函数的具体用法?PHP Sql_Insert_Id怎么用?PHP Sql_Insert_Id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Sql_Insert_Id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addEmail

 function addEmail($email, $password = "")
 {
     Sql_Query(sprintf('insert into user set email = "%s",
   entered = now(),password = "%s",
   passwordchanged = now(),disabled = 0,
   uniqid = "%s",htmlemail = 1
   ', $email, $password, getUniqid()), 1);
     $id = Sql_Insert_Id();
     if (is_array($_SESSION["userdata"])) {
         saveUserByID($id, $_SESSION["userdata"]);
     }
     $_SESSION["userid"] = $id;
     return $id;
 }
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:14,代码来源:phplist.php

示例2: runtest

 function runtest()
 {
     if (empty($this->userdata['email'])) {
         print $GLOBALS['I18N']->get('Test email not set ');
         return 0;
     }
     ## insert an HTML page as a message
     Sql_Query(sprintf('insert into %s
   (subject,fromfield,message,footer,entered,status,sendformat)
   values("phplist test sendpage","test","[URL:http://www.phplist.com]","Unsubscribe link: [UNSUBSCRIBE]",current_timestamp,"test","text and HTML")', $GLOBALS['tables']['message']));
     require_once dirname(__FILE__) . '/../sendemaillib2.php';
     $testmsg = Sql_Insert_Id($GLOBALS['tables']['message'], 'id');
     print $GLOBALS['I18N']->get('Sending HTML version to ') . $this->userdata['email'];
     $suc6 = 0;
     $suc6 = sendEmail($testmsg, $this->userdata['email'], $this->userdata['uniqid'], 1);
     if ($suc6) {
         print ' ... ' . $GLOBALS['I18N']->get('OK');
     } else {
         print ' ... ' . $GLOBALS['I18N']->get('Failed');
     }
     print '<br/>';
     print $GLOBALS['I18N']->get('Sending Text version to ') . $this->userdata['email'];
     $suc6 = $suc6 && sendEmail($testmsg, $this->userdata['email'], $this->userdata['uniqid'], 0);
     if ($suc6) {
         print ' ... ' . $GLOBALS['I18N']->get('OK');
     } else {
         print ' ... ' . $GLOBALS['I18N']->get('Failed');
     }
     print '<br/>';
     if (CLICKTRACK) {
         print $GLOBALS['I18N']->get('Note: Links in emails will not work, because this is a test message, which is deleted after sending') . '<br/>';
     }
     print $GLOBALS['I18N']->get('Check your INBOX to see if all worked ok') . '<br/>';
     #deleteMessage($testmsg);
     print "Message ID: {$testmsg}<br/>";
     return $suc6;
 }
开发者ID:dehvCurtis,项目名称:phplist,代码行数:37,代码来源:sendpage.php

示例3: getPageLock

function getPageLock() {
	global $tables;
	$thispage = $GLOBALS["page"];
  $running_req = Sql_query("select now() - modified,id from ".$tables["sendprocess"]." where page = \"$thispage\" and alive order by started desc");
  $running_res = Sql_Fetch_row($running_req);
	$waited = 0;
  while ($running_res[1]) { # a process is already running
    output ("A process for this page is already running and it was still alive $running_res[0] seconds ago");
    output ("Sleeping for 20 seconds, aborting will now quit");
    $abort = ignore_user_abort(0);
    sleep(20);
		$waited++;
		if ($waited > 10) {
			# we have waited 10 cycles, abort and quit script
			output("We've been waiting too long, I guess the other script is still going ok");
			exit;
		}
    $running_req = Sql_query("select now() - modified,id from ".$tables["sendprocess"]." where page = \"$thispage\" and alive order by started desc");
    $running_res = Sql_Fetch_row($running_req);
    if ($running_res[0] > 1200) # some sql queries can take quite a while
      # process has been inactive for too long, kill it
      Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = $running_res[1]");
  }
  $res = Sql_query('insert into '.$tables["sendprocess"].' (started,page,alive,ipaddress) values(now(),"'.$thispage.'",1,"'.getenv("REMOTE_ADDR").'")');
  $send_process_id = Sql_Insert_Id();
  $abort = ignore_user_abort(1);
  return $send_process_id;
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:28,代码来源:lib.php

示例4: saveUserAttribute

function saveUserAttribute($userid,$attid,$data) {
	if ($data["nodbsave"]) {
  	dbg("Not saving $attid");
  	return;
 	}
  if ($attid == "emailcheck" || $attid == "passwordcheck") {
  	dbg("Not saving $attid");
  	return;
	}

	if (!$data["type"])
  	$data["type"] = "textline";

  if ($data["type"] == "static" || $data["type"] == "password") {
   	Sql_Query(sprintf('update user set %s = "%s" where id = %d',
    	$attid,$data["value"],$userid));
    return 1;
  }

  $attid_req = Sql_Fetch_Row_Query(sprintf('
    select id,type,tablename from attribute where id = %d',$attid));
  if (!$attid_req[0]) {
    $attid_req = Sql_Fetch_Row_Query(sprintf('
      select id,type,tablename from attribute where name = "%s"',$data["name"]));
    if (!$attid_req[0]) {
    	if ($GLOBALS["config"]["autocreate_attributes"]) {
        Dbg("Creating new Attribute: ".$data["name"]);
        sendError("creating new attribute ".$data["name"]);
        $atttable= getNewAttributeTablename($data["name"]);
        Sql_Query(sprintf('insert into attribute (name,type,tablename) values("%s","%s","%s")',$data["name"],$data["type"],$atttable));
        $attid = Sql_Insert_Id();
      } else {
        dbg("Not creating new Attribute: ".$data["name"]);
       # sendError("Not creating new attribute ".$data["name"]);
			}
    } else {
      $attid = $attid_req[0];
      $atttable = $attid_req[2];
  	}
	} else {
    $attid = $attid_req[0];
    $atttable = $attid_req[2];
  }

  if (!$atttable) {
  	$atttable = getNewAttributeTablename($data["name"]);
  	# fix attribute without tablename
    Sql_Query(sprintf('update attribute set tablename ="%s" where id = %d',
    	$atttable,$attid));
#  	sendError("Attribute without Tablename $attid");
  }

  switch ($data["type"]) {
  	case "static":
    case "password":
    	Sql_Query(sprintf('update user set %s = "%s" where id = %d',
      	$attid,$data["value"],$userid));
			break;
    case "select":
    	$curval = Sql_Fetch_Row_Query(sprintf('select id from phplist_listattr_%s
      	where name = "%s"',$atttable,$data["displayvalue"]),1);
      if (!$curval[0]) {
      	Sql_Query(sprintf('insert into phplist_listattr_%s (name) values("%s")',$atttable,
        	$data["displayvalue"]));
        sendError("Added ".$data["displayvalue"]." to $atttable");
        $valid = Sql_Insert_id();
      } else {
      	$valid = $curval[0];
      }
    	Sql_Query(sprintf('replace into user_attribute (userid,attributeid,value)
		  	values(%d,%d,"%s")',$userid,$attid,$valid));

			break;
   	default:
    	Sql_Query(sprintf('replace into user_attribute (userid,attributeid,value)
		  	values(%d,%d,"%s")',$userid,$attid,$data["value"]));
     	break;
 	}
  return 1;
}
开发者ID:radicaldesigns,项目名称:amp,代码行数:80,代码来源:userlib.php

示例5: Sql_fetch_array

        $count_exist++;
        $user = Sql_fetch_array($result);
        $userid = $user["id"];
        $uniqid = $user["uniqid"];
        Sql_Query(sprintf('update %s set htmlemail = %d where id = %d', $tables["user"], $_POST["markhtml"] ? "1" : "0", $userid));
    } else {
        // Email does not exist
        $new = 1;
        // Create unique number
        mt_srand((double) microtime() * 1000000);
        $randval = mt_rand();
        $uniqid = getUniqid();
        $query = sprintf('INSERT INTO %s (email,entered,confirmed,uniqid,htmlemail)
 values("%s",current_timestamp,%d,"%s",%d)', $tables["user"], $importuser["email"], $_POST["notify"] != "yes", $uniqid, $_POST["markhtml"] ? "1" : "0");
        $result = Sql_query($query);
        $userid = Sql_Insert_Id($tables['user'], 'id');
        $count_email_add++;
        $some = 1;
    }
    if ($_POST["overwrite"] == "yes") {
        if ($usetwo) {
            Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $firstname_att_id, $userid, $importuser["firstname"]));
            Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $lastname_att_id, $userid, $importuser["lastname"]));
        } else {
            Sql_query(sprintf('replace into %s (attributeid,userid,value) values(%d,%d,"%s")', $tables["user_attribute"], $name_att_id, $userid, $importuser["personal"]));
        }
    }
    #add this user to the lists identified
    reset($lists);
    $addition = 0;
    $listoflists = "";
开发者ID:dehvCurtis,项目名称:phplist,代码行数:31,代码来源:import3.php

示例6: clickTrackLinkId

function clickTrackLinkId($messageid, $userid, $url, $link)
{
    global $cached;
    if (!isset($cached['linktrack']) || !is_array($cached['linktrack'])) {
        $cached['linktrack'] = array();
    }
    if (!isset($cached['linktracksent']) || !is_array($cached['linktracksent'])) {
        $cached['linktracksent'] = array();
    }
    if (!isset($cached['linktrack'][$link])) {
        $query = ' select id' . ' from ' . $GLOBALS['tables']['linktrack_forward'] . ' where url = ?';
        $rs = Sql_Query_Params($query, array($url));
        $exists = Sql_Fetch_Row($rs);
        if (!$exists[0]) {
            $personalise = preg_match('/uid=/', $link);
            $query = ' insert into ' . $GLOBALS['tables']['linktrack_forward'] . '    (url, personalise)' . ' values' . '    (?, ?)';
            Sql_Query_Params($query, array($url, $personalise));
            $fwdid = Sql_Insert_Id($GLOBALS['tables']['linktrack_forward'], 'id');
        } else {
            $fwdid = $exists[0];
        }
        $cached['linktrack'][$link] = $fwdid;
    } else {
        $fwdid = $cached['linktrack'][$link];
    }
    if (!isset($cached['linktracksent'][$messageid]) || !is_array($cached['linktracksent'][$messageid])) {
        $cached['linktracksent'][$messageid] = array();
    }
    if (!isset($cached['linktracksent'][$messageid][$fwdid])) {
        $query = ' select total' . ' from ' . $GLOBALS['tables']['linktrack_ml'] . ' where messageid = ?' . '   and forwardid = ?';
        $rs = Sql_Query_Params($query, array($messageid, $fwdid));
        if (!Sql_Num_Rows($rs)) {
            $total = 1;
            ## first time for this link/message
            # BCD: Isn't this just an insert?
            Sql_Replace($GLOBALS['tables']['linktrack_ml'], array('total' => $total, 'messageid' => $messageid, 'forwardid' => $fwdid), array('messageid', 'forwardid'));
        } else {
            $tot = Sql_Fetch_Row($rs);
            $total = $tot[0] + 1;
            Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $total, $messageid, $fwdid));
        }
        $cached['linktracksent'][$messageid][$fwdid] = $total;
    } else {
        $cached['linktracksent'][$messageid][$fwdid]++;
        ## write every so often, to make sure it's saved when interrupted
        if ($cached['linktracksent'][$messageid][$fwdid] % 100 == 0) {
            Sql_Query(sprintf('update %s set total = %d where messageid = %d and forwardid = %d', $GLOBALS['tables']['linktrack_ml'], $cached['linktracksent'][$messageid][$fwdid], $messageid, $fwdid));
        }
    }
    /*  $req = Sql_Query(sprintf('insert ignore into %s (messageid,userid,forwardid)
        values(%d,%d,"%s","%s")',$GLOBALS['tables']['linktrack'],$messageid,$userdata['id'],$url,addslashes($link)));
      $req = Sql_Fetch_Row_Query(sprintf('select linkid from %s where messageid = %s and userid = %d and forwardid = %d
      ',$GLOBALS['tables']['linktrack'],$messageid,$userid,$fwdid));*/
    return $fwdid;
}
开发者ID:bcantwell,项目名称:website,代码行数:55,代码来源:sendemaillib.php

示例7: Sql_query

 if (preg_match("/(.*)\n/U", $email, $regs)) {
     $email = $regs[1];
 }
 $result = Sql_query("select * from {$GLOBALS["tables"]["user"]} where email = \"{$email}\"");
 #"
 if (isset($_POST['rssfrequency'])) {
     $rssfrequency = validateRssFrequency($_POST['rssfrequency']);
 } else {
     $rssfrequency = '';
 }
 if (!Sql_affected_rows()) {
     # they do not exist, so add them
     $query = sprintf('insert into %s (email,entered,uniqid,confirmed,
   htmlemail,subscribepage,rssfrequency) values("%s",now(),"%s",0,%d,%d,"%s")', $GLOBALS["tables"]["user"], addslashes($email), getUniqid(), $htmlemail, $id, $rssfrequency);
     $result = Sql_query($query);
     $userid = Sql_Insert_Id();
     addSubscriberStatistics('total users', 1);
 } else {
     # they do exist, so update the existing record
     # read the current values to compare changes
     $old_data = Sql_fetch_array($result);
     if (ASKFORPASSWORD && $old_data["password"]) {
         if (ENCRYPTPASSWORD) {
             $canlogin = md5($_POST["password"]) == $old_data["password"];
         } else {
             $canlogin = $_POST["password"] == $old_data["password"];
         }
         if (!$canlogin) {
             $msg = $GLOBALS["strUserExists"];
             $msg .= '<p>' . $GLOBALS["strUserExistsExplanationStart"] . sprintf('<a href="%s&email=%s">%s</a>', getConfig("preferencesurl"), $email, $GLOBALS["strUserExistsExplanationLink"]) . $GLOBALS["strUserExistsExplanationEnd"];
             return;
开发者ID:TheReaCompany,项目名称:pooplog,代码行数:31,代码来源:subscribelib2.php

示例8: while

 while (list($key, $val) = each($selected)) {
     $entry = readentry("data/{$val}");
     list($name, $desc) = explode(":", $entry);
     print "<br/><br/>" . $GLOBALS['I18N']->get('Loading') . " {$desc}<br/>\n";
     $lc_name = str_replace(" ", "", strtolower(str_replace(".txt", "", $val)));
     $lc_name = preg_replace("/[\\W]/", "", $lc_name);
     if ($lc_name == "") {
         Fatal_Error($GLOBALS['I18N']->get('Name cannot be empty:') . " {$lc_name}");
     }
     Sql_Query("select * from {$tables['attribute']} where tablename = \"{$lc_name}\"");
     if (Sql_Affected_Rows()) {
         Fatal_Error($GLOBALS['I18N']->get('Name is not unique enough'));
     }
     $query = sprintf('insert into %s (name,type,required,tablename) values("%s","%s",%d,"%s")', $tables["attribute"], addslashes($name), "select", 1, $lc_name);
     Sql_Query($query);
     $insertid = Sql_Insert_Id($tables['attribute'], 'id');
     $query = "create table {$table_prefix}" . "listattr_{$lc_name} (id integer not null primary key auto_increment, name varchar(255) unique,listorder integer default 0)";
     Sql_Query($query);
     $fp = fopen("data/{$val}", "r");
     $header = "";
     while (!feof($fp)) {
         $buffer = fgets($fp, 4096);
         if (strpos($buffer, "#") === false) {
             if (!$header) {
                 $header = $buffer;
             } else {
                 if (trim($buffer) != "") {
                     Sql_Query(sprintf('insert into %slistattr_%s (name) values("%s")', $table_prefix, $lc_name, trim($buffer)));
                 }
             }
         }
开发者ID:dehvCurtis,项目名称:phplist,代码行数:31,代码来源:defaults.php

示例9: getPageLock

function getPageLock($force = 0)
{
    global $tables;
    $thispage = $GLOBALS["page"];
    if ($thispage == 'pageaction') {
        $thispage = $_GET['action'];
    }
    #  cl_output('getting pagelock '.$thispage);
    #  ob_end_flush();
    if ($GLOBALS["commandline"] && $thispage == 'processqueue') {
        if (is_object($GLOBALS['MC'])) {
            ## multi-send requires a valid memcached setup
            $max = MAX_SENDPROCESSES;
        } else {
            $max = 1;
        }
    } else {
        $max = 1;
    }
    ## allow killing other processes
    if ($force) {
        Sql_Query_Params("delete from " . $tables['sendprocess'] . " where page = ?", array($thispage));
    }
    $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
    $running_req = Sql_Query_Params($query, array($thispage));
    $running_res = Sql_Fetch_Assoc($running_req);
    $count = Sql_Num_Rows($running_req);
    if (VERBOSE) {
        cl_output($count . ' out of ' . $max . ' active processes');
    }
    $waited = 0;
    # while ($running_res['age'] && $count >= $max) { # a process is already running
    while ($count >= $max) {
        # don't check age, as it may be 0
        #   cl_output('running process: '.$running_res['age'].' '.$max);
        if ($running_res['age'] > 600) {
            # some sql queries can take quite a while
            #cl_output($running_res['id'].' is old '.$running_res['age']);
            # process has been inactive for too long, kill it
            Sql_query("update {$tables["sendprocess"]} set alive = 0 where id = " . $running_res['id']);
        } elseif ((int) $count >= (int) $max) {
            #   cl_output (sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'),$running_res['age']));
            output(sprintf($GLOBALS['I18N']->get('A process for this page is already running and it was still alive %s seconds ago'), $running_res['age']), 0);
            sleep(1);
            # to log the messages in the correct order
            if ($GLOBALS["commandline"]) {
                cl_output($GLOBALS['I18N']->get('Running commandline, quitting. We\'ll find out what to do in the next run.'));
                exit;
            }
            output($GLOBALS['I18N']->get('Sleeping for 20 seconds, aborting will quit'), 0);
            flush();
            $abort = ignore_user_abort(0);
            sleep(20);
        }
        $waited++;
        if ($waited > 10) {
            # we have waited 10 cycles, abort and quit script
            output($GLOBALS['I18N']->get('We have been waiting too long, I guess the other process is still going ok'), 0);
            return false;
        }
        $query = ' select current_timestamp - modified as age, id' . ' from ' . $tables['sendprocess'] . ' where page = ?' . ' and alive > 0' . ' order by age desc';
        $running_req = Sql_Query_Params($query, array($thispage));
        $running_res = Sql_Fetch_Assoc($running_req);
        $count = Sql_Num_Rows($running_req);
    }
    $query = ' insert into ' . $tables['sendprocess'] . '    (started, page, alive, ipaddress)' . ' values' . '    (current_timestamp, ?, 1, ?)';
    if (!empty($GLOBALS['commandline'])) {
        $processIdentifier = SENDPROCESS_SERVERNAME . ':' . getmypid();
    } else {
        $processIdentifier = $_SERVER['REMOTE_ADDR'];
    }
    $res = Sql_Query_Params($query, array($thispage, $processIdentifier));
    $send_process_id = Sql_Insert_Id($tables['sendprocess'], 'id');
    $abort = ignore_user_abort(1);
    #  cl_output('Got pagelock '.$send_process_id );
    return $send_process_id;
}
开发者ID:juvenal,项目名称:PHPlist,代码行数:77,代码来源:lib.php

示例10: while

   while ($item = $rss->getNextItem()) {
   	set_time_limit(60);
     $alive = checkLock($process_id);
     if ($alive)
       keepLock($process_id);
     else
       ProcessError("Process Killed by other process");
   	$itemcount++;
   	Sql_Query(sprintf('select * from %s where title = "%s" and link = "%s"',
     	$tables["rssitem"],addslashes(substr($item["title"],0,100)),addslashes(substr($item["link"],0,100))));
    	if (!Sql_Affected_Rows()) {
     	$newitemcount++;
       Sql_Query(sprintf('insert into %s (title,link,source,list,added)
       	values("%s","%s","%s",%d,now())',
         $tables["rssitem"],addslashes($item["title"]),addslashes($item["link"]),addslashes($feed[0]),$feed[1]));
       $itemid = Sql_Insert_Id();
       foreach ($item as $key => $val) {
       	if ($item != "title" && $item != "link") {
           Sql_Query(sprintf('insert into %s (itemid,tag,data)
             values("%s","%s","%s")',
             $tables["rssitem_data"],$itemid,$key,addslashes($val)));
        	}
       }
     }
   }
   printf('<br/>%d items, %d new items',$itemcount,$newitemcount);
   $report .= sprintf('%d items, %d new items'."\n",$itemcount,$newitemcount);
   $mailreport .= sprintf('-> %d items, %d new items'."\n",$itemcount,$newitemcount);
 }
 flush();
 Sql_Query(sprintf('insert into %s (listid,type,entered,info) values(%d,"retrieval",now(),"%s")',
开发者ID:radicalsuz,项目名称:amp,代码行数:31,代码来源:getrss.php

示例11: saveUserAttribute

function saveUserAttribute($userid, $attid, $data)
{
    global $usertable_prefix, $tables;
    # workaround for integration webbler/phplist
    if (!isset($usertable_prefix)) {
        $usertable_prefix = '';
    }
    if (!empty($tables["attribute"])) {
        $att_table = $usertable_prefix . $tables["attribute"];
        $user_att_table = $usertable_prefix . $tables["user_attribute"];
    } else {
        $att_table = $usertable_prefix . "attribute";
        $user_att_table = $usertable_prefix . "user_attribute";
    }
    if ($data["nodbsave"]) {
        dbg("Not saving {$attid}");
        return;
    }
    if (strtolower($data) == 'invalid attribute index') {
        return;
    }
    if ($attid == "emailcheck" || $attid == "passwordcheck") {
        dbg("Not saving {$attid}");
        return;
    }
    if (!$data["type"]) {
        $data["type"] = "textline";
    }
    if ($data["type"] == "static" || $data["type"] == "password" || $data['type'] == 'htmlpref') {
        Sql_Query(sprintf('update user set %s = "%s" where id = %d', $attid, $data["value"], $userid));
        if ($data["type"] == "password") {
            Sql_Query(sprintf('update user set passwordchanged = now() where id = %d', $userid));
        }
        return 1;
    }
    $attid_req = Sql_Fetch_Row_Query(sprintf('
    select id,type,tablename from %s where id = %d', $att_table, $attid));
    if (!$attid_req[0]) {
        $attid_req = Sql_Fetch_Row_Query(sprintf('
      select id,type,tablename from %s where name = "%s"', $att_table, $data["name"]));
        if (!$attid_req[0]) {
            if ($GLOBALS["config"]["autocreate_attributes"]) {
                Dbg("Creating new Attribute: " . $data["name"]);
                sendError("creating new attribute " . $data["name"]);
                $atttable = getNewAttributeTablename($data["name"]);
                Sql_Query(sprintf('insert into %s (name,type,tablename) values("%s","%s","%s")', $att_table, $data["name"], $data["type"], $atttable));
                $attid = Sql_Insert_Id();
            } else {
                dbg("Not creating new Attribute: " . $data["name"]);
                # sendError("Not creating new attribute ".$data["name"]);
            }
        } else {
            $attid = $attid_req[0];
            $atttable = $attid_req[2];
        }
    } else {
        $attid = $attid_req[0];
        $atttable = $attid_req[2];
    }
    if (!$atttable) {
        $atttable = getNewAttributeTablename($data["name"]);
        # fix attribute without tablename
        Sql_Query(sprintf('update %s set tablename ="%s" where id = %d', $att_table, $atttable, $attid));
        #   sendError("Attribute without Tablename $attid");
    }
    switch ($data["type"]) {
        case "static":
        case "password":
            Sql_Query(sprintf('update user set %s = "%s" where id = %d', $attid, $data["value"], $userid));
            break;
        case "select":
            $curval = Sql_Fetch_Row_Query(sprintf('select id from phplist_listattr_%s
        where name = "%s"', $atttable, $data["displayvalue"]), 1);
            if (!$curval[0] && $data['displayvalue'] && $data['displayvalue'] != '') {
                Sql_Query(sprintf('insert into phplist_listattr_%s (name) values("%s")', $atttable, $data["displayvalue"]));
                sendError("Added " . $data["displayvalue"] . " to {$atttable}");
                $valid = Sql_Insert_id();
            } else {
                $valid = $curval[0];
            }
            Sql_Query(sprintf('replace into %s (userid,attributeid,value)
        values(%d,%d,"%s")', $user_att_table, $userid, $attid, $valid));
            break;
        case 'avatar':
            if (is_array($_FILES)) {
                ## only avatars are files
                $formfield = 'attribute' . $attid . '_file';
                ## the name of the fileupload element
                if (!empty($_FILES[$formfield]['name'])) {
                    $tmpnam = $_FILES[$formfield]['tmp_name'];
                    move_uploaded_file($tmpnam, '/tmp/avatar' . $userid . '.jpg');
                    if (function_exists('resizeImageFile')) {
                        resizeImageFile('/tmp/avatar' . $userid . '.jpg', 250, 1);
                    }
                    $size = filesize('/tmp/avatar' . $userid . '.jpg');
                    #          dbg('New size: '.$size);
                    if ($size < MAX_AVATAR_SIZE) {
                        $avatar = file_get_contents('/tmp/avatar' . $userid . '.jpg');
                        Sql_Query(sprintf('replace into %s (userid,attributeid,value)
              values(%d,%d,"%s")', $user_att_table, $userid, $attid, base64_encode($avatar)));
//.........这里部分代码省略.........
开发者ID:kvervo,项目名称:phplist-aiesec,代码行数:101,代码来源:userlib.php

示例12: Sql_Fetch_Row_Query

<?php

## add default system template
## this should be part of the "UI theme"
print '<h2>Default system template</h2>';
$template = '<div style="margin:0; text-align:center; width:100%; background:#EEE;min-width:240px;height:100%;"><br />
    <div style="width:96%;margin:0 auto; border-top:6px solid #369;border-bottom: 6px solid #369;background:#DEF;" >
        <h3 style="margin-top:5px;background-color:#69C; font-weight:normal; color:#FFF; text-align:center; margin-bottom:5px; padding:10px; line-height:1.2; font-size:21px; text-transform:capitalize;">[SUBJECT]</h3>
        <div style="text-align:justify;background:#FFF;padding:20px; border-top:2px solid #369;min-height:200px;font-size:13px; border-bottom:2px solid #369;">[CONTENT]<div style="clear:both"></div></div>
        <div style="clear:both;background:#69C;font-weight:normal; padding:10px;color:#FFF;text-align:center;font-size:11px;margin:5px 0px">[FOOTER]<br/>[SIGNATURE]</div>
    </div>
<br /></div>';
$exists = Sql_Fetch_Row_Query(sprintf('select * from %s where title = "System Template"', $GLOBALS['tables']['template']));
if ($exists[0]) {
    print '<p>' . $GLOBALS['I18N']->get('The default system template already exists') . '</p>';
    print '<p>' . PageLinkButton('templates', $GLOBALS['I18N']->get('Go back to templates')) . '</p>';
} else {
    Sql_Query(sprintf('insert into %s (title,template,listorder) values("System Template","%s",0)', $GLOBALS['tables']['template'], addslashes($template)));
    $newid = Sql_Insert_Id();
    saveConfig('systemmessagetemplate', $newid);
    print '<p>' . $GLOBALS['I18N']->get('The default system template has been added as template with ID') . ' ' . $newid . ' </p>';
    print '<p>' . PageLinkButton('templates', $GLOBALS['I18N']->get('Go back to templates')) . '</p>';
    print '<p>' . PageLinkButton('template&amp;id=' . $newid, $GLOBALS['I18N']->get('Edit template')) . '</p>';
}
开发者ID:dehvCurtis,项目名称:phplist,代码行数:24,代码来源:defaultsystemtemplate.php

示例13: explode

                         $att["value"] = $valueid[0];
                     }
                     break;
                 case "checkboxgroup":
                     $vals = explode(",", $att["displayvalue"]);
                     array_pop($vals);
                     $att["value"] = "";
                     foreach ($vals as $val) {
                         $query = sprintf('select id from %slistattr_%s where name = ?', $table_prefix, $tname[0]);
                         $rs = Sql_Query_Params($query, array($val));
                         $valueid = Sql_Fetch_Row($rs);
                         if (!$valueid[0]) {
                             $tn = $table_prefix . 'listattr_' . $tname[0];
                             $query = sprintf('insert into %s set name = ?', $tn);
                             Sql_Query_Params($query, array($val));
                             $att["value"] .= Sql_Insert_Id($tn, 'id') . ',';
                         } else {
                             $att["value"] .= $valueid[0] . ",";
                         }
                     }
                     $att["value"] = substr($att["value"], 0, -1);
                     break;
             }
             if ($att["value"]) {
                 Sql_Replace($tables["user_attribute"], array('attributeid' => $localattid, 'userid' => $userid, 'value' => $att['value']), array('attributeid', 'userid'));
             }
         }
     }
 }
 if (is_array($userlists)) {
     foreach ($userlists as $list) {
开发者ID:dehvCurtis,项目名称:phplist,代码行数:31,代码来源:import4.php

示例14: Sql_Fetch_Row_Query

 if (!empty($data['values'][$item["index"]])) {
     $attribute_index = $item["record"];
     $value = $data['values'][$item["index"]];
     # check whether this is a textline or a selectable item
     $att = Sql_Fetch_Row_Query("select type,tablename,name from " . $tables["adminattribute"] . " where id = {$attribute_index}");
     switch ($att[0]) {
         case "select":
         case "radio":
             $query = "select id from {$table_prefix}adminattr_{$att['1']} where name = ?";
             $val = Sql_Query_Params($query, array($value));
             # if we don't have this value add it '
             if (!Sql_Num_Rows($val)) {
                 $tn = $table_prefix . 'adminattr_' . $att[1];
                 Sql_Query_Params("insert into {$tn} (name) values (?)", array($value));
                 Warn($GLOBALS['I18N']->get("Value") . " {$value} " . $GLOBALS['I18N']->get("added to attribute") . " {$att['2']}");
                 $att_value = Sql_Insert_Id($tn, 'id');
             } else {
                 $d = Sql_Fetch_Row($val);
                 $att_value = $d[0];
             }
             break;
         case "checkbox":
             if ($value) {
                 $val = Sql_Fetch_Row_Query("select id from {$table_prefix}" . "adminattr_{$att['1']} where name = \"Checked\"");
             } else {
                 $val = Sql_Fetch_Row_Query("select id from {$table_prefix}" . "adminattr_{$att['1']} where name = \"Unchecked\"");
             }
             $att_value = $val[0];
             break;
         default:
             $att_value = $value;
开发者ID:dehvCurtis,项目名称:phplist,代码行数:31,代码来源:importadmin.php

示例15: Sql_Query

                 $templateok = 0;
             }
         }
     }
 } else {
     if (!$title) {
         $actionresult .= $GLOBALS['I18N']->get('No Title') . "<br/>";
     } else {
         $actionresult .= $GLOBALS['I18N']->get('Template does not contain the [CONTENT] placeholder') . "<br/>";
     }
     $templateok = 0;
 }
 if ($templateok) {
     if (!$id) {
         Sql_Query("insert into {$tables["template"]} (title) values(\"{$title}\")");
         $id = Sql_Insert_Id($tables['template'], 'id');
     }
     Sql_Query(sprintf('update %s set title = "%s",template = "%s" where id = %d', $tables["template"], $title, sql_escape($content), $id));
     Sql_Query(sprintf('select * from %s where filename = "%s" and template = %d', $tables["templateimage"], "powerphplist.png", $id));
     if (!Sql_Affected_Rows()) {
         Sql_Query(sprintf('insert into %s (template,mimetype,filename,data,width,height)
   values(%d,"%s","%s","%s",%d,%d)', $tables["templateimage"], $id, "image/png", "powerphplist.png", $newpoweredimage, 70, 30));
     }
     $actionresult .= '<p class="information">' . s('Template saved') . '</p>';
     ## ##17419 don't prompt for remote images that exist
     $missingImages = array();
     while (list($key, $val) = each($images)) {
         $key = trim($key);
         if (preg_match('~^https?://~i', $key)) {
             $imageFound = testUrl($key);
             if (!$imageFound) {
开发者ID:dehvCurtis,项目名称:phplist,代码行数:31,代码来源:template.php


注:本文中的Sql_Insert_Id函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。