function InsertAll(array $obj) { $res = true; foreach ($obj as $item) { $table = GetTabelByModel($item); $res &= Insert($table, $item); } return $res; }
function InsertUser($config, $data, $filename) { $rows = array(); switch ($config['adapter']) { case 'Mysql': include '../modules/Application/src/Application/Model/Mysql/Execute.php'; include '../modules/Application/src/Application/Model/Mysql/Connect.php'; $link = Connect($config['slave']); $query = 'INSERT INTO user (iduser, name, email, password, photo, description, bdate, city_idcity, gender_idgender) VALUES ' . '("4", "' . $data['name'] . '", "' . $data['email'] . '", "' . $data['password'] . '", "' . $_FILES['photo']['name'] . '", "' . $data['description'] . '", "' . $data['bdate'] . '", 1, 1)'; $rows = Execute($link, $query); break; case 'Txt': include "../modules/Application/src/Application/Model/Txt/Insert.php"; Insert($_POST, $filename); break; } // Obtener nombre de la imagen subida $_POST['photo'] = $_FILES['photo']['name']; // Comprobar si el nombre de archivo existe $dir = $_SERVER['DOCUMENT_ROOT'] . '/img/'; $files = scandir($dir); if (in_array($_POST['photo'], $files)) { // Si existe se concatena con un numero // Comprobar si hay algun otro archivo con el mismo nombre y un numero concatenado $filtrado = "/" . substr($_POST['photo'], 0, -4) . "*/"; $extension = substr($_POST['photo'], -3); $filesMatch = array(); foreach ($files as $archivo) { $ext2 = substr($archivo, -3); if (preg_match($filtrado, $archivo) && $extension === $ext2) { $filesMatch[] = (int) substr($archivo, strrpos($archivo, "_") + 1, strlen($archivo)); } } $filesMatchAux = range(1, max($filesMatch)); $missing = array_diff($filesMatchAux, $filesMatch); if (count($missing) > 0) { $_POST['photo'] = substr($_POST['photo'], 0, -4) . '_' . min($missing) . '.' . $extension; } else { $_POST['photo'] = substr($_POST['photo'], 0, -4) . '_' . (max($filesMatch) + 1) . '.' . $extension; } } // Declarar destino donde guardar la imagen $destination = $_SERVER['DOCUMENT_ROOT'] . '/img/' . $_POST['photo']; // Pasarla de ruta temporal a ruta fisica en el servidor move_uploaded_file($_FILES['photo']['tmp_name'], $destination); return $rows; }
function Insertar() { //read the json file contents $jsondata = file_get_contents('empdetails.json'); //convert json object to php associative array $data = json_decode($jsondata, true); foreach ($data->usuario as $user) { $nombre = $user->nombre; $apellido1 = $user->apellido1; $apellido2 = $user->apellido2; $correo = $user->correo; $telefono = $user->telefono; $usuario = $user->usuario; $rol = $user->rol; $sql = "INSERT INTO usuarios(nombre, apellido1, apellido2, correo, telefono, usuario, rol)\n VALUES('{$nombre}', '{$apellido1}', '{$apellido2}', '{$correo}', {$telefono}, '{$usuario}', '{$rol}')"; AccesoDatos . Insert($sql); } }
<form action="" method="post"> <?php $newissue = ""; foreach ($testsuiteid_to_newissue as $index => $issue) { $newissue .= $issue; } Debug("\n[" . __FILE__ . "][" . __LINE__ . "]allnewissue:\n" . $newissue . "\n"); $remainissue = ""; foreach ($testsuiteid_to_remainissue as $index => $issue) { $remainissue .= $issue; } Debug("\n[" . __FILE__ . "][" . __LINE__ . "]allremainissue:\n" . $remainissue . "\n"); $testdetailtime = date('Y-m-d G:i:s'); $sql = "insert into st_dailytest(testdate, testdetailtime, tester, platform, branch, product, imageinfo, boardno, hardware, note, newissue, remainissue) values(\n '{$reportdate}', '{$testdetailtime}', '{$tester}', '{$platform}', '{$branch}','{$product}', '{$imageinfo}', '{$boardno}', '{$hardware}', '{$note}', '{$newissue}', '{$remainissue}')"; $insertresult = Insert($sql); Debug("\n[" . __FILE__ . "][" . __LINE__ . "]insertresult:\n" . $sql . "\n"); if (!$insertresult) { //插入 到 st_dailytest 表 echo $insertresult . 'insert fail!<br/>'; echo $num_dt . ' line found in table st_dailytest.then will update the table. <br/>'; } else { //insert st_dailytest 成功。 echo $insertresult . 'insert into st_dailytest successfully!<br/>'; #################################################################################################################################################################### $dailytest_id = $insertresult; #################################################################################################################################################################### $sql = "insert into st_issueresult(dailytest_id, testsuite_id, newissue, remainissue)\n values({$dailytest_id}, {$testsuiteid_array['0']}, '" . $testsuiteid_to_newissue[$testsuiteid_array[0]] . "','" . $testsuiteid_to_remainissue[$testsuiteid_array[0]] . "')"; foreach ($testsuiteid_array as $index => $testsuite_id) { if ($index >= 1) { $sql .= ",({$dailytest_id}, {$testsuite_id}, '" . $testsuiteid_to_newissue[$testsuiteid_array[$index]] . "','" . $testsuiteid_to_remainissue[$testsuiteid_array[$index]] . "')";
$thumbpath = 'upload/thumbs/' . $news_image; $obj_img = new thumbnail_images(); $obj_img->PathImgOld = $tpath1; $obj_img->PathImgNew = $thumbpath; $obj_img->NewWidth = 72; $obj_img->NewHeight = 72; if (!$obj_img->create_thumbnail_images()) { echo $_SESSION['msg'] = "Thumbnail not created... please upload image again"; exit; } $data = array('cat_id' => $_POST['category_id'], 'news_heading' => addslashes($_POST['news_heading']), 'news_description' => addslashes($_POST['news_description']), 'news_date' => $_POST['news_date'], 'news_image' => $news_image); } } else { $data = array('cat_id' => $_POST['category_id'], 'news_heading' => addslashes($_POST['news_heading']), 'news_description' => addslashes($_POST['news_description']), 'news_date' => $_POST['news_date']); } $qry = Insert('tbl_news', $data); $_SESSION['msg'] = "10"; header("location:add-news?add"); exit; } if (isset($_GET['news_id'])) { $qry = "SELECT * FROM tbl_news where nid='" . $_GET['news_id'] . "'"; $result = mysql_query($qry); $news_row = mysql_fetch_assoc($result); } if (isset($_POST['submit']) and isset($_POST['news_id'])) { $img_res = mysql_query('SELECT * FROM tbl_news WHERE nid=\'' . $_POST['news_id'] . '\''); $img_row = mysql_fetch_assoc($img_res); if ($img_row['news_image'] != "") { unlink('upload/' . $img_row['news_image']); unlink('upload/thumbs/' . $img_row['news_image']);
function execute($param, $post) { if (count($param) > 0 && $param[0] == "act") { $obj = json_decode($post["json"]); $group = GetSingleByCondition(DRINKERCYCLE_TABLE, array("Name" => $obj->Name)); if ($group instanceof DrinkerCycle) { if ($obj->Action == "exists") { $groupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id)); return ReturnBoolean($groupRela != null); } else { if ($obj->Action == "add") { $drinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->Guid)); if ($drinker instanceof Drinker) { $presGroupRelation = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $drinker->Id)); if ($presGroupRelation == null) { $groupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id)); $newRela = new DrinkerCyclesDrinkersRelation(); $newRela->DrinkerId = $drinker->Id; $newRela->DrinkerCycleId = $group->Id; $newRela->IsAuthenticated = $groupRela == null; return ReturnBoolean(Insert(DRINKERCYCLESDRINKERSRELATION_TABLE, $newRela)); } return ReturnBoolean(true); } else { return ReturnNotFound($obj->Guid, "Drinker"); } } else { if ($obj->Action == "remove") { $drinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->Guid)); if ($drinker instanceof Drinker) { $groupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $drinker->Id)); if ($groupRela instanceof DrinkerCyclesDrinkersRelation) { return ReturnBoolean(DeleteById(DRINKERCYCLESDRINKERSRELATION_TABLE, $groupRela->Id)); } else { return RelationNotFound($group->Id, $drinker->Id, DRINKERCYCLESDRINKERSRELATION_TABLE); } } else { return ReturnNotFound($obj->Guid, DRINKER_TABLE); } } else { if ($obj->Action == "authenticate" || $obj->Action == "deauthenticate") { $newVal = true; if ($obj->Action == "deauthenticate") { $newVal = false; } $drinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->Guid)); if ($drinker instanceof Drinker) { $groupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $drinker->Id)); if ($groupRela instanceof DrinkerCyclesDrinkersRelation) { //can change others status if ($groupRela->IsAuthenticated) { $otherDrinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->AuthGuid)); if ($otherDrinker instanceof Drinker) { $otherGroupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $otherDrinker->Id)); if ($otherGroupRela instanceof DrinkerCyclesDrinkersRelation) { $otherGroupRela->IsAuthenticated = $newVal; return ReturnBoolean(Update(DRINKERCYCLESDRINKERSRELATION_TABLE, $otherGroupRela)); } else { return RelationNotFound($group->Id, $otherDrinker->Id, DRINKERCYCLESDRINKERSRELATION_TABLE); } } else { return ReturnNotFound($obj->AuthGuid, "Drinker"); } } else { //not authenticated return ReturnBoolean(false); } } else { return RelationNotFound($group->Id, $drinker->Id, DRINKERCYCLESDRINKERSRELATION_TABLE); } } else { return ReturnNotFound($obj->Guid, "Drinker"); } } else { if ($obj->Action == "removeforeign") { $drinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->Guid)); if ($drinker instanceof Drinker) { $groupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $drinker->Id)); if ($groupRela instanceof DrinkerCyclesDrinkersRelation) { //can change others status if ($groupRela->IsAuthenticated) { $otherDrinker = GetSingleByCondition(DRINKER_TABLE, array("Guid" => $obj->AuthGuid)); if ($otherDrinker instanceof Drinker) { $otherGroupRela = GetSingleByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $group->Id, "DrinkerId" => $otherDrinker->Id)); if ($otherGroupRela instanceof DrinkerCyclesDrinkersRelation) { return ReturnBoolean(Delete(DRINKERCYCLESDRINKERSRELATION_TABLE, $otherGroupRela)); } else { return RelationNotFound($group->Id, $otherDrinker->Id, DRINKERCYCLESDRINKERSRELATION_TABLE); } } else { return ReturnNotFound($obj->AuthGuid, "Drinker"); } } else { //not authenticated return ReturnBoolean(false); } } else { return RelationNotFound($group->Id, $drinker->Id, DRINKERCYCLESDRINKERSRELATION_TABLE); } } else { return ReturnNotFound($obj->Guid, "Drinker"); } } else { return ReturnError(LINK_INVALID); } } } } } } if ($obj->Action == "exists") { return ReturnBoolean(false); } else { if ($obj->Action == "add") { $newGroup = new DrinkerCycle(); $newGroup->Name = $obj->Name; $newGroup->Guid = GenerateGuid(); if (Insert(DRINKERCYCLE_TABLE, $newGroup)) { return $this->execute($param, $post); } else { return ReturnCrudError($newGroup, "add"); } } else { return ReturnNotFound($obj->Guid, DRINKERCYCLE_TABLE); } } } else { if (ValidateGuid($param[0])) { //construct model puh $drinker = GetByGuid("Drinker", $param[0]); if ($drinker != null && $drinker instanceof Drinker) { $relations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerId" => $drinker->Id)); $cyclesEnt = array(); $cycles = array(); $authCycles = array(); foreach ($relations as $relation) { if ($relation instanceof DrinkerCyclesDrinkersRelation) { $cycle = GetById(DRINKERCYCLE_TABLE, $relation->DrinkerCycleId); if ($cycle instanceof DrinkerCycle) { if ($relation->IsAuthenticated) { $cycl = new DrinkerCycleEntity($cycle); $cycl->IsAuthenticated = true; $authCycles[] = $cycle; $cyclesEnt[] = $cycl; } else { $cycles[] = $cycle; $cycl = new DrinkerCycleEntity($cycle); $cycl->IsAuthenticated = false; $cyclesEnt[] = $cycl; } } } } $drinkers = array(); foreach ($authCycles as $cycle) { $userRelations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerCycleId" => $cycle->Id)); foreach ($userRelations as $userRelation) { if ($userRelation instanceof DrinkerCyclesDrinkersRelation) { //exclude self if ($drinker->Id != $userRelation->DrinkerId) { if (!isset($drinkers[$userRelation->DrinkerId])) { $user = GetById(DRINKER_TABLE, $userRelation->DrinkerId); if ($user instanceof Drinker) { $drinkers[$userRelation->DrinkerId] = new DrinkerEntity($user); } } if ($drinkers[$userRelation->DrinkerId] instanceof DrinkerEntity) { if ($userRelation->IsAuthenticated) { $drinkers[$userRelation->DrinkerId]->AuthDrinkerCycles[] = $cycle->Guid; } else { $drinkers[$userRelation->DrinkerId]->NonAuthDrinkerCycles[] = $cycle->Guid; } } } } } } $coll = new DrinkerCycleResponse(); $coll->DrinkerCycles = $cyclesEnt; foreach ($drinkers as $drinker) { $coll->Drinkers[] = $drinker; } return json_encode($coll); } else { return ReturnNotFound($param[0], "Drinker"); } } else { return ReturnError(LINK_INVALID); } } }
Insert($file, $pos, $text, $error); } } $file = "admin/view/template/common/header.tpl"; $text = '<li><a href="<?php echo $download; ?>">'; $pos = FindText($file, $text, 1); if ($pos == 'yes') { echo 'SUCCESS File: ' . $file . ' Text already installed <br />'; } else { if ($pos == 'no') { echo 'FAIL Text not found in file: ' . $file . ' <br />'; } else { $text = ' <li><a href="<?php echo $suppler; ?>"><?php echo $text_suppler; ?></a></li> <!--*suppler*--> '; Insert($file, $pos, $text, $error); } } require_once 'config.php'; $dbhost = DB_HOSTNAME; $dbuser = DB_USERNAME; $dbpass = DB_PASSWORD; $dbdatabase = DB_DATABASE; $dbprefix = DB_PREFIX; $conn = new mysqli($dbhost, $dbuser, $dbpass, $dbdatabase); if (!$conn) { die('Could not connect: ' . mysql_error()); } $sql = 'CREATE TABLE IF NOT EXISTS `' . $dbprefix . 'key`( ' . 'id INT NOT NULL AUTO_INCREMENT, ' . 'value text, ' . 'main_key VARCHAR(256), ' . 'license_key text, ' . 'primary key ( id ))'; $retval = $conn->query($sql); if (!$retval) {
exit; } createBookSourceCopy($b, -1, 0); Update('libbook', "Year = '{$l}'", "BookId = {$b}"); $un = Sel("name FROM users WHERE uid={$u}"); Insert('libactions', 'UserName, ActionSQL, ActionDesc, ActionUndo', "\"{$un}\", \"UPDATE libbook SET Year = '{$l}' WHERE BookId = {$b}\", \r\n \"Set Year {$l} for {$b}\", \"UPDATE libbook SET Year = '{$l1}' WHERE BookId = {$b}\""); /* case 'setyear': $l = (integer) $_GET['l']; if (!$b || !$l || !$u) exit; Update ('libbook', "Year = '$l'", "BookId = $b"); $un = Sel("name FROM users WHERE uid=$u"); Insert ('libactions', 'UserName, ActionSQL, ActionDesc, ActionUndo', "\"$un\", \"UPDATE libbook SET Year = '$l' WHERE BookId = $b\", \"Set Year $l for $b\", \"UPDATE libbook SET Year = '$l1' WHERE BookId = $b\""); */ exit; case 'setuid': if (!$a || !$u) { exit; } $l = addslashes($_GET['l']); $uid = 0; if ($l == '' or $uid = Sel("uid FROM users WHERE name = '{$l}'")) { $ouid = Sel("uid FROM libavtorname WHERE AvtorId = {$a}"); createAvtorSourceCopy($a, -1, 0); Update('libavtorname', "uid = {$uid}", "AvtorId = {$a}"); $un = Sel("name FROM users WHERE uid={$u}"); Insert('libactions', 'UserName, ActionSQL, ActionDesc, ActionUndo', "\"{$un}\", 'UPDATE libavtorname SET uid = {$uid} WHERE AvtorId = {$a}', \r\n 'Set Avtor UID to {$uid} for {$a}', 'UPDATE libavtorname SET uid = '{$ouid}' WHERE AvtorId = {$a}'"); } print "uid = {$uid}"; exit; }
break; case 'insert': if ($_POST) { include '../modules/Utils/src/Utils/Form/FilterData.php'; $formdef = "../modules/Application/src/Application/Form/register.json"; $data = FilterData($_POST, $formdef); $validate = ValidateData($data, $formdef); if ($validate['result'] === true) { $_POST['photo'] = $_FILES['photo']['name']; echo "<pre>"; print_r($_FILES); echo "</pre>"; $destination = $_SERVER['DOCUMENT_ROOT'] . '/img/' . $_POST['photo']; move_uploaded_file($_FILES['photo']['tmp_name'], $destination); include "../modules/Application/src/Application/Model/Txt/Insert.php"; Insert($_POST, $userfilename); header("Location: /user/select"); } echo "<pre>"; print_r($validate); echo "</pre>"; // TODO: mostrar formulario con datos de usuario } else { include "../modules/Application/views/user/insert.phtml"; } break; case 'update': if ($_POST) { // print_r($_POST); // $_POST['photo']=$_FILES['photo']['name']; include "../modules/Application/src/Application/Model/Txt/Update.php";
function InsertDefaultData($data, $parent = 0) { // 자식은 복사해놓기 $children = $data['children']; unset($data['children']); // 메뉴도 복사해 놓기 $menu = explode(':', $data[0]); unset($data[0]); // array_pop 하면서 데이터 입력 $_key = array(); while ($_data = array_pop($data)) { $_key = Insert($_data, $_key); } // 최종적으로 메뉴삽입 $parent를 활용 $clear = array('m_id' => trim($menu[0]), 'm_layout' => trim($menu[1]), 'm_parent' => $parent, 'm_hidden' => $menu[2]); $clear['m_contents'] = ''; foreach ($_key as $v) { $clear['m_contents'] .= '[[Widget|' . $v . ']]'; } $parent = DB::Get()->InsertEx(DB::Get()->prefix() . 'magic', $clear); // 자식이 있다면 부모아이디를 추가하면서 호출함 if (is_array($children) && sizeof($children)) { foreach ($children as $v) { InsertDefaultData($v, $parent); } } }
function readlsfile($path) { if (!preg_match('#-md-(.+?)\\.ls#', $path, $re)) { events("Unable to determine source from this file " . basename($path)); return true; } else { $external_source = $re[1]; } $file_name = basename($path); $filename = $path; $filesize = @filesize($filename); events("Request for analyze file {$path} size {$filesize} bytes"); if ($filesize == 0) { events("Obytes -> Abort but return true;"); return true; } if (preg_match('#(.+?)-md-.+?\\.[a-z0-9]+$#', $path, $re)) { $database_path = $re[1]; } $database_name = basename($database_path); if (preg_match('#(.+?)\\-.+?\\-diff#', $database_name, $re)) { $database_name = $re[1]; } if ($filesize > 400) { DeleteDatabase($database_name); } $source_path = GetSources($database_path); if ($source_path == null) { $source_path = GetSources($database_name); } $external_source_pattern = $_GET["STORAGES"][$external_source]; if ($external_source == null) { events("Unable to find source for {$external_source} !!"); return false; } events("*********************************************************************"); events("Analyzing cache from {$filename}..."); events("MD5 source....: {$external_source}"); events("Pattern source: {$external_source_pattern}"); events("database name.: {$database_name}"); events("database Path.: {$database_path}"); events("Source Path...: {$source_path}"); events("*********************************************************************"); $content = file_get_contents($filename); $md5 = md5($content); $ini = new Bs_IniHandler("/etc/artica-postfix/dar.cache.ini"); if ($ini->_params["{$database_name}"]["md5"] == $md5) { events("Analyzing {$database_name} cache:{$md5} already set"); return true; } $ini->set($database_name, "md5", $md5); $ini->saveFile("/etc/artica-postfix/dar.cache.ini"); $filesize = @filesize($filename); $filesize = round($filesize / 1024, 2) . " Ko"; events("Analyzing " . basename($filename) . " ({$filesize}) for database: {$database_name} cache:{$md5}"); if ($fd = @fopen($filename, "r")) { while ($fd && !feof($fd)) { $line = trim(fgets($fd, 4096)); if (preg_match("#^\\[.+?\\]\\s+\\[.*?\\]\\s+[a-z\\-]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+[a-zA-Z0-9\\-\\_\\.]+\\s+([0-9]+)\\s+([a-zA-Z0-9\\s\\:]+)\\s+(.+)#", $line, $re)) { if (!Insert($re[3], $re[1], $re[2], $source_path, $database_name, $external_source_pattern)) { events("Failed line \"{$line}\" aborting process"); return false; } } else { events("Failed line {$num} \"{$line}\" -> continue reading file..."); } } fclose($fd); events("{$_GET["COUNT"][$database_name]} files added..."); events("Optimize table..."); $sql = "OPTIMIZE TABLE `dar_index`"; $q = new mysql(); $q->QUERY_SQL($sql, "artica_backup"); return true; } }
<?php if (isset($_GET['action'])) { $action = $_GET['action']; } else { $action = 'select'; } switch ($action) { case 'insert': if ($_POST) { $_POST['photo'] = $_FILES['photo']['name']; include "../modules/Application/src/Application/Model/Txt/Insert.php"; Insert($_POST, 'user.txt'); // saltar a tabla header("Location: /UserController.php"); } else { include "../modules/Application/views/user/insert.phtml"; } break; case 'update': if ($_POST) { // print_r($_POST); // $_POST['photo']=$_FILES['photo']['name']; include "../modules/Application/src/Application/Model/Txt/Update.php"; Update($_POST['id'], $_POST, 'user.txt'); // saltar a tabla header("Location: /UserController.php"); } else { // Formulario relleno con los datos $id = $_GET['id']; $_GET['filename'] = 'user.txt';
/** * @param $noteTakerGuid * @param NoteCollection[] $collections */ private function addNoteCollections($noteTakerGuid, array $collections) { $ret = true; $noteTakerId = $this->getNoteTakerId($noteTakerGuid); foreach ($collections as $collection) { if (Insert("NoteCollections", $collection)) { $db = GetDatabaseConnection(); $pdo = $db->prepare("INSERT INTO NoteTakerNoteCollectionRelations (NoteTakerId, NoteCollectionId)\n VALUES (:NoteTakerId, :NoteCollectionId)"); $pdo->bindValue(":NoteTakerId", $noteTakerId); $pdo->bindValue(":NoteCollectionId", $collection->Id); $ret &= $pdo->execute(); } else { $ret = false; } } return $ret; }
$obj_img = new thumbnail_images(); $obj_img->PathImgOld = $tpath1; $obj_img->PathImgNew = $thumbpath; $obj_img->NewWidth = 100; $obj_img->NewHeight = 100; if (!$obj_img->create_thumbnail_images()) { echo $_SESSION['msg'] = "Thumbnail not created... please upload image again"; } $data = array('category_name' => $_POST['category_name'], 'category_image' => $category_image); } else { echo $_SESSION['msg'] = "This is not an image"; } } else { $data = array('category_name' => $_POST['category_name']); } $qry = Insert('tbl_news_category', $data); $_SESSION['msg'] = "5"; header("location:add-category?add"); exit; } if (isset($_GET['cat_id'])) { $qry = "SELECT * FROM tbl_news_category where cid='" . $_GET['cat_id'] . "'"; $result = mysql_query($qry); $row = mysql_fetch_assoc($result); } if (isset($_POST['submit']) and isset($_POST['cat_id'])) { $img_res = mysql_query('SELECT * FROM tbl_news_category WHERE cid=\'' . $_POST['cat_id'] . '\''); $img_row = mysql_fetch_assoc($img_res); if ($img_row['category_image'] != "") { unlink('upload/category/' . $img_row['category_image']); }
<?php //these are for the PHP Helper files include 'databaseConn.php'; if (isset($_GET["no"]) && $_GET["no"] == "1") { // for inserting Insert($_GET["email"], $_GET["name"], $_GET["tel"], $_GET["age"]); } function Insert($email, $name, $tel, $age) { $resp = "-1"; try { $query = "insert into skrillex(Email, Name, Tel, Age) values('{$email}', '{$name}', '{$tel}', '{$age}')"; $rs = mysql_query($query); if (!$rs) { $resp = "-1"; } else { $resp = "1"; } echo $resp; } catch (Exception $e) { $resp = "-1"; echo $resp; } }
$avatar = $_FILES['avatar']['type']; $allowed = array('image/gif', 'image/png', 'image/jpg', 'image/jpeg'); if (!in_array($avatar, $allowed)) { $url = "register.php"; $_SESSION['errors'] = ['message' => "Avatar images must be JPG, PNG or GIF"]; header('Location: ' . $url); } } if ($password != $password2 || !validPass($password)) { $url = "register.php"; $_SESSION['errors'] = ['message' => "Passwords should be at least 8 characters long and consist of at least one lowercase letter, one uppercase letter, a number (0-9) and a special character."]; header('Location: ' . $url); } if (!validUser($username)) { $url = "register.php"; $_SESSION['errors'] = ['message' => "Usernames can only consist of a-Z and _ (underscore) OR a user already exists with that name"]; header('Location: ' . $url); } if ($password == $password2 && validUser($username) && validPass($password)) { Insert($username, $password); LogIn($username, $password); $url = "frontPage.php"; $_SESSION['errors'] = ['message' => 'Success! Thank you for registering.']; header('Location: ' . $url); } echo 'Noooo'; } else { $url = "register.php"; $_SESSION['errors'] = ['message' => "Something went wrong, please try again."]; header('Location: ' . $url); }
function Create_table($Insert) { $Insert = explode('^', $Insert); $AllHandles1 = explode(',', $Insert[1]); $AllHandles2 = explode('\'', $AllHandles1[0]); if (formIdMap(2, "Form_Handle", $AllHandles2[0]) != null) { $AllHandles2[0] = formIdMap(2, "Form_Handle", $AllHandles2[0]); } $s1 = "CREATE TABLE IF NOT EXISTS `" . Prefix . "_formulize_{$AllHandles2['0']}` (\n`entry_id` int(7) unsigned NOT NULL AUTO_INCREMENT,\n`creation_datetime` datetime DEFAULT NULL,\n`mod_datetime` datetime DEFAULT NULL,\n`creation_uid` int(7) DEFAULT '0',\n`mod_uid` int(7) DEFAULT '0',"; $s2 = " PRIMARY KEY (`entry_id`),\n\tKEY `i_creation_uid` (`creation_uid`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=23 ;"; foreach ($AllHandles1 as $k => $column) { if ($k != 0) { if (formIdMap(2, "Element_Handle", $column) != null) { $column = formIdMap(2, "Element_Handle", $column); } $s1 .= "`{$column}` text,"; } } $s1 .= $s2; $s1 .= $Insert[2]; $s1 .= ";"; $s1 = preg_replace('/Table_Name/', "`" . Prefix . "_formulize_{$AllHandles2['0']}`", $s1); Insert($s1); Insert("UPDATE `" . Prefix . "_formulize_{$AllHandles2['0']}` SET `creation_uid`=" . SID . ",`mod_uid`=" . MOD_ID . ""); //To Update Formulize_Handle Mod ID to the User who's carrying out the Impot echo "Creating Table Formulize_{$AllHandles2['0']} <br/>"; }
function execute($param, $post) { if (count($param) > 0) { if ($param[0] == "act") { $obj = json_decode($post["json"]); $user = GetByGuid("Drinker", $obj->Guid); if ($obj->Action == "exists") { return ReturnBoolean($user != null); } else { if ($obj->Action == "update") { if ($user instanceof Drinker) { $user->Name = $obj->UserInformations->Name; $user->Color = $obj->UserInformations->Color; return ReturnBoolean(Update(DRINKER_TABLE, $user)); } else { $user = new Drinker(); $user->Name = $obj->UserInformations->Name; $user->Color = $obj->UserInformations->Color; $user->Guid = $obj->Guid; return ReturnBoolean(Insert(DRINKER_TABLE, $user)); } } else { if ($obj->Action == "remove") { if ($user instanceof Drinker) { //remove all DrinkerCycleRelations $relations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerId" => $user->Id)); if (DeleteAll($relations)) { return ReturnBoolean(Delete(DRINKER_TABLE, $user)); } else { return ReturnCrudError($relations, "DeleteAll"); } } else { return ReturnNotFound($obj->Guid, "Drinker"); } } } } } else { if (ValidateGuid($param[0])) { $user = GetByGuid("Drinker", $param[0]); if ($user instanceof Drinker) { $drinker = new DrinkerEntity($user); $relations = GetAllByCondition(DRINKERCYCLESDRINKERSRELATION_TABLE, array("DrinkerId" => $drinker->Id)); foreach ($relations as $relation) { if ($relation instanceof DrinkerCyclesDrinkersRelation) { $cycle = GetById(DRINKER_TABLE, $relation->DrinkerCycleId); if ($cycle instanceof DrinkerCycle) { if ($relation->IsAuthenticated) { $drinker->AuthDrinkerCycles[] = $cycle->Guid; } else { $drinker->NonAuthDrinkerCycles[] = $cycle->Guid; } } } } $resp = new DrinkerResponse(); $resp->Drinker = $drinker; return json_encode($resp); } else { return ReturnNotFound($param[0], "Drinker"); } } } } return ReturnError(LINK_INVALID); }
$buffer = str_replace("'", "\\'", $buffer); $buffer = str_replace($space, '', $buffer); //分割关键词 //自动跳过空行 if ($buffer == '') { continue; } $arr = explode('|', $buffer); $key = $arr[0]; $keys = $arr[1]; $adKey = $arr[2]; //自动跳过空行 if ($key == '') { continue; } $insertToDB_sql .= Insert($key, $keys, $adKey); //断点安装,避免php运行时间过长超时 $xx++; $x++; if ($xx > 1000) { $insertToDB_sql = str_replace(',xbakfffeeee', '', $insertToDB_sql . 'xbakfffeeee'); $insertToDB_sql = str_replace('xbakfffeeee', '', $insertToDB_sql) . ';'; $db->query($insertToDB_sql); echo "<br>解锁<br>"; $db->query('UNLOCK TABLES;'); //解锁 $url = "./addkey.php?pwd=7698&x={$x}"; echo "<meta http-equiv=refresh content='0; url={$url}'>"; die; } }
if (isset($_POST["Submit"]) && $_POST["Submit"] == "注册") { $user = $_POST["username"]; $psw = $_POST["password"]; $psw_confirm = $_POST["confirm"]; if ($user == "" || $psw == "" || $psw_confirm == "") { echo "<script>alert('请检查输入的信息!'); history.go(-1);</script>"; } else { if (pass_validate($psw) && pass_validate($psw_confirm)) { if ($psw == $psw_confirm) { if (IsUserExists($user)) { echo "<script>alert('该用户已存在'); history.go(-1);</script>"; } else { $userName = $user; $idNum = ''; $authority = 0; if (Insert($psw, $user, $userName, $idNum, $authority)) { session_start(); $_SESSION["user"] = $user; echo "<script>window.location.href = 'http://2.whoisyourdaddy.sinaapp.com/index.php?s=/addon/WeiSite/WeiSite/index/publicid/154.html';</script>"; // echo "<a href=''>返回</a>"; } else { echo "<script>alert('System Busy'); history.go(-1);</script>"; } } } else { echo "<script>alert('两次输入的密码不同'); history.go(-1);</script>"; } } else { echo "<script>alert('密码必须为6~20位!'); history.go(-1);</script>"; } }
function Wrap($Text, $ColumnBreak, $Indentation) { $Lines = ""; $curLine = ""; $breakIndex = 0; $I = 0; $Lines = explode("\r\n", $Text); $I = 0; while ($I < count($Lines)) { $curLine = rtrim($Lines[$I]); // find out if the current line needs to be split // It needs it if its length is greater than the column // break index if (strlen($curLine) > $ColumnBreak) { // then find the column where we cut. It's the first // space, tab, or dash starting at the end of the line $breakIndex = strrpos(substr($curLine, 0, $ColumnBreak), ' '); $breakIndex = max($breakIndex, strrpos(substr($curLine, 0, $ColumnBreak), '\\t')); $breakIndex = max($breakIndex, strrpos(substr($curLine, $ColumnBreak), '-')); // Do the splitting $Lines[$I] = substr($curLine, 0, $breakIndex); Insert($Lines, $I + 1, substr($curLine, $breakIndex + 1)); } // apply the indentation $Lines[$I] = str_repeat(' ', $Indentation) . $Lines[$I]; // go to next line $I++; } return implode("\r\n", $Lines) . "\r\n"; }