Changeset 190
- Timestamp:
- 06/09/06 16:47:52 (2 years ago)
- Files:
-
- admin.lib.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
admin.lib.php
r189 r190 704 704 } 705 705 } 706 707 // prints a form populated with email addresses that can avoid moderation on comments 706 //prints a form populated with email addresses that can avoid moderation on comments 708 707 function printAuthorisedUsers() { 709 708 echo "<div class=\"entry\">\n"; 710 709 echo "<a name=\"emails\"></a>\n"; 711 710 echo "<h2>"._("Known Users")."</h2>\n"; 711 //if comment moderation is off tell the user its a bit daft 712 712 if(!$this->blog->comment_moderation) { 713 713 echo "<p>"._("Comment moderation is turned off on your blog - anyone can post comments. To turn comment moderation on, visit the")." <a href=\"".$this->adminPath."settings\">"._("settings page")."</a>.</p>\n"; 714 echo "</div ";714 echo "</div>"; 715 715 return; 716 716 } 717 717 echo "<p>"._("Comments posted to your blog with an e-mail address that appears in the list below avoid the moderation queue and appear on your blog immediately.")."</p>\n"; 718 718 echo "<p>"._("To turn off comment moderation, visit the")." <a href=\"{$this->adminPath}settings\">"._("settings page")."</a>.</p>\n"; 719 720 719 echo "<form name=\"emailform\" id=\"emailform\" action=\"".$this->adminPath."updateauthusers\" method=\"post\">\n"; 721 720 echo "<select multiple=\"multiple\" name=\"emaillist[]\" size=\"10\">\n"; 722 723 721 $result = db_query("SELECT name,email FROM authorised_emails WHERE user_id=".$this->id." ORDER BY email ASC"); 724 722 while($r = db_getrow($result)) { … … 736 734 echo "</div>\n"; 737 735 } 738 736 //got here, need to check for valid email address and such before hitting the db 737 //udates the list of authorised users. 739 738 function updateAuthorisedUsers($quiet=FALSE) { 740 739 if(isset($_POST['delete'])) { … … 747 746 } 748 747 $del = substr($del, 0, -4).")"; 749 $sql = "DELETE FROM authorised_emails WHERE $del AND user_id={$this->id}";750 $ret = db_query($sql);751 if(db_error($ret)) {752 error(2, _("Database commit error: ").db_error($ret));753 } else {754 echo "<div class=\"updateinfo\">"._("Address(es) deleted")."</div>\n";755 }748 $sql = "DELETE FROM authorised_emails WHERE $del AND user_id={$this->id}"; 749 $ret = db_query($sql); 750 if(db_error($ret)) { 751 error(2, _("Database commit error: ").db_error($ret)); 752 } else { 753 echo "<div class=\"updateinfo\">"._("Address(es) deleted")."</div>\n"; 754 } 756 755 } 757 756 } elseif(isset($_POST['addnew'])) { … … 772 771 } 773 772 } 774 775 773 } 776 774 if(!$quiet){ … … 779 777 } 780 778 } 781 782 function printEntries($amount=0, $title=TRUE) 783 { 779 //prints a list of entries for the admin front page. 780 function printEntries($amount=0, $title=TRUE)printEntries { 784 781 $limit = ($amount > 0) ? " LIMIT $amount" : ""; 785 782 $result = db_query("SELECT shortsubject,timestamp,subject FROM entries WHERE user_id = '".$this->id."' ORDER BY timestamp DESC $limit;"); 786 783 if(db_num_rows($result)==0){ 787 784 error(5, _("No entries found.")); 788 } 789 else { 785 } else { 790 786 if($title){ 791 787 echo "<div class=\"entry\"><h2>"._("Edit Entries")."</h2>\n"; … … 810 806 } 811 807 } 812 808 //confirm entry deletion 813 809 function confirmDeleteEntries() { 814 810 echo "<form action=\"{$this->adminPath}deleteentries/\" method=\"post\">\n"; … … 816 812 $rownum = 0; 817 813 foreach ($_REQUEST[entry] as $entry) { 814 $entry = $this->blog->makeCleanString($entry); 818 815 echo "<input type=\"hidden\" name=\"entry[".$rownum++."]\" value=\"{$entry}\" />"; 819 816 echo "<li>".$entry."</li>\n"; … … 823 820 echo "</form>\n"; 824 821 } 825 826 function deleteEntries() 827 { 822 //deletes entries 823 function deleteEntries() { 828 824 if (count($_POST['entry'])==0) { 829 825 error(4, _("No entries marked for deletion.")); 830 826 } else { 827 //Need to check the entries exist first 831 828 if ($_REQUEST[submit]==_("Yes")) { 832 829 $sql = "DELETE FROM entries WHERE ("; 833 830 foreach($_POST['entry'] as $id) { 834 831 $sql .= "shortsubject = '".$this->blog->makeCleanString($id)."' OR "; 835 }832 } 836 833 $sql = substr($sql, 0, -4); 837 834 $sql .= ") AND user_id = {$this->id};"; 838 839 835 db_query($sql); 840 836 echo count($_POST['entry'])._(" post(s) deleted"); … … 844 840 } 845 841 } 846 842 //constructs the main page 847 843 function mainPage() { 848 844 //Should display blog entries here … … 855 851 echo "</div>\n"; 856 852 } 857 858 function addUser() 859 { 853 //adds a user 854 function addUser() { 860 855 $username = ''; 861 856 $password = makePassword(); … … 867 862 if (safeuname($_POST['username'])) { 868 863 $username = addslashes(trim(strip_tags($_POST['username']))); 869 } 870 else { 864 } else { 871 865 $this->inputError = _("Invalid Username Provided"); 872 866 } … … 900 894 //check there is a system user with this name (ie if they are a sucs member) 901 895 if(!posix_getpwnam($username)) { 902 $this->inputError = _("You need to be a SUCS member to sign up for a blog here!"); 903 } 904 //check the user is a member of the users, staff or socieys groups 905 else { 896 $this->inputError = _("You need to be a SUCS member to sign up for a blog here!"); 897 } else { 898 //check the user is a member of the users, staff or socieys groups 906 899 $posixInfo = posix_getpwnam($username); 907 900 if ($posixInfo[gid] != 100 && $posixInfo[gid] != 106 && $posixInfo[gid] != 113) { … … 918 911 if (!db_query($sql)) { 919 912 error(2,_("Database Insertion failed - ").db_error(db_query($sql))); 920 } 921 //else mail the password to the user and report sucsess 922 else { 913 } else { 914 //else mail the password to the user and report sucsess 923 915 mail( 924 916 "{$username}@sucs.org", … … 933 925 $this->printLoginForm(); 934 926 } 935 } 936 //return to the form 937 else { 927 } else { 928 //return to the form 938 929 $this->addUserForm(); 939 930 } 940 931 } 941 942 // ok this should take all the input and post it to addUser, passing in the current user and stuff... i think... 943 function addUserForm() 944 { 932 //this should take all the input and post it to addUser, passing in the current user and stuff... i think... 933 function addUserForm() { 945 934 echo "<div class=\"entry\">\n"; 946 935 if ($this->inputError != "") { … … 968 957 echo "<p>\n"; 969 958 echo "<input name=\"submit\" type=\"submit\" id=\"submit\" tabindex=\"4\" value=\""._("Sign Up")."\" />\n"; 970 echo "</p>\n"; 959 echo "</p>\n"; 971 960 echo "</form>\n"; 972 961 echo "<p>"._("You need to be a member of ")."<a href=\"http://sucs.org/\">SUCS</a>"._(" to register")."<br />"._("The normal ")."<a href=\"http://sucs.org/info/conditions.php\">"._("Terms and Conditions")."</a>"._(" apply")."</p>\n"; 973 echo "</div>\n"; 974 echo "</div>\n"; 962 echo "</div>\n"; 963 echo "</div>\n"; 975 964 } 976 965 }
