/**
 * Copy file in one directories to another
 *
 * @param string $source
 * @param string $path
 */
function _copydir($source, $path)
{
    if (is_dir($path) === false) {
        // echo 'Create: ', $path, PHP_EOL;
        _mkdir($path);
    }
    $d = new DirectoryIterator($source);
    foreach ($d as $node) {
        /*@var $node DirectoryIterator*/
        if ($node->isDot()) {
            continue;
        }
        if ($node->isDir() === true) {
            if ($node->getFilename() == '.svn') {
                continue;
            }
            _copydir($node->getPathname(), $path . DIRECTORY_SEPARATOR . $node->getFilename());
            continue;
        }
        if ($node->isFile() === true) {
            //echo 'Copy: ', $node->getPathname(), PHP_EOL;
            _copy($node->getPathname(), $path);
            continue;
        }
    }
}
Example #2
0
    $cnt = $dev_db->getOne('SELECT COUNT(id) FROM feed WHERE uri = ?', array($row['uri']));
    if ($cnt == 0) {
        # insert feed
        $res = $dev_db->autoExecute('feed', $fields, DB_AUTOQUERY_INSERT);
        if ($res === false) {
            trigger_error('Failed to insert feed', E_USER_ERROR);
        } else {
            echo "source: {$index} : {$row['id']}\n";
        }
    } else {
        echo "{$row['name']} is exists\n";
    }
    # member_to_feed
    $fields = array('member_id' => $row['member_id'], 'feed_id' => $row['id']);
    $res = $dev_db->autoExecute('member_to_feed', $fields, DB_AUTOQUERY_INSERT);
    if ($res === false) {
        trigger_error('Failed to insert member_to_feed', E_USER_ERROR);
    }
}
_copy("custom_template");
function _copy($table)
{
    global $pro_db, $dev_db;
    $rows = $pro_db->getAll("SELECT * FROM {$table} ORDER BY id");
    foreach ($rows as $index => $row) {
        $res = $dev_db->autoExecute($table, $row, DB_AUTOQUERY_INSERT);
        if (DB::isError($res)) {
            trigger_error("Failed to insert {$table} " . $res->toString(), E_USER_ERROR);
        }
    }
}