Changeset 3952

Show
Ignore:
Timestamp:
Sat Oct 1 11:50:26 2005
Author:
mugur
Message:

fixed ticket:1360 - Admin Interface: Add ability to start/stop/restart the parser from within the admin interface

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/campsite/implementation/database/campsite-db.sql

    r3832 r3952  
    703 703   `EditorCopyCutPaste` enum('N','Y') NOT NULL default 'N',  
    704 704   `ManageReaders` enum('N','Y') NOT NULL default 'N',  
      705   `InitializeTemplateEngine` enum('N','Y') NOT NULL default 'N',  
    705 706   PRIMARY KEY  (`IdUser`)  
    706 707 ) TYPE=MyISAM;  
     
    710 711 --  
    711 712  
    712   INSERT INTO `UserPerm` (`IdUser`, `ManagePub`, `DeletePub`, `ManageIssue`, `DeleteIssue`, `ManageSection`, `DeleteSection`, `AddArticle`, `ChangeArticle`, `DeleteArticle`, `AddImage`, `ChangeImage`, `DeleteImage`, `ManageTempl`, `DeleteTempl`, `ManageUsers`, `ManageSubscriptions`, `DeleteUsers`, `ManageUserTypes`, `ManageArticleTypes`, `DeleteArticleTypes`, `ManageLanguages`, `DeleteLanguages`, `ManageDictionary`, `DeleteDictionary`, `ManageCountries`, `DeleteCountries`, `ManageClasses`, `MailNotify`, `ViewLogs`, `ManageLocalizer`, `ManageIndexer`, `Publish`, `ManageTopics`, `EditorImage`, `EditorTextAlignment`, `EditorFontColor`, `EditorFontSize`, `EditorFontFace`, `EditorTable`, `EditorSuperscript`, `EditorSubscript`, `EditorStrikethrough`, `EditorIndent`, `EditorListBullet`, `EditorListNumber`, `EditorHorizontalRule`, `EditorSourceView`, `EditorEnlarge`, `EditorTextDirection`, `EditorLink`, `EditorSubhead`, `EditorBold`, `EditorItalic`, `EditorUnderline`, `EditorUndoRedo`, `EditorCopyCutPaste`, `ManageReaders`) VALUES (1,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');  
      713 INSERT INTO `UserPerm` (`IdUser`, `ManagePub`, `DeletePub`, `ManageIssue`, `DeleteIssue`, `ManageSection`, `DeleteSection`, `AddArticle`, `ChangeArticle`, `DeleteArticle`, `AddImage`, `ChangeImage`, `DeleteImage`, `ManageTempl`, `DeleteTempl`, `ManageUsers`, `ManageSubscriptions`, `DeleteUsers`, `ManageUserTypes`, `ManageArticleTypes`, `DeleteArticleTypes`, `ManageLanguages`, `DeleteLanguages`, `ManageDictionary`, `DeleteDictionary`, `ManageCountries`, `DeleteCountries`, `ManageClasses`, `MailNotify`, `ViewLogs`, `ManageLocalizer`, `ManageIndexer`, `Publish`, `ManageTopics`, `EditorImage`, `EditorTextAlignment`, `EditorFontColor`, `EditorFontSize`, `EditorFontFace`, `EditorTable`, `EditorSuperscript`, `EditorSubscript`, `EditorStrikethrough`, `EditorIndent`, `EditorListBullet`, `EditorListNumber`, `EditorHorizontalRule`, `EditorSourceView`, `EditorEnlarge`, `EditorTextDirection`, `EditorLink`, `EditorSubhead`, `EditorBold`, `EditorItalic`, `EditorUnderline`, `EditorUndoRedo`, `EditorCopyCutPaste`, `ManageReaders`, `InitializeTemplateEngine`) VALUES (1,'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');  
    712 713  
    713 714 --  
     
    777 778   `EditorCopyCutPaste` enum('N','Y') NOT NULL default 'N',  
    778 779   `ManageReaders` enum('N','Y') NOT NULL default 'N',  
      780   `InitializeTemplateEngine` enum('N','Y') NOT NULL default 'N',  
    779 781   PRIMARY KEY  (`Name`)  
    780 782 ) TYPE=MyISAM;  
    784 786 --  
    785 787  
    786   INSERT INTO `UserTypes` (`Name`, `Reader`, `ManagePub`, `DeletePub`, `ManageIssue`, `DeleteIssue`, `ManageSection`, `DeleteSection`, `AddArticle`, `ChangeArticle`, `DeleteArticle`, `AddImage`, `ChangeImage`, `DeleteImage`, `ManageTempl`, `DeleteTempl`, `ManageUsers`, `ManageSubscriptions`, `DeleteUsers`, `ManageUserTypes`, `ManageArticleTypes`, `DeleteArticleTypes`, `ManageLanguages`, `DeleteLanguages`, `ManageDictionary`, `DeleteDictionary`, `ManageCountries`, `DeleteCountries`, `ManageClasses`, `MailNotify`, `ViewLogs`, `ManageLocalizer`, `ManageIndexer`, `Publish`, `ManageTopics`, `EditorImage`, `EditorTextAlignment`, `EditorFontColor`, `EditorFontSize`, `EditorFontFace`, `EditorTable`, `EditorSuperscript`, `EditorSubscript`, `EditorStrikethrough`, `EditorIndent`, `EditorListBullet`, `EditorListNumber`, `EditorHorizontalRule`, `EditorSourceView`, `EditorEnlarge`, `EditorTextDirection`, `EditorLink`, `EditorSubhead`, `EditorBold`, `EditorItalic`, `EditorUnderline`, `EditorUndoRedo`, `EditorCopyCutPaste`, `ManageReaders`) VALUES ('Reader','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'),('Administrator','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'),('Editor','N','N','N','N','N','N','N','Y','Y','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N','N','Y','Y','Y','N','Y','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','N'),('Chief Editor','N','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','Y','Y','N','N','N','N','N','N','N','N','Y','Y','N','Y','Y','Y','N','Y','N','N','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y');  
      788 INSERT INTO `UserTypes` (`Name`, `Reader`, `ManagePub`, `DeletePub`, `ManageIssue`, `DeleteIssue`, `ManageSection`, `DeleteSection`, `AddArticle`, `ChangeArticle`, `DeleteArticle`, `AddImage`, `ChangeImage`, `DeleteImage`, `ManageTempl`, `DeleteTempl`, `ManageUsers`, `ManageSubscriptions`, `DeleteUsers`, `ManageUserTypes`, `ManageArticleTypes`, `DeleteArticleTypes`, `ManageLanguages`, `DeleteLanguages`, `ManageDictionary`, `DeleteDictionary`, `ManageCountries`, `DeleteCountries`, `ManageClasses`, `MailNotify`, `ViewLogs`, `ManageLocalizer`, `ManageIndexer`, `Publish`, `ManageTopics`, `EditorImage`, `EditorTextAlignment`, `EditorFontColor`, `EditorFontSize`, `EditorFontFace`, `EditorTable`, `EditorSuperscript`, `EditorSubscript`, `EditorStrikethrough`, `EditorIndent`, `EditorListBullet`, `EditorListNumber`, `EditorHorizontalRule`, `EditorSourceView`, `EditorEnlarge`, `EditorTextDirection`, `EditorLink`, `EditorSubhead`, `EditorBold`, `EditorItalic`, `EditorUnderline`, `EditorUndoRedo`, `EditorCopyCutPaste`, `ManageReaders`, `InitializeTemplateEngine`) VALUES ('Reader','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N'),('Administrator','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y'),('Editor','N','N','N','N','N','N','N','Y','Y','Y','Y','Y','Y','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','Y','N','N','N','N','N','Y','Y','N','N','N','Y','Y','Y','N','Y','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N'),('Chief Editor','N','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N','N','N','N','Y','Y','N','N','N','N','N','N','N','N','Y','Y','N','Y','Y','Y','N','Y','N','N','Y','Y','Y','Y','Y','Y','Y','N','N','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N');  
    786 788  
    787 789 --  
  • trunk/campsite/implementation/management/priv/menu.php

    r3938 r3952  
    163 163     array("icon" => sprintf($iconTemplateStr, "change_password.png")));  
    164 164 $menu_actions->addItem($menu_item);  
    165        
      165  
      166 if ($User->hasPermission("InitializeTemplateEngine")) {  
      167     $menu_item =& DynMenuItem::Create(getGS('Restart the template engine'), "/$ADMIN/home.php?restart_engine=yes",  
      168         array("icon" => sprintf($iconTemplateStr, "actions.png")));  
      169     $menu_actions->addItem($menu_item);  
      170 }  
      171  
    166 172 if ($showConfigureMenu) {  
    167 173     $menu_root->addSplit();  
  • trunk/campsite/implementation/management/priv/users/do_edit.php

    r3903 r3952  
    96 96         'EditorStrikethrough'=>'N', 'EditorIndent'=>'N', 'EditorListBullet'=>'N',  
    97 97         'EditorListNumber'=>'N', 'EditorHorizontalRule'=>'N', 'EditorSourceView'=>'N',  
    98           'EditorEnlarge'=>'N', 'EditorTextDirection'=>'N', 'EditorLink'=>'N', 'EditorSubhead'=>'N');  
      98         'EditorEnlarge'=>'N', 'EditorTextDirection'=>'N', 'EditorLink'=>'N', 'EditorSubhead'=>'N',  
      99         'InitializeTemplateEngine'=>'N');  
    99 100     foreach ($rightsFields as $field=>$value) {  
    100 101         $val = Input::Get($field, 'string', 'off');  
  • trunk/campsite/implementation/management/priv/users/access_form.php

    r3903 r3952  
    42 42     'DeleteTempl'=>'User may delete templates');  
    43 43  
      44 $administrative_group = array('InitializeTemplateEngine'=>'User may restart the template engine');  
      45  
    44 46 $users_group = array('ManageUsers'=>'User may add/change staff accounts and passwords',  
    45 47     'DeleteUsers'=>'User may delete staff accounts',  
    90 92  
    91 93 $rights = array('Content'=>$content_group, 'Templates'=>$templates_group,  
    92       'Staff/Subscribers Management'=>$users_group, 'Article Types'=>$article_types_group,  
    93       'Languages'=>$languages_group, 'Countries'=>$countries_group,  
    94       'Miscellaneous'=>$misc_group, 'Localizer'=>$localizer_group,  
      94     'Staff/Subscribers Management'=>$users_group, 'Administrative tasks'=>$administrative_group,  
      95     'Article Types'=>$article_types_group, 'Languages'=>$languages_group,  
      96     'Countries'=>$countries_group, 'Miscellaneous'=>$misc_group, 'Localizer'=>$localizer_group,  
    95 97     'Editor Basic Settings'=>$editor_group_1, 'Editor Advanced Font Settings'=>$editor_group_2,  
    96 98     'Editor Table Settings'=>$editor_group_3, 'Editor Miscellaneous Settings'=>$editor_group_4);  
  • trunk/campsite/implementation/management/priv/u_types/access.php

    r3903 r3952  
    41 41     'DeleteTempl'=>'User may delete templates');  
    42 42  
      43 $administrative_group = array('InitializeTemplateEngine'=>'User may restart the template engine');  
      44  
    43 45 $users_group = array('ManageUsers'=>'User may add/change staff accounts and passwords',  
    44 46     'DeleteUsers'=>'User may delete staff accounts',  
    89 91  
    90 92 $rights = array('Content'=>$content_group, 'Templates'=>$templates_group,  
    91       'Staff/Subscribers Management'=>$users_group, 'Article Types'=>$article_types_group,  
    92       'Languages'=>$languages_group, 'Countries'=>$countries_group,  
    93       'Miscellaneous'=>$misc_group, 'Localizer'=>$localizer_group,  
      93     'Staff/Subscribers Management'=>$users_group, 'Administrative tasks'=>$administrative_group,  
      94     'Article Types'=>$article_types_group, 'Languages'=>$languages_group,  
      95     'Countries'=>$countries_group, 'Miscellaneous'=>$misc_group, 'Localizer'=>$localizer_group,  
    94 96     'Editor Basic Settings'=>$editor_group_1, 'Editor Advanced Font Settings'=>$editor_group_2,  
    95 97     'Editor Table Settings'=>$editor_group_3, 'Editor Miscellaneous Settings'=>$editor_group_4);  
  • trunk/campsite/implementation/management/priv/u_types/do_access.php

    r3903 r3952  
    36 36     'EditorIndent'=>'N', 'EditorListBullet'=>'N', 'EditorListNumber'=>'N', 'EditorHorizontalRule'=>'N',  
    37 37     'EditorSourceView'=>'N', 'EditorEnlarge'=>'N', 'EditorTextDirection'=>'N', 'EditorLink'=>'N',  
    38       'EditorSubhead'=>'N');  
      38     'EditorSubhead'=>'N', 'InitializeTemplateEngine'=>'N');  
    38 38 foreach ($rightsFields as $field=>$value) {  
    39 39     $val = Input::Get($field, 'string', 'off');  
  • trunk/campsite/implementation/management/priv/globals.en.php

    r3916 r3952  
    268 268 regGS("User may use superscripts", "User may use superscripts");  
    269 269 regGS("User may use subscripts", "User may use subscripts");  
      270 regGS("User may restart the template engine", "User may restart the template engine");  
      271 regGS("Administrative tasks", "Administrative tasks");  
      272 regGS("Restart the template engine", "Restart the template engine");  
      273 regGS("The template engine was (re)started.", "The template engine was (re)started.");  
      274 regGS("The template engine could not be restarted! Please verify if the template engine was started by other user than $1.","The template engine could not be restarted! Please verify if the template engine was started by other user than $1.");  
    270 275 regGS("An user type with the name '$1' already exists.", "An user type with the name '$1' already exists.");  
    271 276 regGS("Localizer", "Localizer");  
  • trunk/campsite/implementation/management/priv/home.php

    r3903 r3952  
    54 54 </TR>  
    55 55 </TABLE>  
      56 <?php  
      57 $restartEngine = Input::Get('restart_engine', 'string', 'no', true);  
      58 if ($restartEngine == 'yes' && $User->hasPermission("InitializeTemplateEngine")) {  
      59     require_once($_SERVER['DOCUMENT_ROOT']."/parser_utils.php");  
      60     if (stop_parser()) {  
      61         $resMsg = getGS("The template engine was (re)started.");  
      62         $res = "OK";  
      63     } else {  
      64         $resMsg = getGS("The template engine could not be restarted! Please verify if the template engine was started by other user than $1.", $Campsite['APACHE_USER']);  
      65         $res = "ERROR";  
      66     }  
      67     start_parser();  
      68 }  
      69 ?>  
      70 <?php if ($resMsg != '') { ?>  
      71 <table border="0" cellpadding="0" cellspacing="0" align="center">  
      72 <tr>  
      73 <?php if ($res == 'OK') { ?>  
      74     <td class="info_message" align="center">  
      75 <?php } else { ?>  
      76     <td class="error_message" align="center">  
      77 <?php } ?>  
      78         <?php echo $resMsg; ?>  
      79     </td>  
      80 </tr>  
      81 </table>  
      82 <?php } ?>  
    56 83  
    57 84 <TABLE BORDER="0" CELLSPACING="4" CELLPADDING="2" WIDTH="100%">  
  • trunk/campsite/implementation/management/parser_utils.php

    r3890 r3952  
    5 5 $DEBUG = false;  
    6 6  
      7 function start_parser()  
      8 {  
      9     global $Campsite;  
      10      
      11     $binFile = $Campsite['BIN_DIR'] . "/campsite_server";  
      12     $args = " -i " . $Campsite['DATABASE_NAME'];  
      13     if (!file_exists($binFile)) {  
      14         $p_output[] = "Can't find the campsite_server binary; please check your Campsite install.";  
      15         return -1;  
      16     }  
      17     $childOutput = popen("$binFile$args", "r");  
      18     usleep(300000);  
      19     pclose($childOutput);  
      20 }  
      21  
      22 function stop_parser()  
      23 {  
      24     global $Campsite;  
      25      
      26     $instanceName = $Campsite['DATABASE_NAME'];  
      27     $cmd = "ps -o pid=pid,cmd=command -C campsite_server";  
      28     exec($cmd, $output, $returnValue);  
      29     foreach ($output as $line) {  
      30         $line = trim($line);  
      31         if (strncmp($line, "pid", 3) == 0) {  
      32             continue;  
      33         }  
      34         $elements = explode(" ", $line);  
      35         $elements = array_map('trim', $elements);  
      36         for ($i = 0; $i < sizeof($elements); $i++) {  
      37             if ($i == 0) {  
      38                 $processId = $elements[$i];  
      39             }  
      40             if ($elements[$i] == '-i') {  
      41                 $currentInstance = $elements[$i + 1];  
      42                 if ($instanceName == $currentInstance) {  
      43                     return posix_kill($processId, 15);  
      44                 }  
      45                 break;  
      46             }  
      47         }  
      48     }  
      49     return true;  
      50 }  
      51  
    7 52 function send_message_to_parser($msg, $close_socket = false)  
    8 53 {  
     
    16 61     debug_msg("parser port: " . $Campsite['PARSER_PORT']);  
    17 62  
    18       @$socket = fsockopen('127.0.0.1', $Campsite['PARSER_PORT'], $errno, $errstr, 30);  
      63     $errno = 0;  
      64     $errstr = "";  
      65     for ($i = 1; $i <= 3; $i++) {  
      66         @$socket = fsockopen('127.0.0.1', $Campsite['PARSER_PORT'], $errno, $errstr, 30);  
      67         if (!$socket) {  
      68             start_parser();  
      69             usleep(100000);  
      70         } else {  
      71             debug_msg("OK.");  
      72         }  
      73     }  
    19 74     if (!$socket) {  
    20           echo "<p>$errstr ($errno)</p>\n<font color=\"red\">\n";  
    21           echo "<h3>Unable to connect to Campsite server, please re-start the service.</h3>\n</font>\n";  
    22           echo "<h3>Type the following commands in a root shell:</h3>\n";  
    23           echo "<blockquote>\n";  
    24           echo "<h3>killall campsite_server</h3>\n";  
    25           echo "<h3>" . $Campsite['BIN_DIR'] . "/campsite_server</h3>\n";  
    26           echo "</blockquote>\n";  
    27 75         exit(0);  
    28       } else {  
    29           debug_msg("OK.");  
    30 76     }  
    31 77     $final_msg = "0001 $size $msg";  
     
    112 158     $parameters = array();  
    113 159     $pairs = explode("&", $query_string);  
    114       foreach ($pairs as $index=>$pair) {  
      160     foreach ($pairs as $pair) {  
    114 160         $pair_array = explode("=", $pair);  
    115 161         if (trim($pair_array[0]) != "")  
     
    135 181     $cookies = array();  
    136 182     $pairs = explode(";", $cookies_string);  
    137       foreach ($pairs as $index=>$pair) {  
      183     foreach ($pairs as $pair) {  
    137 183         $pair_array = explode("=", $pair);  
    138 184         if (trim($pair_array[0]) != "")  
    160 206         exit(0);  
    161 207     $index_file = "$document_root/index.php";  
    162       while ($row = mysql_fetch_array($res)) {  
      208     while (($row = mysql_fetch_array($res)) != null) {  
    162 208         $lang_code = $row["Code"];  
    163 209         $link = "$document_root/$lang_code.php";  
  • trunk/campsite/implementation/management/Makefile

    r3945 r3952  
    14 14     mkdir -p $(HTML_COMMON_DIR)/look  
    15 15     mkdir -p $(HTML_COMMON_DIR)/css  
    16       cp -f css/*.css $(HTML_COMMON_DIR)/css  
      16     cp -fr css $(HTML_COMMON_DIR)  
    16 16     mkdir -p $(HTML_COMMON_DIR)/classes  
    17 17     cp -f classes/*.php $(HTML_COMMON_DIR)/classes  
  • trunk/campsite/implementation/management/classes/UserType.php

    r3752 r3952  
    82 82         'EditorUndoRedo',  
    83 83         'EditorCopyCutPaste',  
    84           'ManageReaders');  
      84         'ManageReaders',  
      85         'InitializeTemplateEngine');  
    85 86      
    86 87      
  • trunk/campsite/implementation/parser/parser.kdevelop

    r2390 r3952  
    13 13     <ignoreparts/>  
    14 14     <secondaryLanguages/>  
      15     <versioncontrol>kdevsubversion</versioncontrol>  
    15 16   </general>  
    16 17   <kdevfileview>  
     
    19 20       <group pattern="*.cpp;*.c;*.cc;*.C;*.cxx;*.ec;*.ecpp;*.lxx;*.l++;*.ll;*.l" name="Sources" />  
    20 21       <group pattern="*" name="Others" />  
    21         <hidenonprojectfiles>false</hidenonprojectfiles>  
      22       <hidenonprojectfiles>true</hidenonprojectfiles>  
    21 22       <hidenonlocation>false</hidenonlocation>  
    22 23     </groups>  
     
    42 43       <customdirectory>/</customdirectory>  
    43 44       <mainprogram>parser/campsite_server</mainprogram>  
    44         <programargs/>  
      45       <programargs>-i campsite</programargs>  
    44 45       <terminal>false</terminal>  
    45 46       <autocompile>true</autocompile>  
     
    62 63       <prio>0</prio>  
    63 64       <makeoptions/>  
      65       <defaulttarget/>  
    64 66     </make>  
    65 67   </kdevcustomproject>  
     
    85 87       <headerCompletionDelay>250</headerCompletionDelay>  
    86 88     </codecompletion>  
      89     <creategettersetter>  
      90       <prefixGet/>  
      91       <prefixSet>set</prefixSet>  
      92       <prefixVariable>m_,_</prefixVariable>  
      93       <parameterName>theValue</parameterName>  
      94       <inlineGet>true</inlineGet>  
      95       <inlineSet>true</inlineSet>  
      96     </creategettersetter>  
    87 97   </kdevcppsupport>  
    88 98   <cppsupportpart>  
    124 134     </projectdoc>  
    125 135   </kdevdocumentation>  
      136   <ctagspart>  
      137     <customArguments/>  
      138     <customTagfilePath/>  
      139   </ctagspart>  
    126 140 </kdevelop>  
  • trunk/campsite/implementation/parser/parser/Makefile

    r2856 r3952  
    6 6  cmessage.o cmessagefactory.o cpublication.o cpublicationsregister.o curl.o\  
    7 7  curlshortnames.o curltype.o curltyperegister.o cxmlreader.o cxmltree.o\  
    8    curltemplatepath.o ccampsiteinstance.o  
      8  curltemplatepath.o  
    8 8  
    9 9  
     
    24 24  
    25 25 export CAMPSITE_SERVER=campsite_server  
    26   export CAMPSITECTL=campsitectl  
    27   export CAMPSITEINIT=campsite  
    28   export RC_INIT=/etc/init.d/  
    29 26  
    30   all: links scripts $(CAMPSITE_SERVER)  
      27 all: links $(CAMPSITE_SERVER)  
    30 27  
    31 28 links: dummy  
    32       if [ ! -L "configure.h" ]; then ln -s "$(INSTALL_CONF)/configure.h"; fi  
    33    
    34   scripts: dummy  
    35       ./create_scripts  
      29     @if [ ! -L "configure.h" ]; then ln -s "$(INSTALL_CONF)/configure.h"; fi  
    36 30  
    37 31 $(CAMPSITE_SERVER): $(OBJ_FILES)  
    47 41  
    48 42 install: all  
    49       ./install_parser  
      43     mkdir -p $(BIN_DIR)  
      44     @if [ -f $(BIN_DIR)/$(CAMPSITE_SERVER) ]; then $(KILLALL) -q campsite_server; rm -f $(BIN_DIR)/$(CAMPSITE_SERVER); fi  
      45     install -o $(APACHE_USER) -g $(APACHE_GROUP) -m 750 $(CAMPSITE_SERVER) "$(BIN_DIR)"  
      46     ./configure_parser  
    50 47  
    51 48 uninstall: dummy  
    52       ./uninstall_parser  
      49     rm -f $(BIN_DIR)/$(CAMPSITE_SERVER)  
    52 49  
    53 50 dummy:  
  • trunk/campsite/implementation/parser/parser/main.cpp

    r3302 r3952  
    57 57 #include "configure.h"  
    58 58 #include "csocket.h"  
    59   #include "ccampsiteinstance.h"  
    60 59 #include "thread.h"  
    61 60 #include "process_req.h"  
     
    65 64 #include "curltemplatepath.h"  
    66 65 #include "cmessagefactory.h"  
      66 #include "configure.h"  
      67 #include "readconf.h"  
    67 68  
    68 69 using std::cout;  
     
    73 74 #define MAX_THREADS 40  
    74 75  
      76 #ifdef _DEBUG_SOURCE  
      77 #warning *******************************************************************************  
      78 #warning This compilation option is for source code debugging, do not use in production!  
      79 #warning *******************************************************************************  
      80 #endif  
    75 81  
    76 82 CMessage* readMessage(CTCPSocket* p_pcoClSock, CMessageFactoryRegister& p_rcoMFReg)  
     
    266 272 }  
    267 273  
    268   // nMainThreadPid: pid of main thread  
    269   int nMainThreadPid;  
    270    
    271   // SigHandler: TERM signal handler  
    272   void SigHandler(int p_nSig)  
    273   {  
    274       if (nMainThreadPid != 0)  
    275       {  
    276           kill(nMainThreadPid, SIGTERM);  
    277           nMainThreadPid = 0;  
    278       }  
    279       exit(0);  
    280   }  
    281    
    282 274 // StartDaemon: run in background  
    283 275 void StartDaemon()  
    284 276 {  
    285       if (fork() != 0)  
      277     pid_t nChildPID = fork();  
      278     if (nChildPID > 0)  
      279     {  
      280         usleep(100000);  
    286 281         exit(0);  
      282     }  
      283     if (nChildPID < 0)  
      284     {  
      285         cerr << "Unable to start daemon" << endl;  
      286         exit(1);  
      287     }  
    287 288     setsid();  
    288 289 }  
     
    293 294 //      bool& p_rbRunAsDaemon - set by this function according to arguments  
    294 295 //      string& p_rcoConfDir - set by this function according to arguments  
    295   void ProcessArgs(int argc, char** argv, bool& p_rbRunAsDaemon, string& p_rcoConfDir)  
      296 void ProcessArgs(int argc, char** argv, bool& p_rbRunAsDaemon, string& p_rcoConfDir,  
      297                  string& p_rcoInstanceName)  
    296 298 {  
    297       if (argc < 2)  
    298           return ;  
      299     bool bError = false;  
    299 300     for (int i = 1; i < argc; i++)  
    300 301     {  
     
    303 304         if (strcmp(argv[i], "-c") == 0)  
    304 305         {  
    305               if (++i < argc)  
      306             if (++i >= argc)  
    305 306             {  
    306                   cerr << "You did not specify the configuration directory.";  
    307                   exit(1);  
      307                 cerr << "ERROR: You did not specify the configuration directory." << endl;  
      308                 bError = true;  
      309                 break;  
    308 310             }  
    309 311             else  
    310 312             {  
    311                   p_rcoConfDir = atoi(argv[i]);  
      313                 p_rcoConfDir = argv[i];  
      314             }  
      315         }  
      316         if (strcmp(argv[i], "-i") == 0)  
      317         {  
      318             if (++i >= argc)  
      319             {  
      320                 cerr << "ERROR: no instance name was specified. You must specify the name of the\n"  
      321                         << "instance you want to start." << endl;  
      322                 bError = true;  
      323                 break;  
      324             }  
      325             else  
      326             {  
      327                 p_rcoInstanceName = argv[i];  
    312 328             }  
    313 329         }  
    314 330         if (strcmp(argv[i], "-h") == 0)  
    315 331         {  
    316               cout << "Usage: campsite_server [-c <conf_dir>|-d|-h]\n"  
    317                       "where:\t-d: run in console (by default run as daemon)\n"  
    318                       "\t-c <conf_dir>: set the configuration directory\n"  
    319                       "\t-h: print this help message" << endl;  
    320               exit(0);  
      332             bError = true;  
      333             break;  
    321 334         }  
    322 335     }  
      336     if (p_rcoInstanceName == "")  
      337     {  
      338         cerr << "ERROR: no instance name was specified. You must specify the name of the\n"  
      339                 << "instance you want to start." << endl;  
      340         bError = true;  
      341     }  
      342     if (bError)  
      343     {  
      344         cout << "Usage: campsite_server -i <instance_name> [-c <conf_dir>|-d|-h]\n"  
      345                 "where:\t-i <instance name>: name of the instance to run\n"  
      346                 "\t-d: run in console (by default run as daemon)\n"  
      347                 "\t-c <conf_dir>: set the configuration directory\n"  
      348                 "\t-h: print this help message" << endl;  
      349         exit(1);  
      350     }  
    323 351 }  
    324 352  
     
    382 410  
    383 411  
    384   void parent_sig_handler(int p_nSigNum)  
    385   {  
    386   #ifdef _DEBUG  
    387       cerr << p_nSigNum << " signal received (parent)" << endl;  
    388   #endif  
    389    
    390       const CCampsiteInstanceMap& rcoInstances =  
    391               CCampsiteInstanceRegister::get().getCampsiteInstances();  
    392       CCampsiteInstanceMap::const_iterator coIt = rcoInstances.begin();  
    393       for (; coIt != rcoInstances.end(); ++coIt)  
    394       {  
    395   #ifdef _DEBUG  
    396           cerr << "stopping instance: " << (*coIt).second->getName() << endl;  
    397   #endif  
    398           (*coIt).second->stop();  
    399       }  
    400    
    401       exit(0);  
    402   }  
    403    
    404    
    405 412 void set_signals(sig_t p_sigHandler, bool p_bSetTERM = true,  
    406 413                  bool p_bSetHUP = true, bool p_bSetINT = true)  
     
    425 432  
    426 433  
    427   int CampsiteInstanceFunc(const ConfAttrValue& p_rcoConfValues);  
    428    
    429    
    430 434 // main: main function  
    431 435 // Return 0 if no error encountered; error code otherwise  
     
    436 440 {  
    437 441     bool bRunAsDaemon = true;  
    438       string coConfDir;  
    439       ProcessArgs(argc, argv, bRunAsDaemon, coConfDir);  
    440   #ifndef _DEBUG_SOURCE  
    441       if (bRunAsDaemon)  
    442           StartDaemon();  
    443    
    444       set_signals(parent_sig_handler);  
    445   #endif  
    446    
      442     string coConfDir, coInstanceName;  
      443     ProcessArgs(argc, argv, bRunAsDaemon, coConfDir, coInstanceName);  
    447 444     if (coConfDir == "")  
    448 445         coConfDir = ETC_DIR;  
    449       const CCampsiteInstanceMap& rcoInstances =  
    450               CCampsiteInstance::readFromDirectory(coConfDir, CampsiteInstanceFunc);  
      446     coConfDir += "/" + coInstanceName;  
    451 447  
    452       CCampsiteInstanceMap::const_iterator coIt = rcoInstances.begin();  
    453       for (; coIt != rcoInstances.end(); ++coIt)  
    454       {  
    455           (*coIt).second->run();  
    456       }  
    457   #ifndef _DEBUG_SOURCE  
    458       while (true)  
    459       {  
    460           int nStatus;  
    461           pid_t nChildPID = waitpid(-1, &nStatus, 0);  
    462           cerr << "child " << nChildPID << " exited with status " << nStatus << endl;  
    463           cerr << "waiting 10 seconds for " << nChildPID << endl;  
    464           sleep(10);  
    465           for (coIt = rcoInstances.begin(); coIt != rcoInstances.end(); ++coIt)  
    466           {  
    467               if (!(*coIt).second->isRunning())  
    468               {  
    469                   cerr << "starting instance " << (*coIt).second->getName() << endl;  
    470                   (*coIt).second->run();  
    471               }  
    472               else  
    473               {  
    474                   cerr << "instance " << (*coIt).second->getName() << " running" << endl;  
    475               }  
    476           }  
    477       }  
    478   #endif  
    479    
    480       return 0;  
    481   }  
    482    
    483   int CampsiteInstanceFunc(const ConfAttrValue& p_rcoConfValues)  
    484   {  
    485       nMainThreadPid = 0;  
    486 448     int nMaxThreads;  
    487 449     int nPort;  
    488       int nUserId;  
    489       int nGroupId;  
    490    
    491       nMaxThreads = atoi(p_rcoConfValues.valueOf("PARSER_MAX_THREADS").c_str());  
    492       nPort = atoi(p_rcoConfValues.valueOf("PARSER_PORT").c_str());  
    493    
    494       const char* pUser = p_rcoConfValues.valueOf("APACHE_USER").c_str();  
    495       struct passwd* pPwEnt = getpwnam(pUser);  
    496       if (pPwEnt == NULL)  
    497       {  
    498           cerr << "Invalid user name in conf file";  
    499           exit(1);  
      450     try {  
      451         // read parser configuration  
      452         string coParserConfFile = coConfDir + "/parser_conf.php";  
      453         ConfAttrValue coAttributes(coParserConfFile);  
      454      
      455         // read database configuration  
      456         string coDatabaseConfFile = coConfDir + "/database_conf.php";  
      457         coAttributes.open(coDatabaseConfFile);  
      458      
      459         nMaxThreads = atoi(coAttributes.valueOf("PARSER_MAX_THREADS").c_str());  
      460         nPort = atoi(coAttributes.valueOf("PARSER_PORT").c_str());  
      461         if (nPort == 0)  
      462         {  
      463             throw ConfException("Template engine port was not specified");  
      464         }  
      465      
      466         SQL_SERVER = coAttributes.valueOf("DATABASE_SERVER_ADDRESS");  
      467         SQL_SRV_PORT = atoi(coAttributes.valueOf("DATABASE_SERVER_PORT").c_str());  
      468         SQL_USER = coAttributes.valueOf("DATABASE_USER");  
      469         SQL_PASSWORD = coAttributes.valueOf("DATABASE_PASSWORD");  
      470         SQL_DATABASE = coAttributes.valueOf("DATABASE_NAME");  
    500 471     }  
    501       nUserId = pPwEnt->pw_uid;  
    502       const char* pGroup = p_rcoConfValues.valueOf("APACHE_GROUP").c_str();  
    503       struct group* pGrEnt = getgrnam(pGroup);  
    504       if (pGrEnt == NULL)  
      472     catch (ConfException& rcoEx)  
    505 473     {  
    506           cerr << "Invalid group name in conf file";  
      474         cerr << "ERROR reading configuration: " << rcoEx.what() << endl;  
    506 474         exit(1);  
    507 475     }  
    508       nGroupId = pGrEnt->gr_gid;  
    509    
    510       SQL_SERVER = p_rcoConfValues.valueOf("DATABASE_SERVER_ADDRESS");  
    511       SQL_SRV_PORT = atoi(p_rcoConfValues.valueOf("DATABASE_SERVER_PORT").c_str());  
    512       SQL_USER = p_rcoConfValues.valueOf("DATABASE_USER");  
    513       SQL_PASSWORD = p_rcoConfValues.valueOf("DATABASE_PASSWORD");  
    514       SQL_DATABASE = p_rcoConfValues.valueOf("DATABASE_NAME");  
    515    
    516   #ifdef _DEBUG_SOURCE  
    517       cout << "max threads: " << nMaxThreads << ", port: " << nPort << ", user id: "  
    518               << nUserId << ", group id: " << nGroupId << endl;  
    519       cout << "sql server: " << SQL_SERVER << ", sql port: " << SQL_SRV_PORT  
    520               << ", sql user: " << SQL_USER << ", sql password: " << SQL_PASSWORD  
    521               << ", db name: " << SQL_DATABASE << endl;  
    522   #endif  
    523 476  
    524       nPort = nPort > 0 ? nPort : 2001;  
    525 477     nMaxThreads = nMaxThreads > 0 ? nMaxThreads : MAX_THREADS;  
      478  
    526 479 #ifndef _DEBUG_SOURCE  
    527       if (setuid(nUserId) != 0)  
    528       {  
    529           cerr << "Error setting user id " << nUserId << endl;  
    530           exit (1);  
    531       }  
    532       if (setgid(nGroupId) != 0)  
      480     if (bRunAsDaemon)  
    533 481     {  
    534           cerr << "Error setting group id " << nGroupId << endl;  
    535           exit (1);  
      482         StartDaemon();  
    536 483     }  
    537    
    538 484     set_signals(sigterm_handler, true, true, false);  
      485 #else  
      486     cout << "max threads: " << nMaxThreads << ", port: " << nPort << endl;  
      487     cout << "sql server: " << SQL_SERVER << ", sql port: " << SQL_SRV_PORT  
      488             << ", sql user: " << SQL_USER << ", sql password: " << SQL_PASSWORD  
      489             << ", db name: " << SQL_DATABASE << endl;  
    539 490 #endif  
    540 491  
    608 559                     throw SocketErrorException("Accept error");  
    609 560 #ifdef _DEBUG_SOURCE  
    610   #warning *******************************************************************************  
    611   #warning This compilation option is for source code debugging, do not use in production!  
    612   #warning *******************************************************************************  
    613 561                 MyThreadRoutine((void*)pcoClSock);  
    614 562 #else  
  • trunk/campsite/implementation/parser/parser.kdevelop.filelist

    r2390 r3952  
    78 78 parser/cxmltree.cpp  
    79 79 parser/cxmltree.h  
    80   parser/CVS/Entries  
    81   parser/CVS/Repository  
    82   parser/CVS/Root  
    83   CVS/Entries  
    84   CVS/Repository  
    85   CVS/Root  
    86   /ccampsiteinstance.h  
    87   /ccampsiteinstance.cpp  
    88   parser/ccampsiteinstance.h  
    89   parser/ccampsiteinstance.cpp  
  • trunk/campsite/install_conf/create_instance.php

    r3945 r3952  
    206 206         return $res;  
    207 207  
    208       $versions = array("2.0.x", "2.1.x", "2.2.x");  
      208     $versions = array("2.0.x", "2.1.x", "2.2.x", "2.3.x");  
    208 208     foreach ($versions as $index=>$db_version) {  
    209 209         if ($old_version > $db_version)  
    259 259             $version = $version < "2.1.x" ? "2.1.x" : $version;  
    260 260         if (in_array($row[0], array("URLTypes", "TemplateTypes", "Templates", "Aliases",  
    261                   "ArticlePublish", "IssuePublish"))) {  
      261                 "ArticlePublish", "IssuePublish", "ArticleImages"))) {  
    261 261             $version = "2.2.x";  
    262 262             if (!$res2 = mysql_query("DESC UserTypes ManageReaders"))  
    263 263                 return "Unable to query the database $p_db_name";  
    264               if (mysql_num_rows($res2) > 0)  
      264             if (mysql_num_rows($res2) > 0) {  
    264 264                 $version = "2.3.x";  
      265             }  
      266             if (!$res2 = mysql_query("DESC UserTypes InitializeTemplateEngine"))  
      267                 return "Unable to query the database $p_db_name";  
      268             if (mysql_num_rows($res2) > 0) {  
      269                 $version = "2.4.x";  
      270             }  
    265 271         }  
    266 272     }