function generateTableBody($pluginId, $structureId, $recordId = NULL)
    {
        $structureInfo = PluginListBuilder::singleStrucArray($structureId);
        $recordArray = PluginListBuilder::strucRecordArray($structureId);
        //begin with building the columns and get the user set columns
        $listFields = explode(',', $structureInfo['listfields']);
        $listFields = PluginListBuilder::validateRecordViaFieldset($listFields, $recordArray['fieldsetId']);
        $listSearch = explode(',', $structureInfo['listsearch']);
        $listSearch = PluginListBuilder::validateRecordViaFieldset($listSearch, $recordArray['fieldsetId']);
        if (!empty($_GET['search' . $structureInfo['db_name']]) && empty($listSearch)) {
            echo 'Search settings not set up...please notify developer';
        }
        $query_q = 'SELECT * FROM cms_content 
					WHERE
					pluginid = "' . $pluginId . '"
					AND recordset = "' . $structureInfo['db_name'] . '"';
        //SEARCH PARAMETERS
        if (!empty($recordId)) {
            $query_q .= ' AND recordid = "' . $recordId . '"';
        }
        if (!empty($_GET['search' . $structureInfo['db_name']]) && !empty($listSearch)) {
            $query_q .= ' AND (';
            $g = 1;
            foreach ($listSearch as $search) {
                $query_q .= $search . ' LIKE "%' . $_GET['search' . $structureInfo['db_name']] . '%"';
                if ($g < count($listSearch)) {
                    $query_q .= ' OR ';
                }
                $g++;
            }
            $query_q .= ')';
        }
        $query_q .= ' ORDER BY ' . ($structureInfo['listorder'] ? $structureInfo['listorder'] : 'id ASC');
        $query_q;
        $query_r = mysql_query($query_q) or die(mysql_error());
        $ptml = '<tbody>';
        while ($query = mysql_fetch_array($query_r)) {
            $ptml .= '<tr>';
            if (count($listFields)) {
                $n = 0;
                foreach ($listFields as $arr) {
                    if ($recordArray[$arr]['type'] == "foreignkey") {
                        $recordOptions = Apps::get_field_options($recordArray[$arr]['options'], $n);
                        ///IF IT IS FOREGIN KEY DO THE WORK
                        $fkeyval = explode(",", $recordOptions['record_fkeyvalue']);
                        $fkeyopt = explode(",", $recordOptions['record_fkeyoptions']);
                        if ($recordOptions['record_fkeyvalue']) {
                            $fetchKeys_q = 'SELECT * FROM cms_content WHERE ' . $recordOptions['record_fkeyvalue'] . ' = "' . $query[$arr] . '"';
                        } else {
                            $fetchKeys_q = 'SELECT * FROM cms_content WHERE id = "' . $query[$arr] . '"';
                        }
                        $fetchKeys_r = mysql_query($fetchKeys_q);
                        $fetchKeys = mysql_fetch_array($fetchKeys_r);
                        if (count($fkeyopt)) {
                            $countfkey = 0;
                            foreach ($fkeyopt as $name) {
                                $recordDisplayVal = ($countfkey > 0 ? " - " : "") . $fetchKeys[$name];
                                $countfkey++;
                            }
                        } else {
                            $recordDisplayVal = $fetchKeys['id'];
                        }
                    } else {
                        $recordDisplayVal = $query[$arr];
                    }
                    $ptml .= '<td align="center">' . ($n == 0 ? '<a href="' . _EQROOT_ . 'plugins/edit/' . $pluginId . '?id=' . $query['id'] . '&psid=' . $structureId . '">' : '') . ($recordArray[$arr]['type'] == 'photo' ? '<img src="' . (!empty($query[$arr]) ? _UPLOADS_ . $query['id'] . '/' . $recordArray[$arr]['db_name'] . '/300xauto_' : _EQROOT_ . 'public/images/no-image.jpg') : '') . $recordDisplayVal . ($recordArray[$arr]['type'] == 'photo' ? '" width="200">' : '') . ($n == 0 ? '</a>' : '') . '</td>';
                    $n++;
                }
            } else {
                $ptml .= '<th>Id #</th>';
            }
            $ptml .= '</tr>';
        }
        $ptml .= '</tbody>';
        $ptml .= '</table>';
        return $ptml;
    }
 public function formBody($plugstrucid, $fieldsetId, $id = NULL)
 {
     if (isset($id)) {
         $current_q = 'SELECT * FROM cms_content 
                       WHERE
                       id = "' . $id . '"';
         $current_r = mysql_query($current_q);
         $current = mysql_fetch_array($current_r);
     }
     $pstruc_q = 'SELECT * FROM cms_plugin_structure 
                  WHERE 
                  id = "' . $plugstrucid . '"';
     $pstruc_r = mysql_query($pstruc_q);
     $pstruc = mysql_fetch_array($pstruc_r);
     $records_q = 'SELECT * FROM cms_records 
     			  WHERE 
     			  fieldsetid = "' . $fieldsetId . '" 
     			  ORDER BY sortorder ASC';
     $records_r = mysql_query($records_q);
     $x = 0;
     $znum = 0;
     $formBody = '';
     while ($records = mysql_fetch_array($records_r)) {
         $x++;
         $znum++;
         $recordOptions = Apps::get_field_options($records['options'], $znum);
         $elementNameId = $pstruc['db_name'] . '_' . $records['db_name'];
         $formBody .= "<div class=\"rowElem" . ($x == 1 ? ' noborder' : '') . "\">\n";
         $formBody .= "<label>" . $records['name'] . ($recordOptions['record_required'] == 'true' ? '* ' : '') . ": " . (!empty($records['helper']) ? '<a onclick="$.jGrowl(\'' . $records['helper'] . '\');">&nbsp;&nbsp;<i class="fa fa-question-circle fa-1x"></i></a>' : '') . "</label>\n";
         $formBody .= "<div class=\"formRight\">\n";
         switch ($records['type']) {
             case "text":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ($recordOptions['record_email'] == 'true' ? ',custom[email]' : '') . "]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>\n";
                 break;
             case "number":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "style=\"" . $recordOptions['record_styles'] . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ",custom[number]]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>";
                 break;
             case "email":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" " . "type=\"text\" name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "style=\"" . $recordOptions['record_styles'] . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . ",custom[email]]\" " . "style=\"" . $recordOptions['record_styles'] . "\"/>\n";
                 break;
             case "html":
                 $formBody .= "<textarea " . "class=\"tinymce validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\">" . stripslashes($current[$records['db_name']]) . "</textarea>\n";
                 break;
             case "textarea":
                 $formBody .= "<textarea " . "name=\"" . $elementNameId . "\" " . "id=\"" . $elementNameId . "\" " . "rows=\"10\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "style=\"" . $recordOptions['record_styles'] . "\">" . $current[$records['db_name']] . "</textarea>\n";
                 break;
             case "select":
             case "multiselect":
                 $formBody .= "<select name=\"" . $elementNameId . ($records['type'] == 'multiselect' ? '[]' : '') . "\" " . "id=\"" . $elementNameId . ($records['type'] == 'multiselect' ? '[]' : '') . "\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" ";
                 switch ($records['type']) {
                     case 'multiselect':
                         $formBody .= "multiple=\"multiple\" ";
                         break;
                 }
                 $formBody .= "style=\"" . $recordOptions['record_styles'] . "\">";
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     // echo $recordOptions['record_select_vals'][$d] . '\b/',$current[$records['db_name']];
                     $formBody .= "\n<option value=\"" . $recordOptions['record_select_vals'][$d] . "\"" . ($recordOptions['record_select_vals'][$d] == $current[$records['db_name']] ? ' selected' : '') . ">" . $recordOptions['record_select_vals'][$d] . "</option>";
                 }
                 $formBody .= "\n</select>\n";
                 break;
             case "yesno":
                 $formBody .= "<input type=\"radio\" id=\"" . $elementNameId . "1\" name=\"" . $elementNameId . "\" checked=\"checked\" value=\"yes\" />\n" . "<label for=\"" . $elementNameId . "1\">Yes</label>\n";
                 $formBody .= "<input type=\"radio\" id=\"" . $elementNameId . "2\" name=\"" . $elementNameId . "\" value=\"no\"/>\n" . "<label for=\"" . $elementNameId . "2\">No</label>\n";
                 break;
             case "checkboxes":
                 $checkArr = explode(',', $current[$records['db_name']]);
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     $formBody .= "<input type=\"checkbox\" " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "id=\"" . $elementNameId . $d . "\" name=\"" . $elementNameId . "[]\" " . (preg_match('/\\b' . $recordOptions['record_select_vals'][$d] . '\\b/', $current[$records['db_name']]) ? 'checked ' : '') . "value=\"" . $recordOptions['record_select_vals'][$d] . "\" />\n" . "<label for=\"" . $elementNameId . $d . "\">" . $recordOptions['record_select_vals'][$d] . "</label>\n";
                 }
                 break;
             case "radio":
                 for ($d = 0; $d < count($recordOptions['record_select_vals']); $d++) {
                     $formBody .= "<input type=\"radio\" class=\"validate[" . ($recordOptions['record_select_vals'][$d] == 'true' ? 'required' : 'optional') . "]\" id=\"" . $elementNameId . $d . "\" name=\"" . $elementNameId . "\" " . (preg_match('/\\b' . $recordOptions['record_select_vals'][$d] . '\\b/', $current[$records['db_name']]) ? 'checked' : '') . " value=\"" . $recordOptions['record_select_vals'][$d] . "\" />\n" . "<label for=\"" . $elementNameId . $d . "\">" . $recordOptions['record_select_vals'][$d] . "</label>\n";
                 }
                 break;
             case "photo":
             case "multiphoto":
                 $formBody .= !empty($current[$records['db_name']]) ? "<div class=\"recordImg\">\n" . "<a title=\"Delete '" . $current[$records['db_name']] . "'\" data-id=\"" . $id . "\" data-recordname=\"" . $records['db_name'] . "\" data-filename=\"" . strtolower($current[$records['db_name']]) . "\"></a>\n" . "<img src=\"" . _SITEROOT_ . "uploads/" . $id . "/" . $records['db_name'] . "/300xauto_" . strtolower($current[$records['db_name']]) . "\" />\n" . "</div>\n" : '';
                 $formBody .= "<input type=\"file\" class=\"validate[" . ($recordOptions['record_required'] == 'true' && empty($current[$records['db_name']]) ? 'required' : 'optional') . ",checkFileType[jpg|jpeg|gif|JPG|png|PNG|ico|bmp]] fileInput\" name=\"" . $elementNameId . ($records['db_name'] == "multiphoto" ? "[]" : "") . "\" " . ($records['db_name'] == "multiphoto" ? " mulitple=\"multiple\" " : "") . " id=\"" . $elementNameId . "[]\" />\n";
                 break;
             case "file":
                 $ext = strtolower(pathinfo($current[$records['db_name']], PATHINFO_EXTENSION));
                 $formBody .= !empty($current[$records['db_name']]) ? "<div class=\"recordFile\">\n" . "<a class=\"deleteRecordFile\" title=\"Delete '" . $current[$records['db_name']] . "'\" data-id=\"" . $id . "\" data-recordname=\"" . $records['db_name'] . "\" data-filename=\"" . $current[$records['db_name']] . "\"></a>\n" . "<a href=\"" . _EQROOT_ . "resources/uploads/" . $id . "/" . $records['db_name'] . "/" . $current[$records['db_name']] . "\" target=\"_blank\" class=\"documentIcon " . $ext . "\"></a>\n" . "</div>\n" : '';
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"file\" class=\"validate[" . ($recordOptions['record_required'] == 'true' && empty($current[$records['db_name']]) ? 'required' : 'optional') . ",checkFileType[pdf|doc|docx|xls|csv|rar|txt|avi|mov|flv|mp3|zip|wav|php|html|css|js|jar|bak|tar|sys|exe|iso]] " . "fileInput\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" />\n";
                 break;
             case "date":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" " . "class=\"datepicker validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" />\n";
                 break;
             case "color":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" " . "class=\"colorpick validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" id=\"" . $elementNameId . "\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\"/>\n\n                                 <label for=\"" . $elementNameId . "\" class=\"pick\"></label>\n";
                 break;
             case "time":
                 $formBody .= "<input value=\"" . $current[$records['db_name']] . "\" type=\"text\" class=\"timepicker validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" name=\"" . $elementNameId . "\" id=\"" . $elementNameId . "\" size=\"10\">\n" . "<span class=\"ml10\">use your mousewheel and keyboard</span>\n";
                 break;
             case "foreignkey":
                 $fcomStruc_q = 'SELECT * FROM cms_plugin_structure 
                 				WHERE 
                 				id = "' . $records['fkey'] . '"';
                 $fcomStruc_r = mysql_query($fcomStruc_q);
                 $fcomStruc = mysql_fetch_array($fcomStruc_r);
                 $fFieldset_q = 'SELECT * FROM cms_fieldsets 
                                 WHERE
                                 com_struc_id = "' . $records['fkey'] . '"';
                 $fFieldset_r = mysql_query($fFieldset_q);
                 $fkeyFieldset = mysql_fetch_array($fFieldset_r);
                 $fetchKeys_q = 'SELECT * FROM cms_content 
                 				WHERE 
                 				pluginid = "' . $fcomStruc['pluginid'] . '"
                 				AND recordset = "' . $fcomStruc['db_name'] . '"';
                 $fetchKeys_r = mysql_query($fetchKeys_q);
                 $fkeyOptions = explode(',', $recordOptions['record_fkeyoptions']);
                 if (count($fkeyOptions)) {
                     $fkeyOptions = PluginListBuilder::validateRecordViaFieldset($fkeyOptions, $fkeyFieldset['id']);
                 } else {
                     $fkeyOptions = array('id');
                 }
                 $fkeyValues = explode(',', $recordOptions['record_fkeyvalue']);
                 if (count($fkeyOptions)) {
                     $fkeyValues = PluginListBuilder::validateRecordViaFieldset($fkeyValues, $fkeyFieldset['id']);
                 } else {
                     $fkeyValues = array('id');
                 }
                 $formBody .= "<select " . "class=\"validate[" . ($recordOptions['record_required'] == 'true' ? 'required' : 'optional') . "]\" " . "name=\"" . $elementNameId . ($recordOptions['record_fkeytype'] == 'multiselect' ? '[]' : '') . "\" " . "id=\"" . $elementNameId . ($recordOptions['record_fkeytype'] == 'multiselect' ? '[]' : '') . "\" " . ($recordOptions['record_fkeytype'] == 'multiselect' ? 'multiple="multiple"' : '') . "style=\"" . $recordOptions['record_styles'] . "\">\n";
                 while ($fetchKey = mysql_fetch_array($fetchKeys_r)) {
                     $fkeyValue = !empty($fkeyValues) ? $fetchKey[$fkeyValues[0]] : $fetchKey['id'];
                     $formBody .= "\n<option " . (preg_match('/\\b' . $fkeyValue . '\\b/', $current[$records['db_name']]) ? ' selected' : '') . ' value="' . $fkeyValue . '">';
                     foreach ($fkeyOptions as $option) {
                         $formBody .= $fetchKey[$option];
                     }
                     $formBody .= "</option>";
                 }
                 $formBody .= "\n</select>\n";
                 break;
             case "custom_url":
                 $formBody .= "<input type=\"text\" disabled=\"disabled\" value=\"" . $current[$records['db_name']] . "\"/>\n";
                 break;
         }
         $formBody .= "</div>\n";
         $formBody .= "<div class=\"fix\"></div>\n";
         $formBody .= "</div>\n";
     }
     return $formBody;
 }
 public function save()
 {
     $eqApp = new Apps();
     $getFinfo_q = 'SELECT * FROM cms_records 
                    WHERE 
                    fieldsetid = "' . $_POST['fieldsetid'] . '" 
                    ORDER BY sortorder ASC';
     $getFinfo_r = mysql_query($getFinfo_q);
     $getFinfo_n = mysql_num_rows($getFinfo_r);
     $pnum = 1;
     $checkPosted = 0;
     //START INSERT QUERY BEGINNING WITH USUAL STARTING VALUES
     $query_q = 'UPDATE cms_content SET ';
     //WHILE LOOP FOR ADDING THE DATABASE VALUES
     while ($getFinfo = mysql_fetch_array($getFinfo_r)) {
         switch ($getFinfo['type']) {
             case "file":
                 if (isset($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"])) {
                     $fileInput = rand() . $_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"];
                     if (!file_exists('../uploads/' . $_POST['id'] . '/')) {
                         mkdir('../uploads/' . $_POST['id'] . '/', 0777);
                     }
                     if (!file_exists('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'])) {
                         mkdir('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'], 0777);
                     } else {
                         foreach (glob('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/*') as $file) {
                             if (is_dir($file)) {
                                 recursiveRemoveDirectory($file);
                             } else {
                                 unlink($file);
                             }
                         }
                     }
                     move_uploaded_file($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["tmp_name"], '../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $fileInput . '" ';
                     $checkPosted++;
                 }
                 break;
             case "photo":
                 if (!empty($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"])) {
                     if (!file_exists('../uploads/' . $_POST['id'] . '/')) {
                         mkdir('../uploads/' . $_POST['id'] . '/', 0777);
                     }
                     if (!file_exists('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'])) {
                         mkdir('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'], 0777);
                     } else {
                         foreach (glob('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/*') as $file) {
                             if (is_dir($file)) {
                                 recursiveRemoveDirectory($file);
                             } else {
                                 unlink($file);
                             }
                         }
                     }
                     $filename = pathinfo($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"], PATHINFO_FILENAME);
                     $fileext = strtolower(pathinfo($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["name"], PATHINFO_EXTENSION));
                     $filename = strtolower(rand() . $filename);
                     $img = new abeautifulsite\SimpleImage($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]['tmp_name']);
                     $img->fit_to_width(300)->save('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/300xauto_' . $filename . '.' . $fileext);
                     $img->save('../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     move_uploaded_file($_FILES[$_POST['recordset'] . '_' . $getFinfo['db_name']]["tmp_name"], '../uploads/' . $_POST['id'] . '/' . $getFinfo['db_name'] . '/' . $filename . '.' . $fileext);
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $filename . '.' . $fileext . '" ';
                     $checkPosted++;
                 }
                 break;
             case "html":
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . addslashes(htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) . '" ';
                 $checkPosted++;
                 break;
             case "yesno":
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] . '" ';
                 $checkPosted++;
                 break;
             case "multiselect":
             case "checkboxes":
                 $vals = "";
                 $x = 0;
                 if (isset($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                     foreach ($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] as $key => $value) {
                         $x++;
                         $vals .= $value . ($x < count($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) ? "," : "");
                     }
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $vals . '" ';
                     $checkPosted++;
                 }
                 break;
             case "radio":
                 $vals = "";
                 $x = 0;
                 if (!empty($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                     $checkPosted++;
                 }
                 break;
             case "foreignkey":
                 $fkeyOptions = $eqApp->get_field_options($getFinfo['options'], $pnum - 1);
                 if ($fkeyOptions['record_fkeytype'] == "select") {
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                     $checkPosted++;
                 } elseif ($fkeyOptions['record_fkeytype'] == "multiselect") {
                     $vals = '';
                     if (isset($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']])) {
                         $d = 0;
                         foreach ($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']] as $key => $value) {
                             $d++;
                             $vals .= htmlspecialchars($value) . ($d < count($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) ? "," : "");
                         }
                     }
                     $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $vals . '" ';
                     $checkPosted++;
                 }
                 break;
             case "custom_url":
                 $custom_url = ltrim(rtrim($getFinfo['custom_url'], '/'), '/');
                 $perma = explode('/', $custom_url);
                 $postedCustomUrl = "";
                 $ddnum = 0;
                 foreach ($perma as $links) {
                     $ddnum++;
                     if (isset($_POST[$links])) {
                         $postedCustomUrl .= $eqApp->permaLink($_POST[$links]) . '/';
                     }
                 }
                 $postedCustomUrl = rtrim($postedCustomUrl, '/');
                 $checkCU_q = 'SELECT * FROM cms_content 
                                     WHERE 
                                     custom_url = "' . $postedCustomUrl . '" 
                                     AND id <> "' . $_POST['id'] . '"';
                 $checkCU_r = mysql_query($checkCU_q);
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . $postedCustomUrl . (mysql_num_rows($checkCU_r) > 0 ? rand() : '') . '" ';
                 $checkPosted++;
                 break;
             default:
                 //for text,textarea,colorpicker,date,select
                 $query_q .= ($pnum > 1 ? ", " : " ") . $getFinfo['db_name'] . '="' . htmlspecialchars($_POST[$_POST['recordset'] . '_' . $getFinfo['db_name']]) . '" ';
                 $checkPosted++;
                 break;
         }
         $pnum++;
     }
     $query_q .= 'WHERE id = "' . $_POST['id'] . '"';
     if ($checkPosted > 0) {
         mysql_query($query_q) or die(mysql_error());
     }
     exit;
 }