コード例 #1
0
ファイル: rpc.php プロジェクト: tiansiyuan/oscommerce2
 switch ($_GET['action']) {
     case 'dbCheck':
         try {
             $OSCOM_Db = Db::initialize($_GET['server'], $_GET['username'], $_GET['password'], $_GET['name']);
         } catch (\Exception $e) {
             $result = $e->getCode() . '|' . $e->getMessage();
         }
         if ($result === false) {
             $result = true;
         } else {
             $error = explode('|', $result, 2);
             if ($error[0] == '1049' && isset($_GET['createDb']) && $_GET['createDb'] == 'true') {
                 $result = false;
                 try {
                     $OSCOM_Db = Db::initialize($_GET['server'], $_GET['username'], $_GET['password'], '');
                     $OSCOM_Db->exec('create database ' . Db::prepareIdentifier($_GET['name']) . ' character set utf8 collate utf8_unicode_ci');
                 } catch (\Exception $e) {
                     $result = $e->getCode() . '|' . $e->getMessage();
                 }
                 if ($result === false) {
                     $result = true;
                 }
             }
         }
         break;
     case 'dbImport':
         try {
             $OSCOM_Db = Db::initialize($_GET['server'], $_GET['username'], $_GET['password'], $_GET['name']);
             $OSCOM_Db->importSQL($dir_fs_www_root . '/oscommerce.sql');
         } catch (\Exception $e) {
             $result = $e->getCode() . '|' . $e->getMessage();