jefferyb Posted June 27, 2008 Share Posted June 27, 2008 Can someone help with a little php/mysql script? I got a program, Podcast Generator 1.0 from http://podcastgen.sourceforge.net/, but it stores username & password in a config file but I would like the program to use the mysql database that I already have, so more than one user can login and upload media, but I can't figure out how to do it... Or if you know of any other Podcast Generator program like this that uses mysql nice and easy to use, it would be great... Here is what the config.php file looks like... . . . $podcastgen_version = "1.0"; // Version $theme_path = "themes/default_ocean/"; $username = "testuser"; $userpassword = "PASSORDsdjkskdjkjsdkfjskdl"; . . . I tried adding this on top of the config.php file //Config file $dbhost = 'localhost'; // Host $dbuser = 'user'; // User $dbpass = 'pass'; // Password $dbname = 'databasename'; // Database $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $userId = $_POST['user'] ; $passwd = $_POST['password'] ; // check if the user id and password combination exist in database $sql = "SELECT NickName FROM Profiles WHERE NickName = '$userId' AND Password = md5('$passwd')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); // the user and password match, then set $username and $userpassword if (mysql_num_rows($result) == 1) { $username = $userId; $userpassword = $passwd; } and then commented out // $username = "testuser"; // $userpassword = "PASSORDsdjkskdjkjsdkfjskdl"; but it still didn't work... Here is the login file what it looks like <?php ############################################################ # PODCAST GENERATOR # # Created by Alberto Betella (beta@yellowjug.com) # http://podcastgen.sourceforge.net # # This is Free Software released under the GNU/GPL License. ############################################################ ########### Security code, avoids cross-site scripting (Register Globals ON) if (isset($_REQUEST['absoluteurl']) OR isset($_REQUEST['amilogged']) OR isset($_REQUEST['theme_path'])) { exit; } ########### End include ("$absoluteurl"."components/loading_indicator/loading.js"); //include top right loading indicator // define login form $loginform =' <br /><br /> <form id="login" action="?p=admin" method="post"> <label for="user">'.$L_user.'</label><br /> <input type="text" id="user" name="user" size="20" maxlength="255"><br /><br /> <label for="password">'.$L_password.'</label><br /> <input type="password" id="password" name="password" size="20" maxlength="255"><br /><br /> <input type="submit" value="'.$L_login.'" onClick="showNotify(\''.$L_logginin.'\');">'; // logout section if(isset($_GET['action']) AND $_GET['action'] == "logout" ){ $action = $_GET['action']; //session_start(); session_unset(); session_destroy(); } // end logout section // check if user is already logged in (Thanks to Pavel Urusov for the MD5 password encoding suggestion) if(isset($_SESSION["user_session"]) AND $_SESSION["user_session"]==$username AND md5($_SESSION["password_session"])==$userpa $PG_mainbody .= '<div class="episode"> '.$L_welcome.' <i>'.$username.'</i> '; if (isset($_GET['do']) AND $_GET['do'] != NULL) { $PG_mainbody .= '(<a href="?p=admin">'.$L_menu_backadmin.'</a> - <a href="?p=admin&action=logout">'.$L_logou } else { $PG_mainbody .= '(<a href="?p=admin&action=logout">'.$L_logout.'</a>)'; } $PG_mainbody .= '<br /><br /> </div>'; }else{ if(isset($_POST["user"]) AND $_POST["user"]==$username AND isset($_POST["password"]) AND md5($_POST["password"])==$u $PG_mainbody .= '<div class="episode"> '.$L_welcome.' <i>'.$username.'</i> (<a href="?p=admin&action=logout">'.$L_logout.'</a>) <br /><br /> </div>'; $_SESSION["user_session"] = $_POST["user"]; $_SESSION["password_session"] = $_POST["password"]; }else{ if(isset($_POST["user"]) AND isset($_POST["password"])){ //if user and pwd are not correct //display AGAIN login form if usr/pwd not correct $PG_mainbody .= ' <div class="topseparator"> <b>'.$L_notvalid.'</b> '.$loginform.' </div> </form>'; }else{ //display login form $PG_mainbody .= ' <div class="topseparator"> <b>'.$L_login.'</b> '.$loginform.' </div> </form>'; } } } ?> and the checklogged.php <?php ############################################################ # PODCAST GENERATOR # # Created by Alberto Betella (beta@yellowjug.com) # http://podcastgen.sourceforge.net # # This is Free Software released under the GNU/GPL License. ############################################################ $amilogged = NULL; //reset variable for security reasons // check if user is already logged in if(isset($_SESSION["user_session"]) AND $_SESSION["user_session"]==$username AND md5($_SESSION["password_session"])==$userpa $amilogged = "true"; } else { $amilogged = "false"; } ?> Any ideas??? Thank you guys for helping me out... Quote Link to comment Share on other sites More sharing options...
Wolphie Posted June 27, 2008 Share Posted June 27, 2008 I'm not even going to attempt to help you until you use the BB tags to post your code. Quote Link to comment Share on other sites More sharing options...
jefferyb Posted June 27, 2008 Author Share Posted June 27, 2008 Can someone help with a little php/mysql script? I got a program, Podcast Generator 1.0 from http://podcastgen.sourceforge.net/, but it stores username & password in a config file but I would like the program to use the mysql database that I already have, so more than one user can login and upload media, but I can't figure out how to do it... Or if you know of any other Podcast Generator program like this that uses mysql nice and easy to use, it would be great... Here is what the config.php file looks like... <?php ################################################################# # Podcast Generator # http://podcastgen.sourceforge.net # developed by Alberto Betella # # Config.php file created automatically - v.1.0 $podcastgen_version = "1.0"; // Version $scriptlang = "en"; $url = "http://mysite.com/"; // Complete URL of the script (Trailing slash REQUIRED) $absoluteurl = "/mnt/local/podcast/"; // Absolute path on the server (Trailing slash REQUIRED) $theme_path = "themes/default_ocean/"; $username = "testuser"; $userpassword = "PASSWORDsjdfhskjfhwiofksjdk"; $max_upload_form_size = "104857600"; //e.g.: "30000000" (about 30MB) $upload_dir = "media/"; // "media/" the default folder (Trailing slash required). Set chmod 755 $img_dir = "images/"; // (Trailing slash required). Set chmod 755 $feed_dir = ""; // Where to create feed.xml (empty value = root directory). Set chmod 755 $max_recent = 3; // How many file to show in the home page $recent_episode_in_feed = "All"; // How many file to show in the XML feed (1,2,5 etc.. or "All") $episodeperpage = 10; $enablestreaming = "yes"; // Enable mp3 streaming? ("yes" or "no") $streamingplayercolor = "grey"; $dateformat = "d-m-Y"; // d-m-Y OR m-d-Y OR Y-m-d $freebox = "yes"; // enable freely customizable box $enablehelphints = "yes"; $enablepgnewsinadmin = "yes"; $strictfilenamepolicy = "yes"; // strictly rename files (just characters A to Z and numbers) $categoriesenabled = "yes"; ################### # XML Feed elements # The followings specifications will be included in your podcast "feed.xml" file. $podcast_title = "PodCast"; $podcast_subtitle = "Welcome to my PodCast!"; $podcast_description = "My PodCast portal. Find, play, and download audio and video podcasts from all over the world here "; $author_name = "PodCaster"; $author_email = "webmaster@mysite.com"; $itunes_category[0] = "Arts"; // iTunes categories (mainCategory:subcategory) $itunes_category[1] = ""; $itunes_category[2] = ""; $link = $url."?p=episode&name="; // permalink URL of single episode (appears in the <link> and <guid> tags in the feed) $feed_language = "en"; // Language used in the XML feed (can differ from the script language). $copyright = "Copyright"; // Copyright notice $feed_encoding = "utf-8"; // Feed Encoding (e.g. "iso-8859-1", "utf-8"). UTF-8 is strongly suggested $explicit_podcast = "no"; //does your podcast contain explicit language? ("yes", "no" or "clean") // END OF CONFIGURATION ?> I tried adding this on top of the config.php file something like this... //Config file $dbhost = 'localhost'; // Host $dbuser = 'user'; // User $dbpass = 'pass'; // Password $dbname = 'databasename'; // Database $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $userId = $_POST['user'] ; $passwd = $_POST['password'] ; // check if the user id and password combination exist in database $sql = "SELECT NickName FROM Profiles WHERE NickName = '$userId' AND Password = md5('$passwd')"; $result = mysql_query($sql) or die('Query failed. ' . mysql_error()); // the user and password match, then set $username and $userpassword if (mysql_num_rows($result) == 1) { $username = $userId; $userpassword = $passwd; } and then commented out // $username = "testuser"; // $userpassword = "PASSORDsdjkskdjkjsdkfjskdl"; but it still didn't work... Here is what the login.php file looks like <?php ############################################################ # PODCAST GENERATOR # # Created by Alberto Betella (beta@yellowjug.com) # http://podcastgen.sourceforge.net # # This is Free Software released under the GNU/GPL License. ############################################################ ########### Security code, avoids cross-site scripting (Register Globals ON) if (isset($_REQUEST['absoluteurl']) OR isset($_REQUEST['amilogged']) OR isset($_REQUEST['theme_path'])) { exit; } ########### End include ("$absoluteurl"."components/loading_indicator/loading.js"); //include top right loading indicator // define login form $loginform =' <br /><br /> <form id="login" action="?p=admin" method="post"> <label for="user">'.$L_user.'</label><br /> <input type="text" id="user" name="user" size="20" maxlength="255"><br /><br /> <label for="password">'.$L_password.'</label><br /> <input type="password" id="password" name="password" size="20" maxlength="255"><br /><br /> <input type="submit" value="'.$L_login.'" onClick="showNotify(\''.$L_logginin.'\');">'; // logout section if(isset($_GET['action']) AND $_GET['action'] == "logout" ){ $action = $_GET['action']; //session_start(); session_unset(); session_destroy(); } // end logout section // check if user is already logged in (Thanks to Pavel Urusov for the MD5 password encoding suggestion) if(isset($_SESSION["user_session"]) AND $_SESSION["user_session"]==$username AND md5($_SESSION["password_session"])==$userpassword){ //if so, keep displaying the page $PG_mainbody .= '<div class="episode"> '.$L_welcome.' <i>'.$username.'</i> '; if (isset($_GET['do']) AND $_GET['do'] != NULL) { $PG_mainbody .= '(<a href="?p=admin">'.$L_menu_backadmin.'</a> - <a href="?p=admin&action=logout">'.$L_logout.'</a>)'; } else { $PG_mainbody .= '(<a href="?p=admin&action=logout">'.$L_logout.'</a>)'; } $PG_mainbody .= '<br /><br /> </div>'; }else{ if(isset($_POST["user"]) AND $_POST["user"]==$username AND isset($_POST["password"]) AND md5($_POST["password"])==$userpassword){ //if user and pwd are valid $PG_mainbody .= '<div class="episode"> '.$L_welcome.' <i>'.$username.'</i> (<a href="?p=admin&action=logout">'.$L_logout.'</a>) <br /><br /> </div>'; $_SESSION["user_session"] = $_POST["user"]; $_SESSION["password_session"] = $_POST["password"]; }else{ if(isset($_POST["user"]) AND isset($_POST["password"])){ //if user and pwd are not correct //display AGAIN login form if usr/pwd not correct $PG_mainbody .= ' <div class="topseparator"> <b>'.$L_notvalid.'</b> '.$loginform.' </div> </form>'; }else{ //display login form $PG_mainbody .= ' <div class="topseparator"> <b>'.$L_login.'</b> '.$loginform.' </div> </form>'; } } } ?> and the checklogged.php <?php ############################################################ # PODCAST GENERATOR # # Created by Alberto Betella (beta@yellowjug.com) # http://podcastgen.sourceforge.net # # This is Free Software released under the GNU/GPL License. ############################################################ $amilogged = NULL; //reset variable for security reasons // check if user is already logged in if(isset($_SESSION["user_session"]) AND $_SESSION["user_session"]==$username AND md5($_SESSION["password_session"])==$userpassword) { $amilogged = "true"; } else { $amilogged = "false"; } ?> Any ideas??? Thank you guys for helping me out... Is that what you mean? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.