PHP - Vbulletin Back-end Acp Help
Hey everyone. So lately I've been searching for someone to do this for me but I figure if I learned it myself it'd be much more helpful to me in the future. I run a gaming clan, and we have a roster. You can view it he http://www.zealotgam...s.php?pageid=15
Obviously, you can see a few things. The default page lists all our staff. That is very easy, and not really the part I need help with. The help begins with the games list you see at the side. When you click a game, it lists all users who have that Game listed as their Main Game in a profile field, and lists other info, such as their rank, In-Game contact (which is another profile field) and join date/last active. The games are also themselves divided into categories. Our code is relatively simple. We keep a manual array of info that keeps these together you can see below: // Define Games and Lists // $gameslist = array(); //SETUP $gamelist[] = array("Game Name","urlshortcode","Name of In-Game Name or Account", "field# for that profile field"); $gameslist[] = array("Battlefield 4 (PS4)", "bf4ps4", "PlayStation ID", "field7"); $gameslist[] = array("Counter Strike: Global Offensive (EU)", "csgoeu", "Steam ID", "field8"); $gameslist[] = array("Counter Strike: Global Offensive (NA)", "csgona", "Steam ID", "field8"); $gameslist[] = array("Elder Scrolls Online (NA)", "esona", "Main Character", "field45"); $gameslist[] = array("League of Legends (EUNE)", "loleune", "Summoner Name", "field12"); $gameslist[] = array("League of Legends (EUW)", "loleuw", "Summoner Name", "field31"); $gameslist[] = array("League of Legends (NA)", "lolna", "Summoner Name", "field32"); $gameslist[] = array("League of Legends (OCE)", "loloce", "Summoner Name", "field47"); $gameslist[] = array("Minecraft", "mc", "Username", "field14"); $gameslist[] = array("Smite (EU)", "smiteeu", "Smite Account", "field22"); $gameslist[] = array("Smite (NA)", "smitena", "Smite Account", "field22"); $gameslist[] = array("Titanfall", "tfall", "Origin ID", "field29"); $gameslist[] = array("WildStar (EU)", "wseu", "Main Character", "field48"); $gameslist[] = array("WildStar (NA)", "wsna", "Main Character", "field48"); $gameslist[] = array("World of Tanks (EU)", "woteu", "WarGaming.NET ID", "field46"); $gameslist[] = array("Other Game", "other", "", ""); // Game Type Categories $gamecats = array(); // ADD the # of the game in the list above (starting from 0) to the appropriate category array number list. $gamecats[] = array("Divisions",array(4,5,6)); $gamecats[] = array("Guilds",array()); $gamecats[] = array("Gaming Groups",array()); $gamecats[] = array("Divisions in Development",array(0,1,2,3,7,8,9,10,11,12,13,14)); $gamecats[] = array("Miscellaneous",array(15)); This gets tedious to keep track of manually, and my admins with no programming experience can barely understand what is happening. The listing of users is very easy, and I do not need any help with that. What I would like to add is a manager in the admin panel where you could save the information listed above to a table such as PREFIX.games. I imagine having several drop down boxes. A mockup is below: I'd then Like a list of games that includes these rows in the table with a [ ] Remove checkbox. I do not know how to add this to the admin panel and would love guidance on how to begin doing this. The sorting would go by Game Status (the second array in my php code) then Alphabetical. This would go a long way in helping my staff edit this list themselves. Any help would be appreciated. Skype: j.c.will my be better to work personally with me. Similar TutorialsHey Ya'll I'm looking for help on making this actually work...
The code was thrown together a couple tears ago and post'ed on both alliedmods and vbulletin forums..
As far as I know I have yet to find someone fix and make it work properly..
I would be willing to donate a small sum if someone would be willing to help me get this working...
Two things that need to be changed with the current code is -
The steam id is not sorted in the userfield table.. It is now stored in the user table under steam_code
I have a forum and a sb DB up and available for testing if needed..
The code I'm pasting a re-work.. The one attached is the original... I would like either working.. I just need it working!!!!
<?php //THIS CODE IS INTENDED FOR USE AS A VBULLETIN 4 CRON SCRIPT, IT REQUIRES THE VBULLETIN GLOBAL VAR PROVIDED BY CRONMANAGER.PHP - YOU MAY EMULATE THIS FUNCTIONALITY BY INCLUDING THE VBULLETIN GLOBAL.PHP //RECCOMENDED SCHEDULE IS EVERY 30 MINUTES TO 1 HOUR // ############################# VARIABLES ################################ mysql_pconnect("******", "root", "*****"); //MYSQL information for the SourceBans/Vbulletin Database $db_sourcebans = "sourcebans"; //Database name for SourceBans $steamid_custom_field = "field11"; //The custom field id for the users SteamID, it is reccomended that you only let the user set their steamid on signup or you may have people changing their steamid's and giving other people admin. define("DB_PREFIX", "sb"); //Table Prefix for SourceBans $groups_with_admin = array(19,18,13,15,16,17); // Comma delimited list of vBulletin groups with admin. $ban_site_url = "http://98.224.170.160.com/bans"; //URL to the Sourcebans installation, no trailing forward slash $clan_name = "[mFc.] Middle Fingah Click"; // Name of your clan $pm_from_userid=1; //The vBulletin UserID to send the PM from $pm_from_user_text="wtfaatp"; //The vBulletin Username to send the PM from // ######################## SET PHP ENVIRONMENT ########################### mysql_select_db($db_sourcebans); mysql_set_charset('utf8'); require "CServerRcon.php"; //This file can be found in Sourcebans_web/includes/ and must be located in the same folder as this script. error_reporting(E_ALL & ~E_NOTICE); //Prevents "Notices" From showing up if (!is_object($vbulletin->db)) // Checks if the vbulletin database is accessiable, otherwise exit the script. { exit; } $vbulletin->db->hide_errors(); // Hide Database errors from Vbulletin // ############################ FUNCTIONS ################################ function encrypt_password($password, $salt='SourceBans') // If you use a different salt for your sourcebans installation, Change this. { return sha1(sha1($salt . $password)); } function getRandomPassword($length = "") //Returns a random alphanumeric string of the specified length, 32 chars if unspecified { $code = md5(uniqid(rand(), true)); if ($length != "") return substr($code, 0, $length); else return $code; } function AddAdmin($sourcebans_group_web, $sourcebans_group_server, $sourcebans_group_server_name, $sourcebans_group_server_access, $username, $email, $steamid, $userid) { $password = getRandomPassword(8); // Generate a password for the user $res2 = mysql_query("SELECT `aid`, `group_id` FROM ".DB_PREFIX."_admins LEFT JOIN ".DB_PREFIX."_admins_servers_groups ON ".DB_PREFIX."_admins.aid=".DB_PREFIX."_admins_servers_groups.admin_id WHERE user='".mysql_real_escape_string($username)."'") or die(mysql_error()); //A quick query so we can check to see if the admin is already an admin and whether they've been promoted or not $row2 = mysql_fetch_assoc($res2); // Fetch the result from the previous query mysql_query("INSERT INTO ".DB_PREFIX."_admins(user, authid, password, gid, email, srv_group) VALUES ('".mysql_real_escape_string($username)."','".mysql_real_escape_string($steamid)."','".encrypt_password($password)."',".$sourcebans_group_web.",'".mysql_real_escape_string($email)."','".mysql_real_escape_string($sourcebans_group_server_name)."') ON DUPLICATE KEY UPDATE srv_group='".mysql_real_escape_string($sourcebans_group_server_name)."', gid='".$sourcebans_group_web."'") or die(mysql_error()); // Add the admin to the SourceBans database or, if they already exist, update their group data. if(mysql_affected_rows() > 0) //Check if the last query affected any rows, did it change anything or add a new admin? If no, skip. { $res3 = mysql_query("SELECT `aid` FROM ".DB_PREFIX."_admins WHERE user='".mysql_real_escape_string($username)."'") or die(mysql_error()); // Select the users AdminID $row3 = mysql_fetch_assoc($res3);// Fetch the result from the previous query mysql_query("DELETE FROM ".DB_PREFIX."_admins_servers_groups WHERE admin_id='".$row3['aid']."'") or die(mysql_error());//Delete the users admin group data from the table mysql_query("INSERT IGNORE INTO ".DB_PREFIX."_admins_servers_groups(admin_id, group_id, srv_group_id, server_id) VALUES (".$row3['aid'].",".$sourcebans_group_server.",".$sourcebans_group_server_access.", -1)") or die(mysql_error()); //Add back their new data. //This next bit handles the PMs, the promotion/demotion will only work if your "highest power" admin group is the first id and the "lowest power" is the last id. i.e - Managers = GID1, Council = GID2, Admins = GID3, Members = GID4, Recruits = GID5 if(mysql_num_rows($res2) == 0) { SendPM($userid, $username, $sourcebans_group_server_name, $password, 0); //Send the user a message with their password and username telling them that they've been added to the system. } elseif ($sourcebans_group_server > $row2['group_id']) { SendPM($userid, $username, $sourcebans_group_server_name, $password, 1); //Tell the user that they have been promoted in sourcebans. } elseif ($sourcebans_group_server < $row2['group_id']) { SendPM($userid, $username, $sourcebans_group_server_name, $password, 2); //Tell the user that they have been demoted in sourcebans. } } } function SendPM($pm_userid, $pm_username, $pm_group_name, $pm_password, $text) // Send a PM to the user, there is an actual datamanager API in vB for this, but it wasn't working reliable so I fell back on this method { global $vbulletin, $ban_site_url, $clan_name, $pm_from_userid, $pm_from_user_text; switch($text) //The messages, pretty self explanatory which is which. { case 0: $pm_text_title="Added to Sourcebans"; $pm_text="[CENTER][IMG]".$ban_site_url."/images/logos/sb-large.png[/IMG] [/CENTER] [LEFT][FONT=Garamond][SIZE=4]Hello ".$pm_username.", You have been added as a ".$pm_group_name." to the ".$clan_name." admin system. Please find below the details required to login to the admin web panel, you will be able to access in-game admin automatically. Username: [B]".$pm_username."[/B] Password: [B]".$pm_password."[/B] You can use this information to login into your new account at: ".$ban_site_url."/index.php?p=login It is HIGHLY recommended for security reasons that you change your password to something memorable once you login. If you have any questions please contact me about any problems. Many thanks, ".$pm_from_user_text." [/SIZE][/FONT][/LEFT]"; break; case 1: $pm_text_title="Promoted in Sourcebans"; $pm_text="[CENTER][IMG]".$ban_site_url."/images/logos/sb-large.png[/IMG] [/CENTER] [LEFT][FONT=Garamond][SIZE=4]Hello ".$pm_username.", Congratulations! You have been promoted to a ".$pm_group_name." on the ".$clan_name." admin system. Your login details are the same as before. You can use this information to login into your account at: ".$ban_site_url."/index.php?p=login If you have any questions please contact me about any problems. Many thanks, ".$pm_from_user_text." [/SIZE][/FONT][/LEFT]"; break; case 2: $pm_text_title="Demoted in Sourcebans"; $pm_text="[CENTER][IMG]".$ban_site_url."/images/logos/sb-large.png[/IMG] [/CENTER] [LEFT][FONT=Garamond][SIZE=4]Hello ".$pm_username.", We are afraid that you have been demoted to a ".$pm_group_name." on the ".$clan_name." admin system. Your login details are the same as before. You can use this information to login into your account at: ".$ban_site_url."/index.php?p=login If you have any questions please contact me about any problems. Many thanks, ".$pm_from_user_text." [/SIZE][/FONT][/LEFT]"; break; case 3: $pm_text_title="Removed from Sourcebans"; $pm_text="[CENTER][IMG]".$ban_site_url."/images/logos/sb-large.png[/IMG] [/CENTER] [LEFT][FONT=Garamond][SIZE=4]Hello ".$pm_username.", We are afraid that you have been removed from the ".$clan_name." admin system. If you have any questions please contact me about any problems. Many thanks, ".$pm_from_user_text." [/SIZE][/FONT][/LEFT]"; break; } $botpermissions['adminpermissions'] = 6; $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY); $pmdm->overridequota = true; $pmdm->set('fromuserid', $pm_from_userid); $pmdm->set('fromusername', $pm_from_userid_text); $pmdm->set_info('receipt', $vbulletin->GPC['receipt']); //false $pmdm->set_info('savecopy', $vbulletin->GPC['savecopy']); //false $pmdm->set('allowsmilie', $vbulletin->GPC['allowsmilie']); //true $pmdm->set('title', $pm_text_title); $pmdm->set('message', $pm_text); $pmdm->set_recipients($pm_username, $botpermissions); $pmdm->set('dateline', TIMENOW); $pmdm->pre_save(); if (empty($pmdm->errors)) { $pmdm->save(); } else { echo "<hr><b><font color=red>PM was not sent, Reason:</font></b><pre>"; print_r($pmdm->errors); echo "</pre><hr> "; } unset($pmdm); } // ######################################################################## // ######################### START MAIN SCRIPT ############################ // ######################################################################## $res = $vbulletin->db->query_read("SELECT `username`, `user`.`userid` as userid, `usergroupid`, `membergroupids`, `email`, `".$steamid_custom_field."` FROM ". TABLE_PREFIX ."user LEFT JOIN `". TABLE_PREFIX ."userfield` ON `user`.`userid`=`userfield`.`userid`"); //Select all users from the Vbulletin Database while($row = mysql_fetch_assoc($res)) { // CLEANUP OLD/INVALID ADMINS $res2 = mysql_query("SELECT `aid` FROM ".DB_PREFIX."_admins WHERE user='".$row['username']."'") or die(mysql_error()); //Check if the user has a sourcebans account $row2 = mysql_fetch_assoc($res2); if (mysql_num_rows($res2)>0 && !in_array($row['usergroupid'], $groups_with_admin)) //If yes, and they are not in one of the admin groups defined above then... { $additionaluser=false; for($i = 0; $i < count($user_additional_groups); $i ++) //Check if they are marked as an additional user to any of the admin groups defined above { if (in_array($user_additional_groups[$i], $groups_with_admin)) { $additionaluser=true; break; } } if($additionaluser == false) // If they aren't remove them from SourceBans. { mysql_query("DELETE FROM ".DB_PREFIX."_admins_servers_group WHERE admin_id='".$row2['aid']."'"); mysql_query("DELETE FROM ".DB_PREFIX."_admins WHERE aid='".$row2['aid']."'"); SendPM($row['userid'], $row['username'], "None", "None", 3); //Send a PM telling them that they've been removed from sourcebans } } // PRIMARY USERGROUP ADMIN CONTROL if (in_array($row['usergroupid'], $groups_with_admin)) //If the user is in a primary group defined as an admin, then add/edit them as such. { switch($row['usergroupid']) { case 16: //Group ID from vBulletin //AddAdmin(Sourcebans Web GroupID, Sourcebans Admin GroupID, Sourcebans Admin Group Name (Must be EXACT), Sourcebans Server GroupID, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']) AddAdmin(1, 1, "Leaders", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 18: AddAdmin(1, 2, "Vice-Founders", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 15: AddAdmin(2, 3, "H-Exec", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 17: AddAdmin(2, 4, "Admins", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 13: AddAdmin(2, 6, "Members", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 19: AddAdmin(2, 5, "Donators", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; } continue; } // ADDITIONAL USERGROUP ADMIN CONTROL if (strlen ($row['membergroupids']) > 0){ $user_additional_groups=explode(",", $row['membergroupids']); } for($i = 0; $i < count($user_additional_groups); $i ++) //If the user is in a secondary group defined as an admin, then add/edit them as such, same format as above. { if (in_array($user_additional_groups[$i], $groups_with_admin)) { switch($user_additional_groups[$i]) { case 16: //Group ID from vBulletin //AddAdmin(Sourcebans Web GroupID, Sourcebans Admin GroupID, Sourcebans Admin Group Name (Must be EXACT), Sourcebans Server GroupID, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']) AddAdmin(1, 1, "Leaders", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 18: AddAdmin(1, 2, "Vice-Founders", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 15: AddAdmin(2, 3, "H-Exec", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 17: AddAdmin(2, 4, "Admins", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 13: AddAdmin(2, 6, "Members", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; case 19: AddAdmin(2, 5, "Donators", 1, $row['username'], $row['email'], $row[$steamid_custom_field], $row['userid']); break; } continue; } } } //REHASH SERVERS, DOES NOT REQUIRE EDITING $res = mysql_query("SELECT ip, port, rcon FROM ".DB_PREFIX."_servers WHERE enabled=1") or die(mysql_error()); while($row = mysql_fetch_assoc($res)) { if (strlen($row['rcon']) > 0) { $rcon = new CServerRcon($row['ip'], $row['port'], $row['rcon']); if(!$rcon->Auth()) { continue; } $rcon->rconCommand("sm_rehash"); unset($rcon); } } ?>vbulletintosourcebans.php.txt 13.33KB 2 downloads Please, take a look to the following code.After clicking Next it goes to overview.php.Why when I click back on my browser to return to this page again, it is not returning back? When I click back I receive "Confirm Form Resubmission" message. After refreshing page it loads page. I guess problem is in "session_start();" part. Something to do with cookies. Please, help me it is very urgent for me. <?php session_start(); echo "<html> <head> <title>Hello World</title> <meta http-equiv='Content-Type' content='text/html; charset=Windows-1252'/> </head>"; require_once ('functions.inc'); if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'index.php'"; echo "</script>"; exit; }else{ session_register("userid", "userpassword"); $username = auth_user($_POST['userid'], $_POST['userpassword']); if(!$username) { $PHP_SELF = $_SERVER['PHP_SELF']; session_unregister("userid"); session_unregister("userpassword"); echo "Authentication failed " . "Please, write correct username or password. " . "try again "; echo "<A HREF=\"index.php\">Login</A><BR>"; exit; } } function auth_user($userid, $userpassword){ global $default_dbname, $user_tablename; $user_tablename = 'user'; $link_id = db_connect($default_dbname); mysql_select_db("d12826", $link_id); $query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = '$userpassword'"; $result = mysql_query($query) or die(mysql_error()); if(!mysql_num_rows($result)){ return 0; }else{ $query_data = mysql_fetch_row($result); return $query_data[0]; } } echo "hello"; echo "<form method='POST' name='myform' action='overview.php'>"; echo "<input type='submit' value='Next'>"; echo "</form>"; ?> This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=330163.0 well.. i have vbulletin 4 forum i try to put video player so if i upload mp4 file so i can play video but sad part is its working only at firefox browser can you help me out .. video code looks like this
<vb:if condition="$attachment[attachmentextension] == mp4"> pls i really want that put to work in every browser sadly it works only in firefox somehow.. I made a file for updating data. I do get the id back from the view page, but not the variable. What do I do wrong? I'm puzzling a few days, but just don't see it. This my code: Code: [Select] <?php // init $msg = ''; $errorMsg = ''; $rep_id = array(); $componist = ''; $repertoire = ''; $titel = ''; $formOK= false; // + + + + + + + + GET + + + + + + + + if(isset($_GET['id'])) { $rep_id = inputControl($_GET['id']); } if(isset($_GET['componist'])) { $componist = inputControl($_GET['componist']); } //print "session: $login_id, $login_recht"; // TEST van de sessie // + + + + + + + + + + + + + + + + POST + + + + + + + + + + if (isset($_POST['UpdateRepSubmit'])) { if (isset($_POST['componist'])) { $componist = inputControl($_POST['componist']); } if (isset($_POST['titel'])) { $titel = inputControl($_POST['titel']); } } //print'<pre>'; print_r($repertoire); print '</pre>'; //TEST2 // + + + + + + + + + + + + + + + + + + + queries $select_query= "SELECT * FROM repertoire_eng ORDER BY componist ASC "; print $select_query; // TEST 3 // # # # # # # # # # # # database connectie # # # # # # # # # # $dblink = mysqli_connect($host,$user,$pass,$db) or die ('Mysql-connectie heeft gefaald.'); if (!$dblink) { // + + + + + + fout bij met maken van databaseverbinding $errorMsg = "Geen verbinding met de MySQL-server"; } else { $result = mysqli_query($dblink, $select_query); if($result) { $i = 0; while ($row = mysqli_fetch_array($result)) { // uitlezen resultaat $repertoire_ids[$i] = $row['id']; $componisten[$i] = $row['componist']; $titels[$i] = $row['titel']; $i++; } } else { // + + + + + fout bij het uitvoeren van de query $errorMsg = "De query kon niet worden uitgevoerd."; } // # # # # # # # # # # einde database connectie # # # # # # # # # mysqli_close($dblink); } ?> In the html block: Code: [Select] <div id="container"> <form action="edit_repertoire.php" method="post" name="edit_repertoire" onsubmit = "return checkForm(this)"> <fieldset> <legend>Update repertoire in your list:</legend> <!-- # # # # # # Toevoegen van een hiddenfield om de id op te halen uit de URL # # # # # # --> <input type="hidden" name="id" value = "<?php echo $rep_id; ?>" > <p>ID= <?php echo $rep_id; ?></p> <p> Componist = <?php echo $componisten; ?></p> <!-- + + + + + + + FORMREGELComponist + + + + + + + --> <div class="formregel"> <div class="formkolomlinks">Composer name:</div> <div class="formkolomrechts"><input name="componist" id="componist" type="text" maxlength="128" value="<?php echo $componist; ?>" /> Name first, then the initials! </div> </div><!-- Einde formregel --> <!-- ++ + + + + + FORMREGEL Compositie en of rol + + + + + + + --> <div class="formregel"> <div class="formkolomlinks">Composition and or role</div> <div class="formkolomrechts"><input name="titel" id="titel" type="text" maxlength="128" value="<?php echo $titel; ?>" /></div> </div><!-- Einde formregel --> <!-- +++++++ FORMREGEL +++++++ --> <div class="formregel"> <div class="formkolomlinks"><input name="updateRepSubmit" type="submit" value="Update repertoire" /></div> </div><!-- Einde formregel --> </fieldset> </form> <div class="clear"></div> </div><!-- einde container --> </div><!-- einde tot_wrap --> edit: added [code][/code] blocks I have the following code. Before back button was working. Now don't understand what happend but when I click Back button I receive "Webpage has expired" window in my browser. What may be the reason? Code: [Select] <html> <head> <title>Økern Frukt og Grønt</title> <link href="calendar/calendar.css" rel="stylesheet" type="text/css" /> <script language="javascript" src="calendar/calendar.js"></script> <style type="text/css"> textarea { resize: none; } </style> <meta http-equiv="Content-Type" content="text/html; charset=Windows-1252"/> </head> <?php if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'login.html'"; echo "</script>"; exit; } require_once ('functions.inc'); require_once('calendar/classes/tc_calendar.php'); global $default_dbname; $link_id = db_connect($default_dbname); mysql_select_db("okern", $link_id); $letters1 = array ("A1", "B1", "C", "D","E", "F", "G", "H","I", "J", "K", "L", "M", "N", "O", "P","Q", "R", "S", "T","U", "V", "W", "X", "Y", "Z", "&#198", "&#216", "&#197"); $letters = array_merge(range("A", "Z"), array("&#38;#198", "&#38;#216", "&#38;#197")); echo "<table border='0' align='center'> <tr> <td colspan=3><b><center>Du har valgt f&#248lgende produkter</center></b></td> </tr> <tr> <th align=left>Produkt</th> <th align=left>Antall</th> <th align=left>Enhet</th> </tr>"; echo "<form method='POST' action='order.php'>"; $userid = $_POST['userid']; echo "<INPUT TYPE='hidden' NAME='userid' VALUE='$userid'>"; foreach($letters as $letter) { if(isset($_POST[$letter])) { $selected = $letter . '1'; $antall = $letter . '2'; $enhet = $letter . '3'; echo "<tr>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$selected' VALUE='$_POST[$selected]'>" . "$_POST[$selected]" . "</td>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$antall' VALUE='$_POST[$antall]'>" . "$_POST[$antall]" . "</td>"; echo "<td>" . "<INPUT TYPE='hidden' NAME='$enhet' VALUE='$_POST[$enhet]'>" . "$_POST[$enhet]" . "</td>"; echo "</tr>"; } } for ($i = 1; $i < 400; $i++) { if (isset($_POST[$i])){ $selected = 'a' . $i; $antall = 'antall' . strval($i); $enhet = 'enhet' . strval($i); echo "<tr>"; echo "<td>" . "$_POST[$selected]" . "</td>"; echo "<td>" . "$_POST[$antall]" . "</td>"; echo "<td>" . "$_POST[$enhet]" . "</td>"; echo "</tr>"; } } echo "<tr height=10></tr> <tr><td colspan=2>Velg dato for bestillingen:</td> <td colspan=1>"; $myCalendar = new tc_calendar("date5", true, false); $myCalendar->setIcon("calendar/images/iconCalendar.gif"); $myCalendar->setDate(date('d'), date('m'), date('Y')); $myCalendar->setPath("calendar/"); $myCalendar->setYearInterval(2000, 2015); $myCalendar->dateAllow('2008-05-13', '2015-03-01'); $myCalendar->setDateFormat('j F Y'); $myCalendar->setAlignment('left', 'bottom'); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year'); $myCalendar->writeScript(); echo "<INPUT TYPE='hidden' NAME='date' VALUE='this.form.date5.value'>"; echo "</td></tr>"; echo "<tr height=10></tr><tr> <td colspan=3>Skrive din melding nedenfor:</td> </tr>"; echo "<tr> <td colspan=3><textarea name='melding' cols='50' rows='5' resize=none></textarea></td> </tr>"; echo "<tr> [b]<td><center><input type='button' value='Tilbake' onClick='history.go(-1)'></center></td>[/b] <td colspan=2><center><input type='submit' value='Bestil'></center></td> </tr>"; echo "</form>"; echo "</table>"; ?> </html> And we're back online... again! It may have taken 3-4 days, but we're back.
Hello everyone! I am a new user and I have a simple question. How to download the database and create a backup. nothing is echoed for the second foreach??? foreach($pictures as $picture) -im breaking cause it's a large file Code: [Select] $doc = new DOMDocument(); $doc->load('accommodation.xml'); $i = 0; $accommodations = $doc->getElementsByTagName('accommodation'); foreach($accommodations as $accommodation) { if(++$i > 2) break; $supplierID = $accommodation->getElementsByTagName('code')->item(0)->nodeValue; $pictures = $accommodation->getElementsByTagName('pictures')->item(0)->nodeValue; $pictures=array(); foreach($pictures as $picture) { echo $url = $picture->getElementsByTagName('url')->item(0)->nodeValue; } }//end //XMl schema <?xml version="1.0" encoding="utf-8"?> <accommodations> <accommodation> <code>1</code> <pictures> <picture> <url>http://example.com/images.k.jpg</url> </picture> </pictures> Perhaps a simple task... I did ASP coding before, now I'm into PHP. So I'm a newbie in PHP. 2 arrays : $array1 = array("1","2","3","4"); and $array2 = array("1","2"); In array2 you'll find the numbers that need to be excluded from array1. So I should have als result 3 and 4. I tried since 2 days now and can only check and exclude 1 number from array2 butnot dynamical ! Code: [Select] $ii = 1; foreach( $arrayLordervalue as $value ) { if( $value == 1 )continue; //komma's tussen de cijfers plaatsen if($ii == 1){ $values[$ii] = $value;} else { $values[$ii] = ",". $value; } $value2= $value2.$values[$ii]; $ii++; } echo $value2; Gives me 2,3,4. I'm completely stuck ! I tried foreach, for ($n...),while... bah what's left ? This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=351259.0 I have found a point in my site where the user may wish to go back a page. Using the back button in the browser works perfectly fine. However, for aesthetical reasons and for "obvious function" reasons i need to create a button on the page which goes back a step in the browsers history. I know I can do this with Javascript, but I would rather get it done with php first. Therefore is it possible to create a back button in PHP. The back button in question will go back one step in the browsers history to the same .php it is currently on but in a previous state. I found this from google, http://www.webmasterworld.com/forum88/870.htm, but then found there was some js in the answers. I cannot find any other posts similar to this in php freaks Hello friends, I've php script that create files for example you enter file name (ex : test.php) file content (ex: any text ) it will create test.php file with the same content you entered. but the problem it add back slah \ before " or ' how can i stop it and make it not add back slash before " and ' here is the code <?php function saveFile($filename,$filecontent){ if (strlen($filename)>0){ $file = @fopen($filename,"w"); if ($file != false){ fwrite($file,$filecontent); fclose($file); return 1; } return -2; } return -1; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="domain" id="domain"> File name: <input name="filename" type="text" value="<?php echo $domainbase; ?>" /> File content: <textarea name="filecontent" rows="15" cols="46"></textarea> <input type="submit" name="submitBtn" value="Save file" /> </form> <?php if (isset($_POST['submitBtn'])){ $filename = (isset($_POST['filename'])) ? $_POST['filename'] : '' ; $filecontent = (isset($_POST['filecontent'])) ? $_POST['filecontent'] : '' ; if (saveFile($filename,$filecontent) == 1){ echo "File was saved"; } else if (saveFile($filename,$filecontent) == -2){ echo "An error occured during saving file"; } else if (saveFile($filename,$filecontent) == -1){ echo "Wrong file name"; } } ?> thank you alot it will really helps me alot hello PHP geniuses! I am new to this whole thing... so please be patient with me I have a form that is working great.... there are just a couple of things that I would like it to do that I can't figure out. PHP is still a mystery to me, but I am trying to learn. If I include the code, I am hoping someone can help. I would like to know if I can 1. cc the sender the form details 2. pull form data to create the subject line This is a HiQform, with attachments... My HTML: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Studio Job Ticket</title> <link rel="stylesheet" type="text/css" href="view.css" media="all"> <script type="text/javascript" src="view.js"></script> <script type="text/javascript" src="calendar.js"></script> </head> <body id="main_body" > <img id="top" src="top.png" alt=""> <div id="form_container"> <h1><a>Studio Job Ticket</a></h1> <form id="studio job ticket" class="appnitro" enctype="multipart/form-data" method="post" action="HiQFM.php"> <div class="form_description"> <input type=hidden name="recipient" value="dayle_sheward@rogers.com,dayle.sheward@juniperpark.com"> <input type="hidden" name="redirect" value="http://dayle.me/form/thankyou.html"> <input type="hidden" name="form_format" value="html"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> <input type="hidden" name="path_to_file" value="http://dayle.me/form/TEMP_FILES"> <input type="hidden" name="subject" value="Studio Job Ticket"> <input type=hidden name="style_sheet" value="view.css"> <br /> <h2>Studio Job Ticket</h2> <p>The purpose of this form is to ensure the Juniper Park Studio receives all necessary files and information needed for dockets to be done in timely and accurate fashion. Please provide as <br /> much information as possible.</p> <p>Once this job ticket is received, you will be contacted by phone or email, confirming your job is <br /> in progress, with a rough estimate on when you can expect the first proof. </p> </div> <ul > <li class="description" id="li_1" > <label class="description" for="account manager">Account Manager</label> <span> <input id="first name" name= "first name" class="element text" maxlength="255" size="10" value=""/> <label>First</label> </span> <span> <input id="last name" name= "last name" class="element text" maxlength="255" size="14" value=""/> <label>Last</label> </span> </li> <li id="li_2" > <label class="description" for="email">Email</label> <div> <input id="email" name="email" class="element text" type="text" maxlength="255" value=""/> </div> </li> <li id="li_3" > <label class="description" for="job">Job</label> <span> <input id="client" name= "client" class="element text" maxlength="255" size="8" value=""/> <label>Client</label> </span> <span> <input id="brand" name= "brand" class="element text" maxlength="255" size="14" value=""/> <label>Brand</label> </span> </li> <li id="li_4" > <label class="description" for="media type">Media Type</label> <div> <select class="element select medium" id="media type" name="media type"> <option value=""selected="selected"></option> <option value="Award Work" >Awards Work</option> <option value="Collateral" >Collateral</option> <option value="OOH" >OOH</option> <option value="Print" >Print</option> <option value="Retouching" >Retouching</option> <option value="Photography" >Photography</option> </select> </div> </li> <li id="li_5" > <label class="description" for="docket">Docket (work cannot start without this)</label> <div> <input id="docket" name="docket" class="element text" type="text" maxlength="255" value=""/> </div> </li> <li id="li_6" > <label class="description" for="job">Creative Team</label> <span> <input id="AD" name= "AD" class="element text" maxlength="255" size="14" value=""/> <label>AD</label> </span> <span> <input id="Writer" name= "Writer" class="element text" maxlength="255" size="14" value=""/> <label>Writer</label> </span></li> <li id="li_7" > <label class="description" for="Supplied">Additional Information to Supply</label> <span> <input id="copy deck" name="copy deck" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_6_1">Copy Deck</label> <input id="spec sheet" name="spec sheet" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_6_2">Spec Sheet</label> <input id="ma" name="ma" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_6_3">MA</label> <input id="creative files" name="creative files" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="element_6_3">Creative Files</label> Please specify location files:</span></li> <li > <div> <input id="creative file location" name="creative file location" class="element text" type="text" maxlength="255" value=""/> or<br /> <input id="emailedYN" name="emailedYN" class="element checkbox" type="checkbox" value="1" /> <label class="choice" for="emailedYN">Check if to be Emailed</label> </div> </li> <li id="li_7" > <label class="description" for="upload">Upload a File </label> <div> <input id="attachment" name="attachment[]" class="element file" type="file"/> </div> </li> <li id="li_3" > <label class="description" for="due date">Due Date </label> <span> <input id="element_3_1" name="MM" class="element text" size="2" maxlength="2" value="" type="text"> / <label for="element_3_1">MM</label> </span> <span> <input id="element_3_2" name="DD" class="element text" size="2" maxlength="2" value="" type="text"> / <label for="element_3_2">DD</label> </span> <span> <input id="element_3_3" name="YYYY" class="element text" size="4" maxlength="4" value="" type="text"> <label for="element_3_3">YYYY</label> </span> <span id="calendar_3"> <img id="cal_img_3" class="datepicker" src="calendar.gif" alt="Pick a date."> </span> <script type="text/javascript"> Calendar.setup({ inputField : "element_3_3", baseField : "element_3", displayArea : "calendar_3", button : "cal_img_3", ifFormat : "%B %e, %Y", onSelect : selectDate }); </script> <li id="li_10" > <label class="description" for="element_10">Production Details</label> <div class="left"> <input id="trim" name="trim" class="element text" value="" type="text"> <label for="trim">Trim Size (width x height)</label> </div> <div class="right"> <input id="live" name="live" class="element text" value="" type="text"> <label for="live">Live (width x height)</label> </div> <div class="left"> <input id="bleed" name="bleed" class="element text" value="" type="text"> <label for="bleed">Bleed (width x height)</label> </div> <div class="right"> <input id="#mechanicals" name="#mechanicals" class="element text" value="" type="text"> <label for="#mechanicals"># of Mechanicals (if multiple, please provide a MA or spreadsheet)</label> </div> <div class="left"> <input id="die line" name="die line" class="element text" value="" type="text"> <label for="die line">Die Line</label> </div> <div class="right"> <input id="PU docket" name="PU docket" class="element text" value="" type="text"> <label for="PU docket">Pick-Up docket</label> </div> <div class="left"> <input id="FilesReq" name="FilesReq" class="element text" maxlength="15" value="" type="text"> <label for="FilesReq">To supply raw collected files or PDFX1a</label> </div> <div class="right"> <select class="element select medium" id="delivery" name="delivery" onClick='alert("Please provide all deliverable details, such as FTP/emails etc.; info in the ADDITIONAL INFO area below.")'> <option value="" selected="selected"></option> <option value="File Cargo" >File Cargo</option> <option value="FTP" >FTP</option> <option value="Email" >Email</option> <option value="Temp Folder" >Temp Folder</option> <option value="Disk" >Disk</option> </select> <label for="deliverable info">Deliverable Info</label> </div> </li> </li> <li id="li_13" > <label class="description" for="Additional">Additional Info</label> <div> <textarea id="Additional" name="Additional" class="element textarea medium"></textarea> </div> </li> </ul> <p> <label for="userCopyMe">Check the box if you wish to be sent a copy of this message</label> <br /> <input type="checkbox" name="userCopyMe" id="userCopyMe" value="1" <?php if ($userCopyMe == "1") { echo "checked=\"checked\""; }?> /> </p> <li class="buttons" id="saveForm"> <input type="reset" value="Reset" > <input id="saveForm" class="button_text" type="submit" name="submit" value="Submit" onclick="verify();"> </li> </ul> </form> <div id="footer"></div> </div> <img id="bottom" src="bottom.png" alt=""> </body> <name="form_delivery" value="digest"/> </form> </html> Thanks in advance! EDIT: pinche code tags. Hi All I am wanting to start writing neater coding so am wanting to refer to coding in a functions file. So for example, If i was getting info from database using the following code Code: [Select] $queryone = "SELECT * from affiliate where size='300x250' ORDER BY RAND() LIMIT 1"; $result = mysql_query($queryone); while ($row = mysql_fetch_assoc($result)) { echo "".$row['code'].""; } I would want this to go in a file called functions.php Then in my index.php(for example) I would want to link up to this code. Can anyone point me in the right direction please? Thanks! Hi guys, I am starting out on mvc, I been reading up on it for a bit now.. and I was just wondering if anyone can take a quick look at it and give me some insight on it? maybe some suggestions etc.. I will be using this for a some what medium site when I know that it is good enough to be published. Note that its not done.. in reality I just need to make sure I am heading in the right direction. Hello guys, im new here , hope i meet great and friendly people here. Anyway, i need some help with a new Post back setup and hope anyone here could help me. This old script work but have problem to put in the new post back, here is it. Code: [Select] include("includes.php"); $subid = $_REQUEST['subid']; $survey = $_REQUEST['survey']; $earn = $_REQUEST['earn']; $pdtshow = $_REQUEST['pdtshow']; //$query_getuserid = mysql_query("SELECT id from members WHERE username= '".$subid."'") or die(mysql_error()); //foreach(mysql_fetch_array($query_getuserid) as $userid); $query_checkRef = mysql_query("SELECT referral_ID from members WHERE username= '".$subid."'") or die(mysql_error()); foreach(mysql_fetch_array($query_checkRef) as $ref_id_user); if ($ref_id_user>=1) { mysql_query("UPDATE members SET points=points+".$pdtshow." WHERE username='".$subid."'"); mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE username ='".$subid."'"); mysql_query("UPDATE members SET points=points+".$refer_points." WHERE id ='".$ref_id_user."'"); mysql_close(); echo "Success: ".$subid." earned ".$pdtshow." points\n and is referred by".$ref_id_user; }else { mysql_query("UPDATE members SET points=points+".$pdtshow." WHERE username='".$subid."'"); mysql_query("UPDATE members SET completed_surveys=completed_surveys+1 WHERE username ='".$subid."'"); mysql_close(); echo "Success: ".$subid." earned ".$pdtshow." points\n and is referred by nobody"; } ?> Here is the new postback i should insert. Code: [Select] cvid ip name status sid And it should seem like this: http://example.com/postback.php?txid=1234&ip=123.123.123.123&name=Unlocker+#1&status=1&sid=abc Can anyone help me out ? Maybe insert it for me and send it over to me -Trizocy I am getting strange behavior after a user submits a comment. After they comment on an article, I display a success message with two buttons: "Return to Article" and "Go to Home Page" Each button seems to work, and I was even able to "Return to Article" and then hit my browser's Back button to return the original "You Comment was Added" message, but if I hit the Back button after hitting "Go to Home Page" I got this error... Quote Notice: Undefined index: pageTitle in /Users/user1/Documents/DEV/++htdocs/01_MyProject/add_comment.php on line 39 Call Stack On Line 39 I have this code... Code: [Select] // Set Page Title. $pageTitle = $_SESSION['pageTitle']; It seems to me that if a user hits the Back button in general it will often cause problems, so is there a way to handle this?? I'm not exactly certain is causing the error above in the first place since my SESSION should be intact.... Debbie Hi everyone reading this, I have used PHP before as a hobby programmer but recently my boss asked me to make a webpage to accept worker's hours and store them in a database. So I realize that in the last few years object oriented style has been added into PHP. I have learnt OOP (C++) about a decade ago and understand the fundamentals of it. If I am writing this website code, am I going to be better off spending the time to get familiar with the new OOP stuff in PHP and use that or would it be better to just use an old sequential style of programming? I know this may seem like apples and oranges and that it varies based on opinion, but maybe there can be reasons for me to use OOP over sequential. For instance, if I write this code to be flexible enough that I can do a basic "worker times" table first, then I might be able to add additional functionality later, like worker details and qualifications, all of which could be brought up with the click of a button. Will it generally be easier to add onto code using OOP? |