Login   Register  
PHP Classes
elePHPant
Icontem

File: keymodify.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Claudia Neu  >  HTTP class  >  keymodify.php  >  Download  
File: keymodify.php
Role: Example script
Content type: text/plain
Description: switch from one database to another by transferring an array
Class: HTTP class
Retrieve data from remote servers via HTTP
Author: By
Last change:
Date: 8 years ago
Size: 4,781 bytes
 

Contents

Class file image Download
<?php
    
require_once("../common/mysql.php");
    require_once(
"../common/si_define.php");
    
$db = &new CMySql;
    
$flag false;
    
$id 0;
    if (isset(
$_GET['id']))
        
$id $_GET['id'];
    
    if (
$id)
    {            
        if (
$db->Connect(SI_DB_SERVERSI_DB_LOGIN_USERSI_DB_LOGIN_PASS))
        {
            if (
$db->SelectDatabase(SI_DATABASE))
            {
                if (
$expire || $bidfailed || $gesdownloads || $downloads || $enabled)
                {
                    
//ändern
                    
if ($expire!=$expiremain) {
                        
                        
$expirespansum=$expirespan."+TO_DAYS("."'".$expire."'".")-TO_DAYS("."'".$expiremain."'".")+1";
                        
                        echo 
$expirespansum;
                        echo 
$expire;
                        echo 
$expiremain;
                        echo 
$expirespansum;
                        
                        
                        
$row="ExpireSpan=".$expirespansum;
                        echo 
$row;
                        
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'");
                    }
                    
$row="InitDownloads="."'".$gesdownloads."'";
                    
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'");
                    
$row="Downloads="."'".$downloads."'";
                    
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'");
                    
$row="BIDFailed="."'".$bidfailed."'";
                    
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'");
                    
$row="Enabled="."'".$enabled."'";
                    
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'");
                    
$row="ExpireDate="."'".$expire."'";
                    if(
$db->UpdateRow(SI_KS_KEY_TABLE$row"KeyVal="."'".$id."'"));
                        {
                        
//echo "alle geändert auf Key Server";
                        
}
                        
                }
                
//löschen - erst Umleitung, löschen auf DS-Server, dann löschen auf KS-Server
                
if ($del) {
                
$strSelect "SELECT ServerID FROM ".SI_KS_KEY_TABLE." WHERE KeyVal=".$db->MakeSqlString($id);
                if (
$result =$db->Select($strSelect)) 
                {
                    
$data =$db->FetchArray($result);
                    
$serverid =$data['ServerID'];
                    
                    
$strSelect "SELECT ID, DNS, HTTP_User, HTTP_Pass, HTTP_InternPhpDir FROM ".SI_KS_SERVER_TABLE." WHERE ID=".$db->MakeSqlString($serverid);
                    if (
$result $db->Select($strSelect))
                    {
                        
//echo "löschen u. ändern auf DServer";
                        
require_once("../common/http.php");
                        require_once(
"../common/sihelper.php");
                        
$http = &new CHttp;
                        if (
$serverData $db->FetchArray($result))
                        {
                            
$flag false;
                            
$http->user $serverData['HTTP_User'];
                            
$http->pass $serverData['HTTP_Pass'];
                            
$http->server $serverData['DNS'];
                            
$array['id'] = $id;
                            
$array['expire'] = $expire;
                            
$array['downloads'] = $downloads;
                            
$array['bidfailed'] = $bidfailed;
                            
$array['keyproperties'] = $keyproperties;
                            
$array['bid'] = $bid;
                            
$array['bidgenau'] = $bidgenau;
                            
$array['enabled'] = $enabled;
                            
$array['del'] = $del;
                            if (
$http->RequestFile($serverData['HTTP_InternPhpDir'].SI_KSDS_PROPERTIES$response$array) && IsResponseOk($response))
                                
$flag true;
                            echo 
$response;
                                    
//echo $serverData['DNS'].$serverData['HTTP_InternPhpDir'].SI_KSDS_PROPERTIES;
                        
}
                    }
                }    
                
//löschen auf Keyserver
                
$strSelect "DELETE FROM ".SI_KS_KEY_TABLE." WHERE KeyVal=".$db->MakeSqlString($id);
                                    
//echo $strSelect."löschen auf KSserver";
                                    
if ($db->Select($strSelect)===true)
                                        {
                                            
//echo "gelöscht auf KS-Server";
                                        
}    
                }
                                
                
//Suche Datenserver
                //bei Änderung der Daten relevant - Umleitung auf Datenserver
                
$strSelect "SELECT ServerID FROM ".SI_KS_KEY_TABLE." WHERE KeyVal=".$db->MakeSqlString($id);
                if (
$result =$db->Select($strSelect)) 
                {
                    
$data =$db->FetchArray($result);
                    
$serverid =$data['ServerID'];
                    
                    
$strSelect "SELECT ID, DNS, HTTP_User, HTTP_Pass, HTTP_InternPhpDir FROM ".SI_KS_SERVER_TABLE." WHERE ID=".$db->MakeSqlString($serverid);
                    if (
$result $db->Select($strSelect))
                    {
                        
                        require_once(
"../common/http.php");
                        require_once(
"../common/sihelper.php");
                        
$http = &new CHttp;
                        if (
$serverData $db->FetchArray($result))
                        {
                            
$flag false;
                            
$http->user $serverData['HTTP_User'];
                            
$http->pass $serverData['HTTP_Pass'];
                            
$http->server $serverData['DNS'];
                            
$array['id'] = $id;
                            
$array['expire'] = $expire;
                            
$array['downloads'] = $downloads;
                            
$array['bidfailed'] = $bidfailed;
                            
$array['bid'] = $bid;
                            
$array['bidgenau'] = $bidgenau;
                            
$array['keyproperties'] = $keyproperties;
                            
$array['enabled'] = $enabled;
                            
$array['del'] = $del;
                            
$array['mod'] = $mod;
                            if (
$http->RequestFile($serverData['HTTP_InternPhpDir'].SI_KSDS_PROPERTIES$response$array) && IsResponseOk($response))
                                
$flag true;
                            echo 
$response;
                                    
//echo $serverData['DNS'].$serverData['HTTP_InternPhpDir'].SI_KSDS_PROPERTIES;
                        
}
                    }
                }
            }
        }
    }
    require_once(
"keyprop.php");    
    
?>