Check alle échte Black Friday-deals Ook zo moe van nepaanbiedingen? Wij laten alleen échte deals zien
Toon posts:

[PHP] Cannot redeclare class

Pagina: 1
Acties:
  • 3.896 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik draai Joomla 1.0.12 Stable

Ik heb een component van Akoforms. Ik heb 1 normale contact formulier om en daarnaast in de zij menu heb ik nog een contact formulier voor aanvraagjes. Wanneer de beide formulier op 1 pagina komen krijg ik volgende foutmelding.

"Cannot redeclare class"

Ik heb in akoforms.php bekeken en gezocht waar de class word ingeludeerdt heb geprobeerd als include_once en require_once.

PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
<?php

/**

* AkoForms - A Mambo Form Generator Component

* @version 1.11 final

* @package AkoForms

* @copyright (C) 2004 by Arthur Konze

* @license http://www.konze.de/ Copyrighted Commercial Software

**/

$func = mosGetParam( $_REQUEST, 'func', null );

$task = mosGetParam( $_REQUEST, 'task', null );

$formid = mosGetParam( $_REQUEST, 'formid', null ); 





$task = mosGetParam( $_REQUEST, 'task', null );

$cid = mosGetParam( $_REQUEST, 'cid', array( 0 ) );

$uid = mosGetParam( $_REQUEST, 'uid', array( 0 ) );

if (!is_array( $cid )) {

   $ocid=$cid;

   $cid = array ();

   $cid[]=$ocid;

   mosArrayToInts($cid);

}



# Don't allow direct linking

  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );



# Load some configuation files

  require($mosConfig_absolute_path."/administrator/components/com_akoforms/fields.akoforms.php");

  require_once($mosConfig_absolute_path."/administrator/components/com_akoforms/class.akoforms.php");

  require($mosConfig_absolute_path."/administrator/components/com_akoforms/config.akoforms.php");

  $akoversion = "V1.11 final";



# Load language if it exists

  if (file_exists($mosConfig_absolute_path.'/components/com_akoforms/languages/'.$mosConfig_lang.'.php')) {

    include($mosConfig_absolute_path.'/components/com_akoforms/languages/'.$mosConfig_lang.'.php');

  } else {

    include($mosConfig_absolute_path.'/components/com_akoforms/languages/english.php');

  }



switch ($func) {



############################################################################



  case 'showform':

    # Load form from database

    $category = new mosAkoforms( $database );

    $category->load( $formid );



    echo "<p class='componentheading'>$category->title</p>";



    if ($category->publish_down < date("Y-m-d",time()) && trim( $category->publish_down ) != "0000-00-00 00:00:00") {

      echo $AKFLANG->AKF_FORMEXPIRED;

    } else if ($category->publish_up > date("Y-m-d",time())." 00:00:00" ) {

      echo $AKFLANG->AKF_FORMPENDING;

    } else {

      # Show form

      echo "<p>$category->text</p>";

      # Load fields from database

      $database->setQuery( "SELECT * FROM #__akoforms_fields"

      . "\n WHERE published = '1'"

      . "\n   AND catid = '$category->id'"

      . "\n   AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())"

      . "\n   AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"

      . "\n ORDER BY ordering"

      );

      $fields = $database->loadObjectList();



      # Form Validation

      echo "<script language='javascript' type='text/javascript'>\n";

      echo "  function akovalidate() {\n";

      echo "   var form = document.akoform;\n";

      echo "    if (form.formid.value == \"\"){\n";

      echo "      alert( \"FormID is missing.\" );\n";

      foreach($fields as $field) {

        if ($field->required) {

          echo "    } else if (form.AKF".$field->id.".value == \"\"){\n";

          echo "      alert( \"".$AKFLANG->AKF_PLEASEFILLREQFIELD." ".$field->title."\" );\n";

        }

      }

      echo "    } else {\n";

      echo "      document.akoform.submit();";

      echo "    } } </script>\n";



      echo "<form action='".sefRelToAbs("index.php?option=com_akoforms&func=processform&Itemid=$itemid")."' name='akoform' id='akoform' method='post' enctype='multipart/form-data'>";

      echo "<input type='hidden' value='$category->id' name='formid'>";



      # AkoForms Template Engine Start

      echo $file_akf_layoutstart;

      # AkoForms Template Engine Rows

      foreach($fields as $field) {

        # Execute Field PreProcessor

        if ($formfields[$field->type][field_php]) eval ($formfields[$field->type][field_php]);

        # Compile Field

        $af_output = $formfields[$field->type][field_html];

        $af_output = str_replace( "af_fieldvalue" , $field->value , $af_output );

        $af_output = str_replace( "af_fieldstyle" , $field->style , $af_output );

        $af_output = str_replace( "af_fieldname"  , "AKF".$field->id , $af_output );

        # Compile Row

        $af_outputrow = $file_akf_layoutrow;

        $af_outputrow = str_replace( "###AFTFIELDTITLE###"  , $field->title , $af_outputrow );

        $af_outputrow = $field->required ? str_replace( "###AFTFIELDREQ###"  , "<span class='small'>*</span>" , $af_outputrow ) : str_replace( "###AFTFIELDREQ###"  , "" , $af_outputrow );

        $af_outputrow = str_replace( "###AFTFIELDDESC###"  , $field->text , $af_outputrow );

        $af_outputrow = str_replace( "###AFTFIELD###"  , $af_output , $af_outputrow );

        echo $af_outputrow;

      }

      # AkoForms Template Engine End

      $file_akf_layoutend = str_replace( "###AFTSENDBUTTON###"  , "<input type='button' name='send' value='".$AKFLANG->AKF_BUTTONSEND."' class='button' onclick='akovalidate()' />" , $file_akf_layoutend );

      $file_akf_layoutend = str_replace( "###AFTCLEARBUTTON###"  , "<input type='reset' value='".$AKFLANG->AKF_BUTTONCLEAR."' name='reset' class='button'>" , $file_akf_layoutend );

      echo $file_akf_layoutend;



      echo "</form>";

      echo "<p align='center' class='small'>* ".$AKFLANG->AKF_REQUIREDFIELD."</p>";

    }

    break;



############################################################################



  case 'processform':

    # Load form from database

    $category = new mosAkoforms( $database );

    $category->load( $formid );



    # Fetch input from submitted form

    $akfip   = getenv("REMOTE_ADDR");

    $akfdate = date ( "Y-m-d H:i:s" , time() );

    foreach($_POST as $key=>$elem) {

      if (is_array($elem)) $elem = implode( ',', $elem );

      $akofieldinput[substr($key,3)] = $elem;

    }



    # Load fields from database

    $database->setQuery( "SELECT * FROM #__akoforms_fields"

    . "\n WHERE published = '1'"

    . "\n   AND catid = '$category->id'"

    . "\n   AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())"

    . "\n   AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"

    . "\n ORDER BY ordering"

    );

    $fields = $database->loadObjectList();



    # Save sender to database

    if ($category->savedb) {

      $database->setQuery( "INSERT INTO #__akoforms_sender (`id` , `formid` , `senderip` , `senderdate`) VALUES ('','$category->id' , '$akfip' , '$akfdate' );" );

      $result = $database->query();

    }

    $akoforms_senderid = mysql_insert_id();



    #Initialise Mail Handler

    require_once($mosConfig_absolute_path."/components/com_akoforms/class.phpmailer.php");

    $mail = new PHPMailer();

    $mail->Mailer   = "mail";

    $mail->Subject  = $file_akf_mailsubject;

    $mail->CharSet  = $file_akf_mailcharset;

    $mail->FromName = $file_akf_mailsender;

    $mail->From     = $file_akf_mailemail;

    if ($category->emails) $akfmailarray = explode ( "," , $category->emails );



    # Handling

    $line = 0;

    $tabclass = array("sectiontableentry1", "sectiontableentry2");

    $akfmailhtml  = "<table width='100%' cellpadding='4' cellspacing='0' border='0' align='center' class='contentpane'>";

    $akfmailhtml .= "<tr><td width='30%' class='sectiontableheader'>".$AKFLANG->AKF_MAILTABLEFIELD."</td><td width='70%' class='sectiontableheader'>".$AKFLANG->AKF_MAILTABLEDATA."</td></tr>";

    foreach($fields as $field) {

      # Post Processor

      if ($formfields[$field->type][field_post]) {

        $post_processor = str_replace( "af_fieldname"  , "AKF".$field->id , $formfields[$field->type][field_post] );

        eval ($post_processor);

      }



      # Save data for later emailing

      $stfieldinput = stripslashes($akofieldinput[$field->id]);

      $akfmailform .= $field->title.": $stfieldinput\n";

      $stfieldinput = preg_replace("/(\015\012)|(\015)|(\012)/","&nbsp;<br />",$stfieldinput);

      $akfmailhtml .= "<tr><td width='30%' valign='top' class='".$tabclass[$line]."'><b>$field->title</b></td>";

      $akfmailhtml .= "<td width='70%' valign='top' class='".$tabclass[$line]."'>$stfieldinput</td></tr>";



      # Save data to database

      if ($category->savedb) {

        $afsavevalue = mysql_escape_string($akofieldinput[$field->id]);

        $database->setQuery( "INSERT INTO #__akoforms_data (`id` , `senderid` , `fieldid` , `data` )"

        ."\n VALUES ('', '$akoforms_senderid', '$field->id' , '$afsavevalue' );" );

        $result = $database->query();

      }

      $line = 1 - $line;



    }

    $akfmailhtml .= "</table>";



    // HTML body

    $akfemailhtml  = "<style>";

    $akfemailhtml .= ".sectiontableheader {".$file_akf_mailheadcss."}";

    $akfemailhtml .= ".sectiontableentry1 {".$file_akf_mailrow1css."}";

    $akfemailhtml .= ".sectiontableentry2 {".$file_akf_mailrow2css."}";

    $akfemailhtml .= "</style>";

//    $akfemailhtml .= "<p>".$AKFLANG->AKF_MAILERHELLO."</p>";

//    $akfemailhtml .= "<p>".$AKFLANG->AKF_MAILERHEADER."</p>";

    $akfemailhtml .= $akfmailhtml;

//    $akfemailhtml .= "<p>".$AKFLANG->AKF_MAILERFOOTER."</p>";



    // Plain text body (for mail clients that cannot read HTML)

//    $akfmailtext  = $AKFLANG->AKF_MAILERHELLO."\n\n";

//    $akfmailtext .= $AKFLANG->AKF_MAILERHEADER."\n\n";

    $akfmailtext .= $akfmailform;

//    $akfmailtext .= "\n".$AKFLANG->AKF_MAILERFOOTER."\n";



    # Send out Emails

    $mail->Body     = $akfemailhtml;

    $mail->AltBody  = $akfmailtext;

    if ($category->sendmail) {

      if (count($akfmailarray) > 0) {

        foreach($akfmailarray as $akfmail) {

          $mail->ClearAddresses();

          $mail->AddAddress( $akfmail );

          if(!$mail->Send()) echo $AKFLANG->AKF_MAILERERROR." $akfmail<br />";

        }

      }

    }



    # Finishing

    if ($category->target=='1') {

      echo "<SCRIPT>document.location.href='$category->targeturl';</SCRIPT>";

    } else {

      echo "<p class='componentheading'>$category->thanktitle</p>";

      echo "<p>$category->thanktext</p>";

      if ($category->showresult=='1') {

        echo $akfmailhtml;

      }

    }

    break;



############################################################################



  default:

    # Get page title

    $database->setQuery("SELECT name from #__menu WHERE id='$Itemid'");

    $menuname = $database->loadResult();

    echo "<p><span class='componentheading'>$menuname</span></p>";

    # Load forms from database

    $database->setQuery( "SELECT * FROM #__akoforms"

    . "\n WHERE published = '1'"

    . "\n   AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= NOW())"

    . "\n   AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= NOW())"

    . "\n ORDER BY ordering"

    );

    $forms = $database->loadObjectList();

    # Bring them to the screen

    echo "<table width='100%' border='0' cellspacing='1' cellpadding='4'>";

    echo "<tr><td width='100%' height='20' class='sectiontableheader'>$menuname</td></tr>";

    $line=1;

    foreach($forms as $form) {

      $linecolor = ($line % 2) + 1;

      echo "<tr class='sectiontableentry".$linecolor."'><td width='100%' valign='top'>";

      echo "<a href='".sefRelToAbs("index.php?option=com_akoforms&func=showform&formid=$form->id&Itemid=$Itemid'>$form->title")."</a><br />$form->text";

      echo "</td></tr>";

      $line++;

    }

    echo "</table>";

    break;

}





?>

  • SchizoDuckie
  • Registratie: April 2001
  • Laatst online: 18-02 23:12

SchizoDuckie

Kwaak

en nu denk jij dat wij 523 regels door gaan lezen.... :? Begin gewoon eens met je classes definieren in een class.classname.php bestandje en include_once die. Dat lijkt me je oplossing (waar je zelf ook best op had kunnen komen volgens mij)

[ Voor 62% gewijzigd door SchizoDuckie op 15-01-2008 10:27 ]

Stop uploading passwords to Github!


  • --MeAngry--
  • Registratie: September 2002
  • Nu online

--MeAngry--

aka Qonstrukt

Ik zou zeggen, mail de makers van die module even. Die zullen ook wel blij zijn te weten dat er een fout in zit.

Tesla Model Y RWD (2024)


  • SchizoDuckie
  • Registratie: April 2001
  • Laatst online: 18-02 23:12

SchizoDuckie

Kwaak

--MeAngry-- schreef op dinsdag 15 januari 2008 @ 10:27:
Ik zou zeggen, mail de makers van die module even. Die zullen ook wel blij zijn te weten dat er een fout in zit.
Er is niets fouts aan de hand als je 2x een .php include die includen elk weer een aantal .php bestanden. vervang alle include statements door include_once en klaar is chason

[ Voor 16% gewijzigd door SchizoDuckie op 15-01-2008 10:33 ]

Stop uploading passwords to Github!


Verwijderd

Topicstarter
Dus alleen waar de class word geincludeert veranderen naar include_once is niet voldoende ook al de andere dus?

  • SchizoDuckie
  • Registratie: April 2001
  • Laatst online: 18-02 23:12

SchizoDuckie

Kwaak

Verwijderd schreef op dinsdag 15 januari 2008 @ 10:38:
Dus alleen waar de class word geincludeert veranderen naar include_once is niet voldoende ook al de andere dus?
Replace alle includes op elke classname naar include_once dan ben je geheid van je probleem af.

Stop uploading passwords to Github!


Verwijderd

Topicstarter
Bedankt mensen voor jullie snelle reactie's

  • NMe
  • Registratie: Februari 2004
  • Laatst online: 20-11 11:59

NMe

Quia Ego Sic Dico.

Dit had je zelf kunnen bedenken, ook zonder het posten van ruim 500 (!) regels code. :) Als ik je topictitel letterlijk intik op Google krijg ik bij de eerste hit al hetzelfde antwoord dat je hier hebt gehad, nota bene op ditzelfde forum. Doe de volgende keer dus iets meer moeite voor je een topic opent. :)

'E's fighting in there!' he stuttered, grabbing the captain's arm.
'All by himself?' said the captain.
'No, with everyone!' shouted Nobby, hopping from one foot to the other.

Pagina: 1

Dit topic is gesloten.