The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

need some help with a old api to work in the new 11.25

Discussion in 'cPanel Developers' started by tens, Jan 6, 2010.

  1. tens

    tens Registered

    Joined:
    Jan 6, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Ok in a nut shell i just started working at this company and the first thing thay put on me is there exsternal system was working fine till there cpanel updated it self and now when thay go to the page to create a subdomain , email , username and pass when they click create a message post "update is done" BUT! nothing happens it dident do anything well thay want me to fix it it's all coded buy a old employ thay let go a few years ago and i have spent a few days trying to fig this out with no luck my mind is fried i need some help

    Ps: my Cpanel and XML and PHP lvl's are beginner i can mod and edit it but just cant grasp typing it out from my head ....Yet so hellp is nice Ez to understand help is better:)

    part 1

    PHP:
    <!-- Mian PHP Script --!>
    <?php


    require_once("../sitemanager/includes/configure.php");
    require_once(
    "session_check.php");
    require_once(
    '../sitemanager/cPanel.php');



    //echo $servername;
    $domainerror_messageaftrpost ="";
    $logindetailserror_messageaftrpost="";
    $MaxfilesAllowed 10;
    $MaxemailsAllowed 5;

    if(isset(
    $_POST['hdn_mode']))
    {    
        
    $mode trim($_POST['hdn_mode']);
        
    $CusId trim($_POST['hdn_userid']);
        
    $UsrSubDomainName str_replace(" """addslashes(stripslashes(trim($_POST['txtbx_domainname']))) );
        
    $UsrName addslashes(stripslashes(trim($_POST['txtbx_UsrName'])));
        
    $UsrPass addslashes(stripslashes(trim($_POST['txtbx_UsrPass'])));
        
    $DomainStatus trim($_POST['hdn_DomainStatus']); 
        
    $UpdatedDate=date("Y-m-d H:i:s");

        if(
    $mode=="create")
        {        
            
    $query="select * from crcustomers where customerid<>".$CusId." AND subdomain='".$UsrSubDomainName."'";            
            
    $result=mysql_query($query); 
            
    $numrows=mysql_num_rows($result);    
            
    $FldrNameToInsrtstr_replace("/","",$UsrSubDomainName);
                
            
    //Create subdomain
            
    if(RUNNING_ON=="local")
            {
                
    $FldrName =$_SERVER['DOCUMENT_ROOT']."/coconutregister/".$FldrNameToInsrt;
                    if(
    is_dir($FldrName))
                    {
                           
    $DomainalreadyExist=true;
                    }
                    else
                    {
                        
    $DomainalreadyExist=false;
                    }
            }
            else
            {                   
                
    //$ObjcPanel = new cPanel(SITENAMEONLY,CPANEL_USRNAME,CPANEL_PASS, 2082, false,'x');                           
                //get sub domain list
                //$arrsubDomains=$ObjcPanel->listSubdomains();
                //check if the sub domain is already exist or not
                //$subDomainForChkduplicate =$FldrNameToInsrt.".".SITENAMEONLY;                    
                
    $DomainalreadyExist is_dir("../".$FldrNameToInsrt)   ; //in_array($subDomainForChkduplicate,$arrsubDomains);
            
    }
            if(
    $numrows || $DomainalreadyExist!=false)
            {                
                
    $domainerror_messageaftrpost="The subdomain you have choosen already exists. Please try entering another subdomain.";
            }
            else 
            {        
                
    //get default theme details
                
    $Themequery="SELECT * from site_themes where set_default='Y' "
                
    $Themeresult mysql_query($Themequery);
                
    $Thmnumofrows mysql_num_rows($Themeresult);
                
                if(
    $Thmnumofrows>0)
                {
                    
    $Thmrow mysql_fetch_array($Themeresult);                                                
                    
    $db_ThemeId=$Thmrow["theme_id"];
                    
    $db_ThemeTitle=stripslashes($Thmrow["title"]);
                    
    $SelectedThmImg stripslashes($Thmrow["image"]);      
                    
    $filecontentsstripslashes($Thmrow["contents"]);
                         
                    
    //remove html tags
                    
    $filecontents eregi_replace("<html>","",$filecontents);
                    
    $filecontents eregi_replace("</html>","",$filecontents);    
                    
    $filecontents eregi_replace("<title>","",$filecontents);
                    
    $filecontents eregi_replace("</title>","",$filecontents);    
                    
    $baseurlTag="<BASE href=\"http://www.cbt.cc\">";
                    
    $PageTitle="New Website from Island Yellow Pages.";
                    
    $filecontents"<html><title>".$PageTitletoEdit."</title>".$baseurlTag.$filecontents."</html>";
                          
                } 
                else 
                {                        
                    
    $filecontents="<html><body><table valign='center' width=\"95%\"><tr><td>&nbsp;</td></tr><tr><td align='center'><font size='6'>This site is under construction. Please check back soon.</font></td></tr></table></body></html>";
                    
    //$FldrNameToInsrt= str_replace("/","",$UsrSubDomainName);                     
                    //$FldrName = "../sitemanager/".str_replace("/","",$UsrSubDomainName);
                
    }

                
    //Create subdomain
                
    if(RUNNING_ON=="local")
                {
                    
    // $FldrName =$_SERVER['DOCUMENT_ROOT']."/coconutregister/".$FldrNameToInsrt;
                    // if(!is_dir($FldrName))
                    
    mkdir($FldrName,0777);

                    
    //for index.php file  
                    
    $phpfilecontents "<?php require_once('C:\inetpub\wwwrootcoconutregister\sitemanager\domains_index.php'); ?>";
                }
                else
                {
                    
    $FldrName =$_SERVER['DOCUMENT_ROOT']."/".$FldrNameToInsrt;
                    
    $ObjcPanel = new Domain(SITENAMEONLY,CPANEL_USRNAME,CPANEL_PASS2086false,'x',"cbt.cc");         
                              
                    
    //get sub domain list
                    
    $arrsubDomains=$ObjcPanel->listSubdomains();

                    
    //check if the sub domain is already exist or not
                    
    $DomainalreadyExist =in_array($FldrNameToInsrt,$arrsubDomains);
                    
                    if(
    $DomainalreadyExist==false
                        {
                            
    $DomainCreated $ObjcPanel->addSubdomain($FldrNameToInsrt);
                                 
                            
    //for index.php file  
                            
    $phpfilecontents "<?php require_once('/home/cbtcc/public_html/sitemanager/domains_index.php'); ?>";
                        }
                }
                       
                if(
    $DomainalreadyExist==false
                {
                    
    $filename "index.html";
                        
                    
    //function used to write the contents in write mode starts
                    
    if(!is_file($FldrName."/".$filename))
                    {
                        
    //change mode                     
                        
    if(RUNNING_ON!="local")
                        {
                            
    chmod_11oo10($FldrNameToInsrt,777);
                            
                            
    //for index.html file  
                            
    filewrite_writemode($FldrName."/".$filename,stripslashes(trim($filecontents)));

                            
    //for index.php file
                            
    filewrite_writemode($FldrName."/index.php",trim($phpfilecontents));
                        }
                            
    //change mode                     
                        
    if(RUNNING_ON!="local")
                        {
                            
    chmod_11oo10($FldrNameToInsrt,755);
                        }
                    }

                    
    //check if the customer already having a domain or not 
                    
    $Countquery="select count(*) as count from crcustomers where customerid=".$CusId;
                    
    $CusCountfun_getMaxValue($Countquery,"count");

                    if(
    $CusCount>0)
                    {
                        
    $update_query="UPDATE crcustomers SET ";
                        
    $update_query.="subdomain='".$UsrSubDomainName."',";
                        
    $update_query.="foldername='".$FldrNameToInsrt."',";    
                         
    $update_query.="maxfilesallowed=$MaxfilesAllowed,";
                        
    $update_query.="disabled='no'";                         
                        
    $update_query.=" WHERE customerid=".$CusId;
                        
    $update_result=mysql_query($update_query);    
                    }
                    else
                    {
                        
    //insert the domain name into the db
                        
    $insertquery="insert into  crcustomers(customerid,subdomain,foldername,maxfilesallowed,maxemails_allowed,disabled,web_offline,lastupdated_date_forfiles) values($CusId,'$UsrSubDomainName','$FldrNameToInsrt',$MaxfilesAllowed,$MaxemailsAllowed,'no','no','$UpdatedDate')";            
                        
    mysql_query($insertquery);
                        
                        
    //insert the file name into the db
                        
    $insertquery="insert into  user_files(user_id,filename,lastupdate) values($CusId,'$filename','$UpdatedDate')";            
                        
    mysql_query($insertquery);

                        
    //get the count of files
                        
    $fileCountQry "select count(*) as count  from user_files where user_id=$CusId";
                        
    $fileCount fun_getMaxValue($fileCountQry,"count");

                        
    //update the count with crcustomers table
                        
    $updatecount_query="UPDATE crcustomers SET ";
                        
    $updatecount_query.="numfilesused=".$fileCount;                     
                        
    $updatecount_query.=" WHERE customerid=".$CusId;
                        
    mysql_query($updatecount_query);    
                    }
                        
    header("Location: createdomain.php?custid=$CusId&processmode=".$mode);
                        exit;
                }
            }
        }             
        else if(
    $mode=="change")
        {      
            
    $CusCountQry "select count(*) as count from crcustomers where customerid<>".$CusId." AND username='".$UsrName."'";        
            
    $CusCount fun_getMaxValue($CusCountQry,"count");
            
            if(
    $CusCount 0)
            {
                
    $logindetailserror_messageaftrpost="The username you have choosen is already exists. Please try to entering another username.";     
            }
            else
            {            
                
    //check if the customer already having a domain or not 
                
    $Countquery="select count(*) as count from crcustomers where customerid=".$CusId;            
                
    $CusCountfun_getMaxValue($Countquery,"count");

                if(
    $CusCount>0)
                {
                    
    $update_query="UPDATE crcustomers SET ";
                    
    $update_query.="username='".$UsrName."',";
                    
    $update_query.="password='".$UsrPass."' ";                
                    
    $update_query.=" WHERE customerid=".$CusId;
                    
    $update_result=mysql_query($update_query);    
                }
                else
                {
                    
    ///insert the domain name into the db
                    
    $insertquery="insert into crcustomers(customerid,username,password) values($CusId,'$UsrName','$UsrPass')";            
                    
    mysql_query($insertquery);
                }
                    
    header("Location: createdomain.php?custid=$CusId&processmode=".$mode);
                    exit;
            }
        }         
        else if(
    $mode=="changedomainstatus"
        {    
            
    //get users domain name
            
    $ArrUsrdomaindetails=funGetFolderName($CusId);
              
            
    //for set permissions
       
     
    #1 tens, Jan 6, 2010
    Last edited: Jan 6, 2010
  2. tens

    tens Registered

    Joined:
    Jan 6, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    part 2

    part 2

    both part 1 & 2 are on the same page as one code and the html for the input for is in this page to and i can post it if you need me to

    PHP:
         $strUsrSubdomnFldrNmOnly $ArrUsrdomaindetails["folder"];

            if(
    RUNNING_ON=="local")
            {
              
    $strUsrSubdomnFldr=$_SERVER['DOCUMENT_ROOT']."/coconutregister/".$strUsrSubdomnFldrNmOnly;
            }
            else
            {
                
    $strUsrSubdomnFldr=$_SERVER['DOCUMENT_ROOT']."/".$strUsrSubdomnFldrNmOnly;
            }        
            
            
    //write the source file data into destination file    
            //change mode                     
            
    if(RUNNING_ON!="local")
            {
             
    chmod_11oo10($strUsrSubdomnFldrNmOnly,777);
            }
            if(
    $DomainStatus=="disable")                  
            {
                
    $strdomstaus "yes";          

                
    //create .htaccess file
                
    filewrite_writemode($strUsrSubdomnFldr."/.htaccess","RedirectMatch 301 (.*)\.html$ /index.php");
            }
            else         
            {
               
    $strdomstaus "no";
            }
            if(
    is_file($strUsrSubdomnFldr."/.htaccess"))
            {
                
    unlink($strUsrSubdomnFldr."/.htaccess");           
            }
             
            
    //change mode                     
            
    if(RUNNING_ON!="local")
            {
                
    chmod_11oo10($strUsrSubdomnFldrNmOnly,755);

                
    //change domain status
                
    $update_query="UPDATE crcustomers SET ";
                
    $update_query.="disabled='".$strdomstaus."'";        
                
    $update_query.=" WHERE customerid=".$CusId;
                
    mysql_query($update_query);    
            }
            
    header("Location: createdomain.php?custid=$CusId&processmode=".$mode);
            exit;

        }     
        else if(
    $mode=="deldomain")
        {
            
    $UsrSubDomainName trim($_POST['txtbx_domainname']);

            if(
    RUNNING_ON!="local")
            {
            
                
    //delete sub domain
                
    $ObjcPanel = new Domain(SITENAMEONLY,CPANEL_USRNAME,CPANEL_PASS2086false,'x',"cbt.cc");         
                
    $ObjcPanel->delSubdomain(stripslashes($UsrSubDomainName));
            
                
    //delete email accounts    
                
    $QryGetemailToEdit="SELECT * from crusers_emailaccount where  user_id=$CusId";
                
    $resultGetemailToEdit mysql_query($QryGetemailToEdit);
                
    $CountGetemailToEdit mysql_num_rows($resultGetemailToEdit);
                
                if(
    $CountGetemailToEdit>0)
                {
                    
    //Create a cPanel object using SSL
                    
    $ObjcPanelEmail = new emailAccount(SITENAMEONLY,CPANEL_USRNAME,CPANEL_PASS2083true,"x","cbt.cc");      
                    
                    while(
    $rowGetemailToEdit=mysql_fetch_array($resultGetemailToEdit))
                    {              
                        
    $EmailToEdit stripslashes($rowGetemailToEdit["email_prefix"]);
                        
    $MailAcntDeleted $ObjcPanelEmail->delete($EmailToEdit,$UsrSubDomainName.".".SITENAMEONLY);
                    }
                }

                
    //delete domain details from db
                
    mysql_query("delete from crcustomers where customerid=".$CusId);
                
    mysql_query("delete from crusers_emailaccount where user_id=".$CusId);        
                
    mysql_query("delete from user_files where user_id=".$CusId);
            }
               
    header("Location: createdomain.php?custid=$CusId&processmode=".$mode);
             exit;
        }
    }
    //post check ends     

    //getting the user details  from the table `crcustomers`
    if(isset($_GET["custid"]))
    {
      if(
    is_numeric($_GET["custid"]))
        {
          
    $CusId $_GET["custid"];
          
          
    //check if the customer id is valid or not
          
    $Countquery="select count(*) as count from pycontact where customerid=".$CusId;
          
    $CusCountfun_getMaxValue($Countquery,"count");

            if(
    $CusCount>0)
            {
              
    $CusId trim($_GET["custid"]);         
             
                
    //get domain details
                
    $query="select * from crcustomers where customerid=".$CusId;
                
    $result=mysql_query($query); 
                
    $numrows=mysql_num_rows($result);
                 
                if(
    $numrows>0)      
                {                                            
                    
    $row=mysql_fetch_array($result);
                    
    $UsrSubDomainName =stripslashes($row['subdomain']);
                    
    $UsrName =stripslashes($row['username']);
                    
    $UsrPass  =stripslashes($row['password']);
                    
    $DomainStatus stripslashes($row['disabled']);
                        
                    
    $MaxFiles $row['maxfilesallowed'];
                    
    $MaxEmails $row['maxemails_allowed'];
                    
    $UsedFiles $row['numfilesused'];
                        
                    
    $emailquery "Select count(*) as totalemails from crusers_emailaccount where user_id = ".$row['customerid'] ;
                    
    $emailresult=mysql_query($emailquery); 
                    
    $emailrow=mysql_fetch_array($emailresult);
                    
    $UsedEmails $emailrow['totalemails'];                    
                }

                
    //for disable or enable the domain 
                
    if($DomainStatus!="yes")
                {
                      
    $DomainStatus "disable";
                }
                else
                {
                      
    $DomainStatus "enable";
                }
            }
          else
            {      
            
    $invaliderror_message"Invalid data processing";
            }
        }
        else                
             
    $invaliderror_message"Invalid data processing";
    }

    $successmessage "";
    if(isset(
    $_GET["processmode"]))
    {
      
    $strprocessMode trim($_GET["processmode"]);
        if(
    $strprocessMode=="create")
        {
            
    $successmessage "Subdomain successfully created.";
        }
        else if(
    $strprocessMode=="change")
        {
            
    $successmessage "Your login details has been changed successfully.";
        }
        else if(
    $strprocessMode=="deldomain")
        {    
            
    $successmessage "Sub domain deleted successfully.";
        }
      else
        {
            
    $successmessage "Subdomain status has been changed successfully.";
        }
    }

    //uploading the file

    if($UsrSubDomainName)
    {
        
    $parentfolder='//'.$UsrSubDomainName;
        
    //echo $parentfolder;
        
    $checkdir SYSTEM_ROOT_PATH.'//'.$UsrSubDomainName.'/files';
        
    //check if the directory exits
        
        
    if(!(is_dir($checkdir)))
        {
            
    //if no, create the directory in the specified path
            
    if(RUNNING_ON!="local")
            {
                
    chmod_11oo10($parentfolder,777);
                
    mkdir(SYSTEM_ROOT_PATH.'/'.$UsrSubDomainName.'/files/'0777);
                
    chmod_11oo10($parentfolder,755);
                
                
    $uploaddir SYSTEM_ROOT_PATH.'/'.$UsrSubDomainName.'//files/';
                
    $uploaddir trim($uploaddir);
                
    //echo $uploaddir;
            
    }
            else
            {
                
    $uploaddir SYSTEM_ROOT_PATH.'/'.$UsrSubDomainName.'/files/';
                
    $uploaddir trim($uploaddir);
                
    //echo $uploaddir;
            
    }
        }    
        if(isset(
    $_POST['Submit']))
        {
            for(
    $i=0;$i<=2;$i++)
            {
                
    $filename "userfile_" .$i;
                        
                
    $userfile $_FILES[$filename]['name'];
                
    //echo $userfile;
                
                
    if(!$userfile)
                {
                    
    //$errorMessage= "Please select the videos to upload.";
                
    }
                else
                {
                    
    $allowed_extensions = array("doc","txt""pdf""ppt" "zip""mpeg""avi""xls""gif","jpg","jpeg","flv","mov","mpg");
                    
    //spliting the file extension from the file name
                    
    list($file$ext) = split('[.]'$userfile);
                    
    //echo $ext;
                    //checking the extension's existence in the allowed extensions
                    
    $tmpfile =  $_FILES[$filename]['tmp_name'];
                    
    //echo $userfile;
                    
    $uploadfile $uploaddir $userfile;
                    
    //echo $uploadfile;
                    
                    
    if(RUNNING_ON!="local")
                    {
                        
    chmod_11oo10($parentfolder,777);
                    }
                    if (
    move_uploaded_file($tmpfile$uploadfile)) 
                    {
                        
    $errorMessage"Files Successfully Uploaded";
                    }
                    else 
                    {
                        
    //echo "Possible file upload attack!  Here's some debugging info:\n";
                    
    }
                    if(
    RUNNING_ON!="local")
                    {
                        
    chmod_11oo10($parentfolder,755);
                        
    // if the file extension is a video file then again it checks if that video file is allowed or not
                        
    $allowed_videofiles = array("mpeg","avi","flv","mov","mpg");
                    }
                    if(
    in_array($ext$allowed_videofiles))
                    {
                        if(
    $ext=="flv")
                        {
                            
    $status ="Y";
                        }
                        else
                        {
                            
    $status ="P";
                            
    //echo $uploadfile;
                            //echo $UsrSubDomainName;
                            
    $flvfile =$uploaddir.$file.'.flv';
                            
    //echo $flvfile;
                            
    $selectvideofiles "select source from encoding";
                            
    $result mysql_query($selectvideofiles);
                        }
                        while(
    $row=mysql_fetch_array($result))
                        {
                            
    $existfile $row[0];
                            
    //echo $existfile;
                            
    if($existfile==$uploadfile)
                            {
                                
    $errorMessage =  "The file already exists";
                                
    $uploadfile="";
                            }
                            else
                            {
                                
    $uploadfile =$uploadfile;
                            }
                        }
                                
                        
    // inserting the video files in to table
                        
    if($uploadfile)
                        {
                            
    $uploadfile addslashes($uploadfile);
                            
    $flvfile addslashes($flvfile);
                            
    $insertvideofiles="insert into  encoding(cus_id,user_domain,source,destination,status,creation_date)values($CusId,'$UsrSubDomainName','$uploadfile','$flvfile','$status',now())";
                            
    //echo $insertvideofiles;
                            
    mysql_query($insertvideofiles);
                        }
                    }
                }
            }
        }
    }
    else
        {
            
    $errorMessage"<font color=\"red\">You can upload video/images only after creating the subdomain.</font>";
        }
    also if any one helps me make this thing work i offer pay for your help
     
    #2 tens, Jan 6, 2010
    Last edited: Jan 6, 2010
Loading...

Share This Page