function show_links() { $options = array(); $options["border"] = "1"; $grid = new JGrid($options); $grid->addRow($options = array()); $colNum = 'TitleNum'; $grid->addColumn($colNum); $grid->setRowCell($colNum, 'ID'); $colName = 'TitleName'; $grid->addColumn($colName); $grid->setRowCell($colName, 'Наименование'); $colParent = 'TitleParent'; $grid->addColumn($colParent); $grid->setRowCell($colParent, 'Родитель'); $colSyn = 'TitleSynonym'; $grid->addColumn($colSyn); $grid->setRowCell($colSyn, 'Синоним'); $colDel = 'Delete'; $grid->addColumn($colDel); $grid->setRowCell($colDel, 'Удалить'); // $name = 'TitleDesc'; // $grid->addColumn($name); // $grid->setRowCell($name, 'Описание'); $db = new Dbprocess(); $db->connectToDb(); $table_prefix = $db->getTablePrefix(); $where = "parent_name IS NULL"; $result = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'"); $i = 1; if ($result['rows'] > 0) { foreach ($result["value"] as $row) { $grid->addRow($options = array()); $grid->setRowCell($colNum, $row["category_links_ID"]); $grid->setRowCell($colName, $row["category_name"]); $grid->setRowCell($colParent, $row["parent_name"]); $grid->setRowCell($colSyn, $row["synonym_name"]); $grid->setRowCell($colDel, ''); $where = "parent_name='" . $row['category_name'] . "'"; $result_childs = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'"); if ($result_childs['rows'] > 0) { foreach ($result_childs["value"] as $row_childs) { $grid->addRow($options = array()); $grid->setRowCell($colNum, $row_childs["category_links_ID"]); $grid->setRowCell($colName, $row_childs["category_name"]); $grid->setRowCell($colParent, $row_childs["parent_name"]); $grid->setRowCell($colSyn, $row_childs["synonym_name"]); $query = "DELETE FROM" . "" . "WHERE category_links_ID = " . $row_childs["category_links_ID"]; $grid->setRowCell($colDel, '<a onclick="return onClickAjax(' . "'" . $query . "'" . ', ' . "'" . "delete_link.php" . "'" . ', ' . "'" . $_GET['result'] . "'" . ')"" href="">удалить</a>'); } } $i++; } } echo $grid->toString(); }
<?php include $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lib.php'; include $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lib_db.php'; $process = new Dbprocess(); $process->connectToDb(); importCategoryLinks($process); function importCategoryLinks($db) { $html = ''; $upload_failure = false; $UPLOAD_FILE_FIELD = "uploadedfilecatlinks"; $TARGET_FILE_NAME = "category_links.csv"; $uploaddir = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . "/" . "upload" . "/"; if (strpos($_FILES[$UPLOAD_FILE_FIELD]['name'], ".csv") === false) { $html .= "<p style='color:red;'>Выберите файл в формате *.csv file!</p>"; $upload_failure = true; } else { if (move_uploaded_file($_FILES[$UPLOAD_FILE_FIELD]['tmp_name'], $uploaddir . $_FILES[$UPLOAD_FILE_FIELD]['name'])) { rename($uploaddir . $_FILES[$UPLOAD_FILE_FIELD]['name'], $uploaddir . $TARGET_FILE_NAME); $html .= iconv('UTF-8', 'windows-1251', "Файл успешно загружен! Импорт начинается...") . "<br />"; $file_name = $uploaddir . $_FILES[$UPLOAD_FILE_FIELD]['name']; } else { $html .= "<p style='color:red;'>Что-то пошло не так при загрузке файла: " . $_FILES['uploadedfile']['error'] . "</p>"; $upload_failure = true; } } if (!$upload_failure) { $html .= ""; $table_prefix = $db->getTablePrefix() . $db->getVMTablePrefix(); $category_links = new CategoriesLinks();
<?php include_once $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'lib_db.php'; $process = new Dbprocess(); $process->connectToDb(); makeInputQuery($process); unset($process); function makeInputQuery($db) { $html = ""; $vals = explode(',', $_GET['valuesSet']); foreach ($vals as $value) { if ($value == "null") { $newvals[] = $value; } elseif (is_numeric($value)) { $newvals[] = $value; } else { $newvals[] = "'" . $value . "'"; } } $temp = $db->insert($_GET['tableName'], implode(",", $newvals)); if ($temp != '') { echo $temp; } else { "<p style='color:blue;'>" . 'Новое значение добавлено!' . "</p>"; } /*ГОВНОКОД*/ require_once "show_links.php"; show_links(); }
function show_links() { $NEW_VALUE_FORM = 'catlinksnew'; if (isset($_GET['result'])) { $result_field = $_GET['result']; } else { $result_field = "tablelinks"; } $options = array(); $options["border"] = "1"; $options["cellpadding"] = "3"; $options["bgcolor"] = "#CCCCCC"; $colNum = 'TitleNum'; $colName = 'TitleName'; $colParent = 'TitleParent'; $colSyn = 'TitleSynonym'; $colDel = 'Delete'; // $name = 'TitleDesc'; // $grid->addColumn($name); // $grid->setRowCell($name, 'Описание'); $db = new Dbprocess(); $db->connectToDb(); $table_prefix = $db->getTablePrefix(); $grid = new JGrid($options); $grid->addRow($options = array()); $grid->addColumn($colNum); $grid->setRowCell($colNum, 'ID'); $grid->addColumn($colName); $grid->setRowCell($colName, 'Наименование'); $grid->addColumn($colParent); $grid->setRowCell($colParent, 'Родитель'); $grid->addColumn($colSyn); $grid->setRowCell($colSyn, 'Синоним'); $grid->addColumn($colDel); $grid->setRowCell($colDel, 'Добавить'); $grid->addRow($options = array()); $max_result = $db->select($table_prefix . "virtuemart_category_links", "category_links_ID", "", 'max'); //include_once("fb.php"); //fb($max_result, "max_result"); $html .= $max_result['html']; $max = $max_result['value'] + 1; $grid->setRowCell($colNum, "<input name='category_links_ID' id='category_links_ID' value='" . $max . "' type='input' />"); $grid->setRowCell($colName, "<input name='category_name' value='' type='input' />"); $grid->setRowCell($colParent, "<input name='parent_name' value='' type='input' />"); $grid->setRowCell($colSyn, "<input name='synonym_name' value='' type='input' />"); $grid->setRowCell($colDel, '<a onclick="return onClickAjax_input(\'' . $NEW_VALUE_FORM . '\', \'' . $table_prefix . "virtuemart_category_links" . '\',\'' . "/components/com_import/make_input_request.php" . '\', \'' . $result_field . '\')"" href="">добавить</a>'); echo "<form name='" . $NEW_VALUE_FORM . "' id='" . $NEW_VALUE_FORM . "'>"; echo "<h4>Введите новое значение:</h4>"; echo $grid->toString(); echo "</form>"; $options = array(); $options["border"] = "1"; $options["cellpadding"] = "7"; $grid = new JGrid($options); $grid->addRow($options = array()); $grid->addColumn($colNum); $grid->setRowCell($colNum, 'ID'); $grid->addColumn($colName); $grid->setRowCell($colName, 'Наименование'); $grid->addColumn($colParent); $grid->setRowCell($colParent, 'Родитель'); $grid->addColumn($colSyn); $grid->setRowCell($colSyn, 'Синоним'); $grid->addColumn($colDel); $grid->setRowCell($colDel, 'Удалить'); $where = "parent_name IS NULL"; $result = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'"); $i = 1; if ($result['rows'] > 0) { foreach ($result["value"] as $row) { $grid->addRow($options = array()); $grid->setRowCell($colNum, $row["category_links_ID"]); $grid->setRowCell($colName, $row["category_name"]); $grid->setRowCell($colParent, $row["parent_name"]); $grid->setRowCell($colSyn, $row["synonym_name"]); $grid->setRowCell($colDel, ''); $where = "parent_name='" . $row['category_name'] . "'"; $result_childs = $db->select($table_prefix . "virtuemart_category_links", "*", "{$where}", 'std', "'category_name'"); if ($result_childs['rows'] > 0) { foreach ($result_childs["value"] as $row_childs) { $grid->addRow($options = array()); $grid->setRowCell($colNum, $row_childs["category_links_ID"]); $grid->setRowCell($colName, $row_childs["category_name"]); $grid->setRowCell($colParent, $row_childs["parent_name"]); $grid->setRowCell($colSyn, $row_childs["synonym_name"]); $query = "category_links_ID = " . $row_childs["category_links_ID"]; $grid->setRowCell($colDel, '<a onclick="return onClickAjax(' . "'" . $query . "'" . ', ' . "'" . "/components/com_import/delete_links.php" . "'" . ', ' . "'" . $result_field . "'" . ')"" href="">удалить</a>'); } } $i++; } } echo "<h4>Текущая таблица:</h4>"; echo $grid->toString(); }
<?php include $_SERVER['DOCUMENT_ROOT'] . '/libraries/lib_db.php'; $process = new Dbprocess(); $link = $process->connectToDb(); $table_prefix = $process->getTablePrefix() . $process->getVMTablePrefix(); $searchValue = trim($_GET['search']); $searchValue = strip_tags($searchValue); // Удаляем HTML и PHP теги $searchValue = mysql_real_escape_string($searchValue); // Экранируем специальные символы $table_name = $table_prefix . "import"; $field_name = "product_sku"; $query_select = 'SELECT * FROM ' . $table_name . ' WHERE ' . $field_name . ' LIKE "%' . addslashes($searchValue) . '%" group by ' . $field_name; $result = mysql_query($query_select); if (mysql_error() != "") { echo "<p style='color:red;'>Error select from " . $table_name . ":" . mysql_error() . "\n" . $query_select . "</p>"; } else { /*HTML Version*/ $count = 0; while ($row = mysql_fetch_array($result)) { if ($count == 0) { $html .= "<div id='firstDiv' className='optionDiv' onmouseover='rollOverActiveDiv(this,false)' onclick='selectDiv(this)'>" . $row[$field_name] . "</div>"; } else { $html .= "<div className='optionDiv' onmouseover='rollOverActiveDiv(this,false)' onclick='selectDiv(this)'>" . $row[$field_name] . "</div>"; } $count++; } } /* JSON Version $html = '{"row":[';