From: Steve Sutton Date: Thu, 1 Dec 2016 18:52:50 +0000 (-0500) Subject: Rewrite for way to not use getLastOid X-Git-Tag: v1.0.0^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=df7725ef41c53aee8b05d9561ed447d973caf5e9;p=web%2Fwww.thelindy.com.git Rewrite for way to not use getLastOid this function has been deprecated in newer vrs of php. --- diff --git a/admin/Toolbox/update_bus.phtml b/admin/Toolbox/update_bus.phtml index 5c3e2e6..54cc92d 100755 --- a/admin/Toolbox/update_bus.phtml +++ b/admin/Toolbox/update_bus.phtml @@ -18,10 +18,10 @@ http_strip($url); if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { switch($Command) { - + case "Move": if(!$dbd = db_connect()) html_error(DB_ERROR_MSG,0); - + $qs = "SELECT pos,id FROM bus_category_bus WHERE id = $id"; @@ -30,16 +30,16 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { $data = db_fetch_array($result,0,PGSQL_ASSOC); $pos = $data['pos']; - + if($newpos < $pos) { $qs = "SELECT id,pos - FROM bus_category_bus + FROM bus_category_bus WHERE pos < $pos AND pos >= $newpos AND catid = $catid ORDER BY pos"; if(!$res = db_exec($dbd,$qs)) html_error(DB_ERROR_MSG.$qs,0); - + $counter = ($newpos + 1); for($i=0;$i"; //echo "catid = $catid[0]
"; */ - if(!$dbd = db_connect()) + if(!$dbd = db_connect()) html_error(DB_ERROR_MSG,0); db_exec($dbd,"BEGIN WORK"); - + $array_counter = 0; - if(is_array($catid)) + if(is_array($catid)) { $query = "select catid,pos from bus_category_bus where busid = $id"; @@ -120,37 +120,37 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { if( !in_array( $row['catid'],$catid ) ) { $query = "update bus_category_bus set pos = pos - 1 where catid = ".$row['catid']." and pos >= $oldpos"; -//echo $query.'
'; +//echo $query.'
'; db_exec($dbd,$query); $query = "delete from bus_category_bus where catid = ".$row['catid']." and busid = $id"; -//echo $query.'
'; - db_exec($dbd,$query); +//echo $query.'
'; + db_exec($dbd,$query); } - + } - foreach($catid as $key=>$value) + foreach($catid as $key=>$value) { - + // do this only if ald catid is being removed if( !in_array( $value,$oldcatid ) ) { $qs = "SELECT count(*) as maxpos FROM bus_category_bus WHERE catid = $value"; - - if(!$res = db_exec($dbd,$qs)) + + if(!$res = db_exec($dbd,$qs)) html_error(DB_ERROR_MSG.$qs,1); - + $row = db_fetch_array($res,0,PGSQL_ASSOC); $pos = ( $row['maxpos'] == 0 ) ? (int)0 : (int)$row['maxpos'] ; $pos++; - - $qs = "INSERT + + $qs = "INSERT INTO bus_category_bus (busid,catid,pos) VALUES ($id,$value,$pos)"; - //echo $qs.'
'; + //echo $qs.'
'; if(!db_exec($dbd,$qs)) { html_error(DB_ERROR_MSG.$qs,1); @@ -161,9 +161,9 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { //exit(); $fields = array_reverse($fields); $qs = "UPDATE ".TABLE." SET "; - for($i=0;$i$value) + foreach($catid as $key=>$value) { $qs = "SELECT count(*) as maxpos FROM bus_category_bus WHERE catid = $value"; - - if(!$res = db_exec($dbd,$qs)) + + if(!$res = db_exec($dbd,$qs)) { html_error(DB_ERROR_MSG.$qs,1); } - + $row2 = db_fetch_array($res,0,PGSQL_ASSOC); if( !$pos = $row2[maxpos]) { @@ -428,17 +428,17 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { { $pos++; } - - $qs = "INSERT + + $qs = "INSERT INTO bus_category_bus (busid,catid,pos) VALUES ($row[id],$value,$pos)"; - + if(!db_exec($dbd,$qs)) { html_error(DB_ERROR_MSG.$qs,1); } - if(!$res = db_exec($dbd,"COMMIT WORK")) + if(!$res = db_exec($dbd,"COMMIT WORK")) { die( pg_errormessage($dbd).$qs ); } @@ -449,12 +449,12 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { $qs = "SELECT count(*) as maxpos FROM bus_category_bus WHERE catid = $catid"; - - if(!$res = db_exec($dbd,$qs)) + + if(!$res = db_exec($dbd,$qs)) { html_error(DB_ERROR_MSG.$qs,1); } - + $row2 = db_fetch_array($res,0,PGSQL_ASSOC); if( !$pos = $row2[maxpos]) { @@ -464,110 +464,110 @@ if( $REQUEST_METHOD == "POST" || $Command == "Move" ) { { $pos++; } - $qs = "INSERT + $qs = "INSERT INTO bus_category_bus (busid,catid,pos) VALUES ($row[id],$catid,$pos)"; - + if(!db_exec($dbd,$qs)) { html_error(DB_ERROR_MSG.$qs,1); } - if(!$res = db_exec($dbd,"COMMIT WORK")) + if(!$res = db_exec($dbd,"COMMIT WORK")) { die( pg_errormessage($dbd).$qs ); } } } - $location = "list_bus.phtml?catid=".$catid[0]."&".SID; - + $location = "list_bus.phtml?catid=".$catid[0]."&".SID; + break; - + case "Delete": $oldcatid = ereg_replace("^:","",$oldcatid); $oldcatid = split(":",$oldcatid); - + $qs = "DELETE FROM bus WHERE id = $id"; if(!db_auto_exec($qs)) html_error("failed ->".$qs,1); - + @unlink(ORIGINAL_PATH."/".$oldimage); @unlink(RESIZED_PATH.$oldimage); @unlink(THUMB_PATH.$oldimage); @unlink(MIDSIZED_PATH.$oldimage); - + @unlink(ORIGINAL_PATH."/".$oldimage2); @unlink(RESIZED_PATH.$oldimage2); @unlink(THUMB_PATH.$oldimage2); @unlink(MIDSIZED_PATH.$oldimage2); - + @unlink(ORIGINAL_PATH."/".$oldimage3); @unlink(RESIZED_PATH.$oldimage3); @unlink(THUMB_PATH.$oldimage3); @unlink(MIDSIZED_PATH.$oldimage3); - + @unlink(UP_BASE.$oldfile); @unlink(UP_BASE.$oldfile2); @unlink(UP_BASE.$oldfile3); $dbd = db_connect(); - + if(!$dbd) html_erro(DB_ERROR_MSG,1); - + foreach($oldcatid as $key=>$value){ $qs = "SELECT id,pos FROM bus_category_bus WHERE busid = $id"; - - if(!$res = db_exec($dbd,$qs)) + + if(!$res = db_exec($dbd,$qs)) html_error(DB_ERROR_MSG.$qs,1); - + $row = db_fetch_array($res,0,PGSQL_ASSOC); - + $qs = "SELECT id FROM bus_category_bus WHERE pos > $row[pos] AND catid = $value ORDER BY pos"; - - if(!$res2 = db_exec($dbd,$qs)) + + if(!$res2 = db_exec($dbd,$qs)) html_error(DB_ERROR_MSG.$qs,1); - + $counter = $row[pos]; for($i=0;$i