Jump to content

jomla

Members
  • Posts

    39
  • Joined

  • Last visited

Posts posted by jomla

  1. Hi at all,

    please read this function:

                function cc(letters, comb, m, k) {

    var ret=[];
                    if (k == 0) {
                        ret.push(comb);
                    } else {
                        for (var i=m; i<= letters.length-k; ++i) {
                            cc(letters, comb+"  "+letters+' ', i+1, k-1);
                        }
                    }

    return ret;
                }

    Function cc() calc combinations of numbers or letters or any other object like words, colors ........ .

    to call cc():

    var c=new Array(1,2,3,4,5,6,7,8,9);// it can be  an array of letters or of any other object

    var k=3;//size of any combination that can be 2 or 3 or 4 ...... or more

    var start=0;

    demo:

    var r=cc(c,"",start,k);

    It work very well but I do not love recursion call.
    How can I do to obtein the some result without recursion call?
    Thank you very much

  2. SOLVED
    Error was into the archives file name because I used prohibited character ":" during mysqldump.
    Script now work fine after changed sftp.class with a normal easy class

    <?php

    ini_set('error_reporting', E_ALL);

    ini_set('display_errors', 1);

    echo "<center><h1>Download SQL archives </h1></center>";

    //Include configuration ftp_host, drp_user and ftp_pass

    include 'ftp_config.php';

    $dir="backups";

    $ftp_host=FTP_HOST;

    $ftp_user=FTP_USER;

    $ftp_pass=FTP_PASS;

    // *** Create the FTP object

    $ftpObj = new FTPClient($ftp_host,$ftp_user,$ftp_pass);

    // *** Connect

    if ($ftpObj -> connect()) {

    } else {

    echo 'Failed to connect';

    }

    // *** Change to folder

    $ftpObj->cd('public_html/'.$dir.'/');

    // *** Get folder contents

    $contentsArray = $ftpObj->ls('*.gzip');

     

    // *** Output our array of folder contents

    echo '<pre>';

    print_r($contentsArray);

    echo "</pre>";

     

    $fileTo = dirname(__FILE__).'/backups/';

     

    $fileFrom =$ftpObj->pwd();

     

    // *** Download files

    for ($i=0;$i<count($contentsArray);$i++){

    $ftpObj->get($fileFrom.'/'. $contentsArray[$i],$fileTo.$contentsArray[$i], FTP_BINARY);

    }

    $ftpObj->close();

    echo "<h2>Download date-timw " . date("d-n-Y h:i:s") . "<br></h2>";

    ?>

  3. I tryed to use ftp functions  without to use class but now it make  following error.
     

    Warning: ftp_get(): Prohibited file name: C:\xampp\htdocs\iomla\backups\dump.php in C:\xampp\htdocs\iomla\ftp0.php on line 40

    $contentsArray=ftp_nlist($conn_id, "*.gzip");
    Now $contentsArray return an array with all .sql.gzip files of the folder to download

  4. <?php
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', 1);
    ini_set('upload_max_filesize', '50M');   
    ini_set('post_max_size', '50M');  
    // *** Include the SFTP class
    include('sftp.class.php');

    //include configuration $ftp_Host, $ftp_user and $ftp_password
    include('config.php');

    $dir="backups";
    $ftp_host=FTP_HOST;
    $ftp_user=FTP_USER;
    $ftp_pass=FTP_PASS;
     
    // *** Create the FTP object
    $ftpObj = new SFTP($ftp_host,$ftp_user,$ftp_pass);
     
    // *** Connect
    if ($ftpObj -> connect()) {
     echo 'connected <br>';
    } else {
        echo 'Failed to connect';
    }

    // *** Change to folder
    $ftpObj->cd('public_html/'.$dir.'/');
     
    // *** Get folder contents
    $contentsArray = $ftpObj->ls($ftpObj->pwd());

    $fileTo = dirname(__FILE__).'/backups/';
    $fileFrom =$ftpObj->pwd();

    // *** Download file
    for ($i=0;$i<count($contentsArray);$i++){
        if (is_dir($contentsArray[$i]))
        {continue;}
        if (substr($contentsArray[$i],-5)!==".gzip")
        {continue;}
        if ($ftpObj->get($fileFrom.'/'. $contentsArray[$i],$fileTo.$contentsArray[$i], FTP_BINARY))
        {echo "I download:".$fileTo.$contentsArray[$i]."<br>"; }
    }
        $ftpObj->close();

    ?>

  5. He at all,
    I am trying  sftp_class.php of Rachel baker
    It is easy to implemet and use but it do not download .sql.gzip archive that corrupt during download.
    Infact I tryed this class only to try to transfer my mysql dump backup from my web site to my local server XAMPP on windoes 10 PC.
    It do not  make errors but  filles transfered are empty (0 bytes) and with the name without extension therefore windows 10 not recognize them as gzip archive.
    By exemple if into web server file is named:
    backup-29-5-2017--17_50.sql.gzip
    locally after transfer its name is:
    backup-29-5-2017-
    Please, have you any idea to solve this problem?
    Thank you very much

  6. The session variable "me" represent my person that I am visiting my web site and its value with which I enter is "foo". So if the session variable $ _SESSION ['me'] !== 'foo' it can be inserted into file.log visitors because visitor I am not me. But I do not want even the search engines are put into visitors file.log so I added the second part of the function but some think do not work

    The session variable "me" I am visiting my site and its value with which I enter is "foo". So if the session variable $ _SESSION [ 'I'] == 'foo' and I must not be inserted into file.log visitors. But I do not want even the search engines are put in the logo file so I added the second part of the function

  7. Hi at all,

     

    I have to intercept search engines and my visits not to insert in the log files of my visits and countless search engine visits. I therefore made this function but it is not working and search engines continue to pass. Where is the mistake?

    Thank you very much

     

     

    <php code>

    function write_log()

    {
    if (!(isset($_SESSION['me']))||($_SESSION['me']!=="pippo") || (preg_match('/bot|bingbot|bing|robot|crawl|slurp|spider|yahoo|se arch/i', $_SERVER['HTTP_USER_AGENT'])==0))
    {return true;}else{return false;}
    }

    if(write_log()===true)
    {
    require_once("log.php");
    }

    </php code>

    I therefore I made this function but it is not working and search engines continue to pass. Where is the mistake? Thank you

  8. PHP code only executes on the server that runs it. If you were running that script on a remote server and expecting files to be downloaded to your local computer, that doesn't work because the remote server doesn't know what the C: drive is, it doesn't have one. There's no connection between your computer and the server, that's what FTP is for, to make that connection. That means that either you need an FTP server installed on your computer that the remote server can connect to and upload files, or you need a web server installed on your local computer to run that code and connect to the remote server. But that code is running on the remote server, when you tell it to copy a file to C: it's looking at its own hard drives, not yours.

     

    But, PHP isn't limited to only copying files into the web server's directory structure, you can use it to copy files to any directory as long as the permissions are set up correctly. You can use that to do whatever you want, just tell it the right path to copy the files to and it will do that if the permissions are set up on your hard drive to allow it to do that.

     

    it was a very informative post Thank you

  9. the script.php that I use now works well but at the beginning simply moved files from one directory and one of remoro server but not brought me the file locally. The mistake was that the script should be installed in a local server and not on a remote server. Now that I've installed the script in HTDOCS directory in my local XAMPP server the script works well but takes the files in the htdocs directory in the midst of the scripts .. In practice it is useless ahahahah So much work for nothing

    the script I use now works well at the beginning but simply moving files from one directory and one of remoro server but not brought me the file locally. The mistake was that the script should be installed in a local server and not on a remote server. Now that I've installed the script in HTDOCS directory in my local XAMPP server the script works well but takes the files in the htdocs directory in the midst of the script .. In practice it is useless ahahahah So much work for nothing

  10. It sounds like you need to check the items that you're telling it to download. It looks like you're trying to tell it to download the file "/.", which is the current directory. You need to check each item that ftp_nlist returned to see if it's a file or directory. It looks like that function in the comments in the manual uses the trick of trying to change to the directory. If that works, then it's a directory, otherwise it's a file. For some reason there isn't just a function to check if an FTP entry is a directory, but that might be a limitation of FTP.

    Now error is this:

    Warning: ftp_get(C:/Users/Markus/Documents/web_sites/lands/backups/lands-20161105-1747.gz): failed to open stream: No such file or directory in /home/xyz/public_html/backups.php on line 38

  11. What does it print? What happens when you run that?

    [10-Nov-2016 11:20:10 Europe/Berlin] PHP Warning: ftp_get(): Filename cannot be empty in /public_html/backup.php on line 28
    [10-Nov-2016 11:20:10 Europe/Berlin] PHP Warning: ftp_get(): Error opening in public_html/backup.php on line 28
    [10-Nov-2016 11:24:00 Europe/Berlin] PHP Warning: ftp_get(C:/Users/markus/Documents/web site/lands/backups//.): failed to open stream: No such file or directory in /public_html/backup.php on line 26
    [10-Nov-2016 11:24:00 Europe/Berlin]
  12. ftp_get expects a file, not a directory. There is a function in the comments in the documentation to list the files in a directory and download each one.

     

    http://php.net/manual/en/function.ftp-get.php

    Ok thankyou.

    Follow I report the new stram of my new php code that try to download files but that do not work still now:

     

    $local_dir = "C:/Users/markus/Documents/web sites/lands/backups";
    $server_dir="/public_html/backups";
    $contents = ftp_nlist($conn_id, $server_dir);//works fine still here
    foreach ($contents as $file) {
    if (ftp_get($conn_id, $local_dir."/".$file, $server_dir."/".$file, FTP_ASCII)) {
    echo " amd Successfully written to $local_file\n";
    } else {
    echo " but There was a problem in download<br>".$server_dir."/".$file."<br>";
    }
    }

    // please where is problem? is there in $local_dir name or $server_dir name?

  13. Hi at all

    When I make a nysql backup I memorize the files to a remote backup folder and only after I transfer them with FileZilla to my local PC.
    It is a long way therefore To send local files automatically I tryed a script that compresses my gz files and send the zip file to me, but after I must unzip it to an appropriate folder and it is always a long way .
    Therefore I am looking for a ftp script that works well.
    NOW I'm testing follow script but works well only until the login.
    but ftp_get function does not work, perhaps why the path of the local or remote file are wrong???

     

    This is my ftp script

    <?php
    $local_file = 'C:\Users\bull\Documents\web site\town\backups';
    $server_file = '/home/markus/public_html/backups';
    $ftp_user="markus";
    $ftp_pass="aaaaaaaaaaa";
    $ftp_server="server.net.net";
    // set up a connection or die
    $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
    // try to login
    if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    echo "Connected as $ftp_user@$ftp_server<br> successfully";
    } else {
    echo " connect falled as $ftp_user\n";
    }
    //IT work very well still here only But the follow ftp_get function make error
    if (ftp_get($conn_id, $local_file, $server_file, FTP_ASCII)) {
    echo " amd Successfully written to $local_file\n";
    } else {
    echo " but There was a problem in download<br>$conn_id<br>$local_file<br>$server_file";
    }
    // close the connection
    ftp_close($conn_id);
    ?>

    IF error is remote and/or local folder name how can I do to discover right folder name because I tryed many name still now and all falled

    Program not display any warning

  14. Hi at all,

    I have a session variable called securty_level
    what is the best script to verify if exist and if is set to a certain value?
    I wrote:

    <?php
    session_start();
    if (!isset($_SESSION['securty_level']) || $_SESSION['securty_level']<5)
    {
    header('Location: http:/www.goaway.com/');
    exit;
    }
    ?>
    My script sufficiently protects?
  15. hello

    please take a look at this my page:


    It is made with pure html.

    There are 2 input fields that when they receive fire waiting to be pressed a key.

    Every time a key is pressed is sent to the server with ajax the text and ajax returns suggestions if there are any.

    The page works fine on the PC desktop but works poorly on mobile devices because it is not going to wait for a key press.

    Why?

×
×
  • Create New...