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


PHP DB_insertID函数代码示例

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


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

示例1: nexform_importForm

function nexform_importForm($_SQL, $cntr)
{
    global $CONF_FE, $_TABLES;
    DB_query($_SQL[0], '1');
    if (DB_error()) {
        COM_errorLog("nexform SQL error importing form: {$_SQL[0]}");
    }
    $newformid = DB_insertID();
    /* Delete any previous imported form field definition records
          New field definition records will have a formid of '99999' assigned
          Insert the new records and then update to match the new form definition
       */
    DB_query("DELETE FROM {$_TABLES['nxform_fields']} WHERE formid='{$cntr}'");
    next($_SQL);
    // Increment to the field definition records
    for ($i = 1; $i < count($_SQL); $i++) {
        DB_query(current($_SQL), '1');
        if (DB_error()) {
            COM_errorLog("executing " . current($_SQL));
            COM_errorLog("Error executing SQL", 1);
            exit;
        }
        next($_SQL);
    }
    DB_query("UPDATE {$_TABLES['nxform_fields']} set formid='{$newformid}' WHERE formid='{$cntr}'");
    // Need to cycle thru the fields now and update any fieldnames if auto fieldname used
    $query = DB_query("SELECT id,type FROM {$_TABLES['nxform_fields']} WHERE formid='{$newformid}' AND field_name LIKE '%_frm%'");
    while (list($fieldid, $fieldtype) = DB_fetchArray($query)) {
        $fieldname = "{$CONF_FE['fieldtypes'][$fieldtype][0]}{$newformid}_{$fieldid}";
        DB_query("UPDATE {$_TABLES['nxform_fields']} set field_name='{$fieldname}' WHERE id='{$fieldid}'");
    }
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:32,代码来源:import.php

示例2: _ff_check4files

function _ff_check4files($id, $tempfile = false)
{
    global $_FILES, $_CONF, $_TABLES, $_USER, $_FF_CONF, $LANG_GF00, $_FF_CONF, $filemgmt_FileStore;
    $retval = '';
    for ($z = 1; $z <= $_FF_CONF['maxattachments']; $z++) {
        $filelinks = '';
        $varName = 'file_forum' . $z;
        $chk_usefilemgmt = 'chk_usefilemgmt' . $z;
        $filemgmtcat = 'filemgmtcat' . $z;
        $filemgmt_desc = 'filemgmt_desc' . $z;
        if (isset($_FILES[$varName]) && is_array($_FILES[$varName])) {
            $uploadfile = $_FILES[$varName];
        } else {
            $uploadfile['name'] = '';
        }
        if ($uploadfile['name'] != '') {
            if (isset($_POST[$chk_usefilemgmt]) && $_POST[$chk_usefilemgmt] == 1) {
                $filename = $uploadfile['name'];
                $pos = strrpos($uploadfile['name'], '.') + 1;
                $ext = strtolower(substr($uploadfile['name'], $pos));
            } else {
                $uploadfilename = glfRandomFilename();
                $pos = strrpos($uploadfile['name'], '.') + 1;
                $ext = strtolower(substr($uploadfile['name'], $pos));
                $filename = "{$uploadfilename}.{$ext}";
            }
            $set_chk_usefilemgmt = isset($_POST[$chk_usefilemgmt]) ? (int) $_POST[$chk_usefilemgmt] : 0;
            if (_ff_uploadfile($filename, $uploadfile, $_FF_CONF['allowablefiletypes'], $set_chk_usefilemgmt)) {
                if (array_key_exists($uploadfile['type'], $_FF_CONF['inlineimageypes'])) {
                    if (isset($_POST[$chk_usefilemgmt]) && $_POST[$chk_usefilemgmt] == 1) {
                        $srcImage = "{$filemgmt_FileStore}{$filename}";
                        $destImage = "{$_FF_CONF['uploadpath']}/tn/{$filename}";
                    } else {
                        $srcImage = "{$_FF_CONF['uploadpath']}/{$filename}";
                        $destImage = "{$_FF_CONF['uploadpath']}/tn/{$uploadfilename}.{$ext}";
                    }
                    $ret = IMG_resizeImage($srcImage, $destImage, $_FF_CONF['inlineimage_height'], $_FF_CONF['inlineimage_width']);
                }
                // Store both the created filename and the real file source filename
                $realfilename = $filename;
                $filename = "{$filename}:{$uploadfile['name']}";
                if ($tempfile) {
                    $temp = 1;
                } else {
                    $temp = 0;
                }
                if (isset($_POST[$chk_usefilemgmt]) && $_POST[$chk_usefilemgmt] == 1) {
                    $cid = COM_applyFilter($_POST[$filemgmtcat], true);
                    $sql = "INSERT INTO {$_TABLES['filemgmt_filedetail']} (cid, title, url, size, submitter, status,date ) ";
                    $sql .= "VALUES ('" . DB_escapeString($cid) . "', '" . DB_escapeString($realfilename) . "', '" . DB_escapeString($realfilename) . "', '" . DB_escapeString($uploadfile['size']) . "', '{$_USER['uid']}', 1, UNIX_TIMESTAMP())";
                    DB_query($sql);
                    $newid = DB_insertID();
                    DB_query("INSERT INTO {$_TABLES['ff_attachments']} (topic_id,repository_id,filename,tempfile)\n                        VALUES ('" . DB_escapeString($id) . "',{$newid},'" . DB_escapeString($filename) . "',{$temp})");
                    $description = glfPrepareForDB($_POST[$filemgmt_desc]);
                    DB_query("INSERT INTO {$_TABLES['filemgmt_filedesc']} (lid, description) VALUES ({$newid}, '{$description}')");
                } else {
                    DB_query("INSERT INTO {$_TABLES['ff_attachments']} (topic_id,filename,tempfile)\n                        VALUES ('" . DB_escapeString($id) . "','" . DB_escapeString($filename) . "',{$temp})");
                }
            } else {
                COM_errorlog("upload error:" . $GLOBALS['ff_errmsg']);
                $retval .= $GLOBALS['ff_errmsg'];
                $filelinks = -1;
            }
        }
    }
    if (!$tempfile and isset($_POST['uniqueid']) and COM_applyFilter($_POST['uniqueid'], true) > 0 and DB_COUNT($_TABLES['ff_topic'], 'id', (int) $id)) {
        $tid = COM_applyFilter($_POST['uniqueid']);
        DB_query("UPDATE {$_TABLES['ff_attachments']} SET topic_id=" . (int) $id . ", tempfile=0 WHERE topic_id=" . (int) $tid);
    }
    return $retval;
}
开发者ID:spacequad,项目名称:glfusion,代码行数:71,代码来源:upload.inc.php

示例3: count

         // Check if new logical Task ID = 0 - not allowed
     }
     // lets determine if there are any other tasks in this workflow.. otherwise we have to set the first task bit..
     $sql = "SELECT count( * ) FROM {$_TABLES['nf_templatedata']} WHERE nf_templateID = '{$templateID}'";
     $fields = 'logicalID, nf_templateID,nf_stepType, nf_handlerId, function, formid, optionalParm, firstTask, taskname, regenerate,reminderInterval';
     if (DB_numRows(DB_Query($sql))) {
         // no rows.. thus first task
         $sql = "INSERT INTO {$_TABLES['nf_templatedata']} ({$fields}) ";
         $sql .= "VALUES ('{$lID}','{$templateID}','{$stepID}','{$handlerID}','{$taskFunction}','{$task_formid}','{$optionalParm}',1,'{$taskName}','{$regen}','{$notifyinterval}')";
         $result = DB_Query($sql);
         $taskID = DB_insertID();
     } else {
         $sql = "INSERT INTO {$_TABLES['nf_templatedata']} ({$fields}) ";
         $sql .= "VALUES ('{$lID}','{$templateID}','{$stepID}','{$handlerID}','{$taskFunction}','{$task_formid}','{$optonalParm}',0,'{$taskName}','{$regen}','{$notifyinterval}')";
         $result = DB_Query($sql);
         $taskID = DB_insertID();
     }
     // echo $sql;
 }
 // Update the timestamp - used to sort records if we have duplicates that need to be re-ordered
 // Assume the latest updated record should have the logical ID entered - in case of new duplicate
 DB_query("UPDATE {$_TABLES['nf_templatedata']} set last_updated = now() WHERE id='{$taskID}'");
 // Check and see if we have any duplicate logical ID's and need to reorder
 $sql = "SELECT id FROM {$_TABLES['nf_templatedata']} WHERE nf_templateID='{$templateID}' AND logicalID = '{$lID}'";
 if (DB_numRows(DB_query($sql)) > 1) {
     $sql = "SELECT id,logicalID FROM {$_TABLES['nf_templatedata']} WHERE nf_templateID='{$templateID}' ";
     $sql .= "AND logicalID >= '{$lID}' ORDER BY logicalID ASC, last_updated DESC";
     $query = DB_query($sql);
     $id = $lID;
     while ($A = DB_fetchArray($query)) {
         // Reset field firstTask
开发者ID:hostellerie,项目名称:nexpro,代码行数:31,代码来源:index.php

示例4: prj_insertProject

function prj_insertProject($parentID = 0)
{
    global $_TABLES;
    //first check if this has a parent project ID..
    //if it dosent, then we're insertting a top level task
    $newid = 0;
    // New project record id
    if ($parentID == 0) {
        if (!prj_checkTableSemaphore("{$_TABLES['prj_projects']}")) {
            //its locked....
            //we can loop here, or bail.. I'd loop 1/2 the wait duration if i really had to...
            COM_errorLog('prj_insertproject - Table is locked, will try again ...');
        } else {
            //its not locked
            //first, lock the table
            prj_lockTable("{$_TABLES['prj_projects']}");
            //we're now locked for X seconds depending on the lockduration field
            //you could conceivably just keep relocking before each sql call to make sure....
            $sql = "SELECT max(rhs) FROM {$_TABLES['prj_projects']}";
            $res = DB_query($sql);
            list($lhs) = DB_fetchArray($res);
            $lhs = $lhs + 1;
            $rhs = $lhs + 1;
            $sql = "INSERT INTO {$_TABLES['prj_projects']} (lhs, rhs, parent_id) ";
            $sql .= "VALUES ('{$lhs}', '{$rhs}', 0 )";
            DB_query($sql);
            $newid = DB_insertID();
            prj_unlockTable("{$_TABLES['prj_projects']}");
            //set it free!
        }
    } else {
        //we have a pid and have to do our crafty inserts here...
        if (!prj_checkTableSemaphore("{$_TABLES['prj_projects']}")) {
            //its locked.... we can loop here, or bail.. I'd loop 1/2 the wait duration if i really had to...
            COM_errorLog('prj_insertProject - Table is locked, will try again ...');
        } else {
            //its not locked need to first, lock the table
            prj_lockTable("{$_TABLES['prj_projects']}");
            $sql = "SELECT rhs FROM {$_TABLES['prj_projects']} WHERE pid='{$parentID}'";
            $res = DB_query($sql);
            list($rhs) = DB_fetchArray($res);
            $sql = "UPDATE {$_TABLES['prj_projects']} set lhs = lhs+2 where lhs >= '{$rhs}'";
            DB_query($sql);
            $sql = "UPDATE {$_TABLES['prj_projects']} set rhs = rhs+2 where rhs >= '{$rhs}'";
            DB_query($sql);
            $lhs = $rhs;
            $rhs = $rhs + 1;
            $sql = "INSERT INTO {$_TABLES['prj_projects']} (lhs, rhs, parent_id) ";
            $sql .= "VALUES ( '{$lhs}', '{$rhs}', '{$parentID}')";
            DB_query($sql);
            $newid = DB_insertID();
            prj_unlockTable("{$_TABLES['prj_projects']}");
            //set it free!
        }
    }
    //end else for testing if we have a pid
    return $newid;
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:58,代码来源:library.php

示例5: Save

 /**
  *  Save the current values to the database.
  *
  *  @param  array   $A      Attributeal array of values from $_POST
  *  @return boolean         True if no errors, False otherwise
  */
 function Save($A = array())
 {
     global $_TABLES, $_PP_CONF;
     if (is_array($A)) {
         // Put this field at the end of the line by default
         if (empty($A['orderby'])) {
             $A['orderby'] = 65535;
         }
         $this->SetVars($A);
     }
     // Get the option group in from the text field, or selection
     if (isset($_POST['attr_name']) && !empty($_POST['attr_name'])) {
         $this->attr_name = $_POST['attr_name'];
     } else {
         $this->attr_name = $_POST['attr_name_sel'];
     }
     // Make sure the necessary fields are filled in
     if (!$this->isValidRecord()) {
         return false;
     }
     // Insert or update the record, as appropriate.
     if ($this->isNew) {
         $sql1 = "INSERT INTO {$_TABLES['paypal.prod_attr']}";
         $sql3 = '';
     } else {
         $sql1 = "UPDATE {$_TABLES['paypal.prod_attr']}";
         $sql3 = " WHERE attr_id={$this->attr_id}";
     }
     $sql2 = " SET item_id='{$this->item_id}',\n                attr_name='" . DB_escapeString($this->attr_name) . "',\n                attr_value='" . DB_escapeString($this->attr_value) . "',\n                orderby='{$this->orderby}',\n                attr_price='{$this->attr_price}',\n                enabled='{$this->enabled}'";
     $sql = $sql1 . $sql2 . $sql3;
     DB_query($sql, 1);
     $err = DB_error();
     if ($err == '') {
         if ($this->isNew) {
             $this->attr_id = DB_insertID();
         }
         $this->ReOrder();
         return true;
     } else {
         $this->AddError($err);
         return false;
     }
 }
开发者ID:NewRoute,项目名称:paypal,代码行数:49,代码来源:attribute.class.php

示例6: nexform_check4files

function nexform_check4files($result_id = 0, $single_file = '')
{
    global $_CONF, $_TABLES, $CONF_FE, $LANG_FE_ERR;
    if ($CONF_FE['debug']) {
        COM_errorLog("Check4files - result_id:{$result_id}");
    }
    /* Check if custom hidden field is used on the form to specify allowable file types */
    if ($uploadFileTypesAllowed != '' and !is_array($allowablefiletypes)) {
        $formtypes = explode(',', $uploadFileTypesAllowed);
        $allowablefiletypes = array();
        foreach ($CONF_FE['allowablefiletypes'] as $key => $haystack) {
            foreach ($formtypes as $needle) {
                if (strpos($haystack, $needle) !== false) {
                    $allowablefiletypes[$key] = $haystack;
                } else {
                }
            }
        }
    }
    if (!is_array($allowablefiletypes)) {
        $allowablefiletypes = $CONF_FE['allowablefiletypes'];
    }
    foreach ($_FILES as $var => $uploadfile) {
        if ($single_file != '' and $single_file != $var) {
            continue;
        }
        if ($uploadfile['size'][0] <= 0 and $single_file != '') {
            return false;
        }
        /* The variable names contain the fieldtype and fieldid */
        /* XXX_frm{formid}_{fieldid}    - where XXX is the fieldtype */
        $parts = explode('_', $var);
        $fieldtype = $parts[0];
        $field_id = (int) $parts[2];
        $is_dynamicfield_result = false;
        if (isset($parts[4])) {
            $dynamicFieldInstance = $parts['4'];
            $sfield_id = (int) $parts['2'];
            $field_id = (int) $parts['3'];
            $instance = (int) $parts['4'];
            $is_dynamicfield_result = true;
            $dynamicForm = DB_getItem($_TABLES['nxform_fields'], 'formid', "id='{$field_id}'");
            // Get the results currently recorded for the source form field
            $dynamicResults = explode('|', DB_getItem($_TABLES['nxform_resdata'], 'field_data', "result_id='{$result_id}' AND field_id='{$sfield_id}'"));
            // Check if this instance of the dynamic form is already created as a result.
            if (isset($dynamicResults[$instance]) and $dynamicResults[0] != '' and count($dynamicResults) > 0) {
                $dynamicResult = $dynamicResults[$instance];
            } else {
                // User must be submitting the form with a new instance of this dynamic subform (field)
                // Need to create a new result record and update relating fields with the new resultid
                DB_query("INSERT INTO {$_TABLES['nxform_results']} (form_id,uid,date)\r\n                                VALUES ('{$dynamicForm}','{$userid}','{$date}') ");
                $dynamicResult = DB_insertID();
                $dynamicResults[$instance] = $dynamicResult;
                $relatedFieldResults = implode('|', $dynamicResults);
                DB_query("UPDATE {$_TABLES['nxform_resdata']} set field_data = '{$relatedFieldResults}' WHERE result_id='{$result_id}' AND field_id='{$sfield_id}'");
                // Now need to update the related Results field in the main results records
            }
        } else {
            $field_id = (int) $parts['2'];
            $is_dynamicfield_result = false;
        }
        if (is_array($uploadfile['name'])) {
            /* Skip if no files uploaded in the multi-file field */
            if ($uploadfile[name][0] != '') {
                for ($i = 0; $i < count($uploadfile[name]); $i++) {
                    /* Upload class is not expecting an array of upload files - so pass a single associative array */
                    $upload_newfile = array('name' => $uploadfile['name'][$i], 'type' => $uploadfile['type'][$i], 'tmp_name' => $uploadfile['tmp_name'][$i], 'error' => $uploadfile['error'][$i], 'size' => $uploadfile['size'][$i]);
                    $uploadfilename = ppRandomFilename();
                    $pos = strrpos($uploadfile['name'][$i], '.') + 1;
                    $ext = strtolower(substr($uploadfile['name'][$i], $pos));
                    $filename = "{$uploadfilename}.{$ext}";
                    if ($CONF_FE['debug']) {
                        COM_errorLog("Mfile upload: Original file: {$uploadfile['name'][$i]} and new filename: {$filename}");
                    }
                    if (nexform_uploadfile($filename, $upload_newfile, $allowablefiletypes)) {
                        // Store both the created filename and the real file source filename
                        $realfilename = $filename;
                        $filename = "{$filename}:{$upload_newfile['name']}";
                        if ($is_dynamicfield_result) {
                            DB_query("INSERT INTO {$_TABLES['nxform_resdata']} (result_id,field_id,field_data,is_dynamicfield_result)\r\n                                VALUES ('{$dynamicResult}','{$field_id}','{$filename}',1) ");
                            if ($single_file != '') {
                                $retval = DB_insertID();
                            }
                        } else {
                            DB_query("INSERT INTO {$_TABLES['nxform_resdata']} (result_id,field_id,field_data)\r\n                                VALUES ('{$result_id}','{$field_id}','{$filename}') ");
                            if ($single_file != '') {
                                $retval = DB_insertID();
                            }
                        }
                    } else {
                        COM_errorLog("upload error:" . $GLOBALS['fe_errmsg']);
                        $errmsg = $GLOBALS['fe_errmsg'];
                        return false;
                    }
                }
            }
        } else {
            if ($uploadfile['size'] > 0 and $uploadfile['name'] != '') {
                $uploadfilename = ppRandomFilename();
                $pos = strrpos($uploadfile['name'], '.') + 1;
//.........这里部分代码省略.........
开发者ID:hostellerie,项目名称:nexpro,代码行数:101,代码来源:lib-uploadfiles.php

示例7: Save

 /**
  *  Save the current values to the database.
  *  Appends error messages to the $Errors property.
  *
  *  @param  array   $A      Optional array of values from $_POST
  *  @return boolean         True if no errors, False otherwise
  */
 public function Save($A = '')
 {
     global $_TABLES, $_PP_CONF;
     USES_paypal_class_productimage();
     USES_paypal_class_ppFile();
     if (is_array($A)) {
         $this->SetVars($A);
     }
     // Zero out the shipping amount if a non-fixed value is chosen
     if ($this->shipping_type < 2) {
         $this->shipping_amt = 0;
     }
     // Handle file uploads.  This is done first so we know whether
     // there is a valid filename for a download product
     // No weight or shipping for downloads
     if (!empty($_FILES['uploadfile']['tmp_name'])) {
         $F = new ppFile('uploadfile');
         $filename = $F->uploadFiles();
         if ($F->areErrors() > 0) {
             $this->Errors[] = $F->printErrors(true);
         } elseif ($filename != '') {
             $this->file = $filename;
         }
         PAYPAL_debug('Uploaded file: ' . $this->file);
     }
     // For downloadable files, physical product options don't apply
     if ($this->prod_type == PP_PROD_DOWNLOAD) {
         $this->weight = 0;
         $this->shipping_type = 0;
         $this->shipping_amt = 0;
     }
     // Serialize the quantity discount array
     $qty_discounts = $this->qty_discounts;
     if (!is_array($qty_discounts)) {
         $qty_discounts = array();
     }
     $qty_discounts = DB_escapeString(@serialize($qty_discounts));
     // Insert or update the record, as appropriate
     if ($this->id > 0) {
         PAYPAL_debug('Preparing to update product id ' . $this->id);
         $sql1 = "UPDATE {$_TABLES['paypal.products']} SET ";
         $sql3 = " WHERE id='{$this->id}'";
     } else {
         PAYPAL_debug('Preparing to save a new product.');
         $sql1 = "INSERT INTO {$_TABLES['paypal.products']} SET \n                dt_add = '" . DB_escapeString($_PP_CONF['now']->toMySQL()) . "',";
         $sql3 = '';
     }
     $sql2 = "name='" . DB_escapeString($this->name) . "',\n                cat_id='" . (int) $this->cat_id . "',\n                short_description='" . DB_escapeString($this->short_description) . "',\n                description='" . DB_escapeString($this->description) . "',\n                keywords='" . DB_escapeString($this->keywords) . "',\n                price='" . (double) $this->price . "',\n                prod_type='" . (int) $this->prod_type . "',\n                weight='" . (double) $this->weight . "',\n                file='" . DB_escapeString($this->file) . "',\n                expiration='" . (int) $this->expiration . "',\n                enabled='" . (int) $this->enabled . "',\n                featured='" . (int) $this->featured . "',\n                views='" . (int) $this->views . "',\n                taxable='" . (int) $this->taxable . "',\n                shipping_type='" . (int) $this->shipping_type . "',\n                shipping_amt='" . (double) $this->shipping_amt . "',\n                comments_enabled='" . (int) $this->comments_enabled . "',\n                rating_enabled='" . (int) $this->rating_enabled . "',\n                show_random='" . (int) $this->show_random . "',\n                show_popular='" . (int) $this->show_popular . "',\n                onhand='{$this->onhand}',\n                track_onhand='{$this->track_onhand}',\n                oversell = '{$this->oversell}',\n                qty_discounts = '{$qty_discounts}',\n                options='{$options}',\n                custom='" . DB_escapeString($this->custom) . "',\n                sale_price={$this->sale_price},\n                sale_beg='" . DB_escapeString($this->sale_beg) . "',\n                sale_end='" . DB_escapeString($this->sale_end) . "',\n                avail_beg='" . DB_escapeString($this->avail_beg) . "',\n                avail_end='" . DB_escapeString($this->avail_end) . "',\n                buttons= '" . DB_escapeString($this->btn_type) . "'";
     $sql = $sql1 . $sql2 . $sql3;
     //echo $sql;die;
     DB_query($sql);
     if (!DB_error()) {
         if ($this->isNew) {
             $this->id = DB_insertID();
         }
         $status = true;
     } else {
         COM_errorLog("Paypal- SQL error in Product::Save: {$sql}", 1);
         $status = false;
     }
     PAYPAL_debug('Status of last update: ' . print_r($status, true));
     if ($status) {
         // Handle image uploads.  This is done last because we need
         // the product id to name the images filenames.
         if (!empty($_FILES['images'])) {
             $U = new ProductImage($this->id, 'images');
             $U->uploadFiles();
             if ($U->areErrors() > 0) {
                 $this->Errors[] = $U->printErrors(false);
             }
         }
         // Clear the button cache
         self::DeleteButtons($this->id);
     }
     // Update the category crossref
     /*DB_delete($_TABLES['paypal.prodXcat'], 'prod_id', $prod_id);
       foreach ($this->categories as $cat) {
           DB_query("INSERT INTO {$_TABLES['paypal.prodXcat']}
                   (prod_id, cat_id)
               VALUES
                   ({$prod_id}, " . (int)$cat . ")");
       }*/
     if (empty($this->Errors)) {
         PAYPAL_debug('Update of product ' . $this->id . ' succeeded.');
         return true;
     } else {
         PAYPAL_debug('Update of product ' . $this->id . ' failed.');
         return false;
     }
 }
开发者ID:JohnToro,项目名称:paypal,代码行数:97,代码来源:product.class.php

示例8: updateMenuRecord

function updateMenuRecord($mode)
{
    global $_CONF, $CONF_NEXMENU, $_TABLES, $id, $idCurrent;
    $parent = ppPrepareForDB($_POST['menu_parent']);
    $order = ppPrepareForDB($_POST['menu_order']);
    $label = addslashes(ppPrepareForDB(htmlspecialchars($_POST['menu_label'], ENT_QUOTES, $CONF_NEXMENU['charset'])));
    $image = ppPrepareForDB($_POST['menu_image']);
    $menutype = ppPrepareForDB($_POST['menutype']);
    $menu_location = ppPrepareForDB($_POST['menu_location']);
    $coremenutype = ppPrepareForDB($_POST['coremenutype']);
    $phpfunction = ppPrepareForDB($_POST['phpfunction']);
    $grp_access = ppPrepareForDB($_POST['grp_access']);
    $is_enabled = isset($_POST['menu_status']) ? 1 : 0;
    if ($label == '') {
        $GLOBALS['statusmsg'] = 'Error adding or updating Record. Label can not be blank';
        return;
    }
    switch ($menutype) {
        case 1:
            $url = $_POST['menu_url'];
            break;
        case 2:
            $url = $_POST['menu_url'];
            break;
        case 3:
            $url = '';
            break;
        case 4:
            $url = $CONF_NEXMENU['coremenu'][$coremenutype];
            break;
        case 5:
            $url = $phpfunction;
            break;
    }
    if ($mode == 'add') {
        if ($order < 1) {
            $query = DB_query("SELECT MAX(menuorder) FROM {$_TABLES['nexmenu']} WHERE pid={$parent}");
            list($order) = DB_fetchArray($query);
            $order++;
        }
        $sql = "INSERT INTO {$_TABLES['nexmenu']} (pid,menutype,location,menuorder,label,url,grp_access,image,is_enabled) ";
        $sql .= "VALUES ('{$parent}','{$menutype}','{$menu_location}','{$order}','{$label}','{$url}','{$grp_access}','{$image}','{$is_enabled}')";
        DB_query($sql);
        $GLOBALS['id'] = DB_insertID();
        $GLOBALS['statusmsg'] = 'Record Added';
        $idCurrent = DB_insertID();
        // Make the new record the current record
        foreach ($_POST['alternatelabel'] as $langid => $languagelabel) {
            if (trim($languagelabel) != '') {
                if (DB_count($_TABLES['nexmenu_language'], array('menuitem', 'language'), array($id, $langid))) {
                    DB_query("UPDATE {$_TABLES['nexmenu_language']} SET label = '{$languagelabel}' WHERE menuitem={$idCurrent} AND language={$langid} ");
                } else {
                    DB_query("INSERT INTO {$_TABLES['nexmenu_language']} (menuitem,language,label) VALUES ({$idCurrent},{$langid},'{$languagelabel}')");
                }
            }
        }
    } elseif (DB_count($_TABLES['nexmenu'], "id", $id) == 1) {
        if ($order < 1) {
            $query = DB_query("SELECT MAX(menuorder) FROM {$_TABLES['nexmenu']} WHERE pid={$parent}");
            list($order) = DB_fetchArray($query);
            $order++;
        }
        /* Check if this is a menu and the location has changed (header or block location of menu */
        $curLocation = DB_getItem($_TABLES['nexmenu'], "location", "id='{$id}'");
        if ($menutype == 3 and $menu_location != '$curlocation') {
            /* update any menuitems or submenus as well - need to move them all */
            updateFolderLocation($id, $menu_location);
        }
        $sql = "UPDATE {$_TABLES['nexmenu']} SET pid='{$parent}',menutype='{$menutype}',location='{$menu_location}', image='{$image}', ";
        $sql .= "menuorder='{$order}',label='{$label}', url='{$url}',grp_access='{$grp_access}',is_enabled='{$is_enabled}' WHERE id='{$id}'";
        DB_query($sql);
        foreach ($_POST['alternatelabel'] as $langid => $languagelabel) {
            if (trim($languagelabel) != '') {
                if (DB_count($_TABLES['nexmenu_language'], array('menuitem', 'language'), array($id, $langid))) {
                    DB_query("UPDATE {$_TABLES['nexmenu_language']} SET label = '{$languagelabel}' WHERE menuitem={$id} AND language={$langid} ");
                } else {
                    DB_query("INSERT INTO {$_TABLES['nexmenu_language']} (menuitem,language,label) VALUES ({$id},{$langid},'{$languagelabel}')");
                }
            }
        }
        $GLOBALS['statusmsg'] = 'Record Updated';
    } else {
        COM_errorLOG("nexmenu Plugin: Admin Error updating Record");
        $GLOBALS['statusmsg'] = 'Error adding or updating Record';
    }
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:86,代码来源:index.php

示例9: Save

 /**
  *  Save the current values to the database.
  *
  *  @param  array   $A      Optional array of values from $_POST
  *  @return boolean         True if no errors, False otherwise
  */
 public function Save($A = array())
 {
     global $_TABLES, $_PP_CONF;
     if (is_array($A)) {
         $this->SetVars($A);
     }
     // Handle image uploads.
     // We don't want to delete the existing image if one isn't
     // uploaded, we should leave it unchanged.  So we'll first
     // retrieve the existing image filename, if any.
     if (!$this->isNew) {
         $img_filename = DB_getItem($_TABLES['paypal.categories'], 'image', "cat_id='" . $this->cat_id . "'");
     } else {
         // New entry, assume no image
         $img_filename = '';
     }
     if (is_uploaded_file($_FILES['imagefile']['tmp_name'])) {
         $img_filename = rand(100, 999) . "_" . COM_sanitizeFilename($_FILES['imagefile']['name'], true);
         $status = IMG_resizeImage($_FILES['imagefile']['tmp_name'], $_PP_CONF['catimgpath'] . "/{$img_filename}", $_PP_CONF['max_thumb_size'], $_PP_CONF['max_thumb_size'], '', true);
         if ($status[0] == false) {
             $this->AddError('Error Moving Image');
         } else {
             // If a new image was uploaded, and this is an existing
             // category, then delete the old image file, if any.
             // The DB still has the old filename at this point.
             if (!$this->isNew) {
                 $this->DeleteImage(false);
             }
         }
     }
     $this->image = $img_filename;
     // Insert or update the record, as appropriate, as long as a
     // previous error didn't occur.
     if (empty($this->Errors)) {
         if ($this->isNew) {
             $sql1 = "INSERT INTO {$_TABLES['paypal.categories']} SET ";
             $sql3 = '';
         } else {
             $sql1 = "UPDATE {$_TABLES['paypal.categories']} SET ";
             $sql3 = " WHERE cat_id='{$this->cat_id}'";
         }
         $sql2 = "parent_id='" . $this->parent_id . "',\n                cat_name='" . DB_escapeString($this->cat_name) . "',\n                description='" . DB_escapeString($this->description) . "',\n                enabled='{$this->enabled}',\n                grp_access ='{$this->grp_access}',\n                image='" . DB_escapeString($this->image) . "'";
         $sql = $sql1 . $sql2 . $sql3;
         DB_query($sql);
         if (!DB_error()) {
             if ($this->isNew) {
                 $this->cat_id = DB_insertID();
             }
         } else {
             $this->AddError('Failed to insert or update record');
         }
     }
     if (empty($this->Errors)) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:JohnToro,项目名称:paypal,代码行数:64,代码来源:category.class.php

示例10: nc_copyRecord

function nc_copyRecord($table, $primary_key, $value)
{
    //first get the values of the requested record
    $record = DB_query("SELECT * FROM {$table} WHERE {$primary_key} = '{$value}';");
    $R = DB_fetchArray($record, false);
    //then discover the schema of the table
    $schema = DB_query("DESCRIBE {$table};");
    //now build an sql string to copy one to the other
    $fields = '';
    $values = '';
    while ($A = DB_fetchArray($schema, false)) {
        if ($A['Field'] != $primary_key) {
            if ($fields != '') {
                $fields .= ', ';
                $values .= ', ';
            }
            $fields .= $A['Field'];
            $values .= "'" . addslashes($R[$A['Field']]) . "'";
        }
    }
    $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$values});";
    DB_query($sql);
    $retval = DB_insertID();
    return $retval;
}
开发者ID:hostellerie,项目名称:nexpro,代码行数:25,代码来源:library.php

示例11: Save

 /**
  *  Save the current values to the database.
  *  Appends error messages to the $Errors property.
  *
  *  @param  array   $A      Optional array of values from $_POST
  *  @return boolean         True if no errors, False otherwise
  */
 public function Save($A = '')
 {
     global $_TABLES, $_EV_CONF;
     if (is_array($A)) {
         $this->SetVars($A);
     }
     $this->isNew = $this->det_id > 0 ? false : true;
     // If integrating with the Locator plugin, try to get and save
     // the coordinates to be used when displaying the event.
     // At least a city and state/province is required.
     if ($_EV_CONF['use_locator'] == 1 && $this->city != '' && $this->province != '') {
         $address = $this->street . ' ' . $this->city . ', ' . $this->province . ' ' . $this->postal . ' ' . $this->country;
         $lat = $this->lat;
         $lng = $this->lng;
         if ($lat == 0 && $lng == 0) {
             $status = LGLIB_invokeService('locator', 'getCoords', $address, $output, $svc_msg);
             if ($status == PLG_RET_OK) {
                 $this->lat = $output['lat'];
                 $this->lng = $output['lng'];
             }
         }
     }
     $fld_set = array();
     foreach ($this->fields as $fld_name) {
         $fld_set[] = "{$fld_name}='" . DB_escapeString($this->{$fld_name}) . "'";
     }
     $fld_sql = implode(',', $fld_set);
     // Fix decimal if PHP locale uses the comma.
     $lat = number_format($this->lat, 8, '.', '');
     $lng = number_format($this->lng, 8, '.', '');
     // Insert or update the record, as appropriate
     if (!$this->isNew) {
         // For updates, delete the event from the cache table.
         $sql = "UPDATE {$_TABLES['evlist_detail']}\n                    SET {$fld_sql},\n                    lat = '{$lat}',\n                    lng = '{$lng}'\n                    WHERE det_id='" . (int) $this->det_id . "'";
         //echo $sql;die;
         DB_query($sql);
     } else {
         $sql = "INSERT INTO {$_TABLES['evlist_detail']}\n                    SET \n                    det_id = 0,\n                    lat = '{$lat}',\n                    lng = '{$lng}',\n                    {$fld_sql}";
         //echo $sql;die;
         DB_query($sql);
         $this->det_id = DB_insertID();
     }
     return $this->det_id;
 }
开发者ID:matrox66,项目名称:evlist,代码行数:51,代码来源:evDetail.class.php

示例12: addDownload

function addDownload()
{
    global $_CONF, $_USER, $_FM_TABLES, $filemgmt_FileStore, $filemgmt_SnapStore, $myts, $eh;
    $filename = $myts->makeTboxData4Save($_FILES['newfile']['name']);
    $url = $myts->makeTboxData4Save(rawurlencode($filename));
    $snapfilename = $myts->makeTboxData4Save($_FILES['newfileshot']['name']);
    $logourl = $myts->makeTboxData4Save(rawurlencode($snapfilename));
    $title = $myts->makeTboxData4Save($_POST['title']);
    $homepage = $myts->makeTboxData4Save($_POST['homepage']);
    $version = $myts->makeTboxData4Save($_POST['version']);
    $description = $myts->makeTareaData4Save($_POST['description']);
    $commentoption = $_POST['commentoption'];
    $submitter = $_USER['uid'];
    $size = $myts->makeTboxData4Save(intval($_FILES['newfile']['size']));
    $result = DB_query("SELECT COUNT(*) FROM {$_FM_TABLES['filemgmt_filedetail']} WHERE url='{$url}'");
    list($numrows) = DB_fetchArray($result);
    $errormsg = "";
    // Check if Title blank
    if ($title == "") {
        $eh->show("1104");
    }
    // Check if Description blank
    if ($description == "") {
        $eh->show("1105");
    }
    // Check if a file was uploaded
    if ($_FILES['newfile']['size'] == 0) {
        $eh->show("1017");
    }
    if (!empty($_POST['cid'])) {
        $cid = $_POST['cid'];
    } else {
        $cid = 0;
    }
    if (uploadNewFile($_FILES["newfile"], $filemgmt_FileStore)) {
        $AddNewFile = true;
    }
    if (uploadNewFile($_FILES["newfileshot"], $filemgmt_SnapStore)) {
        $AddNewFile = true;
    }
    if ($AddNewFile) {
        DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedetail']} " . "(cid, title, url, homepage, version, size, " . "logourl, submitter, status, date, hits, rating, votes, comments) " . "VALUES ('{$cid}', '{$title}', '{$url}', '{$homepage}', '{$version}', '{$size}', '{$logourl}', " . "'{$submitter}', 1, " . time() . ", 0, 0, 0,'{$commentoption}')");
        $newid = DB_insertID();
        DB_query("INSERT INTO {$_FM_TABLES['filemgmt_filedesc']} " . "(lid, description) VALUES ({$newid}, '{$description}')");
        if ($duplicatefile) {
            redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php", 2, _MD_NEWDLADDED_DUPFILE);
        } elseif ($duplicatesnap) {
            redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php", 2, _MD_NEWDLADDED_DUPSNAP);
        } else {
            redirect_header("{$_CONF['site_admin_url']}/plugins/filemgmt/index.php", 2, _MD_NEWDLADDED);
        }
        exit;
    } else {
        redirect_header("index.php", 2, _MD_ERRUPLOAD . "");
        exit;
    }
}
开发者ID:milk54,项目名称:geeklog-japan,代码行数:57,代码来源:index.php

示例13: while

    while (list($id, $qorder) = DB_fetchArray($query)) {
        $order++;
        DB_query("UPDATE {$_TABLES['quiz_questions']} SET qorder='{$order}' WHERE qid={$id}");
    }
}
// Handling of submit code
switch ($op) {
    case 'savequestion':
        $HTTP_POST_VARS = qz_cleandata($HTTP_POST_VARS);
        $question = $HTTP_POST_VARS['question'];
        $qanswer = $HTTP_POST_VARS['qanswer'];
        $qvalue = $HTTP_POST_VARS['qvalue'];
        $qorder = $HTTP_POST_VARS['qorder'] == "" ? "99" : $HTTP_POST_VARS['qorder'];
        if (!empty($question) and !empty($qvalue)) {
            DB_query("INSERT INTO {$_TABLES['quiz_questions']} (quizid,question,qanswer,qvalue,qorder) VALUES ('{$quizid}', '{$question}', '{$qanswer}', '{$qvalue}', '{$qorder}')");
            $qid = DB_insertID();
            qz_updateQuestionOrder($quizid);
            $questionDir = $_CONF['path_html'] . "quiz/question_images/{$qid}/";
            if (isset($HTTP_POST_FILES['image'])) {
                include 'addimage.php';
            }
        } else {
            echo "Please complete all fields<br>";
        }
        break;
    case 'savemultiquestions':
        $HTTP_POST_VARS = qz_cleandata($HTTP_POST_VARS);
        $question = $HTTP_POST_VARS['question'];
        $qanswer = $HTTP_POST_VARS['qanswer'];
        $qvalue = $HTTP_POST_VARS['qvalue'];
        $qorder = $HTTP_POST_VARS['qorder'] == "" ? "99" : $HTTP_POST_VARS['qorder'];
开发者ID:Geeklog-Plugins,项目名称:quiz,代码行数:31,代码来源:questions.php

示例14: updatePage

function updatePage($mode, $type)
{
    global $_CONF, $_TABLES, $_FILES, $_POST, $CONF_SE, $LANG_SE_ERR;
    global $_DB_name, $catid, $pageid;
    include_once $_CONF['path_system'] . 'classes/upload.class.php';
    $name = substr(htmlentities($_POST['name']), 0, 32);
    $pid = ppPrepareForDB($_POST['category']);
    $old_sid = ppPrepareForDB($_POST['old_sid']);
    $sid = ppPrepareForDB($_POST['sid'], true, 40);
    $pageorder = COM_applyFilter($_POST['pageorder'], true);
    if ($type == 'link') {
        $menutype = 3;
    } else {
        $menutype = COM_applyFilter($_POST['menu_type'], true);
    }
    $blkformat = ppPrepareForDB($_POST['blk_format']);
    $heading = substr(htmlentities($_POST['heading']), 0, 255);
    $grp_access = ppPrepareForDB($_POST['grp_access']);
    $imgdelete = $_POST['imgdelete'];
    $chkscale = $_POST['chkscale'];
    $submenutype = COM_applyFilter($_POST['rad_submenu'], true);
    $blockmenutype = COM_applyFilter($_POST['rad_blockmenu'], true);
    $is_menu_newpage = $_POST['chknewwindow'] == 1 ? 1 : 0;
    $is_draft = $_POST['chkdraft'] == 1 ? 1 : 0;
    $show_breadcrumbs = $_POST['chkbreadcrumbs'] == 1 ? 1 : 0;
    $owner_id = ppPrepareForDB($_POST['owner_id']);
    $group_id = ppPrepareForDB($_POST['group_id']);
    $perm_owner = $_POST['perm_owner'];
    $perm_group = $_POST['perm_group'];
    $perm_members = $_POST['perm_members'];
    $perm_anon = $_POST['perm_anon'];
    $pagetitle = substr(htmlentities($_POST['pagetitle']), 0, 255);
    $metadesc = ppPrepareForDB($_POST['metadesc']);
    $metakeywords = ppPrepareForDB($_POST['metakeywords']);
    // Convert array values to numeric permission values
    list($perm_owner, $perm_group, $perm_members, $perm_anon) = SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon);
    // Allow full HTML in the introtext field
    if (!get_magic_quotes_gpc()) {
        $content = addslashes($_POST['sitecontent']);
        $help = addslashes($_POST['help']);
    } else {
        $content = $_POST['sitecontent'];
        $help = $_POST['help'];
    }
    if ($sid != '') {
        $sid = COM_sanitizeID($sid);
    }
    if ($sid != '' and DB_count($_TABLES['nexcontent_pages'], 'sid', $sid) > 0) {
        if ($sid != $old_sid) {
            $duplicate_sid = true;
            if ($old_sid == '') {
                $sid = "{$sid}_{$pid}";
                $dupmsg = ' - Duplicate Page ID';
            } else {
                $sid = $old_sid;
                $dupmsg = ' - Duplicate Page ID, Page ID not changed.';
            }
        }
    } else {
        $duplicate_sid = false;
    }
    if ($mode == 'add') {
        $gid = uniqid($_DB_name, FALSE);
        $category = COM_applyFilter($category, true);
        if ($type == 'category') {
            // Create a new record - set the category value to 0
            DB_query("INSERT INTO {$_TABLES['nexcontent_pages']} (pid,gid,type) values ({$category},'{$gid}','category')");
            $pageid = DB_insertID();
            $GLOBALS['statusmsg'] = 'New Category Added';
            $query = DB_query("SELECT max(pageorder) FROM {$_TABLES['nexcontent_pages']} WHERE type='category'");
            list($maxorder) = DB_fetchArray($query);
            $order = $maxorder + 10;
            DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder='{$order}' WHERE id='{$pageid}'");
        } else {
            // Create a new record - need to get the record id for the category
            DB_query("INSERT INTO {$_TABLES['nexcontent_pages']} (pid,gid,type) values ('{$category}','{$gid}','{$type}')");
            $pageid = DB_insertID();
            $GLOBALS['statusmsg'] = 'New Page Added';
            $query = DB_query("SELECT max(pageorder) FROM {$_TABLES['nexcontent_pages']} WHERE pid='category'");
            list($maxorder) = DB_fetchArray($query);
            $order = $maxorder + 10;
            DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder='{$order}' WHERE id='{$pageid}'");
        }
    } else {
        if ($type == 'category') {
            $GLOBALS['statusmsg'] = "{$name} Updated";
        } else {
            $GLOBALS['statusmsg'] = "{$name} Updated";
        }
        if ($duplicate_sid) {
            $GLOBALS['statusmsg'] .= $dupmsg;
        }
    }
    DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET name='{$name}', blockformat='{$blkformat}', pid='{$pid}', sid='{$sid}', heading='{$heading}',content='{$content}', menutype='{$menutype}', is_menu_newpage='{$is_menu_newpage}', show_submenu='{$submenutype}', show_blockmenu='{$blockmenutype}', show_breadcrumbs='{$show_breadcrumbs}', is_draft='{$is_draft}', owner_id='{$owner_id}', group_id='{$group_id}', perm_owner='{$perm_owner}', perm_group='{$perm_group}', perm_members='{$perm_members}', perm_anon='{$perm_anon}' , pagetitle='{$pagetitle}', meta_description='{$metadesc}', meta_keywords='{$metakeywords}' WHERE id='{$pageid}'");
    DB_query("UPDATE {$_TABLES['nexcontent']} SET help='{$help}'");
    //update the page order
    if ($pageorder != '' and $pageid != '') {
        DB_query("UPDATE {$_TABLES['nexcontent_pages']} SET pageorder={$pageorder} WHERE id={$pageid};");
        $porder = DB_query("SELECT id FROM {$_TABLES['nexcontent_pages']} WHERE pid={$pid} ORDER BY pageorder ASC;");
        $i = 0;
//.........这里部分代码省略.........
开发者ID:hostellerie,项目名称:nexpro,代码行数:101,代码来源:index.php

示例15: updateFieldRecord

function updateFieldRecord($mode)
{
    global $_CONF, $_POST, $CONF_FE, $_TABLES, $formid, $fieldid;
    $fieldname = $_POST['fieldname'];
    $type = $_POST['type'];
    $label = $_POST['label'];
    $style = $_POST['style'];
    $fieldorder = $_POST['fieldorder'];
    $is_vertical = $_POST['is_vertical'];
    $is_reverseorder = $_POST['is_reverseorder'];
    $is_newline = COM_applyFilter($_POST['is_newline'], true);
    $is_mandatory = COM_applyFilter($_POST['is_mandatory'], true);
    $is_searchfield = COM_applyFilter($_POST['is_searchfield'], true);
    $is_resultsfield = COM_applyFilter($_POST['is_resultsfield'], true);
    $is_internaluse = COM_applyFilter($_POST['is_internaluse'], true);
    $hidelabel = COM_applyFilter($_POST['hidelabel'], true);
    $is_htmlfiltered = COM_applyFilter($_POST['is_htmlfiltered'], true);
    $function_used = COM_applyFilter($_POST['use_function'], true);
    $col_width = COM_applyFilter($_POST['col_width']);
    $col_padding = COM_applyFilter($_POST['col_padding']);
    $label_padding = COM_applyFilter($_POST['label_padding']);
    $field_values = $_POST['field_values'];
    if (!get_magic_quotes_gpc()) {
        $validation = addslashes($_POST['validation']);
        $label = addslashes($label);
        $field_attributes = addslashes($_POST['field_attributes']);
        $javascript = addslashes($_POST['javascript']);
        $field_help = addslashes($_POST['field_help']);
    } else {
        $validation = $_POST['validation'];
        $field_attributes = $_POST['field_attributes'];
        $javascript = $_POST['javascript'];
        $field_help = $_POST['field_help'];
    }
    if ($mode == 'add') {
        $fieldorder = COM_applyFilter($fieldorder, true);
        $is_vertical = COM_applyFilter($is_vertical, true);
        $is_reverseorder = COM_applyFilter($is_reverseorder, true);
        $fields = 'formid,type,field_name,fieldorder,label,style,is_vertical,is_reverseorder,is_newline,';
        $fields .= 'is_mandatory,is_searchfield,is_resultsfield,is_htmlfiltered,is_internaluse,hidelabel,';
        $fields .= 'field_attributes,field_help,field_values,value_by_function,validation,javascript';
        $values = "'{$formid}','{$type}','{$fieldname}','{$fieldorder}',";
        $values .= "'{$label}','{$style}','{$is_vertical}','{$is_reverseorder}','{$is_newline}',";
        $values .= "'{$is_mandatory}','{$is_searchfield}','{$is_resultsfield}','{$is_htmlfiltered}',";
        $values .= "'{$is_internaluse}','{$hidelabel}','{$field_attributes}','{$field_help}','{$field_values}','{$function_used}',";
        $values .= "'{$validation}','{$javascript}'";
        DB_query("INSERT INTO {$_TABLES['nxform_fields']}( {$fields} ) VALUES ( {$values} )");
        $fieldid = DB_insertID();
        $date = time();
        DB_query("UPDATE {$_TABLES['nxform_definitions']} SET date='{$date}' WHERE id='{$formid}'");
        $GLOBALS['statusmsg'] = 'Record Added';
        // Set the template field id now - incremental id per form
        $query = DB_query("SELECT max(tfid) FROM {$_TABLES['nxform_fields']} WHERE formid='{$formid}'");
        list($maxtfid) = DB_fetchArray($query);
        $tfid = $maxtfid + 1;
        DB_query("UPDATE {$_TABLES['nxform_fields']} SET tfid='{$tfid}' WHERE id='{$fieldid}'");
        if ($fieldname == '') {
            // BL Note: Use tfid to set fieldname
            $fieldname = "{$CONF_FE['fieldtypes'][$type][0]}{$formid}_{$fieldid}";
            DB_query("UPDATE {$_TABLES['nxform_fields']} SET field_name='{$fieldname}' WHERE id='{$fieldid}'");
        }
        if ($fieldorder == '') {
            $query = DB_query("SELECT max(fieldorder) FROM {$_TABLES['nxform_fields']} WHERE formid='{$formid}'");
            list($maxorder) = DB_fetchArray($query);
            $order = $maxorder + 10;
            DB_query("UPDATE {$_TABLES['nxform_fields']} SET fieldorder='{$order}' WHERE id='{$fieldid}'");
        }
    } elseif (DB_count($_TABLES['nxform_fields'], "id", $fieldid) == 1) {
        // Set the template field id if it was not set (earlier bug) - incremental id per form
        if (DB_getItem($_TABLES['nxform_fields'], 'tfid', "id='{$fieldid}'") == 0) {
            $query = DB_query("SELECT max(tfid) FROM {$_TABLES['nxform_fields']} WHERE formid='{$formid}'");
            list($maxtfid) = DB_fetchArray($query);
            $tfid = $maxtfid + 1;
            DB_query("UPDATE {$_TABLES['nxform_fields']} SET tfid='{$tfid}' WHERE id='{$fieldid}'");
        }
        if ($fieldname == '') {
            // BL Note: Use tfid to set fieldname
            $fieldname = "{$CONF_FE['fieldtypes'][$type][0]}{$formid}_{$fieldid}";
        } else {
            // Check and see if fieldtype has changed
            if (DB_getItem($_TABLES['nxform_fields'], 'type', "id='{$fieldid}'") != $type) {
                $fieldname = "{$CONF_FE['fieldtypes'][$type][0]}{$formid}_{$fieldid}";
            }
        }
        $data = "type='{$type}',field_name='{$fieldname}',fieldorder='{$fieldorder}',";
        $data .= "label='{$label}',style='{$style}',is_vertical='{$is_vertical}',";
        $data .= "field_attributes='{$field_attributes}', field_help='{$field_help}',";
        $data .= "field_values='{$field_values}', value_by_function='{$function_used}',";
        $data .= "validation='{$validation}',javascript='{$javascript}',is_internaluse='{$is_internaluse}',";
        $data .= "is_vertical='{$is_vertical}',is_reverseorder='{$is_reverseorder}',";
        $data .= "is_newline='{$is_newline}',is_mandatory='{$is_mandatory}',";
        $data .= "is_searchfield='{$is_searchfield}',is_resultsfield='{$is_resultsfield}',";
        $data .= "hidelabel='{$hidelabel}'";
        //echo "UPDATE {$_TABLES['nxform_fields']} SET $data  WHERE id='$fieldid'";
        DB_query("UPDATE {$_TABLES['nxform_fields']} SET {$data}  WHERE id='{$fieldid}'");
        $date = time();
        DB_query("UPDATE {$_TABLES['nxform_definitions']} SET date='{$date}' WHERE id='{$formid}'");
        $GLOBALS['statusmsg'] = 'Record Updated';
    } else {
        COM_errorLog("Form Editor Plugin: Admin Error updating Field Record: {$id} for Form:{$formid}");
//.........这里部分代码省略.........
开发者ID:hostellerie,项目名称:nexpro,代码行数:101,代码来源:index.php


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