# Help convert php code to eruby

**URL:** <https://www.ruby-forum.com/t/help-convert-php-code-to-eruby/171710>\
**Category:** Ruby\
**Created:** [July 8, 2009, 12:30am UTC](https://www.ruby-forum.com/t/help-convert-php-code-to-eruby/171710 "2009-07-08T00:30:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rayholland](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e8c25b/32.png) [@rayholland](https://www.ruby-forum.com/u/rayholland)\
**Post date:** [July 8, 2009, 12:30am UTC](https://www.ruby-forum.com/t/help-convert-php-code-to-eruby/171710/1 "2009-07-08T00:30:18Z")

</div>

Hi,

I want to convert my site from php to eruby(no rails). I’m really new to  
ruby and need some help.

The most trival php code i use in my web-page is to use php for password  
protect my pages.

Can someone help me to convert this php code to use eruby -\> rhtml?

I use the following php code to password protect my pages (with php  
session var):

## config.php
\<?php //--------------------------------------- // CONFIG //--------------------------------------- $password = "geheim123"; //set password ?\>
## common.php
\<?php $password = ""; if (file\_exists("config.php")) include "config.php"; $showLogin = false; if( !isset( $\_SESSION ) ) { session\_start(); } // starting session if (isset($\_GET['action']) && $\_GET['action']=="LOGOUT") { session\_unset(); $showLogin = true; } else if ($password!="" && !isset($cron\_update) && !isset($cron\_ping) ) { if (isset($\_POST["form\_password"])) {//vin din login $pass = $\_POST['form\_password']; if ($pass == $password) $\_SESSION["password"] = $password; else { $showLogin = true; } } else if ($\_SESSION["password"] != $password) $showLogin = true; } if ($showLogin == true) { include "login.php"; exit; } ?\>
## login.php
  
  
  
  
  
  

|   
  
CCcamInfoPHP\</font |
|   
  

| &nbsp;&nbsp; |

 |

## index.php
\<?php include "common.php"?\>
# It works!

## testpage.php
\<?php include "common.php"?\>
# It works2!
