Ejemplo n.º 1
1
function diy_compile($payload, $storage)
{
    global $app;
    $result["controller"] = __FUNCTION__;
    $result["function"] = substr($app->request()->getPathInfo(), 1);
    $result["method"] = $app->request()->getMethod();
    $params = loadParameters();
    $result->function = substr($app->request()->getPathInfo(), 1);
    $result->method = $app->request()->getMethod();
    $params = loadParameters();
    $srcfile = OAuth2\Request::createFromGlobals()->request["srcfile"];
    $srclib = OAuth2\Request::createFromGlobals()->request["srclib"];
    $device = OAuth2\Request::createFromGlobals()->request["device"];
    $comp = OAuth2\Request::createFromGlobals()->request["comp"];
    $filename = OAuth2\Request::createFromGlobals()->request["filename"];
    $writedevice = OAuth2\Request::createFromGlobals()->request["writedevice"];
    $up = json_decode(base64_decode($payload));
    $client_id = $up->client_id;
    $diy_error["post"]["device"] = $device;
    $post["srcfile"] = $srcfile;
    //organisation                                  oauth_devices
    $post["device"] = $device;
    //organisation                                  oauth_devices
    $post["comp"] = $comp;
    //organisation                                  oauth_devices
    $post["filename"] = $filename;
    //organisation                                  oauth_devices
    $post["writedevice"] = $writedevice;
    //organisation                                  oauth_devices
    $gump = new GUMP();
    $gump->validation_rules(array('device' => 'required|alpha_numeric', 'filename' => 'required|alpha_numeric', 'comp' => 'required|alpha_numeric', 'writedevice' => 'required|alpha_numeric'));
    $gump->filter_rules(array('device' => 'trim|sanitize_string', 'filename' => 'trim|sanitize_string', 'comp' => 'trim|sanitize_string', 'writedevice' => 'trim|sanitize_string'));
    $validated = $gump->run($post);
    if ($validated === false) {
        $result["parse_errors"] = $gump->get_readable_errors(true);
        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $gump->get_readable_errors(true);
    } else {
        try {
            $sourceWriteDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $device . '/' . $filename;
            if (file_exists($sourceWriteDir)) {
                throw new \Exception('Filename ' . $filename . ' for user ' . $client_id . ' and device ' . $device . ' already exists');
            }
            $stmt2 = $storage->prepare('SELECT * FROM oauth_devices WHERE device = :device');
            $stmt2->execute(array('device' => trim($device)));
            $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
            if ($row2["organisation"]) {
                $org = trim($row2["organisation"]);
            }
            if ($row2["mode"]) {
                $mode = trim($row2["mode"]);
            }
            if ($row2["status"]) {
                $status = trim($row2["status"]);
            }
            if ($row2["client_id"]) {
                $devclient_id = trim($row2["client_id"]);
            }
            $orgscopeadmin = "no";
            $orgscopedevel = "no";
            if ($mode == "devel" && $status == "org") {
                $userscopes = explode(' ', trim($userscope));
                $adminscope = $org . "_admin";
                $develscope = $org . "_admin";
                // o user aniki sto scope
                for ($i = 0; $i <= count($userscopes); $i++) {
                    if (trim($userscopes[$i]) == $adminscope) {
                        $orgscopeadmin = "yes";
                    }
                    if (trim($userscopes[$i]) == $develscope) {
                        $orgscopedevel = "yes";
                    }
                }
                // einai o owner
                if ($devclient_id == $client_id) {
                    $orgscopeadmin = "yes";
                }
            }
            // einmai o owner
            if ($mode == "devel" && $status == "private" && $devclient_id == $client_id) {
                $orgscopeadmin = "yes";
            }
            $result["result"]["sketch1"] = $orgscopeadmin;
            if ($orgscopeadmin == "yes" || $orgscopedevel == "yes") {
                try {
                    $stmt2 = $storage->prepare('SELECT * FROM oauth_clients WHERE client_id = :device');
                    $stmt2->execute(array('device' => trim($device)));
                    $row2 = $stmt2->fetch(PDO::FETCH_ASSOC);
                    if ($row2["apiport"]) {
                        // *************************************** compiler *********************************
                        // srcfile echeis se base64 ton kodika
                        // compiler echeis ton compiler pou thelei o user   mechri stigmis echoume   gcc, ino
                        // filename to filename pou edosse o user
                        // o poros compilesketch
                        // afou kanei compile
                        // epistrefei
                        // error   ta lathi  h noerrors
                        // binfile    to hex file
                        $compilerserver = diyConfig::read("compiler.host");
                        $compilerserver .= ":" . diyConfig::read("compiler.port");
                        $data1 = 'filename=' . $filename;
                        $data1 .= '&compiler=' . $comp;
                        $data1 .= '&srcfile=' . $srcfile;
                        $fixedFiles = array();
                        foreach ($srclib as $curName => $curFile) {
                            $fixedFiles[] = 'srclib[' . $curName . ']=' . $curFile;
                        }
                        $data1 .= '&' . implode('&', $fixedFiles);
                        $ch = curl_init();
                        curl_setopt($ch, CURLOPT_URL, "{$compilerserver}/api/compilesketch");
                        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                        curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
                        curl_setopt($ch, CURLOPT_POST, 1);
                        $or = curl_exec($ch);
                        if (!$or) {
                            $or = curl_error($ch);
                        }
                        $result["compiler"] = $or;
                        $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
                        $result["status"] = "200";
                        $r = json_decode($or, true);
                        if (!$r) {
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
                            $result["compiler"] = $or;
                            $result["status"] = "500";
                            return $result;
                        }
                        if ($r['status'] != 200) {
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: CompilationError";
                            $result["status"] = "500";
                            return $result;
                        }
                        unset($result["compiler"]);
                        // No need to transfer this to the user
                        //$srcfilebase64encode = base64_encode($srcfile);
                        $apiport = trim($row2["apiport"]);
                        // *************************************** compiler *********************************
                        if ($r['status'] == 200 && $writedevice == "yes") {
                            $apiport = trim($row2["apiport"]);
                            $binfile = $r['hex'];
                            $data1 = 'file=base64';
                            $data1 .= '&binfile=' . $binfile;
                            $ch = curl_init();
                            curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:{$apiport}/api/writesketch");
                            curl_setopt($ch, CURLOPT_TIMEOUT, 90);
                            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                            curl_setopt($ch, CURLOPT_POSTFIELDS, $data1);
                            curl_setopt($ch, CURLOPT_POST, 1);
                            $r = curl_exec($ch);
                            $result["sketch"] = $r;
                            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]: NoErrors";
                            $result["status"] = "200";
                            //$result["result"]=  $r;
                        }
                        // If we are here with no exceptions then everything went well. Lets save the sketch.
                        $ziptmp = tempnam(sys_get_temp_dir(), 'diytmpzip') . '.tgz';
                        file_put_contents($ziptmp, base64_decode($r['zip']));
                        $p = new PharData($ziptmp);
                        $p->decompress();
                        // creates /path/to/my.tar
                        $ziptmpextracted = str_replace('.tgz', '.tar', $ziptmp);
                        $phar = new PharData($ziptmpextracted);
                        $writeDir = __DIR__ . '/../../../data/sketches/' . $client_id . '/' . $filename;
                        $phar->extractTo($sourceWriteDir);
                    }
                } catch (Exception $e) {
                    $diy_error["db"] = $e->getCode();
                    $result["status"] = $e->getCode();
                    $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
                }
            }
        } catch (Exception $e) {
            $diy_error["db"] = $e->getCode();
            $result["status"] = $e->getCode();
            $result["message"] = "[" . $result["method"] . "][" . $result["function"] . "]:" . $e->getMessage();
        }
    }
    if (diyConfig::read('debug') == 1) {
        $result["debug"] = $diy_error;
    }
    return $result;
}
Ejemplo n.º 2
0
 /**
  * Load and extract our application development files
  *
  * @return  void
  */
 public static function extract()
 {
     /* Are we IN_DEV (and does it matter)? */
     if (static::$checkInDev) {
         if (!defined('\\IPS\\IN_DEV') or !\IPS\IN_DEV) {
             return;
         }
     }
     /* Attempt to load our application */
     $thisApp = NULL;
     $applications = \IPS\Application::applications();
     foreach ($applications as $application) {
         if ($application->directory === static::$appDir) {
             $thisApp = $application;
         }
     }
     if (!$thisApp) {
         \IPS\Log::i(\LOG_ERR)->write('Error : Application ' . static::$appDir . ' not found', 'devpackager_error');
         return;
     }
     /* Set our paths */
     $appPath = join(\DIRECTORY_SEPARATOR, [\IPS\ROOT_PATH, 'applications', $thisApp->directory]);
     $devPath = join(\DIRECTORY_SEPARATOR, [$appPath, 'dev']);
     $devTar = join(\DIRECTORY_SEPARATOR, [$appPath, 'data', 'dev.tar']);
     /* Load and extract our tarball */
     try {
         if (!is_dir($devPath)) {
             mkdir($devPath, 0777, true);
         }
         $devFiles = new \PharData($devTar, 0, NULL, \Phar::TAR);
         $devFiles->extractTo($devPath, NULL, TRUE);
     } catch (\Exception $e) {
         \IPS\Log::i(\LOG_ERR)->write('Error : ' . $e->getMessage() . "\n" . $e->getTraceAsString(), 'devpackager_error');
     }
 }
Ejemplo n.º 3
0
 protected function getArchivers($use_cache = true)
 {
     $arcs = array('create' => array(), 'extract' => array());
     $obj = $this;
     // php 5.3 compatibility
     if (class_exists('ZipArchive')) {
         $arcs['extract']['application/zip'] = array('cmd' => function ($archive, $path) use($obj) {
             $zip = new \ZipArchive();
             if ($zip->open($archive)) {
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $stat = $zip->statIndex($i);
                     if (empty($stat['size'])) {
                         // directory
                         continue;
                     }
                     $filename = $stat['name'];
                     if (!$obj->tyghIsUTF8($filename) && function_exists('iconv')) {
                         $newfile = iconv('cp866', 'utf-8', $filename);
                     } else {
                         $newfile = $filename;
                     }
                     $obj->tyghMkdir(dirname($path . '/' . $newfile));
                     copy('zip://' . $archive . '#' . $filename, $path . '/' . $newfile);
                 }
                 $zip->close();
                 return true;
             }
             return false;
         }, 'ext' => 'zip');
         $arcs['create']['application/zip'] = array('cmd' => function ($archive, $files) use($obj) {
             $zip = new \ZipArchive();
             if ($zip->open($archive, \ZipArchive::CREATE) === true) {
                 $base_path = dirname($archive);
                 foreach ($files as $file) {
                     $path = $base_path . DIRECTORY_SEPARATOR . $file;
                     if (is_file($path)) {
                         $zip->addFile($path, $file);
                     } elseif (is_dir($path)) {
                         foreach ($obj->tyghGetFiles($path) as $_file) {
                             $zip->addFile($path . DIRECTORY_SEPARATOR . $_file, $_file);
                         }
                     }
                 }
                 $zip->close();
                 return true;
             }
             return false;
         }, 'ext' => 'zip');
     }
     if (class_exists('PharData')) {
         $arcs['extract']['application/x-gzip'] = array('cmd' => function ($archive, $path) {
             $phar = new \PharData($archive);
             $phar->extractTo($path, null, true);
         }, 'ext' => 'tgz');
     }
     return $arcs;
 }
Ejemplo n.º 4
0
 /**
  * Parse a tarball of .gcov files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // Find the data.json file and extract the source directory from it.
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "data.json") {
             $jsonContents = file_get_contents($fileinfo->getRealPath());
             $jsonDecoded = json_decode($jsonContents, true);
             if (is_null($jsonDecoded) || !array_key_exists("Source", $jsonDecoded) || !array_key_exists("Binary", $jsonDecoded)) {
                 $this->DeleteDirectory($dirName);
                 return false;
             }
             $this->SourceDirectory = $jsonDecoded['Source'];
             $this->BinaryDirectory = $jsonDecoded['Binary'];
             break;
         }
     }
     if (empty($this->SourceDirectory) || empty($this->BinaryDirectory)) {
         $this->DeleteDirectory($dirName);
         return false;
     }
     // Check if any Labels.json files were included
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "Labels.json") {
             $this->ParseLabelsFile($fileinfo);
         }
     }
     // Recursively search for .gcov files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         if (pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION) == "gcov") {
             $this->ParseGcovFile($fileinfo);
         }
     }
     // Insert coverage summary (removing any old results first)
     //$this->CoverageSummary->RemoveAll();
     $this->CoverageSummary->Insert();
     $this->CoverageSummary->ComputeDifference();
     // Delete the directory when we're done.
     $this->DeleteDirectory($dirName);
     return true;
 }
Ejemplo n.º 5
0
 /**
  * TODO: Is it possible to extract directly from the stream? With stream filters?
  *
  * @param $target
  */
 public function extract($target)
 {
     if (!isset($this->target)) {
         $this->target = sys_get_temp_dir() . '/' . uniqid() . '.tar';
         $this->saveTar($this->target);
         $this->removeTarget = true;
     }
     $phar = new \PharData($this->target);
     $phar->extractTo($target);
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function extract($file, $target, Format\FormatInterface $format)
 {
     $this->checkSupport($format);
     try {
         $archive = new \PharData($file);
         $archive->extractTo($target, null, true);
     } catch (\Exception $e) {
         throw new FileCorruptedException($file);
     }
     return true;
 }
Ejemplo n.º 7
0
 public function extract($source, $target)
 {
     try {
         $phar = new PharData($source);
         $phar->extractTo($target, null, true);
         // throws exception
         exec("find " . $target . " -type d -exec chmod 0777 {} +");
         exec("find " . $target . " -type f -exec chmod 0777 {} +");
     } catch (Exception $e) {
     }
 }
Ejemplo n.º 8
0
 /**
  * Загружает и распаковывает данные с ipgeobase.ru
  * 
  * @param string $path Путь до каталога с БД
  * @return boolean
  */
 public function loadArchive($path)
 {
     $path = rtrim($path, '/');
     $tmpfname = '/tmp/' . basename($this->archiveUri);
     copy($this->archiveUri, $tmpfname);
     $phar = new \PharData($tmpfname);
     $phar->extractTo($path, null, true);
     $cities = file_get_contents($path . '/cities.txt');
     file_put_contents($path . '/cities.txt', iconv('WINDOWS-1251', 'UTF-8', $cities));
     return true;
 }
Ejemplo n.º 9
0
 public function extract()
 {
     $varDir = $this->rootDir . DIRECTORY_SEPARATOR . 'var';
     $tarFile = $varDir . DIRECTORY_SEPARATOR . 'magento.tar';
     if (file_exists($tarFile)) {
         unlink($tarFile);
     }
     $phar = new \PharData($this->filename);
     $phar->decompress();
     $phar = new \PharData($tarFile);
     $phar->extractTo($varDir, null, true);
 }
Ejemplo n.º 10
0
 /**
  * Unpack PHAR archive
  *
  * @param string $file File path
  * @param string $dir  Dir to extract to
  *
  * @return string
  */
 public static function unpack($file, $dir)
 {
     $dir = \Includes\Utils\FileManager::getCanonicalDir($dir) . pathinfo($file, PATHINFO_FILENAME);
     try {
         $phar = new \PharData($file);
         $result = $phar->extractTo($dir, null, true);
     } catch (\Exception $exception) {
         $result = false;
         \XLite\Upgrade\Logger::getInstance()->logError($exception->getMessage());
     }
     return array($dir, $result);
 }
Ejemplo n.º 11
0
 /**
  * @param string            $path           The path to the archive.
  * @param string            $destination    The directory to extract any contents into.
  * @param null|array|string $files          Any specific file(s) to extract as a string or array,
  *                                          defaults to NULL which extracts everything.
  * @param bool              $allowOverwrite Whether overwrite of any existing files should be allowed
  *                                          during extraction.
  * @param bool              $deleteArchive  Whether the archive should be deleted after successful extraction
  *
  * @throws ExtractionException If extraction failed.
  */
 public function extract($path, $destination, $files = null, $allowOverwrite = false, $deleteArchive = false)
 {
     try {
         $phar = new \PharData($path);
         $phar->extractTo($destination, $files, $allowOverwrite);
     } catch (\Exception $e) {
         throw new ExtractionException(sprintf('Failed to extract contents from archive with path: "%s"', $destination), null, $e);
     }
     if ($deleteArchive === true) {
         unlink($path);
     }
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function extract($file, $target, Format\FormatInterface $format)
 {
     $this->checkSupport($format);
     try {
         $pharFormat = $this->getPharFormat($format);
         $archive = new \PharData($file);
         $archive->extractTo($target, null, true);
     } catch (\Exception $e) {
         return false;
     }
     return true;
 }
Ejemplo n.º 13
0
 private static function _extract($tarball, $dest)
 {
     if (!class_exists('PharData')) {
         $cmd = "tar xz --strip-components=1 --directory=%s -f {$tarball}";
         WP_CLI::launch(Utils\esc_cmd($cmd, $dest));
         return;
     }
     $phar = new PharData($tarball);
     $tempdir = implode(DIRECTORY_SEPARATOR, array(dirname($tarball), basename($tarball, '.tar.gz'), $phar->getFileName()));
     $phar->extractTo(dirname($tempdir), null, true);
     self::_copy_overwrite_files($tempdir, $dest);
     self::_rmdir(dirname($tempdir));
 }
Ejemplo n.º 14
0
 protected function retrieveAndPrintHtml($suite)
 {
     $tempFile = str_replace('.', '', tempnam(sys_get_temp_dir(), 'C3')) . '.tar';
     file_put_contents($tempFile, $this->c3Request('html'));
     $destDir = Configuration::outputDir() . $suite . '.remote.coverage';
     if (is_dir($destDir)) {
         FileSystem::doEmptyDir($destDir);
     } else {
         mkdir($destDir, 0777, true);
     }
     $phar = new \PharData($tempFile);
     $phar->extractTo($destDir);
     unlink($tempFile);
 }
Ejemplo n.º 15
0
 /**
  * Installs PEAR source files according to package.xml definitions and removes extracted files
  *
  * @param  string                    $target target install location. all source installation would be performed relative to target path.
  * @param  array                     $roles  types of files to install. default role for PEAR source files are 'php'.
  * @param  array                     $vars   used for replacement tasks
  * @throws \RuntimeException
  * @throws \UnexpectedValueException
  *
  */
 public function extractTo($target, array $roles = array('php' => '/', 'script' => '/bin'), $vars = array())
 {
     $extractionPath = $target . '/tarball';
     try {
         $archive = new \PharData($this->file);
         $archive->extractTo($extractionPath, null, true);
         if (!is_file($this->combine($extractionPath, '/package.xml'))) {
             throw new \RuntimeException('Invalid PEAR package. It must contain package.xml file.');
         }
         $fileCopyActions = $this->buildCopyActions($extractionPath, $roles, $vars);
         $this->copyFiles($fileCopyActions, $extractionPath, $target, $roles, $vars);
         $this->filesystem->removeDirectory($extractionPath);
     } catch (\Exception $exception) {
         throw new \UnexpectedValueException(sprintf('Failed to extract PEAR package %s to %s. Reason: %s', $this->file, $target, $exception->getMessage()), 0, $exception);
     }
 }
Ejemplo n.º 16
0
 /**
  * Parse a tarball of JSON files.
  **/
 public function Parse($handle)
 {
     global $CDASH_BACKUP_DIRECTORY;
     // This function receives an open file handle, but we really just need
     // the path to this file so that we can extract it.
     $meta_data = stream_get_meta_data($handle);
     $filename = $meta_data["uri"];
     fclose($handle);
     // Create a new directory where we can extract our tarball.
     $pathParts = pathinfo($filename);
     $dirName = $CDASH_BACKUP_DIRECTORY . "/" . $pathParts['filename'];
     mkdir($dirName);
     // Extract the tarball.
     $phar = new PharData($filename);
     $phar->extractTo($dirName);
     // Check if this submission included a  package_map.json file.
     // This tells us how Java packages correspond to CDash subprojects.
     $mapFound = false;
     $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirName), RecursiveIteratorIterator::CHILD_FIRST);
     foreach ($iterator as $fileinfo) {
         if ($fileinfo->getFilename() == "package_map.json") {
             $this->ParsePackageMap($fileinfo);
         }
     }
     // Recursively search for .java.json files and parse them.
     $iterator->rewind();
     foreach ($iterator as $fileinfo) {
         // need the longest extension, so getExtension() won't do here.
         $ext = substr(strstr($fileinfo->getFilename(), '.'), 1);
         if ($ext === "java.json") {
             $this->ParseJavaJSONFile($fileinfo);
         }
     }
     // Insert coverage summaries
     $completedSummaries = array();
     foreach ($this->CoverageSummaries as $coverageSummary) {
         if (in_array($coverageSummary->BuildId, $completedSummaries)) {
             continue;
         }
         $coverageSummary->Insert();
         $coverageSummary->ComputeDifference();
         $completedSummaries[] = $coverageSummary->BuildId;
     }
     // Delete the directory when we're done.
     $this->DeleteDirectory($dirName);
     return true;
 }
Ejemplo n.º 17
0
 public function unpack($files = [])
 {
     $this->isPackageFileValid();
     // decompress from gz
     $tarFile = str_replace('.tar.gz', '.tar', $this->filePath);
     @unlink($tarFile);
     $gz = new \PharData($this->filePath);
     $gz->decompress();
     $this->cleanupFiles[] = $tarFile;
     $unzipDir = str_replace('.tar', '', $tarFile);
     // un-archive from the tar
     $phar = new \PharData($tarFile);
     $extractFiles = $files ? array_map(function ($file) {
         return Package::ARCHIVE_INNER_DIR . DIRECTORY_SEPARATOR . $file;
     }, $files) : null;
     $phar->extractTo($unzipDir, $extractFiles, true);
     $this->cleanupFiles[] = $unzipDir;
     $this->unpackedDir = $unzipDir . DIRECTORY_SEPARATOR . self::ARCHIVE_INNER_DIR;
     return $this->unpackedDir;
 }
Ejemplo n.º 18
0
function unpack_tar($path)
{
    $response = new Response();
    //echo "Unpack.\n";
    //echo "path:".$path;
    /*
     system("mkdir archiv/name");
     system("cp upload/FosCam9805.tar.gz archiv/name/FosCam9805.tar.gz");
     system("mkdir archiv/name/temp");
     //system("tar -xvzf archiv/name/FosCam9805.tar.gz -C archiv/name/temp/");
    */
    // This input should be from somewhere else, hard-coded in this example
    $file_name = $path;
    // Raising this value may increase performance
    $buffer_size = 4096;
    // read 4kb at a time
    $out_file_name = str_replace('.gz', '', $file_name);
    // Open our files (in binary mode)
    $file = gzopen($file_name, 'rb');
    $out_file = fopen($out_file_name, 'wb');
    // Keep repeating until the end of the input file
    while (!gzeof($file)) {
        // Read buffer-size bytes
        // Both fwrite and gzread and binary-safe
        fwrite($out_file, gzread($file, $buffer_size));
    }
    // Files are done, close files
    fclose($out_file);
    gzclose($file);
    //var_dump($out_file_name);
    //return;
    $phar_data = new PharData($out_file_name);
    $phar_data->extractTo(str_replace(".tar", "", $out_file_name));
    //unlink($out_file_name);
    unset($phar_data);
    Phar::unlinkArchive($out_file_name);
    //echo "finish unpacking archive<br>";
}
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     parent::execute($input, $output);
     $dialog = $this->getHelperSet()->get('dialog');
     $_configuration = $this->getHelper('configuration')->getConfiguration();
     $file = $input->getArgument('file');
     $connection = $this->getHelper('configuration')->getConnection();
     if (is_file($file) && is_readable($file)) {
         $phar = new \PharData($file);
         if ($phar->hasMetadata()) {
             $langInfo = $phar->getMetadata();
             $connection = $this->getHelper('configuration')->getConnection();
             if ($connection) {
                 $q = mysql_query("SELECT * FROM language WHERE dokeos_folder = '{$langInfo['dokeos_folder']}' ");
                 $langInfoFromDB = mysql_fetch_array($q, MYSQL_ASSOC);
                 $langFolderPath = $_configuration['root_sys'] . 'main/lang/' . $langInfoFromDB['dokeos_folder'];
                 if ($langInfoFromDB && $langFolderPath) {
                     //Overwrite lang files
                     if (!$dialog->askConfirmation($output, '<question>The ' . $langInfo['original_name'] . ' language already exists in Chamilo. Did you want to overwrite the contents? (y/N)</question>', false)) {
                         return;
                     }
                     if (is_writable($langFolderPath)) {
                         $output->writeln("Trying to save files here: {$langFolderPath}");
                         $phar->extractTo($langFolderPath, null, true);
                         // extract all files
                         $output->writeln("Files were copied.");
                     } else {
                         $output->writeln("<error>Make sure that this folder {$langFolderPath} has writable permissions or execute the script with sudo </error>");
                     }
                 } else {
                     //Check if parent_id exists
                     $parentId = '';
                     if (!empty($langInfo['parent_id'])) {
                         $sql = "select selected_value from settings_current where variable = 'allow_use_sub_language'";
                         $result = mysql_query($sql);
                         $subLanguageSetting = mysql_fetch_array($result, MYSQL_ASSOC);
                         $subLanguageSetting = $subLanguageSetting['selected_value'];
                         if ($subLanguageSetting == 'true') {
                             $q = mysql_query("SELECT * FROM language WHERE id = '{$langInfo['parent_id']}' ");
                             $parentLangInfoFromDB = mysql_fetch_array($q, MYSQL_ASSOC);
                             if ($parentLangInfoFromDB) {
                                 $output->writeln("Setting parent language: " . $parentLangInfoFromDB['original_name']);
                                 $parentId = $langInfo['parent_id'];
                             } else {
                                 $output->writeln("The lang parent_id = {$langInfo['parent_id']} does not exist in Chamilo. Try to import first the parent language.");
                                 exit;
                             }
                         } else {
                             $output->writeln("<comment>Please turn ON the sublanguage feature in this portal</comment>");
                             exit;
                         }
                     } else {
                         $output->writeln("Parent language was not provided");
                     }
                     $q = mysql_query("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available, parent_id) VALUES (\n                                '" . $langInfo['original_name'] . "',\n                                '" . $langInfo['english_name'] . "',\n                                '" . $langInfo['isocode'] . "',\n                                '" . $langInfo['dokeos_folder'] . "',\n                                '1',\n                                '" . $parentId . "')");
                     if ($q) {
                         $output->writeln("Language inserted in the DB");
                         $langFolderPath = $_configuration['root_sys'] . 'main/lang/' . $langInfo['dokeos_folder'];
                         $phar->extractTo($langFolderPath, null, true);
                         // extract all files
                         $output->writeln("<comment>Files were copied here {$langFolderPath} </comment>");
                     } else {
                         $output->writeln("An error ocurred while tring to create the language");
                     }
                 }
             }
         } else {
             $output->writeln("<comment>The file is not a valid Chamilo language package<comment>");
         }
     } else {
         $output->writeln("<comment>The file located in '{$file}' is not accessible<comment>");
     }
 }
Ejemplo n.º 20
0
<?php

$fname = dirname(__FILE__) . '/files/bogus.zip';
$fname2 = dirname(__FILE__) . '/files/notbogus.zip';
$extract = dirname(__FILE__) . '/test-extract3';
$phar = new PharData($fname);
try {
    $phar->extractTo($extract);
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
$phar = new PharData($fname2);
foreach ($phar as $filename) {
    echo "{$filename}\n";
}
try {
    $phar->extractTo($extract);
} catch (Exception $e) {
    echo $e->getMessage(), "\n";
}
?>
===DONE===
<?php 
$dir = dirname(__FILE__) . '/test-extract3/';
@unlink($dir . 'stuff.txt');
@unlink($dir . 'nonsense.txt');
@rmdir($dir);
Ejemplo n.º 21
0
 function bws_go_pro_tab_check($plugin_basename)
 {
     global $wp_version, $bstwbsftwppdtplgns_options;
     $result = array();
     $bws_license_key = isset($_POST['bws_license_key']) ? stripslashes(esc_html(trim($_POST['bws_license_key']))) : "";
     if (isset($_POST['bws_license_submit']) && check_admin_referer($plugin_basename, 'bws_license_nonce_name')) {
         if ('' != $bws_license_key) {
             if (strlen($bws_license_key) != 18) {
                 $result['error'] = __("Wrong license key", 'bestwebsoft');
             } else {
                 $bws_license_plugin = stripslashes(esc_html($_POST['bws_license_plugin']));
                 if (isset($bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count']) && $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['time'] > time() - 24 * 60 * 60) {
                     $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] = $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] + 1;
                 } else {
                     $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] = 1;
                     $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['time'] = time();
                 }
                 /* download Pro */
                 if (!function_exists('get_plugins')) {
                     require_once ABSPATH . 'wp-admin/includes/plugin.php';
                 }
                 $all_plugins = get_plugins();
                 if (!array_key_exists($bws_license_plugin, $all_plugins)) {
                     $current = get_site_transient('update_plugins');
                     if (is_array($all_plugins) && !empty($all_plugins) && isset($current) && is_array($current->response)) {
                         $to_send = array();
                         $to_send["plugins"][$bws_license_plugin] = array();
                         $to_send["plugins"][$bws_license_plugin]["bws_license_key"] = $bws_license_key;
                         $to_send["plugins"][$bws_license_plugin]["bws_illegal_client"] = true;
                         $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'body' => array('plugins' => serialize($to_send)), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'));
                         $raw_response = wp_remote_post('http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options);
                         if (is_wp_error($raw_response) || 200 != wp_remote_retrieve_response_code($raw_response)) {
                             $result['error'] = __("Something went wrong. Please try again later. If the error appears again, please contact us", 'bestwebsoft') . ' <a href="http://support.bestwebsoft.com">BestWebSoft</a>. ' . __("We are sorry for inconvenience.", 'bestwebsoft');
                         } else {
                             $response = maybe_unserialize(wp_remote_retrieve_body($raw_response));
                             if (is_array($response) && !empty($response)) {
                                 foreach ($response as $key => $value) {
                                     if ("wrong_license_key" == $value->package) {
                                         $result['error'] = __("Wrong license key", 'bestwebsoft');
                                     } elseif ("wrong_domain" == $value->package) {
                                         $result['error'] = __("This license key is bind to another site", 'bestwebsoft');
                                     } elseif ("you_are_banned" == $value->package) {
                                         $result['error'] = __("Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'bestwebsoft');
                                     } elseif ("time_out" == $value->package) {
                                         $result['error'] = __("Unfortunately, Your license has expired. To continue getting top-priority support and plugin updates you should extend it in your", 'bestwebsoft') . ' <a href="http://bestwebsoft.com/wp-admin/admin.php?page=bws_plugins_client_area">Client area</a>';
                                     } elseif ("duplicate_domen_for_trial" == $value->package) {
                                         $result['error'] = __("Unfortunately, the PRO licence was already installed to this domain. The PRO Trial license can be installed only once.", 'bestwebsoft');
                                     }
                                 }
                                 if (empty($result['error'])) {
                                     $bstwbsftwppdtplgns_options[$bws_license_plugin] = $bws_license_key;
                                     $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5';
                                     $uploadDir = wp_upload_dir();
                                     $zip_name = explode('/', $bws_license_plugin);
                                     if (!function_exists('curl_init')) {
                                         $received_content = file_get_contents($url);
                                     } else {
                                         $ch = curl_init();
                                         curl_setopt($ch, CURLOPT_URL, $url);
                                         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                                         $received_content = curl_exec($ch);
                                         curl_close($ch);
                                     }
                                     if (!$received_content) {
                                         $result['error'] = __("Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft');
                                     } else {
                                         if (is_writable($uploadDir["path"])) {
                                             $file_put_contents = $uploadDir["path"] . "/" . $zip_name[0] . ".zip";
                                             if (file_put_contents($file_put_contents, $received_content)) {
                                                 @chmod($file_put_contents, octdec(755));
                                                 if (class_exists('ZipArchive')) {
                                                     $zip = new ZipArchive();
                                                     if ($zip->open($file_put_contents) === TRUE) {
                                                         $zip->extractTo(WP_PLUGIN_DIR);
                                                         $zip->close();
                                                     } else {
                                                         $result['error'] = __("Failed to open the zip archive. Please, upload the plugin manually", 'bestwebsoft');
                                                     }
                                                 } elseif (class_exists('Phar')) {
                                                     $phar = new PharData($file_put_contents);
                                                     $phar->extractTo(WP_PLUGIN_DIR);
                                                 } else {
                                                     $result['error'] = __("Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'bestwebsoft');
                                                 }
                                                 @unlink($file_put_contents);
                                             } else {
                                                 $result['error'] = __("Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft');
                                             }
                                         } else {
                                             $result['error'] = __("UploadDir is not writable. Please, upload the plugin manually", 'bestwebsoft');
                                         }
                                     }
                                     /* activate Pro */
                                     if (file_exists(WP_PLUGIN_DIR . '/' . $zip_name[0])) {
                                         if (is_multisite() && is_plugin_active_for_network(plugin_basename(__FILE__))) {
                                             /* if multisite and free plugin is network activated */
                                             $active_plugins = get_site_option('active_sitewide_plugins');
                                             $active_plugins[$bws_license_plugin] = time();
                                             update_site_option('active_sitewide_plugins', $active_plugins);
                                         } else {
                                             /* activate on a single blog */
                                             $active_plugins = get_option('active_plugins');
                                             array_push($active_plugins, $bws_license_plugin);
                                             update_option('active_plugins', $active_plugins);
                                         }
                                         $result['pro_plugin_is_activated'] = true;
                                     } elseif (empty($result['error'])) {
                                         $result['error'] = __("Failed to download the zip archive. Please, upload the plugin manually", 'bestwebsoft');
                                     }
                                 }
                             } else {
                                 $result['error'] = __("Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvenience.", 'bestwebsoft');
                             }
                         }
                     }
                 } else {
                     $bstwbsftwppdtplgns_options[$bws_license_plugin] = $bws_license_key;
                     /* activate Pro */
                     if (!is_plugin_active($bws_license_plugin)) {
                         if (is_multisite() && is_plugin_active_for_network(plugin_basename(__FILE__))) {
                             /* if multisite and free plugin is network activated */
                             $network_wide = true;
                         } else {
                             /* activate on a single blog */
                             $network_wide = false;
                         }
                         activate_plugin($bws_license_plugin, NULL, $network_wide);
                         $result['pro_plugin_is_activated'] = true;
                     }
                 }
                 if (is_multisite()) {
                     update_site_option('bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options);
                 } else {
                     update_option('bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options);
                 }
             }
         } else {
             $result['error'] = __("Please, enter Your license key", 'bestwebsoft');
         }
     }
     return $result;
 }
Ejemplo n.º 22
0
    function cntctfrm_settings_page()
    {
        global $cntctfrm_options, $wpdb, $cntctfrm_option_defaults, $wp_version, $cntctfrm_plugin_info;
        if (!function_exists('get_plugins')) {
            require_once ABSPATH . 'wp-admin/includes/plugin.php';
        }
        if (!function_exists('is_plugin_active_for_network')) {
            require_once ABSPATH . '/wp-admin/includes/plugin.php';
        }
        $all_plugins = get_plugins();
        $active_plugins = get_option('active_plugins');
        /* Get Captcha options */
        if (get_option('cptch_options')) {
            $cptch_options = get_option('cptch_options');
        }
        if (get_option('cptchpr_options')) {
            $cptchpr_options = get_option('cptchpr_options');
        }
        /* Get Contact Form to DB options */
        if (get_option('cntctfrmtdb_options')) {
            $cntctfrmtdb_options = get_option('cntctfrmtdb_options');
        }
        if (get_option('cntctfrmtdbpr_options')) {
            $cntctfrmtdbpr_options = get_option('cntctfrmtdbpr_options');
        }
        $userslogin = $wpdb->get_col("SELECT `user_login` FROM  {$wpdb->users} ", 0);
        $error = "";
        /* Save data for settings page */
        if (isset($_POST['cntctfrm_form_submit']) && check_admin_referer(plugin_basename(__FILE__), 'cntctfrm_nonce_name')) {
            $cntctfrm_options_submit['cntctfrm_user_email'] = $_POST['cntctfrm_user_email'];
            $cntctfrm_options_submit['cntctfrm_custom_email'] = stripslashes($_POST['cntctfrm_custom_email']);
            $cntctfrm_options_submit['cntctfrm_select_email'] = $_POST['cntctfrm_select_email'];
            $cntctfrm_options_submit['cntctfrm_from_email'] = $_POST['cntctfrm_from_email'];
            $cntctfrm_options_submit['cntctfrm_custom_from_email'] = stripslashes($_POST['cntctfrm_custom_from_email']);
            $cntctfrm_options_submit['cntctfrm_additions_options'] = isset($_POST['cntctfrm_additions_options']) ? $_POST['cntctfrm_additions_options'] : 0;
            if (0 == $cntctfrm_options_submit['cntctfrm_additions_options']) {
                $cntctfrm_options_submit['cntctfrm_attachment'] = 0;
                $cntctfrm_options_submit['cntctfrm_attachment_explanations'] = 1;
                $cntctfrm_options_submit['cntctfrm_send_copy'] = 0;
                $cntctfrm_options_submit['cntctfrm_from_field'] = get_bloginfo('name');
                $cntctfrm_options_submit['cntctfrm_select_from_field'] = 'custom';
                $cntctfrm_options_submit['cntctfrm_display_name_field'] = 1;
                $cntctfrm_options_submit['cntctfrm_display_address_field'] = 0;
                $cntctfrm_options_submit['cntctfrm_display_phone_field'] = 0;
                $cntctfrm_options_submit['cntctfrm_required_name_field'] = 1;
                $cntctfrm_options_submit['cntctfrm_required_address_field'] = 0;
                $cntctfrm_options_submit['cntctfrm_required_email_field'] = 1;
                $cntctfrm_options_submit['cntctfrm_required_phone_field'] = 0;
                $cntctfrm_options_submit['cntctfrm_required_subject_field'] = 1;
                $cntctfrm_options_submit['cntctfrm_required_message_field'] = 1;
                $cntctfrm_options_submit['cntctfrm_required_symbol'] = '*';
                $cntctfrm_options_submit['cntctfrm_display_add_info'] = 1;
                $cntctfrm_options_submit['cntctfrm_display_sent_from'] = 1;
                $cntctfrm_options_submit['cntctfrm_display_date_time'] = 1;
                $cntctfrm_options_submit['cntctfrm_mail_method'] = 'wp-mail';
                $cntctfrm_options_submit['cntctfrm_display_coming_from'] = 1;
                $cntctfrm_options_submit['cntctfrm_display_user_agent'] = 1;
                $cntctfrm_options_submit['cntctfrm_change_label'] = 0;
                $cntctfrm_options_submit['cntctfrm_action_after_send'] = 1;
                $cntctfrm_options_submit['cntctfrm_delete_attached_file'] = 0;
                $cntctfrm_options_submit['cntctfrm_html_email'] = 1;
                $cntctfrm_options_submit['cntctfrm_site_name_parameter'] = 'SERVER_NAME';
                if (empty($cntctfrm_options['cntctfrm_language'])) {
                    $cntctfrm_options_submit['cntctfrm_name_label'] = $cntctfrm_option_defaults['cntctfrm_name_label'];
                    $cntctfrm_options_submit['cntctfrm_address_label'] = $cntctfrm_option_defaults['cntctfrm_address_label'];
                    $cntctfrm_options_submit['cntctfrm_email_label'] = $cntctfrm_option_defaults['cntctfrm_email_label'];
                    $cntctfrm_options_submit['cntctfrm_phone_label'] = $cntctfrm_option_defaults['cntctfrm_phone_label'];
                    $cntctfrm_options_submit['cntctfrm_subject_label'] = $cntctfrm_option_defaults['cntctfrm_subject_label'];
                    $cntctfrm_options_submit['cntctfrm_message_label'] = $cntctfrm_option_defaults['cntctfrm_message_label'];
                    $cntctfrm_options_submit['cntctfrm_attachment_label'] = $cntctfrm_option_defaults['cntctfrm_attachment_label'];
                    $cntctfrm_options_submit['cntctfrm_attachment_tooltip'] = $cntctfrm_option_defaults['cntctfrm_attachment_tooltip'];
                    $cntctfrm_options_submit['cntctfrm_send_copy_label'] = $cntctfrm_option_defaults['cntctfrm_send_copy_label'];
                    $cntctfrm_options_submit['cntctfrm_thank_text'] = $cntctfrm_option_defaults['cntctfrm_thank_text'];
                    $cntctfrm_options_submit['cntctfrm_submit_label'] = $cntctfrm_option_defaults['cntctfrm_submit_label'];
                    $cntctfrm_options_submit['cntctfrm_name_error'] = $cntctfrm_option_defaults['cntctfrm_name_error'];
                    $cntctfrm_options_submit['cntctfrm_address_error'] = $cntctfrm_option_defaults['cntctfrm_address_error'];
                    $cntctfrm_options_submit['cntctfrm_email_error'] = $cntctfrm_option_defaults['cntctfrm_email_error'];
                    $cntctfrm_options_submit['cntctfrm_phone_error'] = $cntctfrm_option_defaults['cntctfrm_phone_error'];
                    $cntctfrm_options_submit['cntctfrm_subject_error'] = $cntctfrm_option_defaults['cntctfrm_subject_error'];
                    $cntctfrm_options_submit['cntctfrm_message_error'] = $cntctfrm_option_defaults['cntctfrm_message_error'];
                    $cntctfrm_options_submit['cntctfrm_attachment_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_error'];
                    $cntctfrm_options_submit['cntctfrm_attachment_upload_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_upload_error'];
                    $cntctfrm_options_submit['cntctfrm_attachment_move_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_move_error'];
                    $cntctfrm_options_submit['cntctfrm_attachment_size_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_size_error'];
                    $cntctfrm_options_submit['cntctfrm_captcha_error'] = $cntctfrm_option_defaults['cntctfrm_captcha_error'];
                    $cntctfrm_options_submit['cntctfrm_form_error'] = $cntctfrm_option_defaults['cntctfrm_form_error'];
                } else {
                    $cntctfrm_options_submit['cntctfrm_name_label']['en'] = $cntctfrm_option_defaults['cntctfrm_name_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_address_label']['en'] = $cntctfrm_option_defaults['cntctfrm_address_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_email_label']['en'] = $cntctfrm_option_defaults['cntctfrm_email_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_phone_label']['en'] = $cntctfrm_option_defaults['cntctfrm_phone_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_subject_label']['en'] = $cntctfrm_option_defaults['cntctfrm_subject_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_message_label']['en'] = $cntctfrm_option_defaults['cntctfrm_message_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_label']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_tooltip']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_tooltip']['en'];
                    $cntctfrm_options_submit['cntctfrm_send_copy_label']['en'] = $cntctfrm_option_defaults['cntctfrm_send_copy_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_thank_text']['en'] = $cntctfrm_option_defaults['cntctfrm_thank_text']['en'];
                    $cntctfrm_options_submit['cntctfrm_submit_label']['en'] = $cntctfrm_option_defaults['cntctfrm_submit_label']['en'];
                    $cntctfrm_options_submit['cntctfrm_name_error']['en'] = $cntctfrm_option_defaults['cntctfrm_name_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_address_error']['en'] = $cntctfrm_option_defaults['cntctfrm_address_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_email_error']['en'] = $cntctfrm_option_defaults['cntctfrm_email_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_phone_error']['en'] = $cntctfrm_option_defaults['cntctfrm_phone_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_subject_error']['en'] = $cntctfrm_option_defaults['cntctfrm_subject_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_message_error']['en'] = $cntctfrm_option_defaults['cntctfrm_message_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_upload_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_upload_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_move_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_move_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_attachment_size_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_size_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_captcha_error']['en'] = $cntctfrm_option_defaults['cntctfrm_captcha_error']['en'];
                    $cntctfrm_options_submit['cntctfrm_form_error']['en'] = $cntctfrm_option_defaults['cntctfrm_form_error']['en'];
                }
                $cntctfrm_options_submit['cntctfrm_redirect_url'] = '';
            } else {
                $cntctfrm_options_submit['cntctfrm_mail_method'] = $_POST['cntctfrm_mail_method'];
                $cntctfrm_options_submit['cntctfrm_from_field'] = $_POST['cntctfrm_from_field'];
                $cntctfrm_options_submit['cntctfrm_select_from_field'] = $_POST['cntctfrm_select_from_field'];
                $cntctfrm_options_submit['cntctfrm_display_name_field'] = isset($_POST['cntctfrm_display_name_field']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_display_address_field'] = isset($_POST['cntctfrm_display_address_field']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_display_phone_field'] = isset($_POST['cntctfrm_display_phone_field']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_attachment'] = isset($_POST['cntctfrm_attachment']) ? $_POST['cntctfrm_attachment'] : 0;
                $cntctfrm_options_submit['cntctfrm_attachment_explanations'] = isset($_POST['cntctfrm_attachment_explanations']) ? $_POST['cntctfrm_attachment_explanations'] : 0;
                $cntctfrm_options_submit['cntctfrm_send_copy'] = isset($_POST['cntctfrm_send_copy']) ? $_POST['cntctfrm_send_copy'] : 0;
                $cntctfrm_options_submit['cntctfrm_delete_attached_file'] = isset($_POST['cntctfrm_delete_attached_file']) ? $_POST['cntctfrm_delete_attached_file'] : 0;
                if (isset($_POST['cntctfrm_display_captcha'])) {
                    if (get_option('cptch_options')) {
                        $cptch_options['cptch_contact_form'] = 1;
                        update_option('cptch_options', $cptch_options, '', 'yes');
                    }
                    if (get_option('cptchpr_options')) {
                        $cptchpr_options['cptchpr_contact_form'] = 1;
                        update_option('cptchpr_options', $cptchpr_options, '', 'yes');
                    }
                } else {
                    if (get_option('cptch_options')) {
                        $cptch_options['cptch_contact_form'] = 0;
                        update_option('cptch_options', $cptch_options, '', 'yes');
                    }
                    if (get_option('cptchpr_options')) {
                        $cptchpr_options['cptchpr_contact_form'] = 0;
                        update_option('cptchpr_options', $cptchpr_options, '', 'yes');
                    }
                }
                if (isset($_POST['cntctfrm_save_email_to_db'])) {
                    if (get_option('cntctfrmtdb_options')) {
                        $cntctfrmtdb_options['cntctfrmtdb_save_messages_to_db'] = 1;
                        update_option('cntctfrmtdb_options', $cntctfrmtdb_options, '', 'yes');
                    }
                    if (get_option('cntctfrmtdbpr_options')) {
                        $cntctfrmtdbpr_options['save_messages_to_db'] = 1;
                        update_option('cntctfrmtdbpr_options', $cntctfrmtdbpr_options, '', 'yes');
                    }
                } else {
                    if (get_option('cntctfrmtdb_options')) {
                        $cntctfrmtdb_options['cntctfrmtdb_save_messages_to_db'] = 0;
                        update_option('cntctfrmtdb_options', $cntctfrmtdb_options, '', 'yes');
                    }
                    if (get_option('cntctfrmtdbpr_options')) {
                        $cntctfrmtdbpr_options['save_messages_to_db'] = 0;
                        update_option('cntctfrmtdbpr_options', $cntctfrmtdbpr_options, '', 'yes');
                    }
                }
                if (0 == $cntctfrm_options_submit['cntctfrm_display_name_field']) {
                    $cntctfrm_options_submit['cntctfrm_required_name_field'] = 0;
                } else {
                    $cntctfrm_options_submit['cntctfrm_required_name_field'] = isset($_POST['cntctfrm_required_name_field']) ? 1 : 0;
                }
                if (0 == $cntctfrm_options_submit['cntctfrm_display_address_field']) {
                    $cntctfrm_options_submit['cntctfrm_required_address_field'] = 0;
                } else {
                    $cntctfrm_options_submit['cntctfrm_required_address_field'] = isset($_POST['cntctfrm_required_address_field']) ? 1 : 0;
                }
                $cntctfrm_options_submit['cntctfrm_required_email_field'] = isset($_POST['cntctfrm_required_email_field']) ? 1 : 0;
                if (0 == $cntctfrm_options_submit['cntctfrm_display_phone_field']) {
                    $cntctfrm_options_submit['cntctfrm_required_phone_field'] = 0;
                } else {
                    $cntctfrm_options_submit['cntctfrm_required_phone_field'] = isset($_POST['cntctfrm_required_phone_field']) ? 1 : 0;
                }
                $cntctfrm_options_submit['cntctfrm_required_subject_field'] = isset($_POST['cntctfrm_required_subject_field']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_required_message_field'] = isset($_POST['cntctfrm_required_message_field']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_required_symbol'] = isset($_POST['cntctfrm_required_symbol']) ? $_POST['cntctfrm_required_symbol'] : '*';
                $cntctfrm_options_submit['cntctfrm_html_email'] = isset($_POST['cntctfrm_html_email']) ? 1 : 0;
                $cntctfrm_options_submit['cntctfrm_site_name_parameter'] = $_POST['cntctfrm_site_name_parameter'];
                $cntctfrm_options_submit['cntctfrm_display_add_info'] = isset($_POST['cntctfrm_display_add_info']) ? 1 : 0;
                if (1 == $cntctfrm_options_submit['cntctfrm_display_add_info']) {
                    $cntctfrm_options_submit['cntctfrm_display_sent_from'] = isset($_POST['cntctfrm_display_sent_from']) ? 1 : 0;
                    $cntctfrm_options_submit['cntctfrm_display_date_time'] = isset($_POST['cntctfrm_display_date_time']) ? 1 : 0;
                    $cntctfrm_options_submit['cntctfrm_display_coming_from'] = isset($_POST['cntctfrm_display_coming_from']) ? 1 : 0;
                    $cntctfrm_options_submit['cntctfrm_display_user_agent'] = isset($_POST['cntctfrm_display_user_agent']) ? 1 : 0;
                } else {
                    $cntctfrm_options_submit['cntctfrm_display_sent_from'] = 1;
                    $cntctfrm_options_submit['cntctfrm_display_date_time'] = 1;
                    $cntctfrm_options_submit['cntctfrm_display_coming_from'] = 1;
                    $cntctfrm_options_submit['cntctfrm_display_user_agent'] = 1;
                }
                $cntctfrm_options_submit['cntctfrm_change_label'] = isset($_POST['cntctfrm_change_label']) ? 1 : 0;
                if (1 == $cntctfrm_options_submit['cntctfrm_change_label']) {
                    foreach ($_POST['cntctfrm_name_label'] as $key => $val) {
                        $cntctfrm_options_submit['cntctfrm_name_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_name_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_address_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_address_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_email_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_email_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_phone_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_phone_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_subject_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_subject_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_message_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_message_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_tooltip'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_tooltip'][$key]));
                        $cntctfrm_options_submit['cntctfrm_send_copy_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_send_copy_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_thank_text'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_thank_text'][$key]));
                        $cntctfrm_options_submit['cntctfrm_submit_label'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_submit_label'][$key]));
                        $cntctfrm_options_submit['cntctfrm_name_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_name_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_address_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_address_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_email_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_email_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_phone_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_phone_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_subject_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_subject_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_message_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_message_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_upload_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_upload_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_move_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_move_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_attachment_size_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_attachment_size_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_captcha_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_captcha_error'][$key]));
                        $cntctfrm_options_submit['cntctfrm_form_error'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_form_error'][$key]));
                    }
                } else {
                    if (empty($cntctfrm_options['cntctfrm_language'])) {
                        $cntctfrm_options_submit['cntctfrm_name_label'] = $cntctfrm_option_defaults['cntctfrm_name_label'];
                        $cntctfrm_options_submit['cntctfrm_address_label'] = $cntctfrm_option_defaults['cntctfrm_address_label'];
                        $cntctfrm_options_submit['cntctfrm_email_label'] = $cntctfrm_option_defaults['cntctfrm_email_label'];
                        $cntctfrm_options_submit['cntctfrm_phone_label'] = $cntctfrm_option_defaults['cntctfrm_phone_label'];
                        $cntctfrm_options_submit['cntctfrm_subject_label'] = $cntctfrm_option_defaults['cntctfrm_subject_label'];
                        $cntctfrm_options_submit['cntctfrm_message_label'] = $cntctfrm_option_defaults['cntctfrm_message_label'];
                        $cntctfrm_options_submit['cntctfrm_attachment_label'] = $cntctfrm_option_defaults['cntctfrm_attachment_label'];
                        $cntctfrm_options_submit['cntctfrm_attachment_tooltip'] = $cntctfrm_option_defaults['cntctfrm_attachment_tooltip'];
                        $cntctfrm_options_submit['cntctfrm_send_copy_label'] = $cntctfrm_option_defaults['cntctfrm_send_copy_label'];
                        $cntctfrm_options_submit['cntctfrm_thank_text'] = $_POST['cntctfrm_thank_text'];
                        $cntctfrm_options_submit['cntctfrm_submit_label'] = $cntctfrm_option_defaults['cntctfrm_submit_label'];
                        $cntctfrm_options_submit['cntctfrm_name_error'] = $cntctfrm_option_defaults['cntctfrm_name_error'];
                        $cntctfrm_options_submit['cntctfrm_address_error'] = $cntctfrm_option_defaults['cntctfrm_address_error'];
                        $cntctfrm_options_submit['cntctfrm_email_error'] = $cntctfrm_option_defaults['cntctfrm_email_error'];
                        $cntctfrm_options_submit['cntctfrm_phone_error'] = $cntctfrm_option_defaults['cntctfrm_phone_error'];
                        $cntctfrm_options_submit['cntctfrm_subject_error'] = $cntctfrm_option_defaults['cntctfrm_subject_error'];
                        $cntctfrm_options_submit['cntctfrm_message_error'] = $cntctfrm_option_defaults['cntctfrm_message_error'];
                        $cntctfrm_options_submit['cntctfrm_attachment_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_error'];
                        $cntctfrm_options_submit['cntctfrm_attachment_upload_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_upload_error'];
                        $cntctfrm_options_submit['cntctfrm_attachment_move_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_move_error'];
                        $cntctfrm_options_submit['cntctfrm_attachment_size_error'] = $cntctfrm_option_defaults['cntctfrm_attachment_size_error'];
                        $cntctfrm_options_submit['cntctfrm_captcha_error'] = $cntctfrm_option_defaults['cntctfrm_captcha_error'];
                        $cntctfrm_options_submit['cntctfrm_form_error'] = $cntctfrm_option_defaults['cntctfrm_form_error'];
                        foreach ($cntctfrm_options_submit['cntctfrm_thank_text'] as $key => $val) {
                            $cntctfrm_options_submit['cntctfrm_thank_text'][$key] = stripcslashes(htmlspecialchars($val));
                        }
                    } else {
                        $cntctfrm_options_submit['cntctfrm_name_label']['en'] = $cntctfrm_option_defaults['cntctfrm_name_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_address_label']['en'] = $cntctfrm_option_defaults['cntctfrm_address_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_email_label']['en'] = $cntctfrm_option_defaults['cntctfrm_email_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_phone_label']['en'] = $cntctfrm_option_defaults['cntctfrm_phone_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_subject_label']['en'] = $cntctfrm_option_defaults['cntctfrm_subject_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_message_label']['en'] = $cntctfrm_option_defaults['cntctfrm_message_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_label']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_tooltip']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_tooltip']['en'];
                        $cntctfrm_options_submit['cntctfrm_send_copy_label']['en'] = $cntctfrm_option_defaults['cntctfrm_send_copy_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_submit_label']['en'] = $cntctfrm_option_defaults['cntctfrm_submit_label']['en'];
                        $cntctfrm_options_submit['cntctfrm_name_error']['en'] = $cntctfrm_option_defaults['cntctfrm_name_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_address_error']['en'] = $cntctfrm_option_defaults['cntctfrm_address_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_email_error']['en'] = $cntctfrm_option_defaults['cntctfrm_email_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_phone_error']['en'] = $cntctfrm_option_defaults['cntctfrm_phone_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_subject_error']['en'] = $cntctfrm_option_defaults['cntctfrm_subject_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_message_error']['en'] = $cntctfrm_option_defaults['cntctfrm_message_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_upload_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_upload_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_move_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_move_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_attachment_size_error']['en'] = $cntctfrm_option_defaults['cntctfrm_attachment_size_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_captcha_error']['en'] = $cntctfrm_option_defaults['cntctfrm_captcha_error']['en'];
                        $cntctfrm_options_submit['cntctfrm_form_error']['en'] = $cntctfrm_option_defaults['cntctfrm_form_error']['en'];
                        foreach ($_POST['cntctfrm_thank_text'] as $key => $val) {
                            $cntctfrm_options_submit['cntctfrm_thank_text'][$key] = stripcslashes(htmlspecialchars($_POST['cntctfrm_thank_text'][$key]));
                        }
                    }
                }
                $cntctfrm_options_submit['cntctfrm_action_after_send'] = $_POST['cntctfrm_action_after_send'];
                $cntctfrm_options_submit['cntctfrm_redirect_url'] = $_POST['cntctfrm_redirect_url'];
            }
            $cntctfrm_options = array_merge($cntctfrm_options, $cntctfrm_options_submit);
            if (0 == $cntctfrm_options_submit['cntctfrm_action_after_send'] && ("" == trim($cntctfrm_options_submit['cntctfrm_redirect_url']) || !preg_match('@^(?:http://)?([^/]+)@i', trim($cntctfrm_options_submit['cntctfrm_redirect_url'])))) {
                $error .= __("If the 'Redirect to page' option is selected then the URL field should be in the following format", 'contact_form') . " <code>http://your_site/your_page</code>";
                $cntctfrm_options['cntctfrm_action_after_send'] = 1;
            }
            if ('user' == $cntctfrm_options_submit['cntctfrm_select_email']) {
                if ('3.3' > $wp_version && function_exists('get_userdatabylogin') && false !== get_userdatabylogin($cntctfrm_options_submit['cntctfrm_user_email'])) {
                    //
                } else {
                    if (false !== get_user_by('login', $cntctfrm_options_submit['cntctfrm_user_email'])) {
                        //
                    } else {
                        $error .= __("Such user does not exist. Settings are not saved.", 'contact_form');
                    }
                }
            } else {
                if ("" == $cntctfrm_options_submit['cntctfrm_custom_email'] || !preg_match("/^((?:[a-z0-9_']+(?:[a-z0-9\\-_\\.']+)?@[a-z0-9]+(?:[a-z0-9\\-\\.]+)?\\.[a-z]{2,5})[, ]*)+\$/i", trim($cntctfrm_options_submit['cntctfrm_custom_email']))) {
                    $error .= __("Please enter a valid email address in the 'FROM' field. Settings are not saved.", 'contact_form');
                }
            }
            if ('custom' == $cntctfrm_options_submit['cntctfrm_from_email']) {
                if ("" == $cntctfrm_options_submit['cntctfrm_custom_from_email'] && !preg_match("/^((?:[a-z0-9_']+(?:[a-z0-9\\-_\\.']+)?@[a-z0-9]+(?:[a-z0-9\\-\\.]+)?\\.[a-z]{2,5})[, ]*)+\$/i", trim($cntctfrm_options_submit['cntctfrm_custom_from_email']))) {
                    $error .= __("Please enter a valid email address in the 'FROM' field. Settings are not saved.", 'contact_form');
                }
            }
            if ('' == $error) {
                update_option('cntctfrm_options', $cntctfrm_options, '', 'yes');
                $message = __("Settings saved.", 'contact_form');
            }
        }
        /* Display form on the setting page */
        $lang_codes = array('aa' => 'Afar', 'ab' => 'Abkhazian', 'af' => 'Afrikaans', 'ak' => 'Akan', 'sq' => 'Albanian', 'am' => 'Amharic', 'ar' => 'Arabic', 'an' => 'Aragonese', 'hy' => 'Armenian', 'as' => 'Assamese', 'av' => 'Avaric', 'ae' => 'Avestan', 'ay' => 'Aymara', 'az' => 'Azerbaijani', 'ba' => 'Bashkir', 'bm' => 'Bambara', 'eu' => 'Basque', 'be' => 'Belarusian', 'bn' => 'Bengali', 'bh' => 'Bihari', 'bi' => 'Bislama', 'bs' => 'Bosnian', 'br' => 'Breton', 'bg' => 'Bulgarian', 'my' => 'Burmese', 'ca' => 'Catalan; Valencian', 'ch' => 'Chamorro', 'ce' => 'Chechen', 'zh' => 'Chinese', 'cu' => 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', 'cv' => 'Chuvash', 'kw' => 'Cornish', 'co' => 'Corsican', 'cr' => 'Cree', 'cs' => 'Czech', 'da' => 'Danish', 'dv' => 'Divehi; Dhivehi; Maldivian', 'nl' => 'Dutch; Flemish', 'dz' => 'Dzongkha', 'eo' => 'Esperanto', 'et' => 'Estonian', 'ee' => 'Ewe', 'fo' => 'Faroese', 'fj' => 'Fijjian', 'fi' => 'Finnish', 'fr' => 'French', 'fy' => 'Western Frisian', 'ff' => 'Fulah', 'ka' => 'Georgian', 'de' => 'German', 'gd' => 'Gaelic; Scottish Gaelic', 'ga' => 'Irish', 'gl' => 'Galician', 'gv' => 'Manx', 'el' => 'Greek, Modern', 'gn' => 'Guarani', 'gu' => 'Gujarati', 'ht' => 'Haitian; Haitian Creole', 'ha' => 'Hausa', 'he' => 'Hebrew', 'hz' => 'Herero', 'hi' => 'Hindi', 'ho' => 'Hiri Motu', 'hu' => 'Hungarian', 'ig' => 'Igbo', 'is' => 'Icelandic', 'io' => 'Ido', 'ii' => 'Sichuan Yi', 'iu' => 'Inuktitut', 'ie' => 'Interlingue', 'ia' => 'Interlingua (International Auxiliary Language Association)', 'id' => 'Indonesian', 'ik' => 'Inupiaq', 'it' => 'Italian', 'jv' => 'Javanese', 'ja' => 'Japanese', 'kl' => 'Kalaallisut; Greenlandic', 'kn' => 'Kannada', 'ks' => 'Kashmiri', 'kr' => 'Kanuri', 'kk' => 'Kazakh', 'km' => 'Central Khmer', 'ki' => 'Kikuyu; Gikuyu', 'rw' => 'Kinyarwanda', 'ky' => 'Kirghiz; Kyrgyz', 'kv' => 'Komi', 'kg' => 'Kongo', 'ko' => 'Korean', 'kj' => 'Kuanyama; Kwanyama', 'ku' => 'Kurdish', 'lo' => 'Lao', 'la' => 'Latin', 'lv' => 'Latvian', 'li' => 'Limburgan; Limburger; Limburgish', 'ln' => 'Lingala', 'lt' => 'Lithuanian', 'lb' => 'Luxembourgish; Letzeburgesch', 'lu' => 'Luba-Katanga', 'lg' => 'Ganda', 'mk' => 'Macedonian', 'mh' => 'Marshallese', 'ml' => 'Malayalam', 'mi' => 'Maori', 'mr' => 'Marathi', 'ms' => 'Malay', 'mg' => 'Malagasy', 'mt' => 'Maltese', 'mo' => 'Moldavian', 'mn' => 'Mongolian', 'na' => 'Nauru', 'nv' => 'Navajo; Navaho', 'nr' => 'Ndebele, South; South Ndebele', 'nd' => 'Ndebele, North; North Ndebele', 'ng' => 'Ndonga', 'ne' => 'Nepali', 'nn' => 'Norwegian Nynorsk; Nynorsk, Norwegian', 'nb' => 'Bokmål, Norwegian, Norwegian Bokmål', 'no' => 'Norwegian', 'ny' => 'Chichewa; Chewa; Nyanja', 'oc' => 'Occitan, Provençal', 'oj' => 'Ojibwa', 'or' => 'Oriya', 'om' => 'Oromo', 'os' => 'Ossetian; Ossetic', 'pa' => 'Panjabi; Punjabi', 'fa' => 'Persian', 'pi' => 'Pali', 'pl' => 'Polish', 'pt' => 'Portuguese', 'ps' => 'Pushto', 'qu' => 'Quechua', 'rm' => 'Romansh', 'ro' => 'Romanian', 'rn' => 'Rundi', 'ru' => 'Russian', 'sg' => 'Sango', 'sa' => 'Sanskrit', 'sr' => 'Serbian', 'hr' => 'Croatian', 'si' => 'Sinhala; Sinhalese', 'sk' => 'Slovak', 'sl' => 'Slovenian', 'se' => 'Northern Sami', 'sm' => 'Samoan', 'sn' => 'Shona', 'sd' => 'Sindhi', 'so' => 'Somali', 'st' => 'Sotho, Southern', 'es' => 'Spanish; Castilian', 'sc' => 'Sardinian', 'ss' => 'Swati', 'su' => 'Sundanese', 'sw' => 'Swahili', 'sv' => 'Swedish', 'ty' => 'Tahitian', 'ta' => 'Tamil', 'tt' => 'Tatar', 'te' => 'Telugu', 'tg' => 'Tajik', 'tl' => 'Tagalog', 'th' => 'Thai', 'bo' => 'Tibetan', 'ti' => 'Tigrinya', 'to' => 'Tonga (Tonga Islands)', 'tn' => 'Tswana', 'ts' => 'Tsonga', 'tk' => 'Turkmen', 'tr' => 'Turkish', 'tw' => 'Twi', 'ug' => 'Uighur; Uyghur', 'uk' => 'Ukrainian', 'ur' => 'Urdu', 'uz' => 'Uzbek', 've' => 'Venda', 'vi' => 'Vietnamese', 'vo' => 'Volapük', 'cy' => 'Welsh', 'wa' => 'Walloon', 'wo' => 'Wolof', 'xh' => 'Xhosa', 'yi' => 'Yiddish', 'yo' => 'Yoruba', 'za' => 'Zhuang; Chuang', 'zu' => 'Zulu');
        /* GO PRO */
        if (isset($_GET['action']) && 'go_pro' == $_GET['action']) {
            global $wpmu;
            $bws_license_key = isset($_POST['bws_license_key']) ? trim($_POST['bws_license_key']) : "";
            $bstwbsftwppdtplgns_options_defaults = array();
            if (1 == $wpmu) {
                if (!get_site_option('bstwbsftwppdtplgns_options')) {
                    add_site_option('bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options_defaults, '', 'yes');
                }
                $bstwbsftwppdtplgns_options = get_site_option('bstwbsftwppdtplgns_options');
            } else {
                if (!get_option('bstwbsftwppdtplgns_options')) {
                    add_option('bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options_defaults, '', 'yes');
                }
                $bstwbsftwppdtplgns_options = get_option('bstwbsftwppdtplgns_options');
            }
            if (isset($_POST['bws_license_submit']) && check_admin_referer(plugin_basename(__FILE__), 'bws_license_nonce_name')) {
                if ('' != $bws_license_key) {
                    if (strlen($bws_license_key) != 18) {
                        $error = __("Wrong license key", 'contact_form');
                    } else {
                        $bws_license_plugin = trim($_POST['bws_license_plugin']);
                        if (isset($bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count']) && $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['time'] < time() + 24 * 60 * 60) {
                            $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] = $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] + 1;
                        } else {
                            $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['count'] = 1;
                            $bstwbsftwppdtplgns_options['go_pro'][$bws_license_plugin]['time'] = time();
                        }
                        /* download Pro */
                        if (!array_key_exists($bws_license_plugin, $all_plugins)) {
                            $current = get_site_transient('update_plugins');
                            if (is_array($all_plugins) && !empty($all_plugins) && isset($current) && is_array($current->response)) {
                                $to_send = array();
                                $to_send["plugins"][$bws_license_plugin] = array();
                                $to_send["plugins"][$bws_license_plugin]["bws_license_key"] = $bws_license_key;
                                $to_send["plugins"][$bws_license_plugin]["bws_illegal_client"] = true;
                                $options = array('timeout' => defined('DOING_CRON') && DOING_CRON ? 30 : 3, 'body' => array('plugins' => serialize($to_send)), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url'));
                                $raw_response = wp_remote_post('http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/update-check/1.0/', $options);
                                if (is_wp_error($raw_response) || 200 != wp_remote_retrieve_response_code($raw_response)) {
                                    $error = __("Something went wrong. Try again later. If the error will appear again, please, contact us <a href=http://support.bestwebsoft.com>BestWebSoft</a>. We are sorry for inconvenience.", 'contact_form');
                                } else {
                                    $response = maybe_unserialize(wp_remote_retrieve_body($raw_response));
                                    if (is_array($response) && !empty($response)) {
                                        foreach ($response as $key => $value) {
                                            if ("wrong_license_key" == $value->package) {
                                                $error = __("Wrong license key", 'contact_form');
                                            } elseif ("wrong_domain" == $value->package) {
                                                $error = __("This license key is bind to another site", 'contact_form');
                                            } elseif ("you_are_banned" == $value->package) {
                                                $error = __("Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'contact_form');
                                            }
                                        }
                                        if ('' == $error) {
                                            global $wpmu;
                                            $bstwbsftwppdtplgns_options[$bws_license_plugin] = $bws_license_key;
                                            $url = 'http://bestwebsoft.com/wp-content/plugins/paid-products/plugins/downloads/?bws_first_download=' . $bws_license_plugin . '&bws_license_key=' . $bws_license_key . '&download_from=5';
                                            $uploadDir = wp_upload_dir();
                                            $zip_name = explode('/', $bws_license_plugin);
                                            if (file_put_contents($uploadDir["path"] . "/" . $zip_name[0] . ".zip", file_get_contents($url))) {
                                                @chmod($uploadDir["path"] . "/" . $zip_name[0] . ".zip", octdec(755));
                                                if (class_exists('ZipArchive')) {
                                                    $zip = new ZipArchive();
                                                    if ($zip->open($uploadDir["path"] . "/" . $zip_name[0] . ".zip") === TRUE) {
                                                        $zip->extractTo(WP_PLUGIN_DIR);
                                                        $zip->close();
                                                    } else {
                                                        $error = __("Failed to open the zip archive. Please, upload the plugin manually", 'contact_form');
                                                    }
                                                } elseif (class_exists('Phar')) {
                                                    $phar = new PharData($uploadDir["path"] . "/" . $zip_name[0] . ".zip");
                                                    $phar->extractTo(WP_PLUGIN_DIR);
                                                } else {
                                                    $error = __("Your server does not support either ZipArchive or Phar. Please, upload the plugin manually", 'contact_form');
                                                }
                                                @unlink($uploadDir["path"] . "/" . $zip_name[0] . ".zip");
                                            } else {
                                                $error = __("Failed to download the zip archive. Please, upload the plugin manually", 'contact_form');
                                            }
                                            /* activate Pro */
                                            if (file_exists(WP_PLUGIN_DIR . '/' . $zip_name[0])) {
                                                array_push($active_plugins, $bws_license_plugin);
                                                update_option('active_plugins', $active_plugins);
                                                $pro_plugin_is_activated = true;
                                            } elseif ('' == $error) {
                                                $error = __("Failed to download the zip archive. Please, upload the plugin manually", 'contact_form');
                                            }
                                        }
                                    } else {
                                        $error = __("Something went wrong. Try again later or upload the plugin manually. We are sorry for inconvienience.", 'contact_form');
                                    }
                                }
                            }
                        } else {
                            /* activate Pro */
                            if (!(in_array($bws_license_plugin, $active_plugins) || is_plugin_active_for_network($bws_license_plugin))) {
                                array_push($active_plugins, $bws_license_plugin);
                                update_option('active_plugins', $active_plugins);
                                $pro_plugin_is_activated = true;
                            }
                        }
                        update_option('bstwbsftwppdtplgns_options', $bstwbsftwppdtplgns_options, '', 'yes');
                    }
                } else {
                    $error = __("Please, enter Your license key", 'contact_form');
                }
            }
        }
        ?>
		<div class="wrap">
			<div class="icon32 icon32-bws" id="icon-options-general"></div>
			<h2><?php 
        _e("Contact Form Settings", 'contact_form');
        ?>
</h2>
			<h2 class="nav-tab-wrapper">
				<a class="nav-tab<?php 
        if (!isset($_GET['action'])) {
            echo ' nav-tab-active';
        }
        ?>
"  href="admin.php?page=contact_form.php"><?php 
        _e('Settings', 'contact_form');
        ?>
</a>
				<a class="nav-tab<?php 
        if (isset($_GET['action']) && 'extra' == $_GET['action']) {
            echo ' nav-tab-active';
        }
        ?>
" href="admin.php?page=contact_form.php&amp;action=extra"><?php 
        _e('Extra settings', 'contact_form');
        ?>
</a>
				<a class="nav-tab bws_go_pro_tab<?php 
        if (isset($_GET['action']) && 'go_pro' == $_GET['action']) {
            echo ' nav-tab-active';
        }
        ?>
" href="admin.php?page=contact_form.php&amp;action=go_pro"><?php 
        _e('Go PRO', 'contact_form');
        ?>
</a>
			</h2>
			<div class="updated fade" <?php 
        if (!isset($_POST['cntctfrm_form_submit']) || "" != $error) {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $message;
        ?>
</strong></p></div>
			<div id="cntctfrm_settings_notice" class="updated fade" style="display:none"><p><strong><?php 
        _e("Notice:", 'contact_form');
        ?>
</strong> <?php 
        _e("The plugin's settings have been changed. In order to save them please don't forget to click the 'Save Changes' button.", 'contact_form');
        ?>
</p></div>
			<div class="error" <?php 
        if ("" == $error) {
            echo "style=\"display:none\"";
        }
        ?>
><p><strong><?php 
        echo $error;
        ?>
</strong></p></div>
			<?php 
        if (!isset($_GET['action'])) {
            ?>
				<form id="cntctfrm_settings_form" method="post" action="admin.php?page=contact_form.php">
					<span style="margin-bottom:15px;">
						<p><?php 
            _e("If you would like to add the Contact Form to your website, just copy and paste this shortcode to your post or page or widget:", 'contact_form');
            ?>
 [contact_form] <?php 
            _e("or", 'contact_form');
            ?>
 [contact_form lang=en]<br />
						<?php 
            _e("If have any problems with the standard shortcode [contact_form], you should use the shortcode", 'contact_form');
            ?>
 [bws_contact_form] (<?php 
            _e("or", 'contact_form');
            ?>
 [bws_contact_form lang=en]) <?php 
            _e("or", 'contact_form');
            ?>
 [bestwebsoft_contact_form] (<?php 
            _e("or", 'contact_form');
            ?>
 
		[bestwebsoft_contact_form lang=en]). <?php 
            _e("They work the same way.", 'contact_form');
            ?>
</p>
						<?php 
            _e("If you leave the fields empty, the messages will be sent to the email address specified during registration.", 'contact_form');
            ?>
					</span>
					<table class="form-table" style="width:auto;">
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("The user's email address:", 'contact_form');
            ?>
 </th>
							<td colspan="2" style="width:750px;">
								<input type="radio" id="cntctfrm_select_email_user" name="cntctfrm_select_email" value="user" <?php 
            if ($cntctfrm_options['cntctfrm_select_email'] == 'user') {
                echo "checked=\"checked\" ";
            }
            ?>
/>
								<select name="cntctfrm_user_email">
									<option disabled><?php 
            _e("Create a username", 'contact_form');
            ?>
</option>
									<?php 
            while (list($key, $value) = each($userslogin)) {
                ?>
										<option value="<?php 
                echo $value;
                ?>
" <?php 
                if ($cntctfrm_options['cntctfrm_user_email'] == $value) {
                    echo "selected=\"selected\" ";
                }
                ?>
><?php 
                echo $value;
                ?>
</option>
									<?php 
            }
            ?>
								</select>
								<span class="cntctfrm_info"><?php 
            _e("Enter a username of the person who should get the messages from the contact form.", 'contact_form');
            ?>
</span>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Use this email address:", 'contact_form');
            ?>
 </th>
							<td colspan="2">
								<input type="radio" id="cntctfrm_select_email_custom" name="cntctfrm_select_email" value="custom" <?php 
            if ('custom' == $cntctfrm_options['cntctfrm_select_email']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <input type="text" name="cntctfrm_custom_email" value="<?php 
            echo $cntctfrm_options['cntctfrm_custom_email'];
            ?>
" onfocus="document.getElementById('cntctfrm_select_email_custom').checked = true;" />
								<span class="cntctfrm_info"><?php 
            _e("Enter the email address you want the messages forwarded to.", 'contact_form');
            ?>
</span>
							</td>
						</tr>
					</table>
					<table class="form-table bws_pro_version" style="width:auto;">
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Add department selectbox to the contact form:", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<input type="radio" id="cntctfrmpr_select_email_department" name="cntctfrmpr_select_email" value="departments" disabled="disabled" /> 
								<div class="cntctfrmpr_department_table"><img src="<?php 
            echo plugins_url('images/pro_screen_1.png', __FILE__);
            ?>
" alt="" /></div>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row" colspan="2">
								* <?php 
            _e('If you upgrade to Pro version all your settings will be saved.', 'contact_form');
            ?>
							</th>
						</tr>
						<tr valign="top" class="bws_pro_version_tooltip">
							<th scope="row" colspan="2">
								<?php 
            _e('This functionality is available in the Pro version of the plugin. For more details, please follow the link', 'contact_form');
            ?>
								<a title="Contact Form Pro" target="_blank" href="http://bestwebsoft.com/plugin/contact-form-pro/?k=697c5e74f39779ce77850e11dbe21962&pn=77&v=<?php 
            echo $cntctfrm_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
"> <?php 
            _e('Contact Form Pro', 'contact_form');
            ?>
</a>
							</th>
						</tr>
					</table>
					<table class="form-table" style="width:auto;">
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Save emails to the database", 'contact_form');
            ?>
 </th>
							<td colspan="2">
								<?php 
            if (array_key_exists('contact-form-to-db/contact_form_to_db.php', $all_plugins) || array_key_exists('contact-form-to-db-pro/contact_form_to_db_pro.php', $all_plugins)) {
                if (0 < count(preg_grep('/contact-form-to-db\\/contact_form_to_db.php/', $active_plugins)) || 0 < count(preg_grep('/contact-form-to-db-pro\\/contact_form_to_db_pro.php/', $active_plugins)) || is_plugin_active_for_network('contact-form-to-db/contact_form_to_db.php') || is_plugin_active_for_network('contact-form-to-db-pro/contact_form_to_db_pro.php')) {
                    ?>
										<input type="checkbox" name="cntctfrm_save_email_to_db" value="1" <?php 
                    if (isset($cntctfrmtdb_options) && 1 == $cntctfrmtdb_options["cntctfrmtdb_save_messages_to_db"] || isset($cntctfrmtdbpr_options) && 1 == $cntctfrmtdbpr_options["save_messages_to_db"]) {
                        echo "checked=\"checked\"";
                    }
                    ?>
 />
										<span style="color: #888888;font-size: 10px;"> (<?php 
                    _e('Using', 'contact_form');
                    ?>
 <a href="admin.php?page=cntctfrmtdb_manager">Contact Form to DB</a> <?php 
                    _e('powered by', 'contact_form');
                    ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>)</span>
									<?php 
                } else {
                    ?>
										<input disabled="disabled" type="checkbox" name="cntctfrm_save_email_to_db" value="1" <?php 
                    if (isset($cntctfrmtdb_options) && 1 == $cntctfrmtdb_options["cntctfrmtdb_save_messages_to_db"] || isset($cntctfrmtdbpr_options) && 1 == $cntctfrmtdbpr_options["save_messages_to_db"]) {
                        echo "checked=\"checked\"";
                    }
                    ?>
 /> 
										<span style="color: #888888;font-size: 10px;">(<?php 
                    _e('Using Contact Form to DB powered by', 'contact_form');
                    ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>) <a href="<?php 
                    echo bloginfo("url");
                    ?>
/wp-admin/plugins.php"><?php 
                    _e('Activate Contact Form to DB', 'contact_form');
                    ?>
</a></span>
									<?php 
                }
            } else {
                ?>
									<input disabled="disabled" type="checkbox" name="cntctfrm_save_email_to_db" value="1" />  
									<span style="color: #888888;font-size: 10px;">(<?php 
                _e('Using Contact Form to DB powered by', 'contact_form');
                ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>) <a href="http://bestwebsoft.com/plugin/contact-form-to-db-pro/?k=19d806f45d866e70545de83169b274f2&pn=77&v=<?php 
                echo $cntctfrm_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
"><?php 
                _e('Download Contact Form to DB', 'contact_form');
                ?>
</a></span>
								<?php 
            }
            ?>
							</td>
						</tr>			
						<tr valign="top">
							<th scope="row" style="width:200px;"><label><input type="checkbox" id="cntctfrm_additions_options" name="cntctfrm_additions_options" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "checked=\"checked\" ";
            }
            ?>
 /> <?php 
            _e("Additional options", 'contact_form');
            ?>
</label></th>
							<td colspan="2">
								<input id="cntctfrm_show_additional_settings" type="button" class="button-small button" value="<?php 
            _e("Show", 'contact_form');
            ?>
" style="display: none;">
								<input id="cntctfrm_hide_additional_settings" type="button" class="button-small button" value="<?php 
            _e("Hide", 'contact_form');
            ?>
" style="display: none;">
							</td>
						</tr>
						<tr class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e('What to use?', 'contact_form');
            ?>
</th>
							<td colspan="2">
								<label><input type='radio' name='cntctfrm_mail_method' value='wp-mail' <?php 
            if ('wp-mail' == $cntctfrm_options['cntctfrm_mail_method']) {
                echo "checked=\"checked\" ";
            }
            ?>
/>
								<?php 
            _e('Wp-mail', 'contact_form');
            ?>
</label> <span class="cntctfrm_info">(<?php 
            _e('You can use the wp_mail function for mailing', 'contact_form');
            ?>
)</span><br />
								<label><input type='radio' name='cntctfrm_mail_method' value='mail' <?php 
            if ('mail' == $cntctfrm_options['cntctfrm_mail_method']) {
                echo "checked=\"checked\" ";
            }
            ?>
/>
								<?php 
            _e('Mail', 'contact_form');
            ?>
 </label> <span class="cntctfrm_info">(<?php 
            _e('To send mail you can use the php mail function', 'contact_form');
            ?>
)</span><br />
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("The text in the 'From' field", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<label><input type="radio" id="cntctfrm_select_from_field" name="cntctfrm_select_from_field" value="user_name" <?php 
            if ('user_name' == $cntctfrm_options['cntctfrm_select_from_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("User name", 'contact_form');
            ?>
</label> 
								<span class="cntctfrm_info">(<?php 
            _e("The name of the user who fills the form will be used in the field 'From'.", 'contact_form');
            ?>
)</span><br/>
								<input type="radio" id="cntctfrm_select_from_custom_field" name="cntctfrm_select_from_field" value="custom" <?php 
            if ('custom' == $cntctfrm_options['cntctfrm_select_from_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> 
								<input type="text" style="width:200px;" name="cntctfrm_from_field" value="<?php 
            echo stripslashes($cntctfrm_options['cntctfrm_from_field']);
            ?>
" onfocus="document.getElementById('cntctfrm_select_from_custom_field').checked = true;" />
								<span  class="cntctfrm_info">(<?php 
            _e("This text will be used in the 'FROM' field", 'contact_form');
            ?>
)</span>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("The email address in the 'From' field", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<label><input type="radio" id="cntctfrm_from_email" name="cntctfrm_from_email" value="user" <?php 
            if ('user' == $cntctfrm_options['cntctfrm_from_email']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("User email", 'contact_form');
            ?>
 </label>
								<span class="cntctfrm_info">(<?php 
            _e("The email address of the user who fills the form will be used in the field 'From'.", 'contact_form');
            ?>
)</span><br />
								<input type="radio" id="cntctfrm_from_custom_email" name="cntctfrm_from_email" value="custom" <?php 
            if ('custom' == $cntctfrm_options['cntctfrm_from_email']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> 
								<input type="text" name="cntctfrm_custom_from_email" value="<?php 
            echo $cntctfrm_options['cntctfrm_custom_from_email'];
            ?>
" onfocus="document.getElementById('cntctfrm_from_custom_email').checked = true;" />
								<span class="cntctfrm_info">(<?php 
            _e("This email address will be used in the 'From' field.", 'contact_form');
            ?>
)</span>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Required symbol", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<input type="text" id="cntctfrm_required_symbol" name="cntctfrm_required_symbol" value="<?php 
            echo $cntctfrm_options['cntctfrm_required_symbol'];
            ?>
"/>
							</td>
						</tr>
					</table>
					<br />
					<table class="cntctfrm_settings_table cntctfrm_additions_block<?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo " cntctfrm_hidden";
            }
            ?>
" style="width:auto;">
						<thead>
							<tr valign="top">
								<th scope="row" style="width: 210px;"><?php 
            _e("Fields", 'contact_form');
            ?>
</th>
								<th><?php 
            _e("Used", 'contact_form');
            ?>
</th>
								<th><?php 
            _e("Required", 'contact_form');
            ?>
</th>
								<th><?php 
            _e("Visible", 'contact_form');
            ?>
</th>
								<th><?php 
            _e("Disabled for editing", 'contact_form');
            ?>
</th>
								<th scope="row" style="width:200px;"><?php 
            _e("Field's default value", 'contact_form');
            ?>
</th>
							</tr>
						</thead>
						<tbody>
							<tr valign="top">
								<td><?php 
            _e("Name", 'contact_form');
            ?>
</td>
								<td><input type="checkbox" name="cntctfrm_display_name_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_name_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td><input type="checkbox" id="cntctfrm_required_name_field" name="cntctfrm_required_name_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_name_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							<tr valign="top">
								<td><?php 
            _e("Address", 'contact_form');
            ?>
</td>
								<td><input type="checkbox" id="cntctfrm_display_address_field" name="cntctfrm_display_address_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_address_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td><input type="checkbox" id="cntctfrm_required_address_field" name="cntctfrm_required_address_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_address_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							<tr valign="top">
								<td><?php 
            _e("Email Address", 'contact_form');
            ?>
</td>
								<td></td>
								<td><input type="checkbox" id="cntctfrm_required_email_field" name="cntctfrm_required_email_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_email_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							<tr valign="top">
								<td><?php 
            _e("Phone number", 'contact_form');
            ?>
</td>
								<td><input type="checkbox" id="cntctfrm_display_phone_field" name="cntctfrm_display_phone_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_phone_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td><input type="checkbox" id="cntctfrm_required_phone_field" name="cntctfrm_required_phone_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_phone_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
							<tr valign="top">
								<td><?php 
            _e("Subject", 'contact_form');
            ?>
</td>
								<td></td>
								<td><input type="checkbox" id="cntctfrm_required_subject_field" name="cntctfrm_required_subject_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_subject_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td class="bws_pro_version"><input class="subject" disabled="disabled" type="checkbox" name="cntctfrmpr_visible_subject" value="1" /></td>
								<td class="bws_pro_version"><input class="subject" disabled="disabled" type="checkbox" name="cntctfrmpr_disabled_subject" value="1" /></td>						
								<td class="bws_pro_version"><input class="subject" disabled="disabled" type="text" name="cntctfrmpr_default_subject" value="" /></td>
							</tr>
							<tr valign="top">
								<td><?php 
            _e("Message", 'contact_form');
            ?>
</td>
								<td></td>
								<td><input type="checkbox" id="cntctfrm_required_message_field" name="cntctfrm_required_message_field" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_required_message_field']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>						
								<td class="bws_pro_version"><input class="message" disabled="disabled" type="checkbox" name="cntctfrmpr_visible_message" value="1" /></td>
								<td class="bws_pro_version"><input class="message" disabled="disabled" disabled="disabled" type="checkbox" name="cntctfrmpr_disabled_message" value="1" /></td>						
								<td class="bws_pro_version"><input class="message" disabled="disabled" type="text" name="cntctfrmpr_default_message" value="" /></td>
							</tr>
							<tr valign="top">
								<td></td>
								<td></td>
								<td></td>
								<td colspan="3" class="bws_pro_version_tooltip"> 
									<?php 
            _e('This functionality is available in the Pro version of the plugin. For more details, please follow the link', 'contact_form');
            ?>
									<a title="Contact Form Pro" target="_blank" href="http://bestwebsoft.com/plugin/contact-form-pro/?k=697c5e74f39779ce77850e11dbe21962&pn=77&v=<?php 
            echo $cntctfrm_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
"> <?php 
            _e('Contact Form Pro', 'contact_form');
            ?>
</a>
								</td>
							</tr>
							<tr valign="top">
								<td>
									<?php 
            _e("Attachment block", 'contact_form');
            ?>
 
									<div class="cntctfrm_help_box" style="margin: -3px 0 0; float:right;">
										<div class="cntctfrm_hidden_help_text" style="display: none;"><?php 
            echo __("Users can attach the following file formats", 'contact_form') . ": html, txt, css, gif, png, jpeg, jpg, tiff, bmp, ai, eps, ps, rtf, pdf, doc, docx, xls, zip, rar, wav, mp3, ppt, aar, sce";
            ?>
</div>
									</div>
								</td>
								<td><input type="checkbox" id="cntctfrm_attachment" name="cntctfrm_attachment" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_attachment']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
						</tbody>
					</table>
					<br />		
					<table class="form-table" style="width:auto;">
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Add to the form", 'contact_form');
            ?>
</th>
							<td style="width:750px;" colspan="3">
								<div style="clear: both;">
									<label style="float: left">
										<input type="checkbox" id="cntctfrm_attachment_explanations" name="cntctfrm_attachment_explanations" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_attachment_explanations'] && '1' == $cntctfrm_options['cntctfrm_attachment']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> 
										<?php 
            _e("Tips below the Attachment", 'contact_form');
            ?>
									</label> 
									<div class="cntctfrm_help_box" style="margin: -3px 0 0 10px;">
										<div class="cntctfrm_hidden_help_text" style="display: none;width: auto;"><img title="" src="<?php 
            echo plugins_url('images/tooltip_attachment_tips.png', __FILE__);
            ?>
" alt=""/></div>
									</div>
								</div>
								<div style="clear: both;">
									<label style="float: left">
										<input type="checkbox" id="cntctfrm_send_copy" name="cntctfrm_send_copy" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_send_copy']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> 
										<?php 
            _e("'Send me a copy' block", 'contact_form');
            ?>
									</label>
									<div class="cntctfrm_help_box" style="margin: -3px 0 0 10px;">
										<div class="cntctfrm_hidden_help_text" style="display: none;width: auto;"><img title="" src="<?php 
            echo plugins_url('images/tooltip_sendme_block.png', __FILE__);
            ?>
" alt=""/></div>
									</div>
								</div>
								<div style="clear: both;">
									<?php 
            if (array_key_exists('captcha/captcha.php', $all_plugins) || array_key_exists('captcha-pro/captcha_pro.php', $all_plugins)) {
                if (0 < count(preg_grep('/captcha\\/captcha.php/', $active_plugins)) || 0 < count(preg_grep('/captcha-pro\\/captcha_pro.php/', $active_plugins)) || is_plugin_active_for_network('captcha/captcha.php') || is_plugin_active_for_network('captcha-pro/captcha_pro.php')) {
                    ?>
											<label><input type="checkbox" name="cntctfrm_display_captcha" value="1" <?php 
                    if (isset($cptch_options) && 1 == $cptch_options["cptch_contact_form"] || isset($cptchpr_options) && 1 == $cptchpr_options["cptchpr_contact_form"]) {
                        echo "checked=\"checked\"";
                    }
                    ?>
 />
											<?php 
                    _e("Captcha", 'contact_form');
                    ?>
</label> <span style="color: #888888;font-size: 10px;">(<?php 
                    _e('powered by', 'contact_form');
                    ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>)</span>
										<?php 
                } else {
                    ?>
											<label><input disabled="disabled" type="checkbox" name="cntctfrm_display_captcha" value="1" <?php 
                    if (isset($cptch_options) && 1 == $cptch_options["cptch_contact_form"] || isset($cptchpr_options) && 1 == $cptchpr_options["cptchpr_contact_form"]) {
                        echo "checked=\"checked\"";
                    }
                    ?>
 /> 
											<?php 
                    _e('Captcha', 'contact_form');
                    ?>
</label> <span style="color: #888888;font-size: 10px;">(<?php 
                    _e('powered by', 'contact_form');
                    ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>) <a href="<?php 
                    echo bloginfo("url");
                    ?>
/wp-admin/plugins.php"><?php 
                    _e('Activate captcha', 'contact_form');
                    ?>
</a></span>
										<?php 
                }
            } else {
                ?>
										<label><input disabled="disabled" type="checkbox" name="cntctfrm_display_captcha" value="1" /> 
										<?php 
                _e('Captcha', 'contact_form');
                ?>
</label> <span style="color: #888888;font-size: 10px;">(<?php 
                _e('powered by', 'contact_form');
                ?>
 <a href="http://bestwebsoft.com/plugin/">bestwebsoft.com</a>) <a href="http://bestwebsoft.com/plugin/captcha-pro/?k=19ac1e9b23bea947cfc4a9b8e3326c03&pn=77&v=<?php 
                echo $cntctfrm_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
"><?php 
                _e('Download captcha', 'contact_form');
                ?>
</a></span>
									<?php 
            }
            ?>
								</div>						
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"></th>
							<td colspan="3" class="bws_pro_version">
								<label><input disabled="disabled" type="checkbox" value="1" name="cntctfrmpr_display_privacy_check"> <?php 
            _e('Agreement checkbox', 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;">(<?php 
            _e('Required checkbox for submitting the form', 'contact_form');
            ?>
)</span><br />
								<label><input disabled="disabled" type="checkbox" value="1" name="cntctfrmpr_display_optional_check"> <?php 
            _e('Optional checkbox', 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;">(<?php 
            _e('Optional checkbox, the results of which will be displayed in email', 'contact_form');
            ?>
)</span><br />
							</td>					
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th></th>
							<td colspan="3" class="bws_pro_version_tooltip"> 
								<?php 
            _e('This functionality is available in the Pro version of the plugin. For more details, please follow the link', 'contact_form');
            ?>
								<a title="Contact Form Pro" target="_blank" href="http://bestwebsoft.com/plugin/contact-form-pro/?k=697c5e74f39779ce77850e11dbe21962&pn=77&v=<?php 
            echo $cntctfrm_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
"> <?php 
            _e('Contact Form Pro', 'contact_form');
            ?>
</a>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Delete an attachment file from the server after the email is sent", 'contact_form');
            ?>
 </th>
							<td colspan="3">
								<input type="checkbox" id="cntctfrm_delete_attached_file" name="cntctfrm_delete_attached_file" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_delete_attached_file']) {
                echo "checked=\"checked\" ";
            }
            ?>
/>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Email in HTML format sending", 'contact_form');
            ?>
</th>
							<td colspan="2"><input type="checkbox" name="cntctfrm_html_email" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_html_email']) {
                echo "checked=\"checked\" ";
            }
            ?>
/></td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ($cntctfrm_options['cntctfrm_additions_options'] == '0') {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Display additional info in the email", 'contact_form');
            ?>
</th>
							<td style="width:15px;">
								<input type="checkbox" id="cntctfrm_display_add_info" name="cntctfrm_display_add_info" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_add_info']) {
                echo "checked=\"checked\" ";
            }
            ?>
/>
							</td>
							<td style="max-width:150px;" class="cntctfrm_display_add_info_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_display_add_info']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
								<label><input type="checkbox" id="cntctfrm_display_sent_from" name="cntctfrm_display_sent_from" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_sent_from']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Sent from (ip address)", 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;"><?php 
            _e("Example: Sent from (IP address):\t127.0.0.1", 'contact_form');
            ?>
</span><br />
								<label><input type="checkbox" id="cntctfrm_display_date_time" name="cntctfrm_display_date_time" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_date_time']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Date/Time", 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;"><?php 
            _e("Example: Date/Time:\tAugust 19, 2013 8:50 pm", 'contact_form');
            ?>
</span><br />
								<label><input type="checkbox" id="cntctfrm_display_coming_from" name="cntctfrm_display_coming_from" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_coming_from']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Sent from (referer)", 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;"><?php 
            _e("Example: Sent from (referer):\thttp://bestwebsoft.com/contacts/contact-us/", 'contact_form');
            ?>
</span><br />
								<label><input type="checkbox" id="cntctfrm_display_user_agent" name="cntctfrm_display_user_agent" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_user_agent']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Using (user agent)", 'contact_form');
            ?>
</label> <span style="color: #888888;font-size: 10px;"><?php 
            _e("Example: Using (user agent):\tMozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36", 'contact_form');
            ?>
</span><br />
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Language settings for the field names in the form", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<select name="cntctfrm_languages" id="cntctfrm_languages" style="width:300px;">
								<?php 
            foreach ($lang_codes as $key => $val) {
                if (in_array($key, $cntctfrm_options['cntctfrm_language'])) {
                    continue;
                }
                echo '<option value="' . esc_attr($key) . '"> ' . esc_html($val) . '</option>';
            }
            ?>
								</select>
								<input type="button" class="button-primary" id="cntctfrm_add_language_button" value="<?php 
            _e('Add a language', 'contact_form');
            ?>
" />
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Change the names of the contact form fields and error messages", 'contact_form');
            ?>
</th>
							<td style="width:15px;">
								<input type="checkbox" id="cntctfrm_change_label" name="cntctfrm_change_label" value="1" <?php 
            if ($cntctfrm_options['cntctfrm_change_label'] == '1') {
                echo "checked=\"checked\" ";
            }
            ?>
/>
							</td>
							<td class="cntctfrm_change_label_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_change_label']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
								<div class="cntctfrm_label_language_tab cntctfrm_active" id="cntctfrm_label_en"><?php 
            _e('English', 'contact_form');
            ?>
</div>
								<?php 
            if (!empty($cntctfrm_options['cntctfrm_language'])) {
                foreach ($cntctfrm_options['cntctfrm_language'] as $val) {
                    echo '<div class="cntctfrm_label_language_tab" id="cntctfrm_label_' . $val . '">' . $lang_codes[$val] . ' <span class="cntctfrm_delete" rel="' . $val . '">X</span></div>';
                }
            }
            ?>
								<div class="clear"></div>
								<div class="cntctfrm_language_tab cntctfrm_tab_en">
									<div class="cntctfrm_language_tab_block_mini" style="display:none;"><?php 
            _e("click to expand/hide the list", 'contact_form');
            ?>
</div>
									<div class="cntctfrm_language_tab_block">
										<input type="text" name="cntctfrm_name_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_name_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Name:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_address_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_address_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Address:", 'contact_form');
            ?>
</span><br />							
										<input type="text" name="cntctfrm_email_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_email_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Email Address:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_phone_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_phone_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Phone number:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_subject_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_subject_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Subject:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_message_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_message_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Message:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_attachment_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Attachment:", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_attachment_tooltip[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_tooltip']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Tips below the Attachment block", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_send_copy_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_send_copy_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Send me a copy", 'contact_form');
            ?>
</span><br />							
										<input type="text" name="cntctfrm_submit_label[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_submit_label']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Submit", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_name_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_name_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Name field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_address_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_address_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Address field", 'contact_form');
            ?>
</span><br />							
										<input type="text" name="cntctfrm_email_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_email_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Email field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_phone_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_phone_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Phone field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_subject_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_subject_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Subject field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_message_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_message_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Message field", 'contact_form');
            ?>
</span><br />							
										<input type="text" name="cntctfrm_attachment_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message about the file type for the Attachment field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_attachment_upload_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_upload_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message while uploading a file for the Attachment field to the server", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_attachment_move_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_move_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message while moving the file for the Attachment field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_attachment_size_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_attachment_size_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message when file size limit for the Attachment field is exceeded", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_captcha_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_captcha_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the Captcha field", 'contact_form');
            ?>
</span><br />
										<input type="text" name="cntctfrm_form_error[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_form_error']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Error message for the whole form", 'contact_form');
            ?>
</span><br />
									</div>
									<span class="cntctfrm_info" style="margin-left: 5px;"><?php 
            _e("Use shortcode", 'contact_form');
            echo " [bestwebsoft_contact_form lang=en] " . __("or", 'contact_form') . " [bestwebsoft_contact_form] ";
            _e("for this language", 'contact_form');
            ?>
</span>
								</div>
								<?php 
            if (!empty($cntctfrm_options['cntctfrm_language'])) {
                foreach ($cntctfrm_options['cntctfrm_language'] as $val) {
                    ?>
										<div class="cntctfrm_language_tab hidden cntctfrm_tab_<?php 
                    echo $val;
                    ?>
">
											<div class="cntctfrm_language_tab_block_mini" style="display:none;"><?php 
                    _e("click to expand/hide the list", 'contact_form');
                    ?>
</div>
											<div class="cntctfrm_language_tab_block">
												<input type="text" name="cntctfrm_name_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_name_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_name_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Name:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_address_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_address_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_address_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Address:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_email_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_email_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_email_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Email Address:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_phone_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_phone_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_phone_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Phone number:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_subject_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_subject_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_subject_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Subject:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_message_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_message_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_message_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Message:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_attachment_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Attachment:", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_attachment_tooltip[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_tooltip'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_tooltip'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Tips below the Attachment block", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_send_copy_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_send_copy_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_send_copy_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Send me a copy", 'contact_form');
                    ?>
</span><br />								
												<input type="text" name="cntctfrm_submit_label[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_submit_label'][$val])) {
                        echo $cntctfrm_options['cntctfrm_submit_label'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Submit", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_name_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_name_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_name_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Name field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_address_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_address_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_address_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Address field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_email_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_email_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_email_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Email field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_phone_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_phone_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_phone_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Phone field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_subject_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_subject_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_subject_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Subject field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_message_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_message_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_message_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Message field", 'contact_form');
                    ?>
</span><br />									
												<input type="text" name="cntctfrm_attachment_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message about the file type for the Attachment field", 'contact_form');
                    ?>
</span><br />									
												<input type="text" name="cntctfrm_attachment_upload_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_upload_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_upload_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message while uploading a file for the Attachment field to the server", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_attachment_move_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_move_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_move_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message while moving the file for the Attachment field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_attachment_size_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_attachment_size_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_attachment_size_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message when file size limit for the Attachment field is exceeded", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_captcha_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_captcha_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_captcha_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the Captcha field", 'contact_form');
                    ?>
</span><br />
												<input type="text" name="cntctfrm_form_error[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_form_error'][$val])) {
                        echo $cntctfrm_options['cntctfrm_form_error'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Error message for the whole form", 'contact_form');
                    ?>
</span><br />
											</div>
											<span class="cntctfrm_info" style="margin-left: 5px;"><?php 
                    _e("Use shortcode", 'contact_form');
                    echo " [bestwebsoft_contact_form lang=" . $val . "] ";
                    _e("for this language", 'contact_form');
                    ?>
</span>
										</div>
									<?php 
                }
            }
            ?>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Action after email is sent", 'contact_form');
            ?>
</th>
							<td colspan="2" class="cntctfrm_action_after_send_block">
								<label><input type="radio" id="cntctfrm_action_after_send" name="cntctfrm_action_after_send" value="1" <?php 
            if ('1' == $cntctfrm_options['cntctfrm_action_after_send']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Display text", 'contact_form');
            ?>
</label><br />
								<div class="cntctfrm_label_language_tab cntctfrm_active" id="cntctfrm_text_en"><?php 
            _e('English', 'contact_form');
            ?>
</div>
								<?php 
            if (!empty($cntctfrm_options['cntctfrm_language'])) {
                foreach ($cntctfrm_options['cntctfrm_language'] as $val) {
                    echo '<div class="cntctfrm_label_language_tab" id="cntctfrm_text_' . $val . '">' . $lang_codes[$val] . ' <span class="cntctfrm_delete" rel="' . $val . '">X</span></div>';
                }
            }
            ?>
								<div class="clear"></div>
								<div class="cntctfrm_language_tab cntctfrm_tab_en" style=" padding: 5px 10px 5px 5px;">
									<input type="text" name="cntctfrm_thank_text[en]" value="<?php 
            echo $cntctfrm_options['cntctfrm_thank_text']['en'];
            ?>
" /> <span class="cntctfrm_info"><?php 
            _e("Text", 'contact_form');
            ?>
</span><br />
									<span class="cntctfrm_info"><?php 
            _e("Use shortcode", 'contact_form');
            echo " [bestwebsoft_contact_form lang=en] " . __("or", 'contact_form') . " [bestwebsoft_contact_form] ";
            _e("for this language", 'contact_form');
            ?>
</span>
								</div>
								<?php 
            if (!empty($cntctfrm_options['cntctfrm_language'])) {
                foreach ($cntctfrm_options['cntctfrm_language'] as $val) {
                    ?>
										<div class="cntctfrm_language_tab hidden cntctfrm_tab_<?php 
                    echo $val;
                    ?>
" style=" padding: 5px 10px 5px 5px;">
											<input type="text" name="cntctfrm_thank_text[<?php 
                    echo $val;
                    ?>
]" value="<?php 
                    if (isset($cntctfrm_options['cntctfrm_thank_text'][$val])) {
                        echo $cntctfrm_options['cntctfrm_thank_text'][$val];
                    }
                    ?>
" /> <span class="cntctfrm_info"><?php 
                    _e("Text", 'contact_form');
                    ?>
</span><br />
											<span class="cntctfrm_info"><?php 
                    _e("Use shortcode", 'contact_form');
                    echo " [bestwebsoft_contact_form lang=" . $val . "] ";
                    _e("for this language", 'contact_form');
                    ?>
</span>
										</div>
									<?php 
                }
            }
            ?>
								<div id="cntctfrm_before"></div>
								<br />
								<input type="radio" id="cntctfrm_action_after_send_url" name="cntctfrm_action_after_send" value="0" <?php 
            if ('0' == $cntctfrm_options['cntctfrm_action_after_send']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> <?php 
            _e("Redirect to the page", 'contact_form');
            ?>
<br />
								<input type="text" name="cntctfrm_redirect_url" value="<?php 
            echo $cntctfrm_options['cntctfrm_redirect_url'];
            ?>
" onfocus="document.getElementById('cntctfrm_action_after_send_url').checked = true;" /> <span class="cntctfrm_info"><?php 
            _e("Url", 'contact_form');
            ?>
</span>
							</td>
						</tr>
						<tr valign="top" class="cntctfrm_additions_block <?php 
            if ('0' == $cntctfrm_options['cntctfrm_additions_options']) {
                echo "cntctfrm_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e('The $_SERVER variable that is used to build a URL of the form', 'contact_form');
            ?>
</th>
							<td colspan="2">
								<label><input type="radio" name="cntctfrm_site_name_parameter" value="HTTP_HOST" <?php 
            if ('SERVER_NAME' == $cntctfrm_options['cntctfrm_site_name_parameter']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> SERVER_NAME</label><br />
								<label><input type="radio" name="cntctfrm_site_name_parameter" value="HTTP_HOST" <?php 
            if ('HTTP_HOST' == $cntctfrm_options['cntctfrm_site_name_parameter']) {
                echo "checked=\"checked\" ";
            }
            ?>
/> HTTP_HOST</label><br />
								<span class="cntctfrm_info"><?php 
            _e("If you are not sure whether to change this setting or not, please do not do that.", 'contact_form');
            ?>
</span>
							</td>
						</tr>
					</table>    
					<input type="hidden" name="cntctfrm_form_submit" value="submit" />
					<p class="submit">
						<input type="submit" class="button-primary" value="<?php 
            _e('Save Changes');
            ?>
" />
					</p>
					<?php 
            wp_nonce_field(plugin_basename(__FILE__), 'cntctfrm_nonce_name');
            ?>
					<div class="bws-plugin-reviews">
						<div class="bws-plugin-reviews-rate">
						<?php 
            _e('If you enjoy our plugin, please give it 5 stars on WordPress', 'contact_form');
            ?>
: 
						<a href="http://wordpress.org/support/view/plugin-reviews/contact-form-plugin" target="_blank" title="Contact Form reviews"><?php 
            _e('Rate the plugin', 'contact_form');
            ?>
</a><br/>
						</div>
						<div class="bws-plugin-reviews-support">
						<?php 
            _e('If there is something wrong about it, please contact us', 'contact_form');
            ?>
: 
						<a href="http://support.bestwebsoft.com">http://support.bestwebsoft.com</a>
						</div>
					</div>
				</form>	
			<?php 
        } elseif ('extra' == $_GET['action']) {
            ?>
				<div id="cntctfrmpr_left_table">
					<table class="form-table bws_pro_version" style="width:auto;" >
						<tr class="bws_pro_version_tooltip">
							<th scope="row" colspan="2">
								<?php 
            _e('This functionality is available in the Pro version of the plugin. For more details, please follow the link', 'contact_form');
            ?>
								<a title="Contact Form Pro" target="_blank" href="http://bestwebsoft.com/plugin/contact-form-pro/?k=697c5e74f39779ce77850e11dbe21962&pn=77&v=<?php 
            echo $cntctfrm_plugin_info["Version"];
            ?>
&wp_v=<?php 
            echo $wp_version;
            ?>
"> <?php 
            _e('Contact Form Pro', 'contact_form');
            ?>
</a>
							</th>
						</tr>
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Errors output", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<select name="cntctfrmpr_error_displaying">
									<option value="labels"><?php 
            _e("Display error messages", 'contact_form');
            ?>
</option>
									<option value="input_colors"><?php 
            _e("Color of the input field errors.", 'contact_form');
            ?>
</option>
									<option value="both" selected="selected"><?php 
            _e("Display error messages & color of the input field errors", 'contact_form');
            ?>
</option>
								</select>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Add placeholder to the input blocks", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<input disabled='disabled' type="checkbox" name="cntctfrmpr_placeholder" value="1" checked="checked"/>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row" style="width:200px;"><?php 
            _e("Add tooltips", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<div>
									<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_name" value="1" checked="checked"/>
									<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_name"><?php 
            _e("Name", 'contact_form');
            ?>
</label>
								</div>
								<?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_address_field']) {
                ?>
									<div>
										<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_address" value="1" checked="checked"/>
										<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_address"><?php 
                _e("Address", 'contact_form');
                ?>
</label>
									</div>
								<?php 
            }
            ?>
								<div>
									<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_email" value="1" checked="checked"/>
									<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_email"><?php 
            _e("Email address", 'contact_form');
            ?>
</label>
								</div>
								<?php 
            if ('1' == $cntctfrm_options['cntctfrm_display_phone_field']) {
                ?>
									<div>
										<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_phone" value="1" checked="checked"/>
										<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_phone"><?php 
                _e("Phone Number", 'contact_form');
                ?>
</label>
									</div>
								<?php 
            }
            ?>
								<div>
									<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_subject" value="1" checked="checked"/>
									<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_subject"><?php 
            _e("Subject", 'contact_form');
            ?>
</label>
								</div>
								<div>
									<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_message" value="1" checked="checked"/>
									<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_message"><?php 
            _e("Message", 'contact_form');
            ?>
</label>
								</div>
								<?php 
            if ('1' == $cntctfrm_options['cntctfrm_attachment_explanations']) {
                ?>
									<div>
										<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_attachment" value="1" checked="checked"/>
										<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_attachment"><?php 
                _e("Attachment", 'contact_form');
                ?>
</label>
									</div>
								<?php 
            }
            ?>
								<div>
									<input disabled='disabled' type="checkbox" name="cntctfrmpr_tooltip_display_captcha" value="1" />
									<label class="cntctfrmpr_tooltip_label" for="cntctfrmpr_tooltip_display_captcha"><?php 
            _e("Captcha", 'contact_form');
            ?>
 </label><span style="color: #888888;font-size: 10px;"><?php 
            _e('(powered by bestwebsoft.com)', 'contact_form');
            ?>
</span>
								</div>									
							</td>
						</tr>
						<tr valign="top">
							<th colspan="3" scope="row" style="width:200px;"><input disabled='disabled' type="checkbox" id="cntctfrmpr_style_options" name="cntctfrmpr_style_options" value="1" checked="checked" /> <?php 
            _e("Style options", 'contact_form');
            ?>
</th>
						</tr>				
						<tr valign="top" class="cntctfrmpr_style_block <?php 
            if ('0' == $cntctfrm_options['style_options']) {
                echo "cntctfrmpr_hidden";
            }
            ?>
">
							<th scope="row" style="width:200px;"><?php 
            _e("Text color", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_label_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e('Label text color', 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_input_placeholder_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e("Placeholder color", 'contact_form');
            ?>
								</div>
							</td>
						</tr>
						<tr valign="top" class="cntctfrmpr_style_block">
							<th scope="row" style="width:200px;"><?php 
            _e("Errors color", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_error_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e('Error text color', 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_error_input_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e('Background color of the input field errors', 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_error_input_border_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e('Border color of the input field errors', 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" id="" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_input_placeholder_error_color" value="" class="cntctfrmpr_colorPicker " />
									<?php 
            _e("Placeholder color of the input field errors", 'contact_form');
            ?>
								</div>
							</td>
						</tr>					
						<tr valign="top" class="cntctfrmpr_style_block">
							<th scope="row" style="width:200px;"><?php 
            _e("Input fields", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" id="" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_input_background" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e("Input fields background color", 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_input_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e("Text fields color", 'contact_form');
            ?>
								</div>
								<input disabled='disabled' style="margin-left: 66px;" size="8" type="text" value="" name="cntctfrmpr_border_input_width" /> <?php 
            _e('Border width in px, numbers only', 'contact_form');
            ?>
<br />
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />								
									<input disabled='disabled' type="text" name="cntctfrmpr_border_input_color" value="" class="cntctfrmpr_colorPicker" />
									 <?php 
            _e('Border color', 'contact_form');
            ?>
								</div>
							</td>
						</tr>
						<tr valign="top" class="cntctfrmpr_style_block">
							<th scope="row" style="width:200px;"><?php 
            _e("Submit button", 'contact_form');
            ?>
</th>
							<td colspan="2">
								<input disabled='disabled' style="margin-left: 66px;" size="8" type="text" value="" name="cntctfrmpr_button_width" /> <?php 
            _e('Width in px, numbers only', 'contact_form');
            ?>
<br />
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_button_backgroud" value="" class="cntctfrmpr_colorPicker" />
									 <?php 
            _e('Button color', 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_button_color" value="" class="cntctfrmpr_colorPicker" />
									<?php 
            _e("Button text color", 'contact_form');
            ?>
								</div>
								<div>
									<input disabled='disabled' type="button" class="cntctfrmpr_default button-small button" value="<?php 
            _e('Default', 'contact_form');
            ?>
" />
									<input disabled='disabled' type="text" name="cntctfrmpr_border_button_color" value="" class="cntctfrmpr_colorPicker" />
									 <?php 
            _e('Border color', 'contact_form');
            ?>
								</div>
							</td>
						</tr>
						<tr valign="top">
							<th scope="row" colspan="2">
								* <?php 
            _e('If you upgrade to Pro version all your settings will be saved.', 'contact_form');
            ?>
							</th>
						</tr>				
					</table>    
					<input type="hidden" name="cntctfrmpr_form_submit" value="submit" />
					<p class="submit">
						<input disabled='disabled' type="button" class="button-primary" value="<?php 
            _e('Save Changes');
            ?>
" />
					</p>
				</div>
				<div id="cntctfrmpr_right_table">
					<h3><?php 
            _e("Contact Form Pro | Preview", 'contact_form');
            ?>
</h3>
					<div id="cntctfrmpr_contact_form">
						<div id="cntctfrmpr_show_errors_block">
							<input disabled="" type="checkbox" id="cntctfrmpr_show_errors" name="cntctfrmpr_show_errors" /> <?php 
            _e("Show with errors", 'contact_form');
            ?>
						</div>
						<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
            echo $cntctfrm_options['cntctfrm_form_error']['en'];
            ?>
</div>
						<div style="text-align: left; padding-top: 5px;">
							<label for="cntctfrmpr_contact_name"><?php 
            echo $cntctfrm_options['cntctfrm_name_label']['en'];
            if (1 == $cntctfrm_options['cntctfrm_required_name_field']) {
                echo '<span class="required"> *</span>';
            }
            ?>
</label>
						</div>
						<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
            echo $cntctfrm_options['cntctfrm_name_error']['en'];
            ?>
</div>
						<div style="text-align: left;">
							<input placeholder="<?php 
            _e("Please enter your full name...", 'contact_form');
            ?>
" class="text" type="text" size="40" value="" name="cntctfrmpr_contact_name" id="cntctfrmpr_contact_name" style="text-align: left; margin: 0;" />
							<div class="cntctfrmpr_help_box">
								<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
            _e("Please enter your full name...", 'contact_form');
            ?>
</div>
							</div>
						</div>
						<?php 
            if (1 == $cntctfrm_options['cntctfrm_display_address_field']) {
                ?>
							<div style="text-align: left;">
								<label for="cntctfrmpr_contact_address"><?php 
                echo $cntctfrm_options['cntctfrm_address_label']['en'];
                if (1 == $cntctfrm_options['cntctfrm_required_address_field']) {
                    echo '<span class="required"> *</span>';
                }
                ?>
</label>
							</div>
							<?php 
                if (1 == $cntctfrm_options['cntctfrm_required_address_field']) {
                    ?>
								<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
                    echo $cntctfrm_options['cntctfrm_address_error']['en'];
                    ?>
</div>
							<?php 
                }
                ?>
							<div style="text-align: left;">
								<input placeholder="<?php 
                _e("Please enter your address...", 'contact_form');
                ?>
" class="text" type="text" size="40" value="" name="cntctfrmpr_contact_address" id="cntctfrmpr_contact_address" style="text-align: left; margin: 0;" />
								<div class="cntctfrmpr_help_box">
									<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
                _e("Please enter your address...", 'contact_form');
                ?>
</div>
								</div>
							</div>
						<?php 
            }
            ?>
						<div style="text-align: left;">
							<label for="cntctfrmpr_contact_email"><?php 
            echo $cntctfrm_options['cntctfrm_email_label']['en'];
            if (1 == $cntctfrm_options['cntctfrm_required_email_field']) {
                echo '<span class="required"> *</span>';
            }
            ?>
</label>
						</div>
						<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
            echo $cntctfrm_options['cntctfrm_email_error']['en'];
            ?>
</div>
						<div style="text-align: left;">
							<input placeholder="<?php 
            _e("Please enter your email address...", 'contact_form');
            ?>
" class="text" type="text" size="40" value="" name="cntctfrmpr_contact_email" id="cntctfrmpr_contact_email" style="text-align: left; margin: 0;" />
							<div class="cntctfrmpr_help_box">
								<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
            _e("Please enter your email address...", 'contact_form');
            ?>
</div>
							</div>
						</div>
						<?php 
            if (1 == $cntctfrm_options['cntctfrm_display_phone_field']) {
                ?>
							<div style="text-align: left;">
								<label for="cntctfrmpr_contact_phone"><?php 
                echo $cntctfrm_options['cntctfrm_phone_label']['en'];
                if (1 == $cntctfrm_options['cntctfrm_required_phone_field']) {
                    echo '<span class="required"> *</span>';
                }
                ?>
</label>
							</div>
							<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
                echo $cntctfrm_options['phone_error']['en'];
                ?>
</div>
							<div style="text-align: left;">
								<input placeholder="<?php 
                _e("Please enter your phone number...", 'contact_form');
                ?>
" class="text" type="text" size="40" value="" name="cntctfrmpr_contact_phone" id="cntctfrmpr_contact_phone" style="text-align: left; margin: 0;" />
								<div class="cntctfrmpr_help_box">
									<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
                _e("Please enter your phone number...", 'contact_form');
                ?>
</div>
								</div>
							</div>
						<?php 
            }
            ?>
						<div style="text-align: left;">
							<label for="cntctfrmpr_contact_subject"><?php 
            echo $cntctfrm_options['cntctfrm_subject_label']['en'];
            if (1 == $cntctfrm_options['cntctfrm_required_subject_field']) {
                echo '<span class="required"> *</span>';
            }
            ?>
</label>
						</div>
						<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
            echo $cntctfrm_options['cntctfrm_subject_error']['en'];
            ?>
</div>
						<div style="text-align: left;">
							<input placeholder="<?php 
            _e("Please enter subject...", 'contact_form');
            ?>
" class="text" type="text" size="40" value="" name="cntctfrmpr_contact_subject" id="cntctfrmpr_contact_subject" style="text-align: left; margin: 0;" />
							<div class="cntctfrmpr_help_box">
								<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
            _e("Please enter subject...", 'contact_form');
            ?>
</div>
							</div>
						</div>
						<div style="text-align: left;">
							<label for="cntctfrmpr_contact_message"><?php 
            echo $cntctfrm_options['cntctfrm_message_label']['en'];
            if (1 == $cntctfrm_options['cntctfrm_required_message_field']) {
                echo '<span class="required"> *</span>';
            }
            ?>
</label>
						</div>
						<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
            echo $cntctfrm_options['cntctfrm_message_error']['en'];
            ?>
</div>
						<div style="text-align: left;">
							<textarea placeholder="<?php 
            _e("Please enter your message...", 'contact_form');
            ?>
" rows="5" cols="30" name="cntctfrmpr_contact_message" id="cntctfrmpr_contact_message"></textarea>
							<div class="cntctfrmpr_help_box">
								<div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
            _e("Please enter your message...", 'contact_form');
            ?>
</div>
							</div>
						</div>
						<?php 
            if (1 == $cntctfrm_options['cntctfrm_attachment']) {
                ?>
							<div style="text-align: left;">
								<label for="cntctfrmpr_contact_attachment"><?php 
                echo $cntctfrm_options['cntctfrm_attachment_label']['en'];
                ?>
</label>
							</div>					
							<div class="cntctfrmpr_error_text hidden" style="text-align: left;"><?php 
                echo $cntctfrm_options['cntctfrm_attachment_error']['en'];
                ?>
</div>
							<div style="text-align: left;">
							<input type="file" name="cntctfrmpr_contact_attachment" id="cntctfrmpr_contact_attachment" style="float:left;" />
							<?php 
                if (1 == $cntctfrm_options['cntctfrm_attachment_explanations']) {
                    ?>
								<div class="cntctfrmpr_help_box cntctfrmpr_hidden_help_text_attach"><div class="cntctfrmpr_hidden_help_text" style="font-size: 12px; display: none;"><?php 
                    echo $cntctfrm_options['cntctfrm_attachment_tooltip']['en'];
                    ?>
</div></div>
							<?php 
                }
                ?>
							</div>
						<?php 
            }
            ?>
						<?php 
            if (1 == $cntctfrm_options['cntctfrm_send_copy']) {
                ?>
							<div style="text-align: left;">
								<input type="checkbox" value="1" name="cntctfrmpr_contact_send_copy" id="cntctfrmpr_contact_send_copy" style="text-align: left; margin: 0;" />
								<label for="cntctfrmpr_contact_send_copy"><?php 
                echo $cntctfrm_options['cntctfrm_send_copy_label']['en'];
                ?>
</label>
							</div>
						<?php 
            }
            ?>
					
						<div style="text-align: left; padding-top: 8px;">
							<input type="submit" value="<?php 
            echo $cntctfrm_options['cntctfrm_submit_label']['en'];
            ?>
" style="cursor: pointer; margin: 0pt; text-align: center;margin-bottom:10px;" /> 
						</div>				
					</div>
					<div id="cntctfrmpr_shortcode">
						<?php 
            _e("If you would like to add the Contact Form to your website, just copy and paste this shortcode to your post or page or widget:", 'contact_form');
            ?>
<br/>
						<div>
							<code id="cntctfrmpr_shortcode_code">
								[bestwebsoft_contact_form]
							</code>					
						</div>
					</div>
				</div>
				<div class="clear"></div>	
			<?php 
        } elseif ('go_pro' == $_GET['action']) {
            ?>
				<?php 
            if (isset($pro_plugin_is_activated) && true === $pro_plugin_is_activated) {
                ?>
					<script type="text/javascript">
						window.setTimeout( function() {
						    window.location.href = 'admin.php?page=contact_form_pro.php';
						}, 5000 );
					</script>				
					<p><?php 
                _e("Congratulations! The PRO version of the plugin is successfully download and activated.", 'contact_form');
                ?>
</p>
					<p>
						<?php 
                _e("Please, go to", 'contact_form');
                ?>
 <a href="admin.php?page=contact_form_pro.php"><?php 
                _e('the setting page', 'contact_form');
                ?>
</a> 
						(<?php 
                _e("You will be redirected automatically in 5 seconds.", 'contact_form');
                ?>
)
					</p>
				<?php 
            } else {
                ?>
					<form method="post" action="admin.php?page=contact_form.php&amp;action=go_pro">
						<p>
							<?php 
                _e('You can download and activate', 'contact_form');
                ?>
 
							<a href="http://bestwebsoft.com/plugin/contact-form-pro/?k=697c5e74f39779ce77850e11dbe21962&pn=77&v=<?php 
                echo $cntctfrm_plugin_info["Version"];
                ?>
&wp_v=<?php 
                echo $wp_version;
                ?>
" target="_blank" title="Contact Form Pro">PRO</a> 
							<?php 
                _e('version of this plugin by entering Your license key.', 'contact_form');
                ?>
<br />
							<span style="color: #888888;font-size: 10px;">
								<?php 
                _e('You can find your license key on your personal page Client area, by clicking on the link', 'contact_form');
                ?>
 
								<a href="http://bestwebsoft.com/wp-login.php">http://bestwebsoft.com/wp-login.php</a> 
								<?php 
                _e('(your username is the email you specify when purchasing the product).', 'contact_form');
                ?>
							</span>
						</p>
						<?php 
                if (isset($bstwbsftwppdtplgns_options['go_pro']['contact-form-pro/contact_form_pro.php']['count']) && '5' < $bstwbsftwppdtplgns_options['go_pro']['contact-form-pro/contact_form_pro.php']['count'] && $bstwbsftwppdtplgns_options['go_pro']['contact-form-pro/contact_form_pro.php']['time'] < time() + 24 * 60 * 60) {
                    ?>
							<p>
								<input disabled="disabled" type="text" name="bws_license_key" value="<?php 
                    echo $bws_license_key;
                    ?>
" />
								<input disabled="disabled" type="submit" class="button-primary" value="<?php 
                    _e('Go!', 'contact_form');
                    ?>
" />
							</p>
							<p>
								<?php 
                    _e("Unfortunately, you have exceeded the number of available tries per day. Please, upload the plugin manually.", 'contact_form');
                    ?>
							</p>
						<?php 
                } else {
                    ?>
							<p>
								<input type="text" name="bws_license_key" value="<?php 
                    echo $bws_license_key;
                    ?>
" />
								<input type="hidden" name="bws_license_plugin" value="contact-form-pro/contact_form_pro.php" />
								<input type="hidden" name="bws_license_submit" value="submit" />
								<input type="submit" class="button-primary" value="<?php 
                    _e('Go!', 'contact_form');
                    ?>
" />
								<?php 
                    wp_nonce_field(plugin_basename(__FILE__), 'bws_license_nonce_name');
                    ?>
							</p>
						<?php 
                }
                ?>
					</form>
				<?php 
            }
        }
        ?>
		</div>
	<?php 
    }
Ejemplo n.º 23
0
<?php

$pd = new PharData(__DIR__ . '/tgz/with_symlink.tar.gz');
$tempdir = tempnam(sys_get_temp_dir(), '');
unlink($tempdir);
mkdir($tempdir);
$pd->extractTo($tempdir);
$fi = new SplFileInfo($tempdir . '/foo/herp');
var_dump($fi->isLink());
var_dump($fi->getLinkTarget());
$rdi = new RecursiveDirectoryIterator($tempdir, FileSystemIterator::SKIP_DOTS);
$rii = new RecursiveIteratorIterator($rdi, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($rii as $path => $info) {
    if ($info->isDir()) {
        rmdir($path);
    } else {
        unlink($path);
    }
}
rmdir($tempdir);
Ejemplo n.º 24
0
 if ($decompressData) {
     fwrite(STDERR, "Decompresing files." . PHP_EOL);
     $clearFolderName = pathinfo($filename, PATHINFO_FILENAME);
     $clearFolderName = pathinfo($clearFolderName, PATHINFO_FILENAME);
     if (!file_exists($clearFolderName . '.tar')) {
         fwrite(STDERR, "Extracting to {$clearFolderName}.tar" . PHP_EOL);
         // decompress from gz
         $p = new PharData($clearFolderName . '.tar.gz');
         $p->decompress();
         // creates files.tar
     }
     if (!file_exists($clearFolderName)) {
         fwrite(STDERR, "Extracting to {$clearFolderName}" . PHP_EOL);
         // unarchive from the tar
         $phar = new PharData($clearFolderName . '.tar');
         $phar->extractTo($clearFolderName);
     }
     $filename = $clearFolderName;
     fwrite(STDERR, "Decompresing complete!" . PHP_EOL);
 }
 try {
     $files = scandir($filename, 1);
     $i = 1;
     $processes = array();
     foreach ($files as $file) {
         if ($file != '.' && $file != '..' && is_dir($filename . '/' . $file)) {
             $allowMultiprocessing = false;
             if ($multiprocessing || $i < $multiprocessing) {
                 $processes[] = $pid = pcntl_fork();
                 if (!$pid) {
                     $allowMultiprocessing = true;
Ejemplo n.º 25
0
 /**
  * @param String $action
  * @param Array $httpVars
  * @param Array $fileVars
  * @throws Exception
  */
 public function receiveAction($action, $httpVars, $fileVars)
 {
     //VAR CREATION OUTSIDE OF ALL CONDITIONS, THEY ARE "MUST HAVE" VAR !!
     $messages = ConfService::getMessages();
     $repository = ConfService::getRepository();
     $userSelection = new UserSelection($repository, $httpVars);
     $nodes = $userSelection->buildNodes();
     $currentDirPath = AJXP_Utils::safeDirname($userSelection->getUniqueNode()->getPath());
     $currentDirPath = rtrim($currentDirPath, "/") . "/";
     $currentDirUrl = $userSelection->currentBaseUrl() . $currentDirPath;
     if (empty($httpVars["compression_id"])) {
         $compressionId = sha1(rand());
         $httpVars["compression_id"] = $compressionId;
     } else {
         $compressionId = $httpVars["compression_id"];
     }
     $progressCompressionFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressCompressionID-" . $compressionId . ".txt";
     if (empty($httpVars["extraction_id"])) {
         $extractId = sha1(rand());
         $httpVars["extraction_id"] = $extractId;
     } else {
         $extractId = $httpVars["extraction_id"];
     }
     $progressExtractFileName = $this->getPluginCacheDir(false, true) . DIRECTORY_SEPARATOR . "progressExtractID-" . $extractId . ".txt";
     if ($action == "compression") {
         $archiveName = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["archive_name"]), AJXP_SANITIZE_FILENAME);
         $archiveFormat = $httpVars["type_archive"];
         $tabTypeArchive = array(".tar", ".tar.gz", ".tar.bz2");
         $acceptedExtension = false;
         foreach ($tabTypeArchive as $extensionArchive) {
             if ($extensionArchive == $archiveFormat) {
                 $acceptedExtension = true;
                 break;
             }
         }
         if ($acceptedExtension == false) {
             file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.16"]);
             throw new AJXP_Exception($messages["compression.16"]);
         }
         $typeArchive = $httpVars["type_archive"];
         //if we can run in background we do it
         if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
             $archivePath = $currentDirPath . $archiveName;
             file_put_contents($progressCompressionFileName, $messages["compression.5"]);
             AJXP_Controller::applyActionInBackground($repository->getId(), "compression", $httpVars);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $messages["compression.5"], true, 2);
             AJXP_XMLWriter::close();
             return null;
         } else {
             $maxAuthorizedSize = 4294967296;
             $currentDirUrlLength = strlen($currentDirUrl);
             $tabFolders = array();
             $tabAllRecursiveFiles = array();
             $tabFilesNames = array();
             foreach ($nodes as $node) {
                 $nodeUrl = $node->getUrl();
                 if (is_file($nodeUrl) && filesize($nodeUrl) < $maxAuthorizedSize) {
                     array_push($tabAllRecursiveFiles, $nodeUrl);
                     array_push($tabFilesNames, substr($nodeUrl, $currentDirUrlLength));
                 }
                 if (is_dir($nodeUrl)) {
                     array_push($tabFolders, $nodeUrl);
                 }
             }
             //DO A FOREACH OR IT'S GONNA HAVE SOME SAMES FILES NAMES
             foreach ($tabFolders as $value) {
                 $dossiers = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($value));
                 foreach ($dossiers as $file) {
                     if ($file->isDir()) {
                         continue;
                     }
                     array_push($tabAllRecursiveFiles, $file->getPathname());
                     array_push($tabFilesNames, substr($file->getPathname(), $currentDirUrlLength));
                 }
             }
             //WE STOP IF IT'S JUST AN EMPTY FOLDER OR NO FILES
             if (empty($tabFilesNames)) {
                 file_put_contents($progressCompressionFileName, "Error : " . $messages["compression.17"]);
                 throw new AJXP_Exception($messages["compression.17"]);
             }
             try {
                 $tmpArchiveName = tempnam(AJXP_Utils::getAjxpTmpDir(), "tar-compression") . ".tar";
                 $archive = new PharData($tmpArchiveName);
             } catch (Exception $e) {
                 file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage());
                 throw $e;
             }
             $counterCompression = 0;
             //THE TWO ARRAY ARE MERGED FOR THE FOREACH LOOP
             $tabAllFiles = array_combine($tabAllRecursiveFiles, $tabFilesNames);
             foreach ($tabAllFiles as $fullPath => $fileName) {
                 try {
                     $archive->addFile(AJXP_MetaStreamWrapper::getRealFSReference($fullPath), $fileName);
                     $counterCompression++;
                     file_put_contents($progressCompressionFileName, sprintf($messages["compression.6"], round($counterCompression / count($tabAllFiles) * 100, 0, PHP_ROUND_HALF_DOWN) . " %"));
                 } catch (Exception $e) {
                     unlink($tmpArchiveName);
                     file_put_contents($progressCompressionFileName, "Error : " . $e->getMessage());
                     throw $e;
                 }
             }
             $finalArchive = $tmpArchiveName;
             if ($typeArchive != ".tar") {
                 $archiveTypeCompress = substr(strrchr($typeArchive, "."), 1);
                 file_put_contents($progressCompressionFileName, sprintf($messages["compression.7"], strtoupper($archiveTypeCompress)));
                 if ($archiveTypeCompress == "gz") {
                     $archive->compress(Phar::GZ);
                 } elseif ($archiveTypeCompress == "bz2") {
                     $archive->compress(Phar::BZ2);
                 }
                 $finalArchive = $tmpArchiveName . "." . $archiveTypeCompress;
             }
             $destArchive = AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $archiveName);
             rename($finalArchive, $destArchive);
             AJXP_Controller::applyHook("node.before_create", array($destArchive, filesize($destArchive)));
             if (file_exists($tmpArchiveName)) {
                 unlink($tmpArchiveName);
                 unlink(substr($tmpArchiveName, 0, -4));
             }
             $newNode = new AJXP_Node($currentDirUrl . $archiveName);
             AJXP_Controller::applyHook("node.change", array(null, $newNode, false));
             file_put_contents($progressCompressionFileName, "SUCCESS");
         }
     } elseif ($action == "check_compression_status") {
         $archivePath = AJXP_Utils::decodeSecureMagic($httpVars["archive_path"]);
         $progressCompression = file_get_contents($progressCompressionFileName);
         $substrProgressCompression = substr($progressCompression, 0, 5);
         if ($progressCompression != "SUCCESS" && $substrProgressCompression != "Error") {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("check_compression_status", array("repository_id" => $repository->getId(), "compression_id" => $compressionId, "archive_path" => SystemTextEncoding::toUTF8($archivePath)), $progressCompression, true, 5);
             AJXP_XMLWriter::close();
         } elseif ($progressCompression == "SUCCESS") {
             $newNode = new AJXP_Node($userSelection->currentBaseUrl() . $archivePath);
             $nodesDiffs = array("ADD" => array($newNode), "REMOVE" => array(), "UPDATE" => array());
             AJXP_Controller::applyHook("node.change", array(null, $newNode, false));
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage($messages["compression.8"], null);
             AJXP_XMLWriter::writeNodesDiff($nodesDiffs, true);
             AJXP_XMLWriter::close();
             if (file_exists($progressCompressionFileName)) {
                 unlink($progressCompressionFileName);
             }
         } elseif ($substrProgressCompression == "Error") {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $progressCompression);
             AJXP_XMLWriter::close();
             if (file_exists($progressCompressionFileName)) {
                 unlink($progressCompressionFileName);
             }
         }
     } elseif ($action == "extraction") {
         $fileArchive = AJXP_Utils::sanitize(AJXP_Utils::decodeSecureMagic($httpVars["file"]), AJXP_SANITIZE_DIRNAME);
         $fileArchive = substr(strrchr($fileArchive, DIRECTORY_SEPARATOR), 1);
         $authorizedExtension = array("tar" => 4, "gz" => 7, "bz2" => 8);
         $acceptedArchive = false;
         $extensionLength = 0;
         $counterExtract = 0;
         $currentAllPydioPath = $currentDirUrl . $fileArchive;
         $pharCurrentAllPydioPath = "phar://" . AJXP_MetaStreamWrapper::getRealFSReference($currentAllPydioPath);
         $pathInfoCurrentAllPydioPath = pathinfo($currentAllPydioPath, PATHINFO_EXTENSION);
         //WE TAKE ONLY TAR, TAR.GZ AND TAR.BZ2 ARCHIVES
         foreach ($authorizedExtension as $extension => $strlenExtension) {
             if ($pathInfoCurrentAllPydioPath == $extension) {
                 $acceptedArchive = true;
                 $extensionLength = $strlenExtension;
                 break;
             }
         }
         if ($acceptedArchive == false) {
             file_put_contents($progressExtractFileName, "Error : " . $messages["compression.15"]);
             throw new AJXP_Exception($messages["compression.15"]);
         }
         $onlyFileName = substr($fileArchive, 0, -$extensionLength);
         $lastPosOnlyFileName = strrpos($onlyFileName, "-");
         $tmpOnlyFileName = substr($onlyFileName, 0, $lastPosOnlyFileName);
         $counterDuplicate = substr($onlyFileName, $lastPosOnlyFileName + 1);
         if (!is_int($lastPosOnlyFileName) || !is_int($counterDuplicate)) {
             $tmpOnlyFileName = $onlyFileName;
             $counterDuplicate = 1;
         }
         while (file_exists($currentDirUrl . $onlyFileName)) {
             $onlyFileName = $tmpOnlyFileName . "-" . $counterDuplicate;
             $counterDuplicate++;
         }
         if (ConfService::backgroundActionsSupported() && !ConfService::currentContextIsCommandLine()) {
             file_put_contents($progressExtractFileName, $messages["compression.12"]);
             AJXP_Controller::applyActionInBackground($repository->getId(), "extraction", $httpVars);
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("check_extraction_status", array("repository_id" => $repository->getId(), "extraction_id" => $extractId, "currentDirUrl" => $currentDirUrl, "onlyFileName" => $onlyFileName), $messages["compression.12"], true, 2);
             AJXP_XMLWriter::close();
             return null;
         }
         mkdir($currentDirUrl . $onlyFileName, 0777, true);
         chmod(AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $onlyFileName), 0777);
         try {
             $archive = new PharData(AJXP_MetaStreamWrapper::getRealFSReference($currentAllPydioPath));
             $fichiersArchive = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($pharCurrentAllPydioPath));
             foreach ($fichiersArchive as $file) {
                 $fileGetPathName = $file->getPathname();
                 if ($file->isDir()) {
                     continue;
                 }
                 $fileNameInArchive = substr(strstr($fileGetPathName, $fileArchive), strlen($fileArchive) + 1);
                 try {
                     $archive->extractTo(AJXP_MetaStreamWrapper::getRealFSReference($currentDirUrl . $onlyFileName), $fileNameInArchive, false);
                 } catch (Exception $e) {
                     file_put_contents($progressExtractFileName, "Error : " . $e->getMessage());
                     throw new AJXP_Exception($e);
                 }
                 $counterExtract++;
                 file_put_contents($progressExtractFileName, sprintf($messages["compression.13"], round($counterExtract / $archive->count() * 100, 0, PHP_ROUND_HALF_DOWN) . " %"));
             }
         } catch (Exception $e) {
             file_put_contents($progressExtractFileName, "Error : " . $e->getMessage());
             throw new AJXP_Exception($e);
         }
         file_put_contents($progressExtractFileName, "SUCCESS");
         $newNode = new AJXP_Node($currentDirUrl . $onlyFileName);
         AJXP_Controller::findActionAndApply("index", array("file" => $newNode->getPath()), array());
     } elseif ($action == "check_extraction_status") {
         $currentDirUrl = $httpVars["currentDirUrl"];
         $onlyFileName = $httpVars["onlyFileName"];
         $progressExtract = file_get_contents($progressExtractFileName);
         $substrProgressExtract = substr($progressExtract, 0, 5);
         if ($progressExtract != "SUCCESS" && $progressExtract != "INDEX" && $substrProgressExtract != "Error") {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::triggerBgAction("check_extraction_status", array("repository_id" => $repository->getId(), "extraction_id" => $extractId, "currentDirUrl" => $currentDirUrl, "onlyFileName" => $onlyFileName), $progressExtract, true, 4);
             AJXP_XMLWriter::close();
         } elseif ($progressExtract == "SUCCESS") {
             $newNode = new AJXP_Node($currentDirUrl . $onlyFileName);
             $nodesDiffs = array("ADD" => array($newNode), "REMOVE" => array(), "UPDATE" => array());
             AJXP_Controller::applyHook("node.change", array(null, $newNode, false));
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(sprintf($messages["compression.14"], $onlyFileName), null);
             AJXP_XMLWriter::triggerBgAction("check_index_status", array("repository_id" => $newNode->getRepositoryId()), "starting indexation", true, 5);
             AJXP_XMLWriter::writeNodesDiff($nodesDiffs, true);
             AJXP_XMLWriter::close();
             if (file_exists($progressExtractFileName)) {
                 unlink($progressExtractFileName);
             }
         } elseif ($substrProgressExtract == "Error") {
             AJXP_XMLWriter::header();
             AJXP_XMLWriter::sendMessage(null, $progressExtract);
             AJXP_XMLWriter::close();
             if (file_exists($progressExtractFileName)) {
                 unlink($progressExtractFileName);
             }
         }
     }
 }
Ejemplo n.º 26
0
 public function add(Application $app, Request $request)
 {
     /** @var $Template \Eccube\Entity\Template */
     $Template = new \Eccube\Entity\Template();
     $form = $app['form.factory']->createBuilder('admin_template', $Template)->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             /** @var $Template \Eccube\Entity\Template */
             $tem = $app['eccube.repository.template']->findByCode($form['code']->getData());
             // テンプレートコードの重複チェック.
             if ($tem) {
                 $form['code']->addError(new FormError('すでに登録されているテンプレートコードです。'));
                 return false;
             }
             // 該当テンプレートのディレクトリ
             $config = $app['config'];
             $templateCode = $Template->getCode();
             $targetRealDir = $config['root_dir'] . '/app/template/' . $templateCode;
             $targetHtmlRealDir = $config['root_dir'] . '/html/template/' . $templateCode;
             // 一時ディレクトリ
             $uniqId = sha1(Str::random(32));
             $tmpDir = $config['template_temp_realdir'] . '/' . $uniqId;
             $appDir = $tmpDir . '/app';
             $htmlDir = $tmpDir . '/html';
             $formFile = $form['file']->getData();
             // ファイル名
             $archive = $templateCode . '.' . $formFile->getClientOriginalExtension();
             // ファイルを一時ディレクトリへ移動.
             $formFile->move($tmpDir, $archive);
             // 一時ディレクトリへ解凍する.
             try {
                 if ($formFile->getClientOriginalExtension() == 'zip') {
                     $zip = new \ZipArchive();
                     $zip->open($tmpDir . '/' . $archive);
                     $zip->extractTo($tmpDir);
                     $zip->close();
                 } else {
                     $phar = new \PharData($tmpDir . '/' . $archive);
                     $phar->extractTo($tmpDir, null, true);
                 }
             } catch (\Exception $e) {
                 $form['file']->addError(new FormError('アップロードに失敗しました。圧縮ファイルを確認してください。'));
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // appディレクトリの存在チェック.
             if (!file_exists($appDir)) {
                 $form['file']->addError(new FormError('appディレクトリが見つかりません。ファイルの形式を確認してください。'));
                 if (file_exists($tmpDir)) {
                     $fs = new Filesystem();
                     $fs->remove($tmpDir);
                 }
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // htmlディレクトリの存在チェック.
             if (!file_exists($htmlDir)) {
                 $form['file']->addError(new FormError('htmlディレクトリが見つかりません。ファイルの形式を確認してください。'));
                 if (file_exists($tmpDir)) {
                     $fs = new Filesystem();
                     $fs->remove($tmpDir);
                 }
                 return $app->render('Store/template_add.twig', array('form' => $form->createView()));
             }
             // 一時ディレクトリから該当テンプレートのディレクトリへコピーする.
             $fs = new Filesystem();
             $fs->mirror($appDir, $targetRealDir);
             $fs->mirror($htmlDir, $targetHtmlRealDir);
             // 一時ディレクトリを削除.
             $fs->remove($tmpDir);
             $DeviceType = $app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
             $Template->setDeviceType($DeviceType);
             $app['orm.em']->persist($Template);
             $app['orm.em']->flush();
             $app->addSuccess('admin.content.template.add.complete', 'admin');
             return $app->redirect($app->url('admin_store_template'));
         }
     }
     return $app->render('Store/template_add.twig', array('form' => $form->createView()));
 }
Ejemplo n.º 27
0
/**
 * Extracts files from archive to specified place
 *
 * @param $archive_name - path to the compressed file
 * @param $dirname - directory, where the files should be extracted to
 * @return bool true if archive was succesfully extracted, false otherwise
 */
function fn_decompress_files($archive_name, $dirname = '')
{
    if (empty($dirname)) {
        $dirname = Registry::get('config.dir.files');
    }
    $ext = fn_get_file_ext($archive_name);
    try {
        // We cannot use PharData for ZIP archives. All extracted data looks broken after extract.
        if ($ext == 'zip') {
            if (!class_exists('ZipArchive')) {
                fn_set_notification('E', __('error'), __('error_class_zip_archive_not_found'));
                return false;
            }
            $zip = new ZipArchive();
            $zip->open($archive_name);
            $zip->extractTo($dirname);
            $zip->close();
        } elseif ($ext == 'tgz' || $ext == 'gz') {
            if (!class_exists('PharData')) {
                fn_set_notification('E', __('error'), __('error_class_phar_data_not_found'));
                return false;
            }
            $phar = new PharData($archive_name);
            $phar->extractTo($dirname, null, true);
            // extract all files, and overwrite
        }
    } catch (Exception $e) {
        fn_set_notification('E', __('error'), __('unable_to_unpack_file'));
        return false;
    }
    return true;
}
Ejemplo n.º 28
0
 /**
  * Untar file to destination folder
  * @return destination folder
  */
 private function untar()
 {
     $file = '/tmp/' . $this->file['name'];
     try {
         //It have to be copied into /tmp directory because Phar doesn't recognize non-tar filenames
         move_uploaded_file($this->file['tmp_name'], $file);
         $tar = new PharData($file);
         $tar->extractTo(DESTINATION . '/' . $this->file['name'], null, true);
         //Remove temporary files
         unlink($file);
         unlink($this->file['tmp_name']);
         return $this->file['name'];
     } catch (Exception $e) {
         return FALSE;
     }
 }
Ejemplo n.º 29
0
 public function unpackPluginArchive($archive, $dir)
 {
     $extension = pathinfo($archive, PATHINFO_EXTENSION);
     try {
         if ($extension == 'zip') {
             $zip = new \ZipArchive();
             $zip->open($archive);
             $zip->extractTo($dir);
             $zip->close();
         } else {
             $phar = new \PharData($archive);
             $phar->extractTo($dir, null, true);
         }
     } catch (\Exception $e) {
         throw new PluginException('アップロードに失敗しました。圧縮ファイルを確認してください。');
     }
 }
Ejemplo n.º 30
-1
 /**
  * @inheritDoc
  */
 public function extractTo($dir)
 {
     $phar = new \PharData($this->file);
     $result = $phar->extractTo($dir, null, true);
     $phar = null;
     return $result;
 }