/admin/lib/resources.inc
PHP | 370 lines | 297 code | 64 blank | 9 comment | 41 complexity | 5010a027a41376f649ac3a755921efb5 MD5 | raw file
- <?php
- include_once($_SERVER['ROOT_DIR'].'conf/global.inc');
-
- class ResourceAdmin{
-
- function ResourceAdmin(){
- }
-
- function getKeyword() {
- global $dblink;
- $arycategory = array();
- $sql= 'SELECT * FROM keyword';
- $rs = mysql_query($sql,$dblink);
- $i =1;
- if($rs && mysql_num_rows($rs) > 0) {
- $arykeyword[0] = array('id'=>'null', 'value'=>'--- Select ---');
- while($ary = mysql_fetch_assoc($rs)){
- $arykeyword[$i]['id'] = $ary['KeywordId'];
- $arykeyword[$i]['value'] = $ary['KeywordText'];
- $i++;
- }
-
- return $arykeyword;
- }
- }
-
- function getResource() {
- global $dblink;
- $arycategory = array();
- $sql= 'SELECT * FROM resources';
- $rs = mysql_query($sql,$dblink);
- $i =1;
- if($rs && mysql_num_rows($rs) > 0) {
- $aryresources[0] = array('id'=>'null', 'value'=>'--- Select ---');
- while($ary = mysql_fetch_assoc($rs)){
- $aryresources[$i]['id'] = $ary['ResourceId'];
- $aryresources[$i]['value'] = $ary['CompanyName'];
- $i++;
- }
-
- return $aryresources;
- }
- }
-
-
-
- function getResourceCity(){
- global $dblink;
- $arycategory = array();
- $sql = 'SELECT * FROM resourcecity Order by CityName';
- $rs = mysql_query($sql,$dblink);
- $i =1;
- if($rs && mysql_num_rows($rs) > 0) {
- while($ary = mysql_fetch_assoc($rs)){
- $ArySend[$i]['id'] = $ary['CityName'];
- $ArySend[$i]['value'] = $ary['CityName'];
- $i++;
- }
- $ArySend[0] = array('id'=>'null', 'value'=>'--- Select ---');
-
- return $ArySend;
- }
- }
-
- function ListResources(){
- global $dblink;
- $sql= 'SELECT * FROM resources r , resourcesinfo r1 , keyword k Where r.ResourceId = r1.ResourceId And r1.KeywordId = k.KeywordId ORDER BY r.ResourceId desc';
- $rs = mysql_query($sql, $dblink);
-
- if (($rs) && (mysql_num_rows($rs))) {
- $j=0;
- while($ary = mysql_fetch_assoc($rs)) {
- $ArylListResources[$j] = $ary;
- $j++;
- }
- } else {
- $ArylListResources = array();
- }
- return $ArylListResources;
- }
-
- function SaveResources(){
- global $dblink;
- $target = "../resourceupload/";
-
- foreach ($_POST as $key => $value) {
- $InsertAry[$key] = StrAddSlashes($value);
- }
-
- $target1 = $target . basename($_FILES['fileaddt1']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt1']['tmp_name'], $target1)){
- $message1= "The file ". basename( $_FILES['fileaddt1']['name']). " has been uploaded";
- } else $mesg = 'Error1';
-
-
- $target2 = $target . basename($_FILES['fileaddt2']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt2']['tmp_name'], $target2)){
- $message1= "The file ". basename( $_FILES['fileaddt2']['name']). " has been uploaded";
- } else $mesg = 'Error2';
-
-
- $target3 = $target . basename($_FILES['fileaddt3']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt3']['tmp_name'], $target3)){
- $message1= "The file ". basename( $_FILES['fileaddt3']['name']). " has been uploaded";
- } else $mesg = 'Error3';
-
-
- $target4 = $target . basename($_FILES['fileaddt4']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt4']['tmp_name'], $target4)){
- $message1= "The file ". basename( $_FILES['fileaddt4']['name']). " has been uploaded";
- } else $mesg = 'Error4';
-
-
- $sql ='INSERT INTO resources(CompanyName, ContactPerson1,ContactPerson2,ContactPerson3,ContactPerson4,
- Address1,Address2,Address3,Address4,
- City,CompanyAddress, OfficialEmail, TelephoneNo,
- Telephone1,Telephone2,Telephone3 ,Telephone4,
- MobileNo1,MobileNo2,MobileNo3,MobileNo4,
- EmailId1,EmailId2,EmailId3,EmailId4 ,
- Url1,Url2,Url3,Url4,
- UrlDescriptor1,UrlDescriptor2,UrlDescriptor3,UrlDescriptor4,
- TeamComment,ExpertComment,
- FileInfo1,FileInfo2,FileInfo3,FileInfo4,
- DownloadPath1,DownloadPath2,DownloadPath3,DownloadPath4,
- FileDescriptor1,FileDescriptor2,FileDescriptor3,FileDescriptor4,
- TimeInfo) VALUES (
- \''.$InsertAry['resourceName'].'\',
- \''.$InsertAry['resourceContactPersonP1'].'\',
- \''.$InsertAry['resourceContactPersonP2'].'\',
- \''.$InsertAry['resourceContactPersonP3'].'\',
- \''.$InsertAry['resourceContactPersonP4'].'\',
- \''.$InsertAry['addt1'].'\',
- \''.$InsertAry['addt2'].'\',
- \''.$InsertAry['addt3'].'\',
- \''.$InsertAry['addt4'].'\',
- \''.$InsertAry['resourceCity'].'\',
- \''.$InsertAry['companyadd'].'\',
- \''.$InsertAry['officialemail'].'\',
- \''.$InsertAry['telephoneno'].'\',
- \''.$InsertAry['telp1'].'\',
- \''.$InsertAry['telp2'].'\',
- \''.$InsertAry['telp3'].'\',
- \''.$InsertAry['telp4'].'\',
- \''.$InsertAry['MobM1'].'\',
- \''.$InsertAry['MobM2'].'\',
- \''.$InsertAry['MobM3'].'\',
- \''.$InsertAry['MobM4'].'\',
- \''.$InsertAry['emailt1'].'\',
- \''.$InsertAry['emailt2'].'\',
- \''.$InsertAry['emailt3'].'\',
- \''.$InsertAry['emailt4'].'\',
- \''.$InsertAry['Urladdt1'].'\',
- \''.$InsertAry['Urladdt2'].'\',
- \''.$InsertAry['Urladdt3'].'\',
- \''.$InsertAry['Urladdt4'].'\',
- \''.$InsertAry['Urldesc1'].'\',
- \''.$InsertAry['Urldesc2'].'\',
- \''.$InsertAry['Urldesc3'].'\',
- \''.$InsertAry['Urldesc4'].'\',
- \''.$InsertAry['no2co2Comment'].'\',
- \''.$InsertAry['ExpertComment'].'\',
- \''.basename($_FILES['fileaddt1']['name']).'\',
- \''.basename($_FILES['fileaddt2']['name']).'\',
- \''.basename($_FILES['fileaddt3']['name']).'\',
- \''.basename($_FILES['fileaddt4']['name']).'\',
- \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt1']['name']).'\',
- \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt2']['name']).'\',
- \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt3']['name']).'\',
- \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt4']['name']).'\',
- \''.$InsertAry['UploadDescriptor1'].'\',
- \''.$InsertAry['UploadDescriptor2'].'\',
- \''.$InsertAry['UploadDescriptor3'].'\',
- \''.$InsertAry['UploadDescriptor4'].'\',
- now())';
-
-
- $rs = mysql_query($sql, $dblink);
- $resourceid = mysql_insert_id();
-
- if ($rs && $resourceid) {
- $sql1 = 'INSERT INTO resourcesinfo(ResourceId, KeyWordId) VALUES(\''.$resourceid.'\',\''.$_POST['Keyword'].'\')';
- $rs2 = mysql_query($sql1, $dblink);
- if($rs2) {
- header('Location: ReDirect.php?action=Tier5');
- }
- } else {
- return 'false';
- }
- }
-
- function delresource(){
- global $dblink;
- $resourceid= base64_decode($_REQUEST['resourceid']);
- $sql='DELETE FROM resources WHERE ResourceId=\''.$resourceid.'\'';
- $result = mysql_query($sql, $dblink);
- $sql1='DELETE FROM resourcesinfo WHERE ResourceId = \''.$resourceid.'\'';
- $result1 = mysql_query($sql1, $dblink);
- if($result)
- return 'true';
- else return 'false';
-
- }
-
-
- function FetchResource($resid) {
- global $dblink;
-
- $sql = "SELECT * FROM resources Where ResourceId = '".$resid."' ";
- $result = mysql_query($sql,$dblink);
-
- if($result && mysql_num_rows($result) > 0){
- while($ary = mysql_fetch_assoc($result)){
- $araytier5 = $ary;
-
- }
- }
- return $araytier5;
- }
-
-
- function EditResources() {
- global $dblink;
- $target = "../resourceupload/";
-
- foreach ($_POST as $key => $value) {
- $InsertAry[$key] = StrAddSlashes($value);
- }
-
- $target1 = $target . basename($_FILES['fileaddt1']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt1']['tmp_name'], $target1)){
- $message1= "The file ". basename( $_FILES['fileaddt1']['name']). " has been uploaded";
- } else $mesg = 'Error1';
-
-
- $target2 = $target . basename($_FILES['fileaddt2']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt2']['tmp_name'], $target2)){
- $message1= "The file ". basename( $_FILES['fileaddt2']['name']). " has been uploaded";
- } else $mesg = 'Error2';
-
-
- $target3 = $target . basename($_FILES['fileaddt3']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt3']['tmp_name'], $target3)){
- $message1= "The file ". basename( $_FILES['fileaddt3']['name']). " has been uploaded";
- } else $mesg = 'Error3';
-
-
- $target4 = $target . basename($_FILES['fileaddt4']['name']) ;
- if(move_uploaded_file($_FILES['fileaddt4']['tmp_name'], $target4)){
- $message1= "The file ". basename( $_FILES['fileaddt4']['name']). " has been uploaded";
- } else $mesg = 'Error4';
-
-
- $sql ='Update resources Set CompanyName = \''.$InsertAry['resourceName'].'\',
- ContactPerson1 = \''.$InsertAry['resourceContactPersonP1'].'\',
- ContactPerson2 = \''.$InsertAry['resourceContactPersonP2'].'\',
- ContactPerson3 = \''.$InsertAry['resourceContactPersonP3'].'\',
- ContactPerson4 = \''.$InsertAry['resourceContactPersonP4'].'\',
- Address1 = \''.$InsertAry['addt1'].'\',
- Address2 = \''.$InsertAry['addt2'].'\',
- Address3 = \''.$InsertAry['addt3'].'\',
- Address4 = \''.$InsertAry['addt4'].'\',
- City = \''.$InsertAry['resourceCity'].'\',
- CompanyAddress = \''.$InsertAry['companyadd'].'\',
- OfficialEmail = \''.$InsertAry['officialemail'].'\',
- TelephoneNo = \''.$InsertAry['telephoneno'].'\',
- Telephone1 = \''.$InsertAry['telp1'].'\',
- Telephone2 = \''.$InsertAry['telp2'].'\',
- Telephone3 = \''.$InsertAry['telp3'].'\',
- Telephone4 = \''.$InsertAry['telp4'].'\',
- MobileNo1 = \''.$InsertAry['MobM1'].'\',
- MobileNo2 = \''.$InsertAry['MobM2'].'\',
- MobileNo3 = \''.$InsertAry['MobM3'].'\',
- MobileNo4 = \''.$InsertAry['MobM4'].'\',
- EmailId1 = \''.$InsertAry['emailt1'].'\',
- EmailId2 = \''.$InsertAry['emailt2'].'\',
- EmailId3 = \''.$InsertAry['emailt3'].'\',
- EmailId4 = \''.$InsertAry['emailt4'].'\',
- Url1 = \''.$InsertAry['Urladdt1'].'\',
- Url2 = \''.$InsertAry['Urladdt2'].'\',
- Url3 = \''.$InsertAry['Urladdt3'].'\',
- Url4 = \''.$InsertAry['Urladdt4'].'\',
- UrlDescriptor1 = \''.$InsertAry['Urldesc1'].'\',
- UrlDescriptor2 = \''.$InsertAry['Urldesc2'].'\',
- UrlDescriptor3 = \''.$InsertAry['Urldesc3'].'\',
- UrlDescriptor4 = \''.$InsertAry['Urldesc4'].'\',
- TeamComment = \''.$InsertAry['no2co2Comment'].'\',
- ExpertComment = \''.$InsertAry['ExpertComment'].'\', ';
-
- if($_FILES['fileaddt1']['name']!='') {
- $sql .= 'FileInfo1 = \''.basename($_FILES['fileaddt1']['name']).'\',
- DownloadPath1 = \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt1']['name']).'\',
- FileDescriptor1 = \''.$InsertAry['UploadDescriptor1'].'\', ';
-
- }
-
- if($_FILES['fileaddt2']['name']!='') {
-
- $sql .= 'FileInfo2 = \''.basename($_FILES['fileaddt2']['name']).'\',
- DownloadPath2 = \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt2']['name']).'\',
- FileDescriptor2 = \''.$InsertAry['UploadDescriptor2'].'\', ';
-
- }
-
-
- if($_FILES['fileaddt3']['name']!='') {
-
- $sql .= 'FileInfo3 = \''.basename($_FILES['fileaddt3']['name']).'\',
- DownloadPath3 = \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt3']['name']).'\',
- FileDescriptor3 = \''.$InsertAry['UploadDescriptor3'].'\', ';
-
- }
-
- if($_FILES['fileaddt4']['name']!='') {
- $sql .= 'FileInfo4 = \''.basename($_FILES['fileaddt4']['name']).'\',
- DownloadPath4 = \''.RootUrl.'resourceupload/'.basename($_FILES['fileaddt4']['name']).'\',
- FileDescriptor4 = \''.$InsertAry['UploadDescriptor4'].'\', ';
- }
-
- $sql .= 'TimeInfo = now()
- Where ResourceId = \''.$InsertAry['ResourceID'].'\' ';
-
- $rs = mysql_query($sql, $dblink);
- $resourceid = mysql_insert_id();
- header('Location: ReDirect.php?action=Tier5');
-
- /*if ($rs && $resourceid) {
- $sql1 = 'Update resourcesinfo SET KeyWordId = \''.$_POST['Keyword'].'\'';
- $rs2 = mysql_query($sql1, $dblink);
- if($rs2) {
- header('Location: ReDirect.php?action=Tier5');
- }
- } else {
- return 'false';
- }*/
- }
-
-
- function DeleteFile($id, $resid) {
- global $dblink;
- if($id==1) {
- $sql = "Update resources Set FileInfo1= '', DownloadPath1= '', FileDescriptor1= '' Where ResourceId = '".$resid."' ";
- $result = mysql_query($sql,$dblink);
- $tier5id = base64_encode($resid);
- header("Location:editTier5.php?Tier5ID=$tier5id");
- }
- if($id==2) {
- $sql = "Update resources Set FileInfo2= '', DownloadPath2= '', FileDescriptor2= '' Where ResourceId = '".$resid."' ";
- $result = mysql_query($sql,$dblink);
- $tier5id = base64_encode($resid);
- header("Location:editTier5.php?Tier5ID=$tier5id");
- }
- if($id==3) {
- $sql = "Update resources Set FileInfo3= '' , DownloadPath3= '' , FileDescriptor3= '' Where ResourceId = '".$resid."' ";
- $result = mysql_query($sql,$dblink);
- $tier5id = base64_encode($resid);
- header("Location:editTier5.php?Tier5ID=$tier5id");
- }
- if($id==4) {
- $sql = "Update resources Set FileInfo4= '', DownloadPath4= '', FileDescriptor4= '' Where ResourceId = '".$resid."' ";
- $result = mysql_query($sql,$dblink);
- $tier5id = base64_encode($resid);
- header("Location:editTier5.php?Tier5ID=$tier5id");
- }
- }
-
-
- }
-
-
- ?>